/* ── Google Fonts ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;700&family=Exo+2:wght@300;400;500&display=swap');

/* ── Design tokens ────────────────────────────────────────────── */
:root {
  /* Space backgrounds */
  --bg:           #020810;
  --bg-card:      #060d1a;
  --bg-card-hover:#091220;
  --bg-input:     #07101f;
  --border:       #112240;
  --border-lit:   #1d3a6e;

  /* Star Wars palette */
  --holo-blue:    #4fc3f7;
  --holo-blue-dim:#1a6fa8;
  --gold:         #ffd700;
  --gold-dim:     #b8960a;
  --rebel-orange: #ff6d00;
  --saber-green:  #7fff7f;
  --imperial-red: #ff1744;

  /* Text */
  --text:         #cdd6f4;
  --text-muted:   #4a6a8a;

  /* Glows */
  --glow-blue:    0 0 8px #4fc3f7, 0 0 24px #4fc3f755;
  --glow-gold:    0 0 8px #ffd700, 0 0 20px #ffd70055;
  --glow-orange:  0 0 8px #ff6d00, 0 0 18px #ff6d0055;
  --glow-green:   0 0 8px #7fff7f, 0 0 20px #7fff7f44;

  /* Typography */
  --font-hud:     'Orbitron', 'Courier New', monospace;
  --font-body:    'Exo 2', system-ui, sans-serif;
  --font-mono:    'Courier New', Courier, monospace;

  --radius:       4px;
  --transition:   0.2s ease;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 300;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Star field via layered radial gradients */
  background-image:
    radial-gradient(1px 1px at 10%  15%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 25%  40%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 40%  8%,  rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 55%  60%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 70%  25%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 80%  75%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 90%  50%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 15%  80%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 35%  90%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 62%  88%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 78%  12%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 92%  35%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(2px 2px at 48%  30%, rgba(200,220,255,0.3) 0%, transparent 100%),
    radial-gradient(2px 2px at 72%  65%, rgba(200,220,255,0.2) 0%, transparent 100%);
  background-attachment: fixed;
}

a { color: var(--holo-blue); text-decoration: none; }
a:hover { text-shadow: var(--glow-blue); }

/* Text links: holo-blue with a permanent subtle underline that lights up on hover/focus.
   Header nav items are menu items and buttons rendered as <a class="btn"> keep their own look. */
.back-link {
  color: var(--holo-blue);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(79,195,247,0.35);
  text-underline-offset: 4px;
  transition: text-decoration-color var(--transition), text-shadow var(--transition);
}
.back-link:hover,
.back-link:focus-visible {
  color: var(--holo-blue);
  text-decoration-color: var(--holo-blue);
}

/* One focus ring for every control: buttons, icon buttons, switch, links. */
.btn:focus-visible,
.btn-tertiary:focus-visible,
.switch-input:focus-visible,
.back-link:focus-visible,
.fs-exit:focus-visible,
.share-close:focus-visible {
  outline: 2px solid var(--holo-blue);
  outline-offset: 2px;
}
.btn-primary:focus-visible { outline-color: var(--gold); }

/* ── Header ──────────────────────────────────────────────────── */
.site-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-lit);
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, #030c1c 0%, transparent 100%);
  position: relative;
}
.site-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--holo-blue-dim), var(--gold-dim), transparent);
  opacity: 0.6;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
}
.site-logo:hover { text-shadow: none; }

