:root {
  /* Projection Room color tokens */
  --bg-canvas: #0C0B0A;
  --bg-stage: #151311;
  --surface-card: #1F1C19;
  --surface-elevated: #2B2622;
  --surface-glass: rgba(28, 24, 21, 0.78);
  --surface-glass-strong: rgba(24, 20, 17, 0.88);
  --border-hairline: rgba(247, 243, 236, 0.12);
  --border-strong: rgba(247, 243, 236, 0.20);
  --border-catchlight: rgba(255, 224, 168, 0.36);

  --text-primary: #F7F3EC;
  --text-secondary: #C7C0B6;
  --text-muted: #8F887E;
  --text-on-accent: #14110D;

  --accent-primary: #F2A93B;
  --accent-highlight: #FFD27D;
  --accent-deep: #C97B18;
  --accent-glow: rgba(242, 169, 59, 0.30);

  --status-success: #47C47F;
  --status-success-hi: #8BE6B1;
  --status-warning: #E56B4E;
  --status-warning-hi: #F49B85;

  --chip-bg: rgba(255, 255, 255, 0.09);
  --chip-border: rgba(255, 255, 255, 0.22);
  --chip-text: #D4D4D8;

  /* Radii */
  --r-chip: 8px;
  --r-input: 12px;
  --r-cell: 16px;
  --r-card: 18px;
  --r-avatar: 18px;
  --r-glass: 28px;
  --r-pill: 999px;

  /* Motion tokens */
  --dur-snap: 180ms;
  --ease-snap: cubic-bezier(0.20, 0.90, 0.30, 1);
  --dur-focus: 260ms;
  --ease-focus: cubic-bezier(0.18, 0.92, 0.26, 1);
  --dur-pill: 280ms;
  --ease-pill: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-panel: 360ms;
  --ease-panel: cubic-bezier(0.16, 1, 0.30, 1);
  --dur-dismiss: 240ms;
  --ease-dismiss: cubic-bezier(0.40, 0, 0.80, 1);
  --dur-celebrate: 520ms;
  --ease-celebrate: cubic-bezier(0.16, 1, 0.30, 1);
  --dur-crossfade: 420ms;
  --ease-crossfade: cubic-bezier(0.25, 0.10, 0.25, 1);
  --dur-backdrop: 1600ms;
  --ease-backdrop: cubic-bezier(0.37, 0, 0.63, 1);
  --dur-drift: 38000ms;

  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, system-ui, Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color-scheme: dark;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

h1, h2, h3, p {
  margin: 0;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2.5px var(--accent-primary), 0 0 18px var(--accent-glow);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Shared utilities ---------- */
.muted { color: var(--text-secondary); }
.subtle { color: var(--text-muted); }
.small { font-size: 13.5px; line-height: 1.45; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt-sm { margin-top: 10px; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 22px; }

/* ---------- Buttons (Capsule + Press-Down) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 22px;
  border-radius: var(--r-pill);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  background: var(--accent-primary);
  color: var(--text-on-accent);
  border: 1px solid rgba(255, 224, 168, 0.35);
  box-shadow: 0 8px 24px var(--accent-glow), inset 0 1px 0 rgba(255, 244, 222, 0.45);
  transition:
    transform var(--dur-snap) var(--ease-snap),
    background-color var(--dur-snap) var(--ease-snap),
    box-shadow var(--dur-focus) var(--ease-focus),
    border-color var(--dur-snap) var(--ease-snap);
  user-select: none;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--accent-highlight);
  box-shadow: 0 12px 30px rgba(242, 169, 59, 0.40), inset 0 1px 0 rgba(255, 250, 235, 0.65);
}

.btn:active:not(:disabled) {
  transform: scale(0.965);
}

.btn.ghost {
  background: rgba(247, 243, 236, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  box-shadow: inset 0 1px 0 rgba(255, 224, 168, 0.14);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--surface-elevated);
  border-color: var(--border-catchlight);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 224, 168, 0.24);
}

.btn.danger {
  background: rgba(229, 107, 78, 0.10);
  color: var(--status-warning-hi);
  border: 1px solid rgba(229, 107, 78, 0.56);
  box-shadow: none;
}

.btn.danger:hover:not(:disabled) {
  background: rgba(229, 107, 78, 0.20);
  border-color: var(--status-warning);
  box-shadow: 0 8px 22px rgba(229, 107, 78, 0.22);
}

.btn.sm {
  min-height: 40px;
  padding: 0 15px;
  font-size: 13.5px;
}

.btn:disabled {
  opacity: 0.42;
  cursor: default;
  box-shadow: none;
}

/* ---------- Inputs, Labels, Selects, Switches ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

label, .field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.invite-input {
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.invite-input::placeholder {
  letter-spacing: 0.08em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input:not([type]),
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--r-input);
  background: rgba(15, 13, 11, 0.86);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.35;
  transition:
    border-color var(--dur-snap) var(--ease-snap),
    background-color var(--dur-snap) var(--ease-snap),
    box-shadow var(--dur-focus) var(--ease-focus);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: var(--border-strong);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  background: #14110E;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(242, 169, 59, 0.24), inset 0 1px 0 rgba(255, 224, 168, 0.18);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.helper {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.err {
  color: var(--status-warning-hi);
  font-size: 13.5px;
  font-weight: 500;
  min-height: 20px;
  margin-top: 10px;
}

/* Custom accessible switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
}

.switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 48px;
  min-width: 48px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  margin: 0;
  border-radius: var(--r-pill);
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition:
    background-color var(--dur-snap) var(--ease-snap),
    border-color var(--dur-snap) var(--ease-snap),
    box-shadow var(--dur-focus) var(--ease-focus);
}

.switch input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  transition:
    transform var(--dur-pill) var(--ease-pill),
    background-color var(--dur-snap) var(--ease-snap);
}

.switch input[type="checkbox"]:checked {
  background: var(--accent-primary);
  border-color: var(--accent-highlight);
}

.switch input[type="checkbox"]:checked::after {
  transform: translateX(20px);
  background: var(--text-on-accent);
}

.switch input[type="checkbox"]:disabled {
  opacity: 0.65;
  cursor: default;
}

/* ---------- Chips & Status Pills ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-chip);
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  color: var(--chip-text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  color: var(--chip-text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
}

.pill.ok {
  background: rgba(71, 196, 127, 0.14);
  border-color: rgba(71, 196, 127, 0.42);
  color: var(--status-success-hi);
}

.pill.amber {
  background: rgba(242, 169, 59, 0.15);
  border-color: rgba(242, 169, 59, 0.44);
  color: var(--accent-highlight);
}

.pill.warn {
  background: rgba(229, 107, 78, 0.14);
  border-color: rgba(229, 107, 78, 0.44);
  color: var(--status-warning-hi);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-success);
  box-shadow: 0 0 10px rgba(71, 196, 127, 0.65);
  flex-shrink: 0;
}

/* ---------- Auth Stage & Drifting Poster Wall ---------- */
.auth-stage {
  position: relative;
  min-height: 100dvh;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding:
    max(28px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background: var(--bg-canvas);
}

.wall-wrap {
  position: fixed;
  inset: -24% -18%;
  transform: rotate(-13deg);
  display: flex;
  gap: 18px;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  animation: wallFadeIn 0.7s var(--ease-crossfade) forwards;
}

.wall-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 180px;
  flex-shrink: 0;
  will-change: transform;
}

.wall-col.up {
  animation: driftUp var(--dur-drift) linear infinite;
}

.wall-col.down {
  animation: driftDown 42000ms linear infinite;
}

.poster {
  width: 180px;
  height: 264px;
  border-radius: var(--r-card);
  border: 1px solid rgba(255, 224, 168, 0.22);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 232, 186, 0.18);
  display: flex;
  align-items: flex-end;
  padding: 16px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

/* Silhouette ridge / landmark layer */
.poster::before {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: 0;
  height: 52%;
  background: linear-gradient(180deg, rgba(16, 12, 10, 0.84) 0%, #0C0A09 100%);
  pointer-events: none;
  z-index: 1;
}

/* Bottom legibility scrim + subtle film edge sheen */
.poster::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(125deg, rgba(255, 226, 168, 0.14) 0%, transparent 38%),
    linear-gradient(180deg, transparent 40%, rgba(10, 9, 8, 0.76) 100%);
  pointer-events: none;
  z-index: 1;
}

.poster span {
  position: relative;
  z-index: 2;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(247, 243, 236, 0.92);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

/* 8 varied cinematic poster scenes: sky, horizon band, sun/moon disc, light leak, silhouettes */
.p1 {
  background:
    radial-gradient(circle at 74% 28%, rgba(255, 224, 152, 0.92) 0%, rgba(242, 169, 59, 0.48) 12%, transparent 32%),
    linear-gradient(132deg, rgba(255, 196, 112, 0.34) 0%, transparent 46%),
    linear-gradient(180deg, #523222 0%, #8A4D2A 46%, #C27B3B 64%, #26160E 100%);
}
.p1::before {
  clip-path: polygon(0% 56%, 24% 40%, 48% 58%, 68% 48%, 73% 20%, 79% 20%, 84% 48%, 100% 38%, 100% 100%, 0% 100%);
}

.p2 {
  background:
    radial-gradient(circle at 30% 42%, rgba(255, 236, 186, 0.88) 0%, rgba(226, 178, 92, 0.42) 15%, transparent 38%),
    linear-gradient(110deg, rgba(164, 210, 178, 0.24) 0%, transparent 48%),
    linear-gradient(180deg, #2D473C 0%, #4A6E5A 48%, #9A8454 64%, #15211B 100%);
}
.p2::before {
  clip-path: polygon(0% 44%, 22% 52%, 44% 64%, 72% 46%, 100% 58%, 100% 100%, 0% 100%);
}

.p3 {
  background:
    radial-gradient(circle at 52% 46%, rgba(255, 206, 118, 0.95) 0%, rgba(232, 116, 48, 0.56) 22%, transparent 48%),
    linear-gradient(145deg, rgba(255, 154, 78, 0.32) 0%, transparent 42%),
    linear-gradient(180deg, #6E3320 0%, #B3582B 50%, #D98A3C 66%, #29130C 100%);
}
.p3::before {
  clip-path: polygon(0% 62%, 18% 42%, 36% 42%, 48% 60%, 70% 54%, 84% 34%, 100% 46%, 100% 100%, 0% 100%);
}

.p4 {
  background:
    radial-gradient(circle at 72% 30%, rgba(255, 232, 168, 0.92) 0%, rgba(242, 169, 59, 0.42) 14%, transparent 34%),
    linear-gradient(120deg, rgba(255, 214, 130, 0.38) 0%, transparent 50%),
    linear-gradient(180deg, #57411D 0%, #9E742E 48%, #CE9E47 64%, #22190B 100%);
}
.p4::before {
  clip-path: polygon(0% 60%, 26% 32%, 52% 58%, 78% 28%, 100% 54%, 100% 100%, 0% 100%);
}

.p5 {
  background:
    radial-gradient(circle at 26% 28%, rgba(255, 216, 154, 0.88) 0%, rgba(212, 92, 74, 0.45) 16%, transparent 38%),
    linear-gradient(138deg, rgba(235, 128, 92, 0.34) 0%, transparent 48%),
    linear-gradient(180deg, #592228 0%, #8E373D 48%, #C4684B 64%, #1E0D10 100%);
}
.p5::before {
  clip-path: polygon(0% 48%, 14% 56%, 32% 42%, 50% 56%, 68% 40%, 86% 56%, 100% 46%, 100% 100%, 0% 100%);
}

.p6 {
  background:
    radial-gradient(circle at 66% 44%, rgba(255, 210, 130, 0.85) 0%, rgba(212, 146, 56, 0.38) 18%, transparent 42%),
    linear-gradient(155deg, rgba(214, 188, 146, 0.22) 0%, transparent 44%),
    linear-gradient(180deg, #3A3834 0%, #635B4E 48%, #9B7B4F 65%, #181613 100%);
}
.p6::before {
  clip-path: polygon(0% 62%, 18% 62%, 22% 36%, 28% 36%, 32% 62%, 54% 62%, 60% 44%, 76% 44%, 82% 62%, 100% 58%, 100% 100%, 0% 100%);
}

.p7 {
  background:
    radial-gradient(circle at 50% 34%, rgba(247, 232, 174, 0.86) 0%, rgba(164, 172, 86, 0.42) 16%, transparent 38%),
    linear-gradient(128deg, rgba(196, 208, 126, 0.28) 0%, transparent 48%),
    linear-gradient(180deg, #3D4E2A 0%, #62753D 48%, #9C9652 64%, #171E0F 100%);
}
.p7::before {
  clip-path: polygon(0% 64%, 12% 40%, 24% 60%, 38% 34%, 52% 62%, 68% 38%, 82% 58%, 94% 42%, 100% 56%, 100% 100%, 0% 100%);
}

.p8 {
  background:
    radial-gradient(circle at 50% 54%, rgba(255, 214, 128, 0.92) 0%, rgba(229, 122, 54, 0.48) 20%, transparent 44%),
    linear-gradient(130deg, rgba(242, 169, 59, 0.32) 0%, transparent 45%),
    linear-gradient(180deg, #5F3D24 0%, #8E542B 48%, #C97D38 64%, #21140C 100%);
}
.p8::before {
  clip-path: polygon(0% 52%, 28% 52%, 44% 68%, 56% 68%, 72% 52%, 100% 52%, 100% 100%, 0% 100%);
}

/* Soft warm projector beam from top center behind the glass card */
.projector-beam {
  position: fixed;
  top: -40px;
  left: 50%;
  width: min(880px, 136vw);
  height: min(680px, 84vh);
  transform: translateX(-50%);
  pointer-events: none;
  background: radial-gradient(ellipse 48% 64% at 50% 6%, rgba(255, 224, 168, 0.26) 0%, rgba(242, 169, 59, 0.12) 44%, transparent 76%);
  clip-path: polygon(41% 0%, 59% 0%, 94% 100%, 6% 100%);
  filter: blur(26px);
}

.projector-beam.is-success {
  background: radial-gradient(ellipse 48% 64% at 50% 6%, rgba(139, 230, 177, 0.24) 0%, rgba(71, 196, 127, 0.10) 44%, transparent 76%);
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 76% 64% at 50% 48%, rgba(12, 11, 10, 0.34) 0%, rgba(12, 11, 10, 0.56) 58%, rgba(12, 11, 10, 0.90) 100%),
    linear-gradient(180deg, rgba(12, 11, 10, 0.52) 0%, rgba(12, 11, 10, 0.16) 45%, rgba(12, 11, 10, 0.78) 100%);
}

.vignette.is-success {
  background:
    radial-gradient(ellipse 72% 62% at 50% 48%, rgba(71, 196, 127, 0.12) 0%, rgba(12, 11, 10, 0.56) 62%, rgba(12, 11, 10, 0.92) 100%);
}

.auth-brand {
  position: relative;
  z-index: 2;
  text-align: center;
  margin-top: 8px;
  animation: slideUp 0.45s var(--ease-panel) 0.06s both;
}

.brand-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.reel-mark {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 6px 18px rgba(242, 169, 59, 0.34));
  animation: reelSettle 0.65s var(--ease-panel) 0.06s both;
}

.wordmark {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--text-primary);
}

.brand-sub {
  margin-top: 6px;
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
}

.card-slot {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 460px;
  display: flex;
  justify-content: center;
}

.glass-card {
  position: relative;
  z-index: 2;
  overflow: hidden;
  width: 100%;
  max-width: 460px;
  margin: 20px 0;
  padding: 28px 26px;
  border-radius: var(--r-glass);
  background: rgba(24, 20, 17, 0.84);
  backdrop-filter: blur(40px) saturate(125%);
  -webkit-backdrop-filter: blur(40px) saturate(125%);
  border: 1px solid var(--border-hairline);
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.74),
    inset 0 1px 0 var(--border-catchlight);
  animation: cardEnter 0.48s var(--ease-panel) 0.16s both;
}

.glass-card.is-step {
  animation: stepEnter 0.28s var(--ease-panel) both;
}

.glass-card h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.18;
}

.glass-card .lead {
  margin-top: 8px;
  font-size: 15px;
  color: var(--text-secondary);
}

.lead-email {
  color: var(--text-primary);
  font-weight: 600;
  word-break: break-word;
}

.auth-legal {
  position: relative;
  z-index: 2;
  max-width: 480px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  animation: slideUp 0.34s var(--ease-panel) 0.32s both;
}

/* ---------- Code Cell Shutter Input (6-digit OTP & 8-char Link Code) ---------- */
.code-field {
  position: relative;
  width: 100%;
  margin-top: 8px;
}

.code-real {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  z-index: 2;
  font-size: 16px;
  caret-color: transparent;
  cursor: text;
}

.code-cells {
  display: grid;
  gap: 8px;
  align-items: center;
}

.code-cells.otp-cells {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.code-cells.device-cells {
  grid-template-columns: repeat(4, minmax(0, 1fr)) 10px repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.code-sep {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  justify-self: center;
}

.code-cell {
  position: relative;
  height: 58px;
  border-radius: var(--r-cell);
  background: linear-gradient(180deg, #29241F 0%, #1B1815 100%);
  border: 1px solid rgba(247, 243, 236, 0.16);
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 224, 168, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  transition:
    border-color var(--dur-snap) var(--ease-snap),
    box-shadow var(--dur-focus) var(--ease-focus),
    background-color var(--dur-snap) var(--ease-snap);
}

.device-cells .code-cell {
  height: 52px;
  font-size: 21px;
  border-radius: 13px;
}

.code-cell::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 2.5px;
  border-radius: 0 0 3px 3px;
  background: var(--accent-primary);
  opacity: 0.42;
  transition: opacity var(--dur-snap) var(--ease-snap);
}

.code-cell.is-filled {
  border-color: rgba(242, 169, 59, 0.36);
  background: linear-gradient(180deg, #2F271F 0%, #1F1A16 100%);
}

.code-cell.is-filled::before {
  opacity: 0.88;
}

.code-field.is-focused .code-cell.is-active {
  border-color: var(--accent-primary);
  box-shadow:
    0 0 0 2px rgba(242, 169, 59, 0.32),
    0 10px 24px rgba(242, 169, 59, 0.18),
    inset 0 1px 0 var(--border-catchlight);
}

.code-field.is-focused .code-cell.is-active::before {
  opacity: 1;
}

.code-field.is-focused .code-cell.is-active:not(.is-filled)::after {
  content: "";
  width: 2px;
  height: 22px;
  border-radius: 2px;
  background: var(--accent-highlight);
  opacity: 0.9;
}

.code-cell.shutter {
  animation: cellShutter 0.34s var(--ease-focus) both;
}

.code-cell.shutter:nth-child(1) { animation-delay: 80ms; }
.code-cell.shutter:nth-child(2) { animation-delay: 150ms; }
.code-cell.shutter:nth-child(3) { animation-delay: 220ms; }
.code-cell.shutter:nth-child(4) { animation-delay: 290ms; }
.code-cell.shutter:nth-child(5) { animation-delay: 360ms; }
.code-cell.shutter:nth-child(6) { animation-delay: 430ms; }

/* ---------- Sign-In Success Celebration ---------- */
.success-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 480px;
  padding: 44px 28px 36px;
  border-radius: var(--r-glass);
  background: var(--surface-glass);
  backdrop-filter: blur(40px) saturate(130%);
  -webkit-backdrop-filter: blur(40px) saturate(130%);
  border: 1px solid rgba(71, 196, 127, 0.32);
  box-shadow:
    0 36px 90px rgba(0, 0, 0, 0.68),
    inset 0 1px 0 rgba(139, 230, 177, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: hidden;
  transition:
    opacity 0.28s var(--ease-dismiss),
    transform 0.28s var(--ease-dismiss);
}

.auth-stage.is-exiting .success-card {
  opacity: 0;
  transform: scale(1.03);
}

.glow-bloom {
  position: absolute;
  width: 380px;
  height: 240px;
  top: -30px;
  background: radial-gradient(ellipse at center, rgba(71, 196, 127, 0.30) 0%, rgba(71, 196, 127, 0.08) 45%, transparent 72%);
  pointer-events: none;
  animation: bloomIn 0.68s var(--ease-celebrate) 0.06s both;
}

.badge-wrap {
  position: relative;
  width: 92px;
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
}

.pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2.5px solid var(--status-success);
  opacity: 0;
  animation: burstRing 0.85s var(--ease-celebrate) 0.22s forwards;
}

.outer-halo {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1.5px solid rgba(71, 196, 127, 0.32);
  background: rgba(71, 196, 127, 0.10);
  animation: badgePop var(--dur-celebrate) var(--ease-celebrate) 0.12s both;
}

.badge {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: linear-gradient(150deg, #6CE09D 0%, #47C47F 55%, #2F9B61 100%);
  box-shadow: 0 14px 34px rgba(71, 196, 127, 0.42), inset 0 1px 1px rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: badgePop var(--dur-celebrate) var(--ease-celebrate) 0.08s both;
}

.check-svg {
  width: 40px;
  height: 40px;
}

.check-path {
  stroke-dasharray: 56;
  stroke-dashoffset: 56;
  animation: drawCheck 0.34s var(--ease-pill) 0.28s forwards;
}

.success-title {
  position: relative;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  animation: riseIn 0.38s var(--ease-panel) 0.28s both;
}

.success-sub {
  position: relative;
  margin-top: 6px;
  font-size: 16px;
  color: var(--text-secondary);
  animation: riseIn 0.36s var(--ease-panel) 0.38s both;
}

.continue-wrap {
  position: relative;
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: riseIn 0.32s ease-out 0.48s both;
}

.continue-track {
  width: 180px;
  height: 4px;
  border-radius: var(--r-pill);
  background: rgba(247, 243, 236, 0.14);
  overflow: hidden;
}

.continue-fill {
  width: 100%;
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--status-success) 0%, var(--accent-primary) 100%);
  transform-origin: left center;
  animation: autoFill 1.15s linear 0.46s both;
}

.continue-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---------- Signed-In Shell (Desktop Rail + Mobile Top/Bottom Bar) ---------- */
.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100dvh;
  background: var(--bg-canvas);
}

.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  background: var(--bg-stage);
  border-right: 1px solid var(--border-hairline);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  animation: railIn 0.34s var(--ease-panel) both;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 6px;
}

.rail-brand .reel-mark {
  width: 32px;
  height: 32px;
  animation: none;
}

.rail-brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.rail-account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(247, 243, 236, 0.04);
  border: 1px solid var(--border-hairline);
}

.avatar-tile {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  border: 1px solid rgba(247, 243, 236, 0.24);
  flex-shrink: 0;
}

.rail-email {
  font-size: 12.5px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-pill {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 44px;
  border-radius: 12px;
  background: rgba(242, 169, 59, 0.14);
  border: 1px solid rgba(242, 169, 59, 0.34);
  box-shadow:
    0 6px 20px rgba(242, 169, 59, 0.12),
    inset 0 1px 0 rgba(255, 224, 168, 0.22);
  pointer-events: none;
  transition:
    transform var(--dur-pill) var(--ease-pill),
    height var(--dur-pill) var(--ease-pill),
    opacity var(--dur-snap) var(--ease-snap);
}

.nav-pill.no-anim {
  transition: none;
}

.nav-pill::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-primary);
}

.nav-btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
  transition:
    color var(--dur-snap) var(--ease-snap),
    background-color var(--dur-snap) var(--ease-snap),
    transform var(--dur-snap) var(--ease-snap);
}

.nav-btn:hover {
  color: var(--text-primary);
  background: rgba(247, 243, 236, 0.04);
}

.nav-btn:active {
  transform: scale(0.965);
}

.nav-btn.on {
  color: var(--text-primary);
  font-weight: 600;
}

.nav-btn.on svg {
  color: var(--accent-primary);
}

.rail-spacer {
  flex: 1;
}

.rail-signout {
  margin-top: 8px;
  border-top: 1px solid var(--border-hairline);
  padding-top: 10px;
}

/* Mobile header & bottom bar (hidden on desktop) */
.mobile-top,
.mobile-bar,
.more-overlay {
  display: none;
}

/* ---------- Main Area & Hero Backdrop Band ---------- */
.main {
  min-width: 0;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 36px 64px;
}

.page-stage {
  will-change: transform, opacity;
}

.page-stage.enter-down {
  animation: pageDown var(--dur-panel) var(--ease-panel) both;
}

.page-stage.enter-up {
  animation: pageUp var(--dur-panel) var(--ease-panel) both;
}

.page-stage.enter-fade {
  animation: pageFade var(--dur-crossfade) var(--ease-crossfade) both;
}

.hero-band {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--border-hairline);
  padding: 28px 28px 26px;
  background: var(--bg-stage);
  box-shadow:
    0 20px 44px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 224, 168, 0.18);
}

.hero-art-inner {
  position: absolute;
  inset: -24px;
  pointer-events: none;
  will-change: transform;
  animation: kenBurns 18s ease-in-out infinite alternate;
}

.hero-horizon {
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: 0;
  height: 52%;
  background:
    radial-gradient(ellipse 68% 45% at 78% 20%, rgba(255, 214, 138, 0.24) 0%, transparent 72%),
    linear-gradient(180deg, rgba(242, 169, 59, 0.14) 0%, rgba(16, 13, 11, 0.62) 100%);
  border-top: 1px solid rgba(255, 224, 168, 0.16);
}

.hero-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.34;
  background-image:
    repeating-radial-gradient(circle at 17% 32%, rgba(255, 244, 222, 0.045) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 2px);
}

