/* ============================================================
   VELAR — Vektoren · Ebenen · Lagebeziehungen analysieren im Raum
   Design System & Liquid Glass
   ============================================================ */

/* ------------------------------------------------------------
   1.  TYPOGRAPHY  —  Fraunces (display) + Geist (UI) + Geist Mono
   ------------------------------------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght,SOFT@0,9..144,300..700,0..100;1,9..144,300..700,0..100&family=Geist:wght@300..700&family=Geist+Mono:wght@400..600&display=swap');

/* ------------------------------------------------------------
   2.  DESIGN TOKENS
   ------------------------------------------------------------ */
:root {
  /* — Surfaces — warmer near-black, no blue cast ——————— */
  --bg-deep:       #0D0E12;
  --bg-base:       #14161C;
  --bg-elevated:   #1B1E26;
  --bg-overlay:    rgba(13, 14, 18, 0.82);

  /* — Glass system (TWO INTENSITIES — switchable) ———— */
  --glass-bg:        rgba(255, 255, 255, 0.025);
  --glass-bg-strong: rgba(255, 255, 255, 0.05);
  --glass-border:    rgba(255, 255, 255, 0.07);
  --glass-border-hi: rgba(255, 255, 255, 0.13);
  --glass-shadow:    rgba(0, 0, 0, 0.4);
  --glass-blur:      14px;
  --glass-saturate:  120%;
  --glass-inner-light: rgba(255, 255, 255, 0.08);

  /* — Two-temperature system, desaturated for craft ——————— */
  --plane-color:   #7FB8C7;   /* Ebene = muted sea-blue */
  --plane-soft:    rgba(127, 184, 199, 0.10);
  --plane-glow:    rgba(127, 184, 199, 0.18);
  --line-color:    #D9A570;   /* Gerade = ochre amber */
  --line-soft:     rgba(217, 165, 112, 0.10);
  --line-glow:     rgba(217, 165, 112, 0.20);

  /* — Mathematical highlights ———————————————— */
  --intersect:     #C97A8E;   /* Schnittpunkt = dusty rose */
  --intersect-glow:rgba(201, 122, 142, 0.30);
  --normal-color:  #A89BC2;   /* Normalenvektor = muted violet */
  --success:       #8FB89A;
  --warning:       #D9B870;
  --error:         #C9707E;

  /* — Coord-axis tints (subtle in scene) ——————————— */
  --axis-x: #C97A8E;
  --axis-y: #8FB89A;
  --axis-z: #7FB8C7;

  /* — Text scale — single warm-neutral gray family —————— */
  --text-primary:   #ECE8E1;
  --text-secondary: #A8A39B;
  --text-muted:     #6B6862;
  --text-faint:     #3D3B36;

  /* — Type ———————————————————————————— */
  --font-display: 'Fraunces', 'Times New Roman', serif;
  --font-body:    'Geist', system-ui, sans-serif;
  --font-mono:    'Geist Mono', ui-monospace, monospace;

  /* — Radii ———————————————————————————— */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* — Spacing ———————————————————————————— */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  /* — Easing ————————————————————————————— */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.45, 0, 0.15, 1);
}

/* Full glass intensity override (toggled in header) */
[data-glass="full"] {
  --glass-bg:        rgba(255, 255, 255, 0.04);
  --glass-bg-strong: rgba(255, 255, 255, 0.075);
  --glass-border:    rgba(255, 255, 255, 0.10);
  --glass-border-hi: rgba(255, 255, 255, 0.20);
  --glass-blur:      20px;
  --glass-saturate:  140%;
  --glass-inner-light: rgba(255, 255, 255, 0.14);
}

/* ------------------------------------------------------------
   3.  RESET + BASE
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: 'ss01' on, 'cv01' on;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Desktop: lock the viewport, internal scrolling only */
@media (min-width: 981px) {
  html, body { overflow: hidden; }
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { background: none; border: none; cursor: pointer; padding: 0; }
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
::selection { background: var(--plane-color); color: var(--bg-deep); }

/* ------------------------------------------------------------
   4.  BACKDROP — single restrained off-axis gradient + film grain
   ------------------------------------------------------------ */
#cosmic-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 70% at 78% 110%, rgba(60, 70, 85, 0.18), transparent 60%),
    var(--bg-deep);
}
#cosmic-bg::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.035 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.55;
  mix-blend-mode: overlay;
}

