
:root {
  color-scheme: dark;
  --bg: #17191c;
  --bg-2: #1d2024;
  --bg-veil: rgba(23, 25, 28, 0.92);
  --bg-veil-0: rgba(23, 25, 28, 0);
  --panel: rgba(33, 36, 41, 0.9);
  --panel-2: rgba(25, 28, 32, 0.94);
  --panel-solid: #202329;
  --line: rgba(255, 247, 230, 0.12);
  --line-strong: rgba(255, 247, 230, 0.24);
  --text: #f4f6f2;
  --text-2: #d9d4cc;
  --muted: #a9a49e;
  --faint: #8a857f;
  --gold: #ffc629;
  --gold-deep: #d4a017;
  --gold-soft: rgba(255, 198, 41, 0.12);
  --gold-line: rgba(255, 198, 41, 0.45);
  --gold-glow: rgba(255, 198, 41, 0.32);
  --leaf: #556239;
  --leaf-soft: rgba(85, 98, 57, 0.35);
  --on-gold: #17191c;
  --z-base: #fff7e6;
  --shadow: 0 24px 80px rgba(8, 9, 11, 0.6);
  --card-shadow: 0 12px 40px rgba(8, 9, 11, 0.5);
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #fbf6ea;
  --bg-2: #f3ecdc;
  --bg-veil: rgba(251, 246, 234, 0.94);
  --bg-veil-0: rgba(251, 246, 234, 0);
  --panel: rgba(255, 252, 245, 0.92);
  --panel-2: rgba(248, 242, 229, 0.96);
  --panel-solid: #fffcf5;
  --line: rgba(23, 25, 28, 0.1);
  --line-strong: rgba(23, 25, 28, 0.22);
  --text: #17191c;
  --text-2: #33363b;
  --muted: #5b5f66;
  --faint: #7a7e85;
  --gold: #e0ab1c;
  --gold-deep: #b98a12;
  --gold-soft: rgba(212, 160, 23, 0.14);
  --gold-line: rgba(212, 160, 23, 0.55);
  --gold-glow: rgba(212, 160, 23, 0.26);
  --leaf: #556239;
  --leaf-soft: rgba(85, 98, 57, 0.18);
  --on-gold: #17191c;
  --z-base: #17191c;
  --shadow: 0 24px 60px rgba(60, 50, 20, 0.16);
  --card-shadow: 0 12px 36px rgba(60, 50, 20, 0.12);
}
html { background: var(--bg); }
body { background: var(--bg); color: var(--text); transition: background-color 0.35s ease, color 0.35s ease; }

/* --- the public header: lockup left, actions right --------------------------- */
.pub-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(14px, 4vw, 44px);
  background: linear-gradient(180deg, var(--bg-veil) 0%, var(--bg-veil-0) 100%);
}
.pub-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  min-height: 44px;
}
.pub-lockup .mark { width: 40px; height: 32px; flex: none; filter: drop-shadow(0 2px 10px var(--gold-glow)); }
.pub-lockup .pub-word { font-weight: 850; letter-spacing: 0.34em; font-size: 0.82rem; }
.pub-lockup .pub-tag { display: none; font-size: 0.56rem; letter-spacing: 0.22em; font-weight: 700; color: var(--gold); }
@media (min-width: 720px) {
  .pub-lockup .pub-word { font-size: 0.9rem; }
  .pub-lockup .pub-text { display: flex; flex-direction: column; gap: 2px; }
  .pub-lockup .pub-tag { display: block; }
}
.pub-actions { display: flex; align-items: center; gap: 10px; }
.pub-link {
  color: var(--text-2);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  padding: 8px 6px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.pub-link:hover { color: var(--gold); }
@media (max-width: 560px) { .pub-link { display: none; } }
.pub-signin {
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0 18px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  background: var(--panel);
  transition: border-color 0.25s, background 0.25s, transform 0.25s;
}
.pub-signin:hover { border-color: var(--gold); background: var(--gold-soft); transform: translateY(-1px); }

/* --- the light / dark toggle ------------------------------------------------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-2);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.25s, background 0.25s, color 0.25s;
}
.theme-toggle:hover { border-color: var(--gold); color: var(--gold); }
.theme-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .tt-sun { display: none; }
.theme-toggle[aria-pressed="true"] .tt-sun { display: block; }
.theme-toggle[aria-pressed="true"] .tt-moon { display: none; }
.tt-track {
  position: relative;
  width: 32px; height: 18px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.25s;
}
.tt-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.theme-toggle[aria-pressed="true"] .tt-track { background: var(--gold-soft); }
.theme-toggle[aria-pressed="true"] .tt-knob { transform: translateX(14px); }

/* --- buttons ----------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 28px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.84rem;
  letter-spacing: 0.12em;
  text-decoration: none;
  transition: transform 0.25s, box-shadow 0.25s, background 0.25s, border-color 0.25s;
}
.btn-primary {
  color: var(--on-gold);
  background: linear-gradient(180deg, #ffd452, var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 8px 30px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 38px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35); filter: brightness(1.04); }
.btn-ghost { color: var(--text); border: 1px solid var(--line-strong); background: var(--panel); }
.btn-ghost:hover { border-color: var(--gold); background: var(--gold-soft); transform: translateY(-2px); }

@media (prefers-reduced-motion: reduce) {
  body, .tt-knob, .btn, .pub-signin, .theme-toggle { transition: none; }
}

/* Light mode for the app stylesheet's own tokens, on this page only: the
   card's inputs, buttons and notices come from app.css. */
html[data-theme="light"] {
  --surface-1: #fffcf5;
  --surface-2: #f3ecdc;
  --surface-3: #e9e0cb;
  --border: rgba(23, 25, 28, 0.2);
  --border-strong: rgba(23, 25, 28, 0.34);
  --divider: rgba(23, 25, 28, 0.1);
  --text-3: #6b6f76;
  --accent: #e0ab1c;
  --accent-strong: #f0bd2d;
  --accent-hover: #e8b424;
  --accent-soft: rgba(212, 160, 23, 0.14);
  --accent-line: rgba(212, 160, 23, 0.55);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  --shadow-1: 0 1px 2px rgba(60, 50, 20, 0.12), 0 4px 12px rgba(60, 50, 20, 0.1);
  --shadow-2: 0 2px 6px rgba(60, 50, 20, 0.14), 0 12px 32px rgba(60, 50, 20, 0.14);
}
body.login-page {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100svh;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 55% at 50% 30%, var(--gold-soft), transparent 62%),
    radial-gradient(ellipse 60% 45% at 80% 90%, var(--leaf-soft), transparent 60%);
  overflow-x: hidden;
}
#gate {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.9s ease;
}
body.arrived #gate { opacity: 1; }
.gate-veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, var(--bg-veil) 0%, var(--bg-veil-0) 26%, var(--bg-veil-0) 70%, var(--bg-veil) 100%);
}
.login-page .pub-top { background: none; }