.logo-icon {
  color: var(--holo-blue);
  filter: drop-shadow(0 0 5px #4fc3f7) drop-shadow(0 0 12px #4fc3f755);
  animation: holo-pulse 3s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes holo-pulse {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 5px #4fc3f7) drop-shadow(0 0 12px #4fc3f755); }
  50%       { opacity: 0.75; filter: drop-shadow(0 0 3px #4fc3f7) drop-shadow(0 0 6px #4fc3f733); }
}

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  transition: color var(--transition), filter var(--transition);
  padding: 0;
}
.nav-icon-btn svg { width: 20px; height: 20px; }
.nav-icon-btn:hover {
  color: var(--holo-blue);
  filter: drop-shadow(0 0 5px #4fc3f7);
}

.logo-text {
  font-family: var(--font-hud);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: var(--glow-gold);
}

/* ── Layout ──────────────────────────────────────────────────── */
.site-main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

/* ── Section headings ────────────────────────────────────────── */
h1, h2 {
  font-family: var(--font-hud);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.4rem;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  background: transparent;
  font-family: var(--font-hud);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: box-shadow var(--transition), background var(--transition), color var(--transition);
  min-height: 44px;
  color: var(--text);
  position: relative;
  overflow: hidden;
}
.btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Subtle scan-line shimmer on hover */
.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 50%, transparent 50%);
  background-size: 100% 4px;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.btn:hover:not(:disabled)::before { opacity: 1; }

.btn-primary {
  color: var(--gold);
  border-color: var(--gold-dim);
}
.btn-primary:hover:not(:disabled) {
  background: rgba(255,215,0,0.07);
  box-shadow: var(--glow-gold), inset 0 0 12px rgba(255,215,0,0.04);
}

.btn-secondary {
  color: var(--holo-blue);
  border-color: var(--holo-blue-dim);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(79,195,247,0.08);
  box-shadow: var(--glow-blue);
}

/* Tertiary: icon only, no box, 48px tap target. Needs aria-label + title. */
.btn-tertiary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: var(--holo-blue);
  cursor: pointer;
  transition: color var(--transition), filter var(--transition), background var(--transition);
}
.btn-tertiary:hover {
  background: rgba(79,195,247,0.08);
  filter: drop-shadow(0 0 5px var(--holo-blue));
}
.btn-tertiary .btn-svg { width: 22px; height: 22px; }
/* Small variant (✎ on the preset line): smaller icon, 44px tap target. */
.btn-tertiary--sm { width: 44px; height: 44px; color: var(--text-muted); }
.btn-tertiary--sm:hover { color: var(--holo-blue); }
.btn-tertiary--sm .btn-svg { width: 16px; height: 16px; }

/* Switch: native checkbox[role=switch], 38×20 visible. Wrap it in .switch-hit for a 44px tap area. */
.switch-hit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
}
.switch-input {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 20px;
  margin: 0;
  border: 1px solid var(--holo-blue-dim);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.switch-input::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
}
.switch-input:hover { box-shadow: var(--glow-blue); }
.switch-input:checked {
  background: rgba(79,195,247,0.18);
  border-color: var(--holo-blue);
}
.switch-input:checked::before {
  transform: translateX(18px);
  background: var(--holo-blue);
  box-shadow: 0 0 6px var(--holo-blue);
}

.btn-full { width: 100%; }
.btn-lg { padding: 1rem 2rem; font-size: 0.85rem; }

/* ── Inputs ──────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label {
  font-family: var(--font-hud);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.field-error { font-size: 0.75rem; color: var(--imperial-red); min-height: 1.1em; }

.input-stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-lit);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-input);
}
.input-stepper input[type="number"] {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--holo-blue);
  font-family: var(--font-hud);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  padding: 0.6rem 0;
  -moz-appearance: textfield;
  min-height: 44px;
}
.input-stepper input[type="number"]::-webkit-outer-spin-button,
.input-stepper input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
.input-stepper input[type="number"]:focus { outline: none; }
.input-stepper.invalid { border-color: var(--imperial-red); }

.stepper-btn {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0 0.9rem;
  cursor: pointer;
  font-family: var(--font-hud);
  min-width: 44px;
  min-height: 44px;
  transition: color var(--transition), background var(--transition);
}
.stepper-btn:first-child { border-left: none; border-right: 1px solid var(--border); }
.stepper-btn:hover { color: var(--holo-blue); background: rgba(79,195,247,0.06); }

/* ── Panel/card ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-lit);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  position: relative;
}
/* Corner bracket accent */
.card::before, .card::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: var(--holo-blue-dim);
  border-style: solid;
  opacity: 0.5;
}
.card::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; border-radius: 4px 0 0 0; }
.card::after  { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; border-radius: 0 0 4px 0; }