/* ------------------------------------------------------------
   5.  APP SHELL
   ------------------------------------------------------------ */
#app {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(340px, 28%) 1fr;
  grid-template-areas:
    "header  header"
    "panels  scene"
    "footer  footer";
  gap: var(--s-4);
  padding: var(--s-4);
}

/* ------------------------------------------------------------
   6.  HEADER
   ------------------------------------------------------------ */
.app-header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-lg);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.brand-logo {
  width: 40px;
  height: 40px;
  display: block;
  opacity: 0.92;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 24px;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 144, "SOFT" 20;
  color: var(--text-primary);
}
.brand-tagline {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-top: 5px;
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* Pill-style header buttons */
.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex;
  align-items: center; justify-content: center;
  border-radius: 12px;
  color: var(--text-secondary);
  transition: all 0.25s var(--ease-out);
  position: relative;
}
.icon-btn:hover {
  color: var(--text-primary);
  background: var(--glass-bg-strong);
  transform: translateY(-1px);
}
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.6; }
/* Lucide injects <i> wrappers — make them inline-flex so sizing is correct */
.icon-btn i[data-lucide] { display: inline-flex; }

/* Chevron in rechenweg toggle */
.rechenweg-toggle .chev svg { width: 14px; height: 14px; stroke-width: 2; }
.rechenweg-toggle .chev i[data-lucide] { display: inline-flex; }

/* Glass-intensity toggle (pill) */
.glass-toggle {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  margin-right: var(--s-2);
}
.glass-toggle button {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--text-muted);
  transition: all 0.2s var(--ease-out);
}
.glass-toggle button.active {
  color: var(--bg-deep);
  background: var(--text-primary);
  font-weight: 600;
}

/* ------------------------------------------------------------
   7.  PANELS COLUMN (left)
   ------------------------------------------------------------ */
.panels-column {
  grid-area: panels;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  /* min-height: 0 is required so the grid constrains this flex container's
     height — without it the item grows to content size and never scrolls */
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* padding-right reserves space so the scrollbar never overlaps content;
     padding-bottom ensures the last card isn't flush-clipped at the edge */
  padding-right: 8px;
  padding-bottom: var(--s-4);
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border-hi) transparent;
}
.panels-column::-webkit-scrollbar { width: 6px; }
.panels-column::-webkit-scrollbar-track { background: transparent; }
.panels-column::-webkit-scrollbar-thumb {
  background: var(--glass-border-hi);
  border-radius: 3px;
}
.panels-column::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ------------------------------------------------------------
   8.  OBJECT PANELS  (Gerade / Ebene cards)
   ------------------------------------------------------------ */
.object-panel {
  padding: var(--s-5);
  border-radius: var(--r-lg);
  position: relative;
  overflow: hidden;
  /* Prevent flex from squishing the card — forces parent to scroll instead */
  flex-shrink: 0;
}
.object-panel::before {
  /* Specular top highlight */
  content: '';
  position: absolute;
  top: 0; left: 12%; right: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-inner-light), transparent);
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-3);
  margin-bottom: var(--s-4);
}
.panel-title {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.panel-badge {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 18px;
  line-height: 1;
  font-variation-settings: "opsz" 24;
}
.panel-badge span {
  display: inline-block;
  line-height: 1;
}
/* g has a descender that pushes the visual body up — nudge down to optically center */
.panel-badge.line-badge span {
  transform: translateY(2px);
}
.panel-badge.line-badge {
  background: var(--line-soft);
  color: var(--line-color);
  border: 1px solid rgba(217, 165, 112, 0.18);
}
.panel-badge.plane-badge {
  background: var(--plane-soft);
  color: var(--plane-color);
  border: 1px solid rgba(127, 184, 199, 0.18);
}
.panel-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  letter-spacing: -0.005em;
}
.panel-name .sub {
  color: var(--text-muted);
  font-style: italic;
  font-size: 14px;
  margin-left: 6px;
}

/* Form-switcher segmented control */
.form-switcher {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  position: relative;
}
.form-switcher button {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  padding: 6px 11px;
  border-radius: 8px;
  color: var(--text-muted);
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}
.form-switcher button.active {
  color: var(--text-primary);
  background: var(--glass-bg-strong);
  box-shadow: inset 0 1px 0 var(--glass-inner-light);
}

