/* Lối An — app shell & components */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.625;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

body[data-lang="en"] .text-vi { display: none !important; }
body[data-lang="vi"] .text-en { display: none !important; }

h1, h2, h3 { text-wrap: balance; color: var(--ink); }
h1 { font-family: var(--font-ui); font-weight: 700; font-size: 22px; line-height: 1.27; }
h2 { font-family: var(--font-ui); font-weight: 600; font-size: 18px; line-height: 1.33; }
.display {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  line-height: 1.2;
  color: var(--ink);
}
.caption { font-size: 12px; line-height: 1.33; color: var(--muted); }
.label { font-size: 13px; font-weight: 600; line-height: 1.23; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ============================================================
   APP SHELL — phone: topbar + tab bar. Tablet+: left rail.
   Desktop: rail + content + aside (the reference's 3-pane).
   ============================================================ */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}
.frame {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
.frame-scroll { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.guest-shell { min-height: 100vh; display: flex; flex-direction: column; }
.guest-main {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
}

/* —— Left rail —— */
.rail { display: none; }
@media (min-width: 768px) {
  .app { grid-template-columns: 84px 1fr; }
  .rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 10px;
    background: var(--shell);
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    z-index: var(--z-nav);
  }
}
@media (min-width: 1180px) {
  .app { grid-template-columns: 208px 1fr; }
  .rail { align-items: stretch; padding: 20px 14px; }
}

.rail-brand {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: oklch(0.42 0.07 140);
  color: var(--shell-ink);
  font-family: var(--font-display);
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  flex-shrink: 0;
  margin-bottom: 14px;
}
.rail-brand:hover { text-decoration: none; opacity: 0.92; }
@media (min-width: 1180px) { .rail-brand { margin-left: 4px; } }

.rail-nav { display: flex; flex-direction: column; gap: 4px; width: 100%; align-items: center; }
@media (min-width: 1180px) { .rail-nav { align-items: stretch; } }

.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 56px;
  padding: 10px 4px;
  border-radius: 14px;
  color: var(--shell-muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: background var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}
.rail-item:hover {
  text-decoration: none;
  color: var(--shell-ink);
  background: oklch(0.96 0.01 130 / 0.08);
}
.rail-item.active {
  background: var(--primary);
  color: var(--primary-ink);
}
.rail-glyph { width: 22px; height: 22px; flex-shrink: 0; }
.rail-glyph svg { width: 100%; height: 100%; display: block; }
.rail-label { display: block; }
@media (min-width: 1180px) {
  .rail-item {
    flex-direction: row;
    justify-content: flex-start;
    width: 100%;
    gap: 12px;
    padding: 11px 14px;
    font-size: 13px;
    text-align: left;
  }
}
.rail-out { margin-top: auto; opacity: 0.7; }
.rail-out:hover { opacity: 1; }

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: var(--shell);
  color: var(--shell-ink);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}
@media (min-width: 768px) {
  /* The rail carries the brand from tablet up — no need to say it twice. */
  .topbar .topbar-brand { display: none; }
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.brand-mark {
  width: 36px; height: 36px; border-radius: 50%;
  background: oklch(0.42 0.07 140);
  color: var(--shell-ink);
  font-family: var(--font-display);
  font-size: 18px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  text-decoration: none;
}
.brand-mark:hover { text-decoration: none; opacity: 0.92; }

.topbar-title {
  font-size: 15px; font-weight: 600; color: var(--shell-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.user-chip {
  display: none;
  font-size: 12px;
  color: var(--shell-muted);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 640px) {
  .user-chip { display: block; }
  .topbar { padding: 12px 24px; }
}

.lang-pills { display: flex; gap: 4px; }
.lang-pill {
  background: transparent;
  border: 1px solid oklch(0.96 0.01 130 / 0.25);
  color: var(--shell-muted);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}
.lang-pill.active {
  background: var(--shell-ink);
  color: var(--shell);
  border-color: var(--shell-ink);
}
.lang-pill:hover:not(.active) { color: var(--shell-ink); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--shell-muted);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.icon-btn:hover { color: var(--shell-ink); text-decoration: none; }
/* Logout is quiet exit — never the loudest element on screen */
.icon-btn.logout-btn {
  color: var(--shell-ink);
  opacity: 0.75;
  border: 1px solid oklch(0.96 0.01 130 / 0.25);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
}
.icon-btn.logout-btn:hover { opacity: 1; color: var(--shell-ink); }

/* —— Page grid: main column, plus an aside rail on wide screens —— */
.page {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) calc(var(--space-7) + 72px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  align-content: start;
}
@media (min-width: 768px) {
  .page { padding-bottom: var(--space-7); }
}
@media (min-width: 1180px) {
  .page.has-aside {
    max-width: 1080px;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: var(--space-6);
    align-items: start;
  }
}
.page.page-wide { max-width: var(--admin-max); }
.page.page-flush { padding: 0; max-width: none; gap: 0; }
.page-main { min-width: 0; }

/* Aside: stacks under the content on narrow screens, becomes the right rail wide */
.page-aside { min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
@media (min-width: 1180px) {
  .page-aside { position: sticky; top: calc(56px + var(--space-5)); }
}

.main {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
}
.main.admin-wide { max-width: var(--admin-max); }

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: var(--danger); color: white; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 8px 14px; font-size: 13px; }

/* —— Cards —— */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--e1);
}
.card-elevated {
  box-shadow: var(--e2);
  border-color: transparent;
}
@media (min-width: 640px) {
  .card { padding: var(--space-5); }
}

/* —— Badges / chips —— */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary);
}
.chip-level { background: oklch(0.55 0.12 240 / 0.12); color: oklch(0.4 0.12 240); }
.chip-gold { background: var(--gold-soft); color: oklch(0.45 0.1 85); }
.chip-success { background: var(--success-soft); color: var(--success); }
.chip-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

