/* =========================================================
   Datei: app.css — FINAL (KORRIGIERT & BEREINIGT)
   ========================================================= */

:root {
  --bgA: #07090e;
  --bgB: #0b0f14;

  --font-ui: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --font-brand: 'Cinzel', Georgia, serif;

  --text: #f2e7c8;
  --muted: rgba(242, 231, 200, 0.72);

  --gold: #c9a14a;
  --gold-light: #e3c676;
  --gold-soft: #f0dfb0;
  --gold-dark: #8b6a2b;

  --line: rgba(201, 161, 74, 0.24);
  --line-strong: rgba(227, 198, 118, 0.46);

  --panel: rgba(255, 255, 255, 0.045);
  --panel-border: rgba(201, 161, 74, 0.18);

  --input-bg: rgba(255, 255, 255, 0.06);
  --input-border: rgba(201, 161, 74, 0.22);

  --activeBg: linear-gradient(180deg, #ecd187, #c69739);
  --activeText: #181208;

  --paper: #f6f3ee;
  --paper2: #fbfaf7;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(900px 600px at 18% 18%, rgba(122, 92, 255, 0.12), transparent 60%),
    radial-gradient(700px 500px at 82% 22%, rgba(0, 255, 209, 0.10), transparent 55%),
    radial-gradient(800px 700px at 55% 90%, rgba(255, 140, 0, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bgA), var(--bgB));
}

body {
  position: relative;
}

.mobile-only {
  display: none;
}

.desktop-only {
  display: block;
}

/* =========================================================
   APP HEADER
   ========================================================= */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 84px;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(10, 14, 22, 0.94), rgba(10, 14, 22, 0.72));
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  backdrop-filter: blur(14px);
  z-index: 9999;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 0 0 auto;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  height: 58px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.55));
}

/* =========================================================
   APP CONTROLS
   ========================================================= */

.controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 120px;
}

.field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-light);
  font-weight: 700;
  font-family: var(--font-brand);
}

.field input,
.field select {
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: linear-gradient(180deg, rgba(25, 29, 40, 0.92), rgba(14, 18, 28, 0.96));
  color: var(--gold-soft);
  padding: 0 12px;
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 6px 18px rgba(0, 0, 0, 0.16);
  font-family: var(--font-ui);
}

.field input:focus,
.field select:focus {
  border-color: var(--line-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 2px rgba(201, 161, 74, 0.10),
    0 10px 22px rgba(0, 0, 0, 0.18);
}

.field input::placeholder {
  color: rgba(240, 223, 176, 0.42);
}

.field select,
.field select option {
  color: #f2e7c8;
  background: #111827;
}

.field select option:checked {
  color: #1a1408;
  background: #d8b15b;
}

.field-code {
  flex: 0 0 140px;
  min-width: 140px;
  max-width: 140px;
}

.field-code input {
  width: 11ch;
  min-width: 11ch;
  max-width: 11ch;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.01em;
  font-weight: 900;
  padding: 0 6px;
}

#sectorWrap {
  min-width: 72px;
  max-width: 72px;
  flex: 0 0 72px;
}

#sector {
  width: 100%;
  padding-left: 10px;
  padding-right: 28px;
  color: #f2e7c8 !important;
  background: linear-gradient(180deg, rgba(25, 29, 40, 0.96), rgba(14, 18, 28, 0.98)) !important;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  -webkit-appearance: menulist;
  appearance: menulist;
  -webkit-text-fill-color: #f2e7c8;
}

#sector option {
  color: #111827;
  background: #ffffff;
}

.primary {
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 220, 140, 0.24);
  background: linear-gradient(180deg, #ecd187, #c69739);
  color: #181208;
  font-weight: 700;
  font-family: var(--font-brand);
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 10px 24px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

.primary:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
}

/* =========================================================
   RIGHT SIDE / ENGINE BUTTONS
   ========================================================= */

.right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.engine-nav {
  display: flex !important;
  gap: 10px;
}

.engine-btn {
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: linear-gradient(180deg, rgba(22, 26, 36, 0.96), rgba(11, 15, 24, 0.96));
  color: var(--gold-light);
  font-weight: 700;
  font-family: var(--font-brand);
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.engine-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, rgba(30, 35, 48, 0.96), rgba(14, 18, 28, 0.96));
  border-color: var(--line-strong);
}

.engine-btn.active {
  background: linear-gradient(180deg, #ecd187, #c69739);
  color: #181208;
  border-color: rgba(255, 226, 149, 0.38);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 10px 24px rgba(0, 0, 0, 0.22);
}

/* =========================================================
   APP MAIN
   ========================================================= */

.app-main {
  position: absolute;
  top: 84px;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  padding: 14px;
}

/* =========================================================
   SLIDER PANEL
   ========================================================= */

.slider-panel {
  position: relative;
  z-index: 2;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 14px;
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
}

.slider-title {
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--gold-light);
  font-family: var(--font-brand);
  letter-spacing: 0.05em;
}