/* ------------------------------------------------------------
   9.  VECTOR INPUT — the heart of the eingabe UX
   ------------------------------------------------------------ */
.vector-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.vector-label {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  color: var(--text-secondary);
  font-variation-settings: "opsz" 144;
  text-align: right;
}
.vector-label .vec-arrow {
  position: relative;
  display: inline-block;
}
.vector-label .vec-arrow::after {
  content: '→';
  position: absolute;
  top: -10px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-style: normal;
  color: var(--text-faint);
}

.vector-input {
  display: flex;
  align-items: center;
  gap: 6px;
}
.vec-bracket {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 300;
  line-height: 0.8;
  color: var(--text-muted);
  user-select: none;
}
.vec-fields {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.num-input {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text-primary);
  width: 100%;
  text-align: center;
  transition: all 0.18s var(--ease-out);
  outline: none;
}
.num-input:focus {
  border-color: var(--plane-color);
  background: rgba(0,0,0,0.4);
  box-shadow: 0 0 0 2px rgba(127, 184, 199, 0.18);
}
.line-panel .num-input:focus {
  border-color: var(--line-color);
  box-shadow: 0 0 0 2px rgba(217, 165, 112, 0.18);
}
.num-input.error {
  border-color: var(--error);
  box-shadow: 0 0 0 2px rgba(201, 112, 126, 0.20);
}

/* Koordinatenform layout */
.coord-eq {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 18px;
  font-style: italic;
  flex-wrap: wrap;
  padding: var(--s-3) 0;
}
.coord-eq .coord-num {
  width: 56px;
  text-align: center;
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 14px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 7px 6px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.18s var(--ease-out);
}
.coord-eq .coord-num:focus {
  border-color: var(--plane-color);
  box-shadow: 0 0 0 2px rgba(127, 184, 199, 0.18);
}
.coord-eq .var { color: var(--plane-color); font-weight: 500; }
.coord-eq .op { color: var(--text-muted); padding: 0 2px; }
.coord-eq .eq { color: var(--text-secondary); padding: 0 6px; }

/* LaTeX live-preview */
.latex-preview {
  margin-top: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--glass-border);
  border-left: 2px solid var(--plane-color);
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.line-panel .latex-preview { border-left-color: var(--line-color); }
.latex-preview .katex { color: var(--text-primary); }

/* Validation indicator */
.panel-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--success);
}
.panel-status.invalid { color: var(--error); }
.panel-status.warning { color: var(--warning); }
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

/* ------------------------------------------------------------
   10.  RESULT PANEL
   ------------------------------------------------------------ */
.result-panel {
  padding: var(--s-5);
  border-radius: var(--r-lg);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.result-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 12%; right: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-inner-light), transparent);
}
.result-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s-3);
}
.result-eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.relation-headline {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  font-variation-settings: "opsz" 144, "SOFT" 60;
  margin: var(--s-2) 0 var(--s-3);
}
.relation-headline .relation-verb {
  font-style: italic;
  color: var(--intersect);
  font-variation-settings: "opsz" 144, "SOFT" 0;
}
.relation-detail {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--s-3);
}
.intersection-display {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: rgba(201, 122, 142, 0.05);
  border: 1px solid rgba(201, 122, 142, 0.18);
  border-radius: var(--r-md);
  margin-bottom: var(--s-3);
}
.intersection-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.intersection-value {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--intersect);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* The Rechenweg-Animation player */
.rechenweg-section {
  margin-top: var(--s-4);
  border-top: 1px dashed var(--glass-border);
  padding-top: var(--s-4);
}
.rechenweg-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text-secondary);
  padding: var(--s-2) 0;
  transition: color 0.2s;
}
.rechenweg-toggle:hover { color: var(--text-primary); }
.rechenweg-toggle .chev {
  transition: transform 0.3s var(--ease-out);
}
.rechenweg-section.open .rechenweg-toggle .chev { transform: rotate(90deg); }

.rechenweg-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.45s var(--ease-out);
}
.rechenweg-section.open .rechenweg-body { max-height: 1200px; }