/* —— Stones —— */
.stones {
  display: flex;
  align-items: center;
  gap: 0;
}
.stone {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
  transition: background var(--motion-med) var(--ease-out), border-color var(--motion-med) var(--ease-out), transform var(--motion-med) var(--ease-out);
}
.stone.done { background: var(--success); border-color: var(--success); }
.stone.next { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
.stone.locked { opacity: 0.45; }
.stone.open { border-color: var(--muted); }
.stone.mastery { background: var(--gold); border-color: var(--gold); transform: scale(1.15); }
.stone-line {
  width: 20px; height: 2px;
  background: var(--line);
  flex-shrink: 0;
}
.stone-line.done { background: var(--success); }

/* —— Track card —— */
.track-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--motion-fast) var(--ease-out);
}
.track-card:hover { border-color: var(--primary); text-decoration: none; }
.track-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.track-card h3 { font-size: 16px; font-weight: 600; }
.track-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.pct { font-size: 13px; font-weight: 600; color: var(--primary); }
.pct.full { color: oklch(0.5 0.1 85); }

/* —— Progress bar —— */
.progress-bar {
  height: 4px;
  background: var(--line);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-bar > span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-pill);
  transition: width var(--motion-med) var(--ease-out);
}
.progress-bar.gold > span { background: var(--gold); }

/* —— Forms —— */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.form-control {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color var(--motion-fast) var(--ease-out);
}
.form-control:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.form-control { min-height: 120px; resize: vertical; line-height: 1.5; }
.form-error {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid oklch(0.55 0.16 25 / 0.25);
}
.form-success {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--success-soft);
  color: var(--success);
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid oklch(0.55 0.1 150 / 0.25);
}

/* —— Empty state —— */
.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--muted);
}
.empty-state .lantern {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--primary);
}
.empty-state h2 { margin-bottom: 8px; color: var(--ink); }
.empty-state p { margin-bottom: 20px; max-width: 32ch; margin-left: auto; margin-right: auto; }

/* —— Stacks —— */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-sm { gap: var(--space-2); }
.stack-lg { gap: var(--space-5); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* —— Tables (admin) —— */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th {
  text-align: left;
  padding: 12px 14px;
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
table.data td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: oklch(0.965 0.008 135 / 0.6); }

/* —— Player: messenger hybrid, with a context rail on wide screens —— */
.player {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  flex: 1;
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
}
@media (min-width: 1180px) {
  .player {
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: var(--space-6);
    max-width: 1180px;
    margin: 0 auto;
    padding: var(--space-5) var(--space-5) var(--space-5) 0;
  }
}
.player-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
@media (min-width: 1180px) {
  .player-stage {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--e1);
  }
}
.player-progress {
  height: 3px;
  background: var(--line);
  flex-shrink: 0;
}
.player-progress > span {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width var(--motion-med) var(--ease-out);
}
.player-rail { display: none; }
@media (min-width: 1180px) {
  .player-rail {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    align-self: start;
    position: sticky;
    top: calc(56px + var(--space-5));
  }
}
.pts { margin-left: 6px; font-variant-numeric: tabular-nums; }
.pts.good { color: var(--success); }
.pts.bad { color: var(--danger); }
.aside-note-num.good { background: var(--success-soft); color: var(--success); }
.aside-note-num.bad { background: var(--danger-soft); color: var(--danger); }
.dock-prompt { margin-bottom: 4px; font-weight: 600; }