.theme-home .hero-art-inner {
  background:
    radial-gradient(circle at 82% 30%, rgba(255, 214, 136, 0.56) 0%, rgba(232, 142, 34, 0.24) 24%, transparent 56%),
    radial-gradient(ellipse 56% 72% at 62% 76%, rgba(128, 76, 34, 0.62) 0%, transparent 78%),
    linear-gradient(125deg, #1E1813 0%, #3A291B 48%, #5D3C1E 78%, #1D1713 100%);
}
.theme-devices .hero-art-inner {
  background:
    radial-gradient(circle at 83% 32%, rgba(114, 218, 158, 0.34) 0%, rgba(71, 196, 127, 0.14) 28%, transparent 56%),
    radial-gradient(ellipse 50% 66% at 66% 68%, rgba(242, 169, 59, 0.28) 0%, transparent 74%),
    linear-gradient(125deg, #181715 0%, #263428 54%, #423320 100%);
}
.theme-servers .hero-art-inner {
  background:
    radial-gradient(circle at 84% 30%, rgba(255, 196, 98, 0.46) 0%, rgba(212, 108, 36, 0.20) 26%, transparent 56%),
    linear-gradient(125deg, #1C1613 0%, #543220 56%, #281D16 100%);
}
.theme-livetv .hero-art-inner {
  background:
    radial-gradient(circle at 82% 34%, rgba(244, 132, 102, 0.42) 0%, rgba(242, 169, 59, 0.22) 28%, transparent 58%),
    linear-gradient(125deg, #1B1514 0%, #482420 54%, #372F1E 100%);
}
.theme-profiles .hero-art-inner {
  background:
    radial-gradient(circle at 84% 32%, rgba(255, 198, 108, 0.46) 0%, transparent 56%),
    linear-gradient(125deg, #1A1613 0%, #4D351E 52%, #392420 100%);
}
.theme-links .hero-art-inner {
  background:
    radial-gradient(circle at 84% 30%, rgba(212, 178, 92, 0.42) 0%, transparent 56%),
    linear-gradient(125deg, #1A1713 0%, #3E3521 55%, #283424 100%);
}
.theme-settings .hero-art-inner {
  background:
    radial-gradient(circle at 84% 32%, rgba(242, 169, 59, 0.40) 0%, transparent 56%),
    linear-gradient(125deg, #1A1714 0%, #3A3229 58%, #201C18 100%);
}
.theme-keys .hero-art-inner {
  background:
    radial-gradient(circle at 84% 30%, rgba(108, 212, 148, 0.36) 0%, rgba(242, 169, 59, 0.20) 32%, transparent 58%),
    linear-gradient(125deg, #171714 0%, #24362B 54%, #3B2E1E 100%);
}
.theme-agents .hero-art-inner {
  background:
    radial-gradient(circle at 83% 32%, rgba(255, 216, 138, 0.46) 0%, transparent 56%),
    linear-gradient(125deg, #1B1713 0%, #473620 56%, #282B22 100%);
}
.theme-activity .hero-art-inner {
  background:
    radial-gradient(circle at 83% 34%, rgba(224, 214, 198, 0.28) 0%, rgba(242, 169, 59, 0.14) 30%, transparent 58%),
    linear-gradient(125deg, #181613 0%, #37312B 55%, #231E1A 100%);
}
.theme-account .hero-art-inner {
  background:
    radial-gradient(circle at 84% 32%, rgba(235, 130, 102, 0.38) 0%, rgba(242, 169, 59, 0.18) 32%, transparent 58%),
    linear-gradient(125deg, #1B1514 0%, #452623 56%, #241D1A 100%);
}

.hero-beam {
  position: absolute;
  top: 12px;
  right: 34px;
  width: 380px;
  height: 118px;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 214, 138, 0.20) 50%, rgba(255, 224, 168, 0.42) 100%);
  transform: rotate(-11deg);
  filter: blur(18px);
}

.hero-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(12, 11, 10, 0.86) 0%, rgba(12, 11, 10, 0.54) 46%, rgba(12, 11, 10, 0.14) 100%),
    linear-gradient(180deg, rgba(12, 11, 10, 0.12) 0%, rgba(12, 11, 10, 0.44) 100%);
}

.hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.hero-text {
  max-width: 660px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-highlight);
  margin-bottom: 6px;
}

.hero-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.12;
  color: var(--text-primary);
}

.hero-sub {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-secondary);
}

/* ---------- Cards, Panels & Focus ---------- */
.panel {
  position: relative;
  overflow: hidden;
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-card);
  padding: 20px;
  margin-top: 16px;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 224, 168, 0.10);
}

.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

@media (min-width: 1200px) {
  .home-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
}

.home-grid > .panel {
  margin-top: 0;
  display: flex;
  flex-direction: column;
}

.home-grid > .panel .panel-foot {
  margin-top: auto;
  padding-top: 12px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.stat-card,
.quick-card,
.item-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-card);
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 224, 168, 0.10);
  transition:
    transform var(--dur-focus) var(--ease-focus),
    border-color var(--dur-focus) var(--ease-focus),
    box-shadow var(--dur-focus) var(--ease-focus),
    background-color var(--dur-snap) var(--ease-snap);
}