/* ── Page: list ──────────────────────────────────────────────── */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.list-header h1 {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.choreo-list { display: flex; flex-direction: column; gap: 0.65rem; }

.choreo-item {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  position: relative;
  overflow: hidden;
}
/* Left accent bar */
.choreo-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--holo-blue-dim);
  transition: background var(--transition), box-shadow var(--transition);
}
.choreo-item:hover {
  border-color: var(--border-lit);
  background: var(--bg-card-hover);
  box-shadow: 0 0 16px rgba(79,195,247,0.08);
  text-shadow: none;
}
.choreo-item:hover::before {
  background: var(--holo-blue);
  box-shadow: var(--glow-blue);
}

.choreo-item-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.choreo-badge {
  font-family: var(--font-hud);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--holo-blue);
  border: 1px solid var(--holo-blue-dim);
  border-radius: 2px;
  padding: 0.15rem 0.45rem;
  background: rgba(79,195,247,0.05);
}
.choreo-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
  font-family: var(--font-hud);
  letter-spacing: 0.05em;
}
.choreo-sequence {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  word-break: break-all;
  color: var(--text);
  opacity: 0.85;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state p {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
}

/* ── Page: new-choreo ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.page-header h1 { font-size: 0.8rem; color: var(--text-muted); }
.back-link { font-size: 0.75rem; font-family: var(--font-hud); letter-spacing: 0.08em; }

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Sequence display — the hologram panel */
.sequence-display {
  display: none;
  background: linear-gradient(160deg, #040e20 0%, #060d1a 100%);
  border: 1px solid var(--holo-blue-dim);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 0 20px rgba(79,195,247,0.1), inset 0 0 30px rgba(79,195,247,0.03);
  position: relative;
  overflow: hidden;
}
.sequence-display::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px,
    transparent 3px,
    rgba(79,195,247,0.015) 3px,
    rgba(79,195,247,0.015) 4px
  );
  pointer-events: none;
}
.sequence-display.visible { display: block; }
.sequence-display .sequence-numbers {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  line-height: 1.9;
  color: var(--holo-blue);
  text-shadow: 0 0 10px #4fc3f7, 0 0 30px #4fc3f755;
  position: relative;
  /* Values are spaced by a gap, not letter-spacing, so "100" reads as one number. */
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.8em;
  row-gap: 0.1em;
  letter-spacing: 0.02em;
  min-height: 3.2rem;
}