.topbar-exit {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--shell-ink);
  background: oklch(0.96 0.01 130 / 0.1);
  flex-shrink: 0;
}
.topbar-exit:hover { background: oklch(0.96 0.01 130 / 0.2); text-decoration: none; }
.topbar-exit svg { width: 18px; height: 18px; }
/* Messages grow up from the dock — Zalo-style, no dead gap */
.chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px;
  min-height: 0;
}
.chat-scene { margin-bottom: 4px; }
.chat-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
}
.chat-msg .chat-avatar { margin-top: 18px; } /* sit next to bubble body under meta */
.chat-msg.guest { align-self: flex-start; }
.chat-msg.staff {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-ui);
  background: var(--line);
  color: var(--ink);
}
.chat-avatar.guest {
  background: oklch(0.55 0.04 140 / 0.2);
  color: var(--primary);
}
.chat-avatar.trainer {
  background: var(--primary);
  color: var(--primary-ink);
  font-family: var(--font-display);
  font-size: 14px;
}
.bubble-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 78%;
}
.chat-msg.staff .bubble-col { align-items: flex-end; }
.bubble {
  padding: 14px 16px;
  border-radius: 16px 16px 16px 4px; /* guest: soft tail bottom-left */
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 16px;
  line-height: 1.5;
  animation: bubbleIn var(--motion-med) var(--ease-out);
  width: fit-content;
  max-width: 100%;
}
.bubble.staff {
  border-radius: 16px 16px 4px 16px; /* staff: soft tail bottom-right */
  background: var(--primary-soft);
  border-color: transparent;
}
.bubble-meta {
  font-size: 12px;
  line-height: 1.33;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  padding-left: 2px;
}
.chat-msg.staff .bubble-meta { padding-right: 2px; padding-left: 0; text-align: right; }
/* Flush dock — no card wrapper, same gutter as chat-log */
.dock,
.choices-dock {
  background: var(--bg);
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
@media (min-width: 1180px) {
  .dock { background: var(--surface); padding-bottom: 16px; }
}
.choice-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: var(--tap);
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--e1);
  text-decoration: none;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: var(--font-ui);
  transition: border-color var(--motion-fast) var(--ease-out), background var(--motion-fast) var(--ease-out);
  animation: choiceIn var(--motion-med) var(--ease-out) both;
}
.choice-card:nth-child(1) { animation-delay: 0ms; }
.choice-card:nth-child(2) { animation-delay: 40ms; }
.choice-card:nth-child(3) { animation-delay: 80ms; }
.choice-card:nth-child(4) { animation-delay: 120ms; }
.choice-card:hover { border-color: var(--primary); background: var(--primary-soft); text-decoration: none; }
.choice-letter {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.coach-note {
  margin: 0 0 8px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.5;
  animation: bubbleIn var(--motion-med) var(--ease-out);
  flex-shrink: 0;
}
.coach-note.good { background: var(--success-soft); border-color: oklch(0.55 0.1 150 / 0.25); }
.coach-note.bad { background: var(--danger-soft); border-color: oklch(0.55 0.16 25 / 0.25); }
.coach-note .coach-label {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--muted);
}
/* SOP citation under a coach note — the bridge back to the standard */
.coach-cite {
  display: block;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
}
.coach-cite:hover { border-color: var(--primary); text-decoration: none; }
.cite-code {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}
.cite-text { display: block; font-size: 13px; line-height: 1.5; font-style: italic; }
.cite-go {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.score-chip {
  background: oklch(0.96 0.01 130 / 0.12);
  color: var(--shell-ink);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
}

/* —— Mastery seal —— */
.mastery-seal {
  width: 96px; height: 96px;
  margin: 0 auto 20px;
  border-radius: 50%;
  border: 3px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--muted);
  background: var(--surface);
}
.mastery-seal.lit {
  border-color: var(--gold);
  color: oklch(0.45 0.1 85);
  background: var(--gold-soft);
  box-shadow: 0 0 0 6px var(--gold-soft);
  animation: sealIgnite 400ms var(--ease-out);
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes choiceIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes sealIgnite {
  from { transform: scale(0.85); opacity: 0.6; }
  to { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .bubble, .choice-card, .coach-note, .mastery-seal.lit {
    animation: none !important;
  }
}

/* —— Resume card —— */
.resume-card {
  display: block;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--e2);
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
}
.resume-card:hover { text-decoration: none; border-color: var(--primary); }
.resume-kicker {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}
.resume-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.resume-sub { font-size: 13px; color: var(--muted); }

/* —— Team list —— */
.readiness-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px !important;
  max-height: 88px;
}
.readiness-num {
  font-size: 32px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 4ch;
}
.readiness-body { flex: 1; min-width: 0; }
.readiness-body .label { margin-bottom: 8px; color: var(--muted); }
.person-list { padding: 4px 16px !important; }
.person-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  column-gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.person-row:last-child { border-bottom: none; }
.person-row.is-you { background: transparent; }
.person-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.person-rank.rank-mastery {
  background: var(--gold-soft);
  color: oklch(0.45 0.1 85);
}
.person-info { min-width: 0; }
.person-name { font-weight: 600; font-size: 16px; line-height: 1.3; }
.person-level { font-size: 12px; color: var(--muted); margin-top: 2px; }
.person-score {
  font-weight: 700;
  color: var(--ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  max-width: 6ch;
}

/* —— Structured SOP reader —— */
.sop { display: flex; flex-direction: column; gap: var(--space-5); }
.sop-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  scroll-margin-top: 76px;
}
@media (min-width: 640px) { .sop-section { padding: var(--space-5); } }
.sop-h {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.sop-h-num {
  width: 24px; height: 24px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sop-steps { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.sop-step {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  scroll-margin-top: 76px;
}
.sop-step:nth-child(odd) { background: oklch(0.965 0.008 135 / 0.6); }
.sop-step-n {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.sop-step-body { font-size: 15px; line-height: 1.6; }
.sop-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.sop-item {
  position: relative;
  padding: 2px 0 2px 18px;
  font-size: 15px;
  line-height: 1.6;
  scroll-margin-top: 76px;
}
.sop-item::before {
  content: '';
  position: absolute;
  left: 4px; top: 11px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.55;
}
.sop-item.is-note {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
}
.sop-item.is-note::before { display: none; }
.sop-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}
.sop-steps + .sop-list, .sop-list + .sop-table-wrap, .sop-steps + .sop-table-wrap { margin-top: 14px; }
.sop-table-wrap table.data td { font-size: 14px; vertical-align: top; }
.chip-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -0.01em; }

/* Section index in the aside */
.sop-toc { max-height: 46vh; overflow-y: auto; }
.toc-link {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  text-decoration: none;
}
.toc-link:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.toc-n {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  min-width: 12px;
  flex-shrink: 0;
}
.rel-code {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
}

/* —— Theory reader (legacy plain-text fallback) —— */
.sop-prose {
  max-width: 68ch;
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
}
.sticky-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: var(--z-nav);
  box-shadow: 0 -4px 16px oklch(0.25 0.02 140 / 0.04);
}

/* —— Section label —— */
.section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
}