.stat-card {
  padding: 16px 18px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
}

.stat-num {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--accent-highlight);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.quick-card {
  padding: 15px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.quick-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(242, 169, 59, 0.14);
  border: 1px solid rgba(242, 169, 59, 0.30);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.quick-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.quick-sub {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* One-time entrance catchlight sweep on cards + hover/focus lift */
.glass-card::before,
.panel.stagger-item::before,
.stat-card::before,
.quick-card::before,
.item-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1.5px;
  background: linear-gradient(90deg, transparent 6%, rgba(255, 224, 168, 0.92) 50%, transparent 94%);
  opacity: 0;
  transform: scaleX(0.25);
  pointer-events: none;
  z-index: 3;
  animation: catchlightEnter 680ms ease-out 180ms 1 both;
}

.stat-card::after,
.quick-card::after,
.item-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1.5px;
  background: linear-gradient(90deg, transparent 8%, rgba(255, 224, 168, 0.92) 50%, transparent 92%);
  opacity: 0;
  transform: scaleX(0.3);
  pointer-events: none;
  z-index: 3;
}

@media (hover: hover) {
  .stat-card:hover,
  .stat-card:focus-visible,
  .quick-card:hover,
  .quick-card:focus-visible,
  .item-card:hover,
  .item-card:focus-within {
    transform: translateY(-4px);
    border-color: var(--border-catchlight);
    background: #24201C;
    box-shadow:
      0 18px 34px rgba(0, 0, 0, 0.56),
      0 10px 28px var(--accent-glow),
      inset 0 1px 0 var(--border-catchlight);
  }

  .stat-card:hover::after,
  .stat-card:focus-visible::after,
  .quick-card:hover::after,
  .quick-card:focus-visible::after,
  .item-card:hover::after,
  .item-card:focus-within::after {
    animation: catchlight 480ms ease-out forwards;
  }

  .stat-card:active,
  .quick-card:active {
    transform: translateY(-1px) scale(0.965);
  }
}