.sliders {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slider-row {
  display: grid;
  grid-template-columns: 14px 18px 1fr;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #888;
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.08);
}

.digit {
  font-weight: 900;
  font-size: 12px;
}

.hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

/* =========================================================
   RANGE SLIDERS
   ========================================================= */

.slider-row input[type="range"] {
  --accent: #aaa;
  --val: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      var(--accent) 0%,
      var(--accent) var(--val),
      rgba(255, 255, 255, 0.16) var(--val),
      rgba(255, 255, 255, 0.16) 100%
    );
  outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid rgba(7, 9, 14, 0.85);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid rgba(7, 9, 14, 0.85);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.slider-row input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

/* =========================================================
   STAGE
   ========================================================= */

.stage {
  position: relative;
  z-index: 1;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.60);
  display: flex;
  flex-direction: column;
}

.stage.paper {
  background:
    radial-gradient(900px 700px at 50% 40%, rgba(0, 0, 0, 0.06), transparent 60%),
    linear-gradient(180deg, var(--paper2), var(--paper));
}

.engine-wrap {
  position: absolute;
  inset: 0;
}

.engine-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: transparent;
}

/* =========================================================
   VIEWER WATERMARK
   (aktuell ungenutzt – Wasserzeichen wird pro Export gesetzt)
   ========================================================= */

.preview-info {
  position: absolute;
  left: 20px;
  bottom: 20px;
  font-size: 12px;
  color: var(--muted);
}

/* =========================================================
   🔒 DRUCKVORSCHAU FIX & ISOLIERUNG (GEGEN ÜBERLAPPUNGEN)
   ========================================================= */

/* Versteckt die Arbeitsfläche dahinter komplett bei geöffneter Vorschau */
body.preview-open .app-main,
body.preview-open .app-header {
  visibility: hidden !important;
}

/* Modal Overlay */
#printPreview {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999999999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  background: rgba(10, 14, 22, 0.96) !important;
  backdrop-filter: blur(14px) !important;
}

#printPreview[hidden] {
  display: none !important;
}

/* Modal Panel */
.print-preview__panel {
  position: relative !important;
  width: min(960px, 94vw) !important;
  max-height: 90vh !important;
  background: #0f131a !important;
  border: 1px solid rgba(201, 161, 74, 0.3) !important;
  border-radius: 20px !important;
  padding: 30px !important;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.95) !important;
  overflow-y: auto !important;
}

/* 2-Spalten-Layout */
.preview-layout {
  display: flex !important;
  flex-direction: row !important;
  gap: 36px !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
}

.preview-left {
  flex: 1 1 420px !important;
  max-width: 420px !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

.preview-right {
  flex: 1 1 400px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  gap: 18px !important;
  text-align: left !important;
}

/* Weißer Rahmen für das Mandala */
.print-preview__image-wrap {
  width: 100% !important;
  max-width: 420px !important;
  aspect-ratio: 2480 / 3508 !important;
  background: #ffffff !important;
  border-radius: 14px !important;
  overflow: hidden !important;
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4) !important;
}

/* Das Bild im Kasten (zentriert und ungetrennt) */
.print-preview__image {
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  display: block !important;
}

/* Schließen-Button */
.print-preview__close {
  position: absolute !important;
  top: 16px !important;
  right: 16px !important;
  width: 38px !important;
  height: 38px !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #ffffff !important;
  font-size: 20px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 20 !important;
}

.print-preview__close:hover {
  background: rgba(255, 255, 255, 0.25) !important;
}

@media (max-width: 768px) {
  .preview-layout {
    flex-direction: column !important;
  }
  .preview-left,
  .preview-right {
    width: 100% !important;
    max-width: 100% !important;
  }
  .preview-right {
    text-align: center !important;
  }
  .print-preview__image-wrap {
    max-height: 50vh !important;
  }
}

/* =========================================================
   MOBILE SLIDER SHEET (Farbintensität)
   Ohne diese Regeln rendert #sliderSheet als normaler Block
   mitten in die Seite (Doppelung der Farbregler).
   ========================================================= */

.slider-sheet {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
}

.slider-sheet.open {
  display: block;
}

.slider-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
}

.slider-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 18px 18px 0 0;
  background: rgba(12, 16, 22, 0.98);
  border-top: 1px solid var(--panel-border);
  padding: 14px;
  max-height: 70vh;
  overflow: auto;
}

.slider-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.slider-sheet__title {
  font-weight: 700;
  color: var(--gold-light);
  font-family: var(--font-brand);
  letter-spacing: 0.05em;
}