/* —— Admin nav strip —— */
.admin-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.admin-strip a {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}
.admin-strip a:hover, .admin-strip a.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  text-decoration: none;
}

.greeting-block { margin-bottom: var(--space-5); }
/* Greeting is functional UI (h1), not a brand moment — Playfair reserved for login + seal */
.greeting-block .greeting-h1 {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.27;
  color: var(--ink);
  margin-bottom: 8px;
}
.greeting-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Team pulse: one quiet line on canvas, not a card */
.team-pulse {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 0;
  text-decoration: none;
  color: var(--muted);
}
.team-pulse:hover { text-decoration: none; color: var(--ink); }
.team-pulse-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.team-pulse .monogram-pill {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 10px;
  line-height: 20px;
}
.team-pulse span.arrow { color: var(--primary); font-weight: 700; flex-shrink: 0; }
.track-meta { margin-top: 8px; }
.track-steps { display: block; margin-top: 0; }

.stone-path-vertical {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.stone-step {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  position: relative;
}
.stone-step + .stone-step { border-top: 1px solid var(--line); }
.stone-step-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 24px;
  flex-shrink: 0;
  padding-top: 4px;
}
.stone-step-body { flex: 1; min-width: 0; }
.stone-step-body h3 { font-size: 15px; margin-bottom: 4px; }
.stone-step.locked { opacity: 0.55; }
.stone-step.next-up .stone { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.stone-step a.step-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.stone-step a.step-link:hover h3 { color: var(--primary); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* —— Tab bar: phones only. The rail replaces it from 768px. —— */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: var(--z-nav);
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px oklch(0.25 0.02 140 / 0.06);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0));
}
@media (min-width: 768px) { .tabbar { display: none; } }
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  min-height: 48px;
}
.tabbar a:hover { text-decoration: none; color: var(--primary); }
.tabbar a.active { color: var(--primary); }
.tab-glyph { width: 22px; height: 22px; }
.tab-glyph svg { width: 100%; height: 100%; display: block; }