@media (hover: none) {
  .stat-card:active,
  .quick-card:active {
    transform: scale(0.965);
  }
}

/* ---------- Lists, Cards & Form Grids ---------- */
.cards-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-card {
  background: rgba(21, 19, 17, 0.72);
  padding: 15px 16px;
}

.item-card .fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
}

.item-card .tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
}

.row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 14px;
  background: rgba(21, 19, 17, 0.62);
  border: 1px solid var(--border-hairline);
}

.row-card + .row-card {
  margin-top: 9px;
}

.row-main {
  min-width: 0;
  flex: 1;
}

.row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 5px;
  font-size: 13px;
  color: var(--text-muted);
}

.line-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-hairline);
}

.line-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.line-row:first-child {
  padding-top: 2px;
}

.activity-label {
  font-weight: 500;
  color: var(--text-primary);
}

.activity-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.actor-chip {
  text-transform: lowercase;
}

.activity-detail {
  color: var(--text-secondary);
  word-break: break-word;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-hairline);
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-key {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}

.setval {
  min-width: 240px;
  max-width: 320px;
}

.pre {
  background: rgba(12, 11, 10, 0.85);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-input);
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 8px 0;
}

.steps {
  padding-left: 20px;
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: 14.5px;
}

.steps li {
  margin: 8px 0;
}