.step-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin: var(--s-3) 0;
}
.step-card {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-sm);
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--glass-border);
  transition: all 0.3s var(--ease-out);
  cursor: pointer;
}
.step-card:hover {
  border-color: var(--glass-border-hi);
  background: rgba(0,0,0,0.3);
}
.step-card.active {
  border-color: rgba(127, 184, 199, 0.4);
  background: rgba(127, 184, 199, 0.04);
}
.step-num {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  color: var(--text-muted);
  text-align: center;
}
.step-card.active .step-num {
  color: var(--plane-color);
}
.step-content { display: flex; flex-direction: column; gap: 6px; }
.step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.step-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.step-formula {
  margin-top: 4px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(0,0,0,0.3);
  font-size: 13px;
  overflow-x: auto;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border);
}
.play-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--text-primary);
  color: var(--bg-deep);
  display: inline-flex;
  align-items: center; justify-content: center;
  transition: transform 0.16s var(--ease-out);
}
.play-btn:hover { transform: scale(1.04); }
.play-btn:active { transform: scale(0.97); }
.play-btn svg { width: 12px; height: 12px; }
.scrubber {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}
.scrubber-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: var(--text-secondary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}
.scrubber-handle {
  position: absolute;
  top: 50%;
  width: 10px; height: 10px;
  margin-left: -5px;
  margin-top: -5px;
  background: var(--text-primary);
  border-radius: 50%;
  left: 0%;
  transition: left 0.1s linear;
}
.step-indicator {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  min-width: 40px;
  text-align: right;
}

/* ------------------------------------------------------------
   11.  3D SCENE AREA
   ------------------------------------------------------------ */
.scene-column {
  grid-area: scene;
  position: relative;
  border-radius: var(--r-xl);
  overflow: hidden;
}
#scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.scene-overlay-top {
  position: absolute;
  top: var(--s-4);
  left: var(--s-4);
  right: var(--s-4);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
  z-index: 3;
}
.scene-meta {
  pointer-events: auto;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.scene-meta .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-dot 2.2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

.scene-controls {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-2);
  border-radius: var(--r-md);
}
.scene-controls .icon-btn { width: 32px; height: 32px; }

.legend {
  position: absolute;
  bottom: var(--s-4);
  left: var(--s-4);
  z-index: 3;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.legend-row { display: flex; align-items: center; gap: var(--s-2); }
.legend-swatch {
  width: 18px;
  height: 4px;
  border-radius: 2px;
}
.legend-swatch.line { background: var(--line-color); }
.legend-swatch.plane { background: var(--plane-color); }
.legend-swatch.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--intersect);
}
.legend-text { color: var(--text-secondary); }
.legend-text .light { color: var(--text-muted); }

/* Scene HUD readout - shows live values during animation */
.scene-hud {
  position: absolute;
  bottom: var(--s-4);
  right: var(--s-4);
  z-index: 3;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 280px;
  opacity: 0;
  transition: opacity 0.3s var(--ease-out);
  pointer-events: none;
}
.scene-hud.visible { opacity: 1; }
.scene-hud .hud-line { display: flex; gap: 8px; padding: 2px 0; }
.scene-hud .hud-key { color: var(--text-muted); }
.scene-hud .hud-val { color: var(--text-primary); font-weight: 500; }

/* ------------------------------------------------------------
   12.  FOOTER
   ------------------------------------------------------------ */
.app-footer {
  grid-area: footer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s-2) var(--s-4);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.app-footer .accent { color: var(--text-muted); }

/* ------------------------------------------------------------
   13.  TOASTS (Konvertierungs-Toast)
   ------------------------------------------------------------ */
.toast-stack {
  position: fixed;
  top: var(--s-5);
  right: var(--s-5);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  max-width: 340px;
  transform: translateX(120%);
  transition: transform 0.5s var(--ease-spring);
}
.toast.visible { transform: translateX(0); }
.toast-icon {
  width: 22px; height: 22px;
  border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--plane-soft);
  color: var(--plane-color);
}
.toast-icon svg { width: 13px; height: 13px; }
.toast-content { flex: 1; }
.toast-title {
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 2px;
}
.toast-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ------------------------------------------------------------
   14.  TOUR OVERLAY
   ------------------------------------------------------------ */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(7, 9, 26, 0.65);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-out);
}
.tour-overlay.active { opacity: 1; pointer-events: auto; }

.tour-spotlight {
  position: absolute;
  border-radius: var(--r-lg);
  box-shadow:
    0 0 0 9999px rgba(13, 14, 18, 0.78),
    0 0 0 1.5px rgba(236, 232, 225, 0.4);
  pointer-events: none;
  transition: all 0.55s var(--ease-out);
}