/* Mode buttons: the active mode is wide and labelled, the other a 52px icon square. */
.mode-actions { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.mode-btn {
  flex: 0 0 52px;
  min-width: 52px;
  height: 52px;
  padding: 0;
  gap: 0;   /* .btn's gap would sit next to the collapsed label and push the icon off-centre */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: flex-grow 0.3s ease, box-shadow var(--transition), background var(--transition), opacity var(--transition);
}
.mode-btn.is-active { flex: 1 1 0; }
.mode-btn:not(.is-active) { opacity: 0.7; }
.mode-btn:not(.is-active):hover:not(:disabled) { opacity: 1; }
.mode-btn:disabled { opacity: 0.3; }
.mode-btn .btn-svg { width: 26px; height: 26px; }
.mode-btn .btn-label {
  display: inline-block;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width 0.3s ease, opacity 0.2s ease, margin 0.3s ease;
}
.mode-btn.is-active .btn-label { max-width: 12em; opacity: 1; margin-left: 0.7rem; }

/* ── Manual entry (edit mode) ──────────────────────────────── */
.sequence-display.is-editing {
  border-color: var(--holo-blue);
  cursor: text;
  box-shadow: 0 0 0 1px rgba(79,195,247,0.25), 0 0 26px rgba(79,195,247,0.22), inset 0 0 30px rgba(79,195,247,0.05);
}
.sequence-display.is-editing .seq-item { border-bottom: 1px dashed rgba(79,195,247,0.35); cursor: pointer; }
.sequence-display.is-editing .seq-item--mapped::after { display: none; }   /* a tap moves the cursor, no tooltip */
.seq-item--invalid { color: var(--imperial-red); text-shadow: 0 0 8px rgba(255,23,68,0.6); }
.seq-item.pop { display: inline-block; animation: seq-pop 0.35s ease-out; }
@keyframes seq-pop { 0% { transform: scale(0.4); opacity: 0.2; } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
.sequence-display.reject { animation: seq-reject 0.3s; border-color: var(--imperial-red); }
@keyframes seq-reject { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.seq-empty { font-family: var(--font-body); font-size: 0.9rem; letter-spacing: normal; color: var(--text-muted); text-shadow: none; }

/* The cursor: one input that sits between the values; a pending value shows in gold. */
.seq-cursor { display: inline-flex; align-items: baseline; }
.seq-input {
  width: 0.6ch;
  padding: 0;
  border: none;
  border-left: 3px solid var(--gold);
  border-radius: 0;
  outline: none;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  color: var(--gold);
  text-shadow: var(--glow-gold);
  caret-color: transparent;
  box-shadow: -4px 0 8px -4px var(--gold);
  animation: seq-blink 1.1s steps(1) infinite;
}
.seq-input.has-value { border-left-color: transparent; border-bottom: 2px solid var(--gold); box-shadow: none; animation: none; }
@keyframes seq-blink { 50% { border-left-color: rgba(255,215,0,0.3); } }
.seq-ghost { opacity: 0.4; margin-left: 0.15em; text-shadow: none; }

.input-stepper.is-auto { opacity: 0.45; }
.count-auto { color: var(--holo-blue-dim); }

/* Mapping chips under the panel: tap to insert, filtered while a value is pending. */
.map-strip { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: -0.6rem 0 0.5rem; }
.map-strip[hidden] { display: none; }
.map-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 34px;
  padding: 0 0.6rem 0 0.5rem;
  border: 1px solid var(--border-lit);
  border-radius: 17px;
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.8rem;
  transition: border-color var(--transition), background var(--transition);
}
.map-chip:hover { border-color: var(--holo-blue-dim); background: rgba(79,195,247,0.06); }
.map-chip:focus-visible { outline: 2px solid var(--holo-blue); outline-offset: 2px; }
.map-chip .n { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--holo-blue); min-width: 1.1em; text-align: right; }
.map-chip .i { font-size: 1rem; line-height: 1; }
.map-chip .l { color: var(--text-muted); }
.map-chip.is-match { border-color: var(--gold-dim); background: rgba(255,215,0,0.07); box-shadow: 0 0 10px rgba(255,215,0,0.15); }
.map-chip.is-match .n { color: var(--gold); }
.map-chip.is-hidden { display: none; }
.chip-more { color: var(--holo-blue); font-family: var(--font-hud); font-size: 0.6rem; letter-spacing: 0.1em; padding: 0 0.75rem; }
.map-none { font-size: 0.8rem; color: var(--text-muted); min-height: 34px; display: flex; align-items: center; }

.seq-hint { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.72rem; color: var(--text-muted); margin-bottom: 1.25rem; }
.seq-hint[hidden] { display: none; }
.seq-hint .err { color: var(--imperial-red); }

.save-form { display: none; }
.save-form.visible { display: block; }

/* ── Page: choreo-detail ────────────────────────────────────── */
/* Same DOM order at every width: back link, meta (with preset line), numbers, Vollbild, Teilen row. */
.detail-back {
  display: flex;
  width: fit-content;
  align-items: center;
  min-height: 44px;
  /* The 44px tap box centres the text; pull it up so the text sits where other pages' back links do. */
  margin-top: -14px;
  margin-bottom: 0.5rem;
}
.detail-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  margin-bottom: 2rem;
}
/* Preset name, symbols switch and ✎. The 44px tap areas overlap the neighbouring lines a little,
   so the line keeps the rhythm of the other meta lines. */