/* Profile preview chip inside profile editor */
.profile-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 26px 16px;
}

.empty-state p {
  max-width: 360px;
  font-size: 14.5px;
  color: var(--text-secondary);
}

/* Staggered card entrances (24px up, 45ms step) */
.stagger-item {
  animation: staggerUp var(--dur-panel) var(--ease-panel) both;
}
.s0 { animation-delay: 0ms; }
.s1 { animation-delay: 45ms; }
.s2 { animation-delay: 90ms; }
.s3 { animation-delay: 135ms; }
.s4 { animation-delay: 180ms; }
.s5 { animation-delay: 225ms; }
.s6 { animation-delay: 270ms; }
.s7 { animation-delay: 315ms; }
.s8 { animation-delay: 360ms; }
.s9 { animation-delay: 405ms; }
.s10 { animation-delay: 450ms; }

/* ---------- Toast (Frosted Glass Pill) ---------- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 11px 20px;
  border-radius: var(--r-pill);
  background: var(--surface-glass-strong);
  backdrop-filter: blur(28px) saturate(130%);
  -webkit-backdrop-filter: blur(28px) saturate(130%);
  border: 1px solid var(--border-strong);
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 var(--border-catchlight);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(20px) scale(0.96);
  transition:
    opacity var(--dur-snap) var(--ease-snap),
    transform var(--dur-snap) var(--ease-snap);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

/* ---------- Keyframes ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes wallFadeIn { from { opacity: 0; } to { opacity: 0.64; } }
@keyframes driftUp { from { transform: translateY(0); } to { transform: translateY(-50%); } }
@keyframes driftDown { from { transform: translateY(-50%); } to { transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes reelSettle { from { opacity: 0; transform: rotate(-28deg) scale(0.9); } to { opacity: 1; transform: rotate(0) scale(1); } }
@keyframes cardEnter { from { opacity: 0; transform: translateY(26px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes stepEnter { from { opacity: 0; transform: translateY(12px) scale(0.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes cellShutter {
  0% { opacity: 0; transform: translateY(14px) scale(0.92); border-color: rgba(242, 169, 59, 0.80); }
  70% { opacity: 1; transform: translateY(0) scale(1); border-color: rgba(255, 210, 125, 0.55); }
  100% { opacity: 1; transform: translateY(0) scale(1); border-color: rgba(247, 243, 236, 0.16); }
}
@keyframes bloomIn {
  from { opacity: 0; transform: scale(0.45); }
  65% { opacity: 1; transform: scale(1.1); }
  to { opacity: 0.88; transform: scale(1); }
}
@keyframes badgePop {
  0% { opacity: 0; transform: scale(0.65); }
  65% { opacity: 1; transform: scale(1.07); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes burstRing {
  0% { opacity: 0.7; transform: scale(0.92); }
  100% { opacity: 0; transform: scale(1.48); }
}
@keyframes drawCheck { to { stroke-dashoffset: 0; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes autoFill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes kenBurns {
  from { transform: scale(1) translate3d(0, 0, 0); }
  to { transform: scale(1.06) translate3d(-16px, -4px, 0); }
}
@keyframes railIn { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pageDown { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pageUp { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pageFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes staggerUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes catchlightEnter {
  0% { opacity: 0; transform: scaleX(0.25); }
  45% { opacity: 0.95; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(1); }
}
@keyframes catchlight {
  0% { opacity: 0; transform: scaleX(0.3); }
  50% { opacity: 1; transform: scaleX(1); }
  100% { opacity: 0.45; transform: scaleX(1); }
}
@keyframes sheetUp { from { opacity: 0; transform: translateY(100%); } to { opacity: 1; transform: translateY(0); } }
@keyframes sheetDown { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(100%); } }

/* ---------- Responsive: Tablet & iPhone (<= 859px) ---------- */
@media (max-width: 859px) {
  .shell {
    display: block;
  }

  .rail {
    display: none;
  }

  .mobile-top {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: rgba(21, 19, 17, 0.84);
    backdrop-filter: blur(28px) saturate(125%);
    -webkit-backdrop-filter: blur(28px) saturate(125%);
    border-bottom: 1px solid var(--border-hairline);
  }

  .mobile-top-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
  }

  .mobile-top-brand .reel-mark {
    width: 28px;
    height: 28px;
    animation: none;
  }

  .mobile-top-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
  }

  .mobile-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
    background: rgba(21, 19, 17, 0.88);
    backdrop-filter: blur(32px) saturate(130%);
    -webkit-backdrop-filter: blur(32px) saturate(130%);
    border-top: 1px solid var(--border-hairline);
    box-shadow: inset 0 1px 0 rgba(255, 224, 168, 0.14);
  }

  .mbar-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    padding: 4px 2px;
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    transition:
      color var(--dur-snap) var(--ease-snap),
      background-color var(--dur-snap) var(--ease-snap),
      transform var(--dur-snap) var(--ease-snap);
  }

  .mbar-btn:active {
    transform: scale(0.95);
  }

  .mbar-btn.on {
    color: var(--accent-primary);
    background: rgba(242, 169, 59, 0.12);
  }

  .mbar-btn.on::before {
    content: "";
    position: absolute;
    top: 2px;
    width: 18px;
    height: 2.5px;
    border-radius: var(--r-pill);
    background: var(--accent-primary);
  }

  .more-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(12, 11, 10, 0.68);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn var(--dur-snap) var(--ease-snap) both;
  }

  .more-overlay.is-closing {
    opacity: 0;
    transition: opacity var(--dur-dismiss) var(--ease-dismiss);
  }

  .more-sheet {
    width: 100%;
    max-width: 540px;
    max-height: 82dvh;
    overflow-y: auto;
    border-radius: 28px 28px 0 0;
    padding: 12px 18px calc(22px + env(safe-area-inset-bottom));
    background: var(--surface-glass-strong);
    backdrop-filter: blur(40px) saturate(130%);
    -webkit-backdrop-filter: blur(40px) saturate(130%);
    border-top: 1px solid var(--border-catchlight);
    box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.72);
    animation: sheetUp var(--dur-panel) var(--ease-panel) both;
  }

  .more-overlay.is-closing .more-sheet {
    animation: sheetDown var(--dur-dismiss) var(--ease-dismiss) both;
  }

  .sheet-grab {
    width: 38px;
    height: 4px;
    border-radius: var(--r-pill);
    background: rgba(247, 243, 236, 0.24);
    margin: 0 auto 12px;
  }

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

  .sheet-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .sheet-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(247, 243, 236, 0.05);
    border: 1px solid var(--border-hairline);
    color: var(--text-secondary);
    font-size: 14.5px;
    font-weight: 600;
    text-align: left;
    transition: transform var(--dur-snap) var(--ease-snap), background-color var(--dur-snap) var(--ease-snap);
  }

  .sheet-btn:active {
    transform: scale(0.965);
  }

  .sheet-btn.on {
    background: rgba(242, 169, 59, 0.16);
    border-color: rgba(242, 169, 59, 0.44);
    color: var(--text-primary);
  }

  .sheet-btn.on svg {
    color: var(--accent-primary);
  }

  .main {
    padding: 14px 16px calc(94px + env(safe-area-inset-bottom));
  }

  .hero-band {
    padding: 20px 18px 18px;
    border-radius: 20px;
  }

  .hero-title {
    font-size: 26px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-grid {
    grid-template-columns: 1fr;
  }

  .setting-row {
    flex-direction: column;
    align-items: stretch;
  }

  .setval {
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  .row-card {
    flex-direction: column;
    align-items: stretch;
  }

  #toast {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 460px) {
  .wall-col {
    width: 136px;
  }

  .poster {
    width: 136px;
    height: 198px;
  }

  .glass-card {
    padding: 24px 18px;
    border-radius: 24px;
  }

  .code-cell {
    height: 50px;
    font-size: 21px;
    border-radius: 12px;
  }

  .device-cells {
    gap: 4px;
  }

  .device-cells .code-cell {
    height: 46px;
    font-size: 18px;
    border-radius: 10px;
  }

  .panel {
    padding: 16px;
  }

  .sheet-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
  }

  .wall-col.up,
  .wall-col.down,
  .hero-art-inner,
  .pulse-ring,
  .glass-card::before,
  .panel.stagger-item::before,
  .stat-card::before,
  .quick-card::before,
  .item-card::before {
    animation: none !important;
  }

  .wall-wrap {
    animation: wallFadeIn 180ms ease-out both !important;
  }

  .auth-brand,
  .glass-card,
  .glass-card.is-step,
  .auth-legal,
  .code-cell.shutter,
  .glow-bloom,
  .outer-halo,
  .badge,
  .success-title,
  .success-sub,
  .continue-wrap,
  .rail,
  .page-stage.enter-down,
  .page-stage.enter-up,
  .page-stage.enter-fade,
  .stagger-item,
  .more-overlay,
  .more-sheet {
    animation: fadeIn 180ms ease-out both !important;
    animation-delay: 0ms !important;
  }

  .more-overlay.is-closing .more-sheet {
    animation: none !important;
  }

  .check-path {
    stroke-dashoffset: 0;
    animation: none !important;
  }

  .continue-fill {
    animation: autoFill 180ms linear both !important;
  }

  .stat-card:hover,
  .stat-card:focus-visible,
  .stat-card:active,
  .quick-card:hover,
  .quick-card:focus-visible,
  .quick-card:active,
  .item-card:hover,
  .item-card:focus-within,
  .nav-btn:active,
  .mbar-btn:active,
  .sheet-btn:active,
  .btn:active:not(:disabled) {
    transform: none !important;
  }

  .stat-card:hover::after,
  .stat-card:focus-visible::after,
  .quick-card:hover::after,
  .quick-card:focus-visible::after,
  .item-card:hover::after,
  .item-card:focus-within::after {
    animation: none !important;
    opacity: 0.45;
    transform: scaleX(1);
  }

  .nav-pill,
  #toast {
    transition: opacity 160ms ease-out !important;
  }
}