/* —— Aside cards (reference right rail) —— */
.aside-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--e1);
}
.aside-card + .aside-card { margin-top: 0; }
.aside-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
}
.aside-note {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.aside-note:last-child { border-bottom: none; padding-bottom: 0; }
.aside-note-num {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.aside-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.aside-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: border-color var(--motion-fast) var(--ease-out), background var(--motion-fast) var(--ease-out);
}
.aside-link:hover { border-color: var(--primary); background: var(--primary-soft); text-decoration: none; }
.aside-link.is-locked { opacity: 0.5; pointer-events: none; }
.aside-link .lg { width: 22px; height: 22px; color: var(--primary); }
.aside-link .lg svg { width: 100%; height: 100%; display: block; }

/* —— Lesson stepper (reference lesson list) —— */
.stepper { display: flex; flex-direction: column; gap: 8px; }
.step-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: border-color var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast) var(--ease-out);
}
.step-row:hover { text-decoration: none; }
a.step-row:hover { border-color: var(--primary); box-shadow: var(--e1); }
.step-row.is-next {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.step-row.is-locked { opacity: 0.6; background: transparent; }
.step-mark {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  flex-shrink: 0;
}
.step-mark svg { width: 14px; height: 14px; }
.step-row.is-done .step-mark { background: var(--success); border-color: var(--success); color: white; }
.step-row.is-next .step-mark { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.step-row.is-mastery .step-mark { background: var(--gold); border-color: var(--gold); color: oklch(0.3 0.06 85); }
.step-kicker {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.01em;
  margin-bottom: 3px;
}
.step-row.is-locked .step-kicker { color: var(--muted); }
.step-title { font-size: 15px; font-weight: 600; line-height: 1.35; margin-bottom: 3px; }
.step-sub { font-size: 12px; color: var(--muted); }

/* —— Section heading row —— */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2 { font-size: 16px; }
.section-head a { font-size: 13px; font-weight: 600; }

/* —— Misc shared bits —— */
.back-link { font-size: 13px; font-weight: 600; color: var(--primary); }
.reader-card { padding: var(--space-5) var(--space-4); }
@media (min-width: 640px) { .reader-card { padding: var(--space-6); } }
.reader-actions { position: sticky; bottom: 84px; }
@media (min-width: 768px) { .reader-actions { bottom: var(--space-4); } }
.reader-actions .btn { box-shadow: var(--e2); }

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-pill {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.filter-pill:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.filter-pill.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-num {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat-lab { font-size: 12px; color: var(--muted); margin-top: 2px; }
.readiness-inline { font-size: 22px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }

.aside-soft { background: var(--bg); box-shadow: none; }

.recap-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.recap-row:last-child { border-bottom: none; }
.recap-choice { font-weight: 600; font-size: 14px; line-height: 1.45; }
.aside-row-link {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.aside-row-link:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

.stepper-mini .step-row { padding: 10px 12px; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; }
.stepper-mini .step-mark { width: 22px; height: 22px; font-size: 10px; }
.stepper-mini .step-title { font-size: 13px; margin-bottom: 0; }
.step-row.is-current { border-color: var(--primary); background: var(--primary-soft); }

.track-card.is-mastery { border-color: oklch(0.72 0.11 85 / 0.5); }
/* The reference shelf is a library, not a path — quieter than a taught track */
.track-card.is-shelf { background: transparent; box-shadow: none; border-style: dashed; }
.track-card.is-shelf .pct { color: var(--muted); }
.resume-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.resume-go { color: var(--primary); font-weight: 700; flex-shrink: 0; }

/* —— Admin: list + editor —— */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-bar .form-control { min-height: 40px; max-width: 240px; font-size: 14px; }
.filter-bar input[type="search"] { flex: 1; min-width: 180px; max-width: 320px; }
.chip-warn { background: oklch(0.72 0.11 85 / 0.18); color: oklch(0.45 0.1 85); }
.issue-list { margin-top: 4px; max-width: 34ch; }
.row-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.inline-form { display: inline; }
.btn-quiet-danger { color: var(--danger); }
.btn-quiet-danger:hover { background: var(--danger-soft); }
.cell-gap { background: var(--danger-soft); color: var(--danger); font-weight: 700; }

.gap-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 14px 16px;
}
.gap-panel summary { cursor: pointer; font-size: 14px; font-weight: 600; }

.issues-panel {
  border: 1px solid oklch(0.72 0.11 85 / 0.35);
  background: var(--gold-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.issues-head { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.issues-panel ul { margin-left: 18px; font-size: 13px; line-height: 1.7; }

.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
@media (min-width: 1000px) {
  .editor-grid { grid-template-columns: 320px minmax(0, 1fr); align-items: start; }
  .editor-grid > section:first-child { position: sticky; top: calc(56px + var(--space-5)); }
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.editor-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: var(--space-5);
  position: sticky; bottom: 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  padding: 14px 0;
}
.node-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
  background: var(--bg);
}
.node-head { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
.node-head .form-control { min-height: 40px; font-size: 14px; }
.node-head .node-id { max-width: 140px; font-family: ui-monospace, Menlo, monospace; }
.opt-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.opt-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.opt-card .form-control { min-height: 38px; font-size: 13px; }
.opt-head { display: grid; grid-template-columns: 100px 80px minmax(0, 1fr); gap: 6px; }
.form-control.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* —— Aside CTA (reference "Go to workbook") —— */
.aside-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.aside-cta:hover { text-decoration: none; filter: brightness(1.08); }

/* —— Staff SOP reports ————————————————————————————————
   The affordance is quiet by design: present on every section, but never
   competing with the procedure itself. It only becomes a form when tapped. */
.report {
  margin-top: var(--space-4);
  border-top: 1px solid var(--line);
  padding-top: var(--space-3);
}
.report > summary {
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  color: var(--muted);
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.report > summary::-webkit-details-marker { display: none; }
.report > summary::before {
  content: "⚑";
  font-size: 12px;
  opacity: 0.75;
}
.report > summary:hover { color: var(--primary); }
.report[open] > summary { color: var(--ink); font-weight: 600; }
.report-form { margin-top: var(--space-3); display: grid; gap: var(--space-3); }
.report-kinds { display: flex; flex-wrap: wrap; gap: var(--space-4); font-size: 14px; }
.report-kinds label {
  display: flex; align-items: center; gap: 6px;
  min-height: 32px; cursor: pointer;
}
.report-form .btn { justify-self: start; }

/* —— Admin: the report queue —— */
.report-row { display: grid; gap: var(--space-3); }
.report-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.report-section { margin: 0; font-weight: 600; color: var(--ink); }
.report-body {
  margin: 0;
  white-space: pre-wrap;          /* staff type line breaks; keep them */
  overflow-wrap: anywhere;        /* and a pasted URL must not widen the page */
  line-height: 1.55;
}
.report-note {
  margin: 0; padding: var(--space-3);
  background: var(--bg); border-radius: var(--radius-sm);
}
.report-actions { display: grid; gap: var(--space-2); }
@media (min-width: 640px) {
  .report-actions { grid-template-columns: 1fr auto; align-items: center; }
}

/* Count of open reports, carried in the admin nav so it is not missed. */
.admin-strip .badge {
  display: inline-block;
  min-width: 18px; padding: 1px 6px; margin-left: 6px;
  border-radius: var(--radius-pill);
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 16px; text-align: center;
}

/* ══════════════════════════════════════════════════════════════════════
   THE GATE — login (v2, illustrated)
   A lantern-lit Hoi An street is the page. The left third settles into
   brand olive so the white lockup and the cream card sit on calm ground;
   the illustration keeps the right side alive. Hanging lanterns, a
   botanical seal and falling petals carry the brand flowers without
   CSS-drawn substitutes — everything here is real illustration.
   ══════════════════════════════════════════════════════════════════════ */
body.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  font-family: var(--font-ui);
  background: var(--shell);      /* what shows before the art decodes */
  overflow: hidden;
}

.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  --px: 0; --py: 0;              /* pointer offset (-.5…-.5), set from JS */
  perspective: 1100px;
  perspective-origin: 50% 38%;
}

/* The building photo is a physical plane inside the perspective: it tilts
   with the pointer while its framing drifts via background-position, so the
   house feels like it stands in space rather than slide like a sticker. */
.scene-photo {
  position: absolute;
  inset: -4%;                    /* oversized so tilt + parallax never expose an edge */
  background-image: url("img/hotel-front.webp");
  background-size: cover;
  background-position: 50% 28%;  /* facade + river edge, crop the dead water */
  transform:
    translate3d(calc(var(--px) * -14px), calc(var(--py) * -10px), 0)
    rotateY(calc(var(--px) * 2.6deg))
    rotateX(calc(var(--py) * -1.8deg))
    scale(1.06);
  transition: transform 700ms var(--ease-out);
  will-change: transform;
  animation: gateDrift 56s ease-in-out infinite alternate;
}

/* Idle drift lives on background-position so it never fights the
   pointer-driven 3D transform on the same element. */
@keyframes gateDrift {
  from { background-position: 49% 30%; }
  to   { background-position: 51% 26%; }
}

/* Sky is bright blue: the wash unifies it into brand olive, deepens the
   left third for the lockup + card, and vignettes the edges. */
.scene-wash {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(97deg,
      oklch(0.27 0.04 140 / 0.96) 0%,
      oklch(0.27 0.04 140 / 0.88) 30%,
      oklch(0.27 0.04 140 / 0.42) 55%,
      oklch(0.27 0.04 140 / 0.10) 76%),
    linear-gradient(oklch(0.30 0.05 150 / 0.30), oklch(0.30 0.05 150 / 0.30)),
    radial-gradient(125% 95% at 55% 38%, transparent 42%, oklch(0.22 0.04 140 / 0.52) 100%),
    linear-gradient(to bottom,
      oklch(0.27 0.04 140 / 0.38) 0%, transparent 26%,
      transparent 52%, oklch(0.22 0.04 140 / 0.22) 72%,
      oklch(0.20 0.04 140 / 0.52) 100%);
}

/* —— Petals —— cream-gold, drifting. Four, not a blizzard. —— */
.petal {
  position: absolute;
  width: 11px; height: 15px;
  border-radius: 60% 40% 55% 45%;
  background: linear-gradient(140deg, oklch(0.93 0.04 95 / 0.9), oklch(0.85 0.07 85 / 0.72));
  filter: blur(0.3px);
  animation: petalFall linear infinite;
}
.petal-1 { left: 12%; animation-duration: 19s; animation-delay: -3s; }
.petal-2 { left: 38%; animation-duration: 26s; animation-delay: -11s; }
.petal-3 { left: 64%; animation-duration: 23s; animation-delay: -17s; }
.petal-4 { left: 86%; animation-duration: 29s; animation-delay: -7s; }

@keyframes petalFall {
  from { top: -6%;  opacity: 0; transform: translateX(0) rotate(0deg) scale(1); }
  10%  { opacity: 0.9; }
  90%  { opacity: 0.5; }
  to   { top: 106%; opacity: 0; transform: translateX(64px) rotate(230deg) scale(0.7); }
}

/* —— Hanging lanterns: nearest plane, so they move the most —— */
.hang {
  position: absolute;
  top: -18px;
  z-index: 1;
  pointer-events: none;
  transform: translate3d(calc(var(--px) * 44px), calc(var(--py) * 30px), 0);
  transition: transform 700ms var(--ease-out);
}
.hang-1 { left: 57%; }
.hang-2 { left: 67%; }
.hang-3 { left: 50%; }
.lantern-hang {
  display: block;
  transform-origin: 50% -30px;
  animation: lanternSway 7.5s ease-in-out infinite alternate;
}
.hang-1 .lantern-hang { width: 120px; }
.hang-2 .lantern-hang { width: 78px; animation-delay: -3.2s; animation-duration: 9s; }
.hang-3 .lantern-hang { width: 60px; animation-delay: -5s; animation-duration: 8.2s; opacity: 0.95; }

@keyframes lanternSway {
  from { transform: rotate(1.6deg); }
  to   { transform: rotate(-1.6deg); }
}

/* —— Botanical seal: mid-ground plane —— */
.botany-medallion {
  position: absolute;
  right: -90px;
  bottom: -80px;
  width: 340px;
  z-index: 1;
  opacity: 0.92;
  pointer-events: none;
  transform: translate3d(calc(var(--px) * 26px), calc(var(--py) * 18px), 0);
  transition: transform 700ms var(--ease-out);
  filter: drop-shadow(0 18px 40px oklch(0.18 0.03 140 / 0.55));
}

/* —— The stage: brand lockup + card hold the left third —— */
.login-stage {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  max-width: 560px;
  padding: clamp(24px, 5vh, 56px) clamp(24px, 6vw, 96px);
}

.gate-brand {
  margin-bottom: var(--space-6);
  animation: gateFade 700ms var(--ease-out) both;
}
.gate-logo {
  width: clamp(180px, 21vw, 230px);
  height: auto;
  display: block;
  filter: drop-shadow(0 12px 32px oklch(0.15 0.02 140 / 0.6));
}
.gate-kicker {
  margin: 14px 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: oklch(0.80 0.09 85);
}
.gate-rule {
  width: 64px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold), oklch(0.72 0.11 85 / 0));
}

@keyframes gateFade {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

/* —— The card: back to the translucent glass the gate was known for —
   white lacquer thin enough to read the hotel through, thick enough that
   text clears 4.5:1 over sky AND dark water (v1-measured floor). —— */
.login-card {
  width: 100%;
  max-width: 400px;
  padding: var(--space-6) var(--space-5) var(--space-5);
  border-radius: 20px;
  background: oklch(1 0 0 / 0.86);
  border: 1px solid oklch(1 0 0 / 0.6);
  box-shadow:
    0 1px 0 oklch(1 0 0 / 0.7) inset,
    0 24px 70px oklch(0.2 0.03 140 / 0.42),
    0 4px 14px oklch(0.2 0.03 140 / 0.22);
  animation: gateRise 640ms var(--ease-out) 120ms both;
}

/* Progressive: backdrop-filter gets real glass and a thinner white,
   so more of the building shows through. */
@supports (backdrop-filter: blur(20px)) or (-webkit-backdrop-filter: blur(20px)) {
  .login-card {
    background: oklch(1 0 0 / 0.72);
    -webkit-backdrop-filter: blur(22px) saturate(1.35);
    backdrop-filter: blur(22px) saturate(1.35);
  }
}

@keyframes gateRise {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.login-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  text-align: center;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.login-sub {
  margin: 2px 0 var(--space-5);
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.login-card .lang-row {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.login-card .form-control { background: oklch(1 0 0 / 0.85); }
.login-card .form-error { margin-bottom: var(--space-4); }

.gate-foot {
  margin-top: var(--space-5);
  font-size: 12px;
  color: var(--shell-muted);
}

/* Wide screens: hold the composition left of centre so the street keeps the frame */
@media (min-width: 1500px) {
  .login-stage { padding-left: clamp(96px, 12vw, 220px); }
}

/* Phones: the hotel is worth seeing — card gives back the top half */
@media (max-width: 899px) {
  .login-stage {
    align-items: center;
    justify-content: flex-end;
    max-width: none;
    padding-bottom: var(--space-6);
  }
  .gate-brand { text-align: center; margin-bottom: var(--space-4); }
  .gate-logo { width: 150px; margin: 0 auto; }
  .gate-rule { margin: 10px auto 0; }
  .scene-wash {
    background:
      linear-gradient(97deg,
        oklch(0.27 0.04 140 / 0.80) 0%,
        oklch(0.27 0.04 140 / 0.30) 45%,
        oklch(0.27 0.04 140 / 0.16) 100%),
      linear-gradient(to bottom,
        oklch(0.27 0.04 140 / 0.55) 0%, transparent 30%,
        transparent 42%, oklch(0.23 0.04 140 / 0.82) 84%);
  }
  .lantern-hang, .botany-medallion { display: none; }
  .login-card { padding: var(--space-5) var(--space-4) var(--space-4); }
  .login-card h1 { font-size: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  .scene-photo { animation: none; }
  .scene-photo, .hang, .botany-medallion { transform: none; transition: none; }
  .login-card, .gate-brand { animation: none; }
  .petal, .lantern-hang { display: none; }
}

/* ══════════════════════════════════════════════════════════════════════
   BRAND IMAGERY — real logo in rail, topbar, guest header
   ══════════════════════════════════════════════════════════════════════ */
.rail-brand img,
.brand-mark img {
  width: 30px; height: 30px;
  object-fit: contain;
  display: block;
}
.rail-brand img { width: 32px; height: 32px; }

.rail-wordmark { display: none; }
@media (min-width: 1180px) {
  .rail-brand {
    width: auto;
    height: auto;
    padding: 12px 10px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border-radius: 14px;
    background: oklch(0.96 0.01 130 / 0.06);
  }
  .rail-brand img { width: 44px; height: 44px; }
  .rail-wordmark {
    display: block;
    text-align: center;
    font-family: var(--font-display);
    font-size: 15px;
    letter-spacing: 0.06em;
    color: var(--shell-ink);
    line-height: 1.15;
  }
  .rail-wordmark .rail-sub {
    display: block;
    font-family: var(--font-ui);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--gold);
    margin-top: 3px;
  }
}

.guest-header {
  padding: var(--space-6) var(--space-4) var(--space-4);
  text-align: center;
}
.guest-logo {
  width: 190px;
  height: auto;
  display: block;
  margin: 0 auto;
}
.guest-sub {
  margin: 12px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ══════════════════════════════════════════════════════════════════════
   ERROR PAGE — lantern illustration instead of a CSS exclamation mark
   ══════════════════════════════════════════════════════════════════════ */
.error-lantern {
  width: 120px;
  height: auto;
  display: block;
  margin: 0 auto var(--space-4);
  animation: lanternGlow 3.6s ease-in-out infinite alternate;
}
@keyframes lanternGlow {
  from { filter: drop-shadow(0 12px 28px oklch(0.42 0.07 140 / 0.30)) brightness(1); }
  to   { filter: drop-shadow(0 14px 34px oklch(0.55 0.09 85 / 0.45)) brightness(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .error-lantern { animation: none; }
}