.preset-line {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin: -12px 0;
  min-height: 44px;
}
.preset-line .detail-preset { margin-right: 0.35rem; }
.detail-id {
  font-family: var(--font-hud);
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
}
.detail-config {
  font-family: var(--font-hud);
  font-size: 0.9rem;
  color: var(--gold);
  text-shadow: var(--glow-gold);
  letter-spacing: 0.1em;
}
.detail-date {
  font-family: var(--font-hud);
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

/* Large sequence — the main holographic display */
.sequence-large {
  background: linear-gradient(160deg, #040e20 0%, #060d1a 100%);
  border: 1px solid var(--holo-blue-dim);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 0 30px rgba(79,195,247,0.12), inset 0 0 40px rgba(79,195,247,0.04);
  position: relative;
  overflow: hidden;
}
/* Scan lines */
.sequence-large::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px,
    transparent 3px,
    rgba(79,195,247,0.018) 3px,
    rgba(79,195,247,0.018) 4px
  );
  pointer-events: none;
}
/* Top edge glow */
.sequence-large::after {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--holo-blue), transparent);
  opacity: 0.5;
}
.sequence-large .sequence-numbers {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 5.5vw, 2.4rem);
  letter-spacing: 0.25em;
  line-height: 2;
  word-break: break-all;
  color: var(--holo-blue);
  text-shadow: 0 0 12px #4fc3f7, 0 0 35px #4fc3f755;
  position: relative;
}

/* ── Fullscreen numbers ──────────────────────────────────────── */
.fs-exit {
  display: none;
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--holo-blue-dim);
  border-radius: 50%;
  background: rgba(4, 14, 32, 0.85);
  color: var(--holo-blue);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

/* Used both for the native Fullscreen API and the viewport-filling fallback. */
.sequence-large.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: #040e20;
}
.sequence-large.is-fullscreen .fs-exit { display: flex; }

/* Columns and rows, font size and gap are set from JS in fitNumbers(). */
.sequence-large.is-fullscreen .sequence-numbers {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 1), minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  justify-items: center;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--fs, 2rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: 0;
  word-break: normal;
  color: #f2fbff;
  text-shadow: 0 0 14px rgba(79, 195, 247, 0.6);
}
.sequence-large.is-fullscreen .seq-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  white-space: nowrap;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.detail-fullscreen { flex: 1; }
.detail-share-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.detail-share { margin-right: 0.25rem; }

/* ── Share overlay ───────────────────────────────────────────── */
.share-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2,8,16,0.88);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
}
.share-overlay.visible { display: flex; }
.share-panel {
  background: linear-gradient(160deg, #05101f 0%, #060d1a 100%);
  border: 1px solid var(--holo-blue-dim);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 300px;
  box-shadow: var(--glow-blue), 0 0 60px rgba(79,195,247,0.1);
  text-align: center;
  position: relative;
}
/* Corner brackets on panel */
.share-panel::before, .share-panel::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border-color: var(--holo-blue);
  border-style: solid;
}
.share-panel::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.share-panel::after  { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

.share-panel h2 {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-shadow: var(--glow-gold);
  margin-bottom: 1.25rem;
}
#qr-canvas { display: flex; justify-content: center; margin-bottom: 1.25rem; }
#qr-canvas canvas, #qr-canvas img { border: 3px solid #fff; border-radius: 2px; }
.share-panel-actions { display: flex; gap: 0.75rem; }
.share-panel-actions .btn { flex: 1; }
.share-close {
  position: absolute;
  top: 0.6rem; right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  font-family: var(--font-hud);
  transition: color var(--transition);
}
.share-close:hover { color: var(--imperial-red); }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-family: var(--font-hud);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.6rem 1.3rem;
  border-radius: var(--radius);
  box-shadow: var(--glow-gold);
  z-index: 200;
  white-space: nowrap;
  animation: toast-in 0.15s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
}

/* ── Page: not-found ─────────────────────────────────────────── */
.not-found {
  text-align: center;
  padding: 3rem 1rem;
}
.not-found h1 {
  font-size: 1rem;
  color: var(--imperial-red);
  margin-bottom: 1rem;
  text-shadow: 0 0 12px var(--imperial-red);
}
.not-found p { color: var(--text-muted); margin-bottom: 1.75rem; font-size: 0.9rem; }