.tour-callout {
  position: absolute;
  width: 320px;
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border-hi);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  transition: all 0.55s var(--ease-out);
}
.tour-callout::before {
  content: '';
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-inner-light), transparent);
}
.tour-step-eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.tour-step-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.015em;
  margin-bottom: var(--s-2);
  line-height: 1.2;
}
.tour-step-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: var(--s-4);
}
.tour-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tour-progress {
  display: flex;
  gap: 6px;
}
.tour-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: all 0.3s;
}
.tour-dot.active {
  background: var(--text-primary);
  width: 18px;
  border-radius: 3px;
}
.tour-buttons { display: flex; gap: var(--s-2); }
.tour-btn {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.2s;
}
.tour-btn.secondary {
  color: var(--text-muted);
}
.tour-btn.secondary:hover { color: var(--text-primary); }
.tour-btn.primary {
  background: var(--text-primary);
  color: var(--bg-deep);
  font-weight: 600;
}
.tour-btn.primary:hover { transform: translateY(-1px); }
.tour-btn.primary:active { transform: translateY(0); }

/* Hotspot arrow pointing to spotlight */
.tour-arrow {
  position: absolute;
  width: 80px;
  height: 80px;
  pointer-events: none;
  transition: all 0.55s var(--ease-out);
}
.tour-arrow svg {
  width: 100%;
  height: 100%;
  stroke: var(--text-secondary);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  animation: arrow-bob 1.8s ease-in-out infinite;
}
@keyframes arrow-bob {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-6px, -6px); }
}

/* ------------------------------------------------------------
   15.  LOADING SCREEN with animated SVG logo
   ------------------------------------------------------------ */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-5);
  transition: opacity 0.6s var(--ease-out), visibility 0.6s;
}
.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
}
.loading-logo {
  width: 120px;
  height: 120px;
}
.loading-name {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 32px;
  letter-spacing: 0.6em;
  padding-left: 0.6em;
  font-variation-settings: "opsz" 144;
  color: var(--text-primary);
  opacity: 0;
  animation: name-fadein 1.2s 0.6s var(--ease-out) forwards;
}
@keyframes name-fadein {
  from { opacity: 0; transform: translateY(8px); letter-spacing: 0.8em; padding-left: 0.8em; }
  to { opacity: 1; transform: translateY(0); letter-spacing: 0.6em; padding-left: 0.6em; }
}
.loading-tagline {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0;
  animation: name-fadein 1.2s 1.1s var(--ease-out) forwards;
}

/* ------------------------------------------------------------
   16.  RESPONSIVE — mobile + tablet portrait
   ------------------------------------------------------------ */
@media (max-width: 980px) {
  #app {
    height: auto;
    min-height: 100dvh;
    grid-template-rows: auto auto auto auto;
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "scene"
      "panels"
      "footer";
    padding: var(--s-3);
    gap: var(--s-3);
  }
  .panels-column {
    overflow: visible;
    padding-right: 0;
    /* Let the document scroll instead of constraining the column */
    max-height: none;
  }
  .scene-column {
    height: 56vh;
    min-height: 320px;
    max-height: 520px;
  }
  .app-header {
    flex-wrap: wrap;
    gap: var(--s-3);
    padding: var(--s-3);
  }
  .brand-name { font-size: 20px; }
  .brand-tagline { font-size: 9.5px; letter-spacing: 0.18em; }
  .brand-logo { width: 34px; height: 34px; }
  .header-actions { gap: 4px; }
  .glass-toggle { margin-right: 0; }
  .glass-toggle button { padding: 5px 9px; font-size: 9.5px; }
  .icon-btn { width: 34px; height: 34px; }
  .object-panel { padding: var(--s-4); }
  .result-panel { padding: var(--s-4); }
  .vector-row { grid-template-columns: 64px 1fr; }
  .num-input { padding: 8px 10px; font-size: 13px; }
  .coord-eq { font-size: 16px; }
  .coord-eq .coord-num { width: 48px; font-size: 13px; }
  .relation-headline { font-size: 22px; }
  .app-footer {
    flex-direction: column;
    gap: 4px;
    text-align: center;
    padding: var(--s-3);
  }
}