.slider-sheet__body {
  padding-bottom: 8px;
}

/* =========================================================
   MOBILE LAYOUT
   ========================================================= */

@media (max-width: 900px) {
  html,
  body {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-header {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    height: auto;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .brand {
    width: 100%;
    flex: 0 0 100%;
    min-width: 0;
  }

  .brand-logo {
    height: 40px;
  }

  .right {
    order: -1;
    width: 100%;
    flex: 0 0 100%;
  }

  .engine-nav {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
  }

  .engine-btn {
    width: 100%;
    padding: 0 8px;
  }

  .controls {
    flex: 1 1 100%;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
  }

  .field {
    min-width: 0;
    flex: 1 1 calc(50% - 8px);
  }

  .field-code {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
    max-width: none;
  }

  .field-code input {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  #sectorWrap {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
    max-width: none;
  }

  #download {
    flex: 1 1 100%;
  }

  .mobile-only {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    flex: 1 1 calc(50% - 8px);
  }

  .desktop-only {
    display: none !important;
  }

  .app-main {
    position: relative;
    top: 0;
    bottom: auto;
    left: auto;
    right: auto;
    grid-template-columns: 1fr;
    padding: 10px;
    gap: 10px;
  }

  .stage {
    min-height: 72vh;
  }
}

/* =========================================================
   PORTAL / STARTSEITE
   Nur body.portal-body – beeinflusst keine andere Seite
   ========================================================= */

body.portal-body {
  overflow: hidden;
}

body.portal-body .portal {
  height: 100svh;
  display: grid;
  place-items: center;
  padding: 18px 14px;
  text-align: center;
}

body.portal-body .portal-card {
  width: min(980px, 100%);
  display: grid;
  justify-items: center;
}

body.portal-body .portal-logo {
  width: min(760px, 92vw);
  height: auto;
  max-height: 26svh;
  object-fit: contain;
  margin: 0 auto 8px;
  display: block;
  filter: none;
  transform: none;
  backface-visibility: hidden;
}

body.portal-body .portal-tagline {
  font-family: var(--font-brand);
  font-weight: 700;
  letter-spacing: 0.22em;
  font-size: 12px;
  color: rgba(255, 225, 160, 0.92);
  text-transform: uppercase;
  margin: 0;
}

body.portal-body .portal-spacer {
  height: clamp(22px, 7svh, 90px);
  width: 1px;
}

body.portal-body .portal-actions {
  width: min(560px, 100%);
  display: grid;
  gap: 10px;
}

body.portal-body .portal-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 46px;
  padding: 0 16px;
  border-radius: 16px;
  font-weight: 700;
  font-family: var(--font-brand);
  letter-spacing: 0.04em;
  font-size: 14px;
  border: 1px solid rgba(255, 210, 120, 0.55);
  background:
    radial-gradient(160px 80px at 20% 30%, rgba(255, 255, 255, 0.22), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  color: rgba(238, 243, 251, 0.92);
  text-decoration: none;
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: transform 0.14s ease, border-color 0.14s ease;
}

body.portal-body .portal-pill:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 225, 160, 0.90);
}

/* Erste Sparte (Lebenscode) traegt den Goldton, die weiteren bleiben ruhig. */
body.portal-body .portal-pill--primary {
  border-color: rgba(255, 225, 160, 0.85);
  background:
    radial-gradient(200px 90px at 20% 25%, rgba(255, 215, 130, 0.28), transparent 70%),
    linear-gradient(180deg, rgba(201, 161, 74, 0.30), rgba(201, 161, 74, 0.12));
  color: #fff6e0;
  box-shadow:
    0 14px 40px rgba(0, 0, 0, 0.60),
    inset 0 1px 0 rgba(255, 235, 190, 0.25);
}

body.portal-body .portal-pill__hint {
  font-size: 11px;
  font-weight: 800;
  color: rgba(255, 225, 160, 0.78);
  font-family: var(--font-ui);
}

body.portal-body .portal-pill--disabled {
  opacity: 0.52;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.15);
}

body.portal-body .portal-pill--disabled .portal-pill__hint {
  color: rgba(238, 243, 251, 0.52);
}

@media (max-width: 420px) {
  body.portal-body .portal-logo {
    max-height: 22svh;
  }

  body.portal-body .portal-tagline {
    font-size: 11px;
    letter-spacing: 0.18em;
  }

  body.portal-body .portal-pill {
    height: 44px;
    font-size: 13px;
  }

  body.portal-body .portal-spacer {
    height: clamp(18px, 6svh, 70px);
  }
}

@media (min-width: 901px) {
  body.portal-body .portal-logo {
    width: min(760px, 70vw);
    max-width: 760px;
    max-height: 260px;
  }
}