.gate-wrap {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 92px 16px 52px;
}
.gate-card {
  width: 100%;
  max-width: 392px;
  text-align: center;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  padding: 30px 26px 24px;
  box-shadow: var(--shadow), 0 0 60px var(--gold-soft), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: gate-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes gate-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.gate-logo {
  width: 96px;
  height: auto;
  aspect-ratio: 300 / 240;
  margin: 0 auto 10px;
  filter: drop-shadow(0 0 20px var(--gold-glow));
}
.gate-logo .mark { width: 100%; height: 100%; display: block; }
.gate-brand {
  margin: 0;
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: var(--text);
}
.gate-sub {
  margin: 7px 0 0;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.36em;
  text-indent: 0.36em;
  color: var(--gold);
}
.gate-card .lede { margin: 16px 0 4px; font-size: 0.85rem; color: var(--muted); }
.gate-card .notice { text-align: left; }
.gate-card form { text-align: left; margin-top: 12px; }
.gate-card label { color: var(--text-2); }
.gate-card .form-actions { margin-top: 18px; }
.gate-card button.primary {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  border-radius: 999px;
  color: var(--on-gold);
  background: linear-gradient(180deg, #ffd452, var(--gold) 55%, var(--gold-deep));
  border-color: var(--gold-line);
  box-shadow: 0 8px 26px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.gate-card button.primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 12px 34px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.gate-card select {
  width: 100%;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  color: var(--text);
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
}
.gate-or {
  display: flex; align-items: center; gap: 12px; margin: 22px 0 4px;
  color: var(--faint); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.24em;
}
.gate-or::before, .gate-or::after { content: ""; flex: 1; height: 1px; background: var(--line-strong); }
.gate-ws button.secondary {
  width: 100%; padding: 0.8rem 1rem; font-size: 0.82rem; font-weight: 800; letter-spacing: 0.14em;
  border-radius: 999px; color: var(--text); background: var(--panel-solid);
  border: 1px solid var(--line-strong); box-shadow: none;
}
.gate-ws button.secondary:hover { border-color: var(--gold); color: var(--gold); }
.gate-back { margin: 12px 0 0; font-size: 0.74rem; text-align: left; }
.gate-back a { color: var(--text-2); text-decoration: none; letter-spacing: 0.06em; }
.gate-back a:hover { color: var(--gold); }
.gate-demo {
  margin: 4px 0 12px;
  padding: 12px 14px;
  text-align: left;
  border: 1px dashed var(--gold-line);
  border-radius: 12px;
  background: var(--gold-soft);
}
.gate-demo-title { margin: 0 0 6px; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.24em; color: var(--gold); }
.gate-demo-line { margin: 2px 0; font-size: 0.9rem; color: var(--text); }
.gate-demo .small { margin: 8px 0 0; font-size: 0.74rem; color: var(--muted); }
.gate-try { margin: 2px 0 10px; text-align: right; }
.gate-try a { color: var(--gold); font-size: 0.74rem; font-weight: 800; letter-spacing: 0.08em; text-decoration: none; }
.gate-try a:hover { color: var(--text); }
.gate-foot { margin: 18px 0 0; font-size: 0.78rem; }
.gate-foot a { color: var(--text-2); text-decoration: none; letter-spacing: 0.06em; }
.gate-foot a:hover { color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  .gate-card { animation: none; }
  #gate { transition: none; }
}