/* ── Dice roll animation ─────────────────────────────────────── */
@keyframes dice-roll {
  0%   { transform: rotate(0deg)   scale(1); }
  20%  { transform: rotate(90deg)  scale(1.2); }
  45%  { transform: rotate(225deg) scale(0.9); }
  70%  { transform: rotate(315deg) scale(1.15); }
  90%  { transform: rotate(350deg) scale(1.05); }
  100% { transform: rotate(360deg) scale(1); }
}
.dice-rolling {
  animation: dice-roll 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Icon-only buttons (mobile) ─────────────────────────────── */
.btn-svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.btn-lg .btn-svg {
  width: 26px;
  height: 26px;
}
.btn-primary .btn-svg {
  filter: drop-shadow(0 0 5px var(--gold)) drop-shadow(0 0 12px rgba(255,215,0,0.45));
}
.btn-secondary .btn-svg {
  filter: drop-shadow(0 0 5px var(--holo-blue)) drop-shadow(0 0 12px rgba(79,195,247,0.45));
}

@media (max-width: 480px) {
  .btn.btn-icon {
    padding: 0;
    width: 52px;
    height: 52px;
  }
  .btn.btn-icon .btn-label { display: none; }
  .btn.btn-full .btn-label { display: none; }
}

/* ── Nav link ───────────────────────────────────────────────── */
.nav-link {
  font-family: var(--font-hud);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.4rem 0.5rem;
  transition: color var(--transition), text-shadow var(--transition);
}
.nav-link:hover {
  color: var(--holo-blue);
  text-shadow: var(--glow-blue);
}

/* Language switcher: flag + code, one tap switches to the other language */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  font-family: var(--font-hud);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition), text-shadow var(--transition);
}
.lang-switch:hover {
  color: var(--holo-blue);
  text-shadow: var(--glow-blue);
}
.lang-flag {
  display: block;
  width: 22px;
  height: 15px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* ── Presets page ───────────────────────────────────────────── */
.preset-item { cursor: default; }
.preset-item:hover { text-shadow: none; }
.preset-name {
  font-family: var(--font-hud);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--text);
}
.preset-badge-default {
  background: rgba(255,215,0,0.1);
  border-color: var(--gold-dim);
  color: var(--gold);
}
.preset-mappings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin: 0.6rem 0;
  font-size: 0.85rem;
}
.preset-mapping-preview {
  font-family: var(--font-mono);
  color: var(--holo-blue);
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(79,195,247,0.04);
}
.preset-mapping-label {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  margin-left: 0.15rem;
}
.preset-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.preset-actions .btn {
  font-size: 0.65rem;
  padding: 0.45rem 0.9rem;
  min-height: 36px;
}

/* ── Delete button ──────────────────────────────────────────── */
.btn-danger {
  color: var(--imperial-red);
  border-color: rgba(255,23,68,0.4);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(255,23,68,0.08);
  box-shadow: 0 0 8px rgba(255,23,68,0.4);
}

/* ── Mapping form rows ──────────────────────────────────────── */
.mapping-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}
.mapping-input {
  background: var(--bg-input);
  border: 1px solid var(--border-lit);
  border-radius: var(--radius);
  color: var(--holo-blue);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.5rem 0.6rem;
  min-height: 40px;
}
.mapping-input:focus {
  outline: none;
  border-color: var(--holo-blue-dim);
  box-shadow: 0 0 6px rgba(79,195,247,0.15);
}
.mapping-number {
  width: 60px;
  text-align: center;
  font-family: var(--font-hud);
  -moz-appearance: textfield;
}
.mapping-number::-webkit-outer-spin-button,
.mapping-number::-webkit-inner-spin-button { -webkit-appearance: none; }
.mapping-label { flex: 1; }
.mapping-icon { width: 90px; text-align: center; }
.btn-remove-mapping {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius);
  min-width: 36px;
  min-height: 36px;
  font-size: 1.1rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Sequence items (mapped rendering) ──────────────────────── */
.seq-item {
  display: inline;
}
.seq-item--mapped {
  cursor: help;
  position: relative;
}

/* CSS tooltip for mapped items on hover */
.seq-item--mapped::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--holo-blue-dim);
  border-radius: var(--radius);
  padding: 0.3rem 0.6rem;
  font-family: var(--font-body);
  font-size: 0.7rem;
  letter-spacing: normal;
  color: var(--text);
  white-space: nowrap;
  box-shadow: var(--glow-blue);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
}
.seq-item--mapped:hover::after {
  opacity: 1;
}

/* Mobile popover for mapped items */
.seq-popover {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--holo-blue-dim);
  border-radius: var(--radius);
  padding: 0.3rem 0.6rem;
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--text);
  white-space: nowrap;
  box-shadow: var(--glow-blue);
  z-index: 10;
  pointer-events: none;
}
.seq-popover::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--holo-blue-dim);
}

/* ── Preset selector on new-choreo page ────────────────────────── */
.preset-select-field {
  margin-bottom: 1.25rem;
}
.preset-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-lit);
  border-radius: var(--radius);
  color: var(--holo-blue);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.6rem 0.8rem;
  min-height: 44px;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234fc3f7' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
}
.preset-select:focus {
  outline: none;
  border-color: var(--holo-blue-dim);
  box-shadow: 0 0 6px rgba(79,195,247,0.15);
}
.preset-select option {
  background: var(--bg-card);
  color: var(--text);
}

/* ── Preset name on detail page ─────────────────────────────── */
.detail-preset {
  font-family: var(--font-hud);
  font-size: 0.7rem;
  color: var(--text);
  letter-spacing: 0.08em;
}
.detail-preset--none { color: var(--text-muted); font-style: italic; }

@media (max-width: 480px) {
  .mapping-row { flex-wrap: wrap; }
  .mapping-label { min-width: 100px; }
  .mapping-icon { flex: 1; min-width: 60px; }
}

/* ── Utility ─────────────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* ── Mobile: burger menu ────────────────────────────────────── */
.nav-burger { display: none; }
.nav-menu-text { display: none; }

@media (max-width: 480px) {
  .nav-burger { display: flex; margin-left: auto; width: 44px; height: 44px; }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 0.4rem 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-lit);
    box-shadow: 0 12px 24px rgba(0,0,0,0.5);
  }
  .site-nav.open { display: flex; }

  /* Every entry is a full-width row with a 48px tap target. */
  .site-nav > .nav-link,
  .site-nav > .lang-switch,
  .site-nav > .nav-icon-btn {
    width: 100%;
    height: auto;
    min-height: 48px;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.6rem;
    font-family: var(--font-hud);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-radius: 0;
  }
  .site-nav > .nav-icon-btn svg { width: 18px; height: 18px; }
  .nav-menu-text { display: inline; }
  /* Language row: label first, current flag + code pushed to the right. */
  .lang-switch .nav-menu-text { order: -1; margin-right: auto; }

  /* Detail actions: Vollbild takes a full row, the Teilen row sits below it. */
  .detail-actions { flex-direction: column; align-items: stretch; }
  .detail-share { flex: 1; }
}

/* ── Dialog (native <dialog>, styled like the QR overlay) ───── */
.app-dialog {
  margin: auto;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  width: calc(100% - 3rem);
  max-width: 360px;
  overflow: visible;
}
.app-dialog::backdrop {
  background: rgba(2,8,16,0.88);
  backdrop-filter: blur(4px);
}
.app-dialog-panel { max-width: none; text-align: left; }
.app-dialog-text {
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}
.app-dialog-warning {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(255,109,0,0.5);
  border-radius: var(--radius);
  background: rgba(255,109,0,0.08);
  color: var(--rebel-orange);
  font-size: 0.85rem;
  line-height: 1.4;
}
.app-dialog-warning[hidden] { display: none; }
.app-dialog-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.app-dialog-actions .btn { flex: 1; }

/* ── Stats page ─────────────────────────────────────────────── */
.site-main--wide { max-width: 1100px; }
.stats-note { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1rem; }
.stats-device {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stats-device-text { font-size: 0.85rem; line-height: 1.5; color: var(--text-muted); flex: 1 1 260px; }
.stats-device-text strong { color: var(--text); font-weight: 600; }
.stats-note--error { color: var(--rebel-orange); }
.stats-scroll { overflow-x: auto; }
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  white-space: nowrap;
}
.stats-table th,
.stats-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.stats-table th {
  font-family: var(--font-hud);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.stats-table td { font-family: var(--font-mono); }
.stats-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.stats-table .stats-group { border-left: 1px solid var(--border-lit); }
.stats-table tbody tr:hover { background: var(--bg-card-hover); }
.stats-zero { color: var(--text-muted); }
