html, body { overflow-x: hidden; }
:root {
  --bg: #1a1a2e;
  --bg-soft: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.12);
  --text: #e8e8f0;
  --muted: rgba(232, 232, 240, 0.55);
  --cyan: #00d4ff;
  --pink: #ff2d9b;
  --ok: #21d07a;
  --warn: #ffb020;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Worn title, shown beside a name on every board. Deliberately quiet — it is a
   mark of rank, not a second username. */
.worn-title {
  display: inline-block; margin-left: 7px; padding: 1px 6px;
  font-size: 11px; letter-spacing: 0.1em; vertical-align: 1px;
  color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent);
  border-radius: 2px; cursor: help;
}

/* --- Focus pages (signed in, nav present but inert) -------------------- */
/* First-run steps that must be completed before the app is navigable. The nav
   is drained of colour and interaction rather than hidden — it reads as "not
   yet", which is true, instead of as "gone". The `inert` attribute in the
   layout is what actually disables it; this is the visual half. */
.nav-inert {
  filter: grayscale(0.85) brightness(0.62);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.3s ease;
}
.focus-wrap {
  min-height: calc(100vh - 60px); padding: 40px 20px 40px;
  background: radial-gradient(ellipse at 50% 0%, #1e2a4a 0%, #1a1a2e 62%);
}
.focus-body { max-width: 1080px; margin: 0 auto; }
.focus-escape { max-width: 1080px; margin: 34px auto 0; text-align: center; }
/* A button_to renders a form + submit; this makes the only exit read as a quiet
   link rather than competing with the primary action. */
.focus-escape .linkish {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline;
}
.focus-escape .linkish:hover { color: var(--text); }

/* --- Centered auth pages --------------------------------------------- */
.auth-wrap {
  min-height: 100vh;
  /* Column, not row: the footer is a sibling of .auth-box here, so the default
     row direction laid it out *beside* the form as a narrow strip. */
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px;
  background: radial-gradient(ellipse at 50% 30%, #1e2a4a 0%, #1a1a2e 70%);
}
/* Sits under the form rather than being pushed to the viewport bottom — these
   pages are short and a floor-anchored footer leaves a dead gap. */
.auth-wrap .app-footer { margin-top: 28px; width: 100%; max-width: 420px; }
.auth-box { width: 100%; max-width: 420px; }
.brand {
  font-size: 48px; font-weight: 800; letter-spacing: 3px;
  text-align: center; margin-bottom: 48px;
}
.brand .a { color: var(--cyan); }
.brand .b { color: var(--pink); }

/* --- Landing: inline email capture, matching the original app --------- */
}

/* --- Cards / forms ---------------------------------------------------- */
.card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}
.card + .card { margin-top: 20px; }
.card h2 { font-size: 17px; margin-bottom: 18px; font-weight: 700; }
.card p.hint { color: var(--muted); font-size: 13px; margin-bottom: 18px; line-height: 1.5; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 16px; }

input[type=text], input[type=email], input[type=password], select {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}
input:focus, select:focus { border-color: var(--cyan); background: rgba(0, 212, 255, 0.05); }
select option { background: var(--bg); }

button, .btn, input[type=submit] {
  display: inline-block;
  background: var(--cyan);
  color: #06121a;
  border: none; border-radius: 50px;
  padding: 12px 26px;
  font-size: 15px; font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
}
button:hover, .btn:hover, input[type=submit]:hover { background: #00e8ff; text-decoration: none; }
.btn-ghost, input[type=submit].btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-soft); border-color: var(--cyan); }
.btn-danger, input[type=submit].btn-danger { background: transparent; color: var(--pink); border: 1px solid var(--pink); }
.btn-danger:hover { background: rgba(255, 45, 155, 0.12); }
.btn-sm { padding: 7px 16px; font-size: 13px; }

.actions { display: flex; gap: 12px; align-items: center; margin-top: 22px; }
.below { text-align: center; margin-top: 20px; font-size: 14px; color: var(--muted); }
.below a { margin: 0 6px; }

/* --- Flash / errors ---------------------------------------------------- */
.flash {
  border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; font-size: 14px;
}
.flash-notice { background: rgba(33, 208, 122, 0.12); border: 1px solid rgba(33, 208, 122, 0.4); }
.flash-alert  { background: rgba(255, 45, 155, 0.12); border: 1px solid rgba(255, 45, 155, 0.4); }
.errors {
  background: rgba(255, 45, 155, 0.1); border: 1px solid rgba(255, 45, 155, 0.35);
  border-radius: 10px; padding: 12px 16px 12px 32px; margin-bottom: 20px; font-size: 14px;
}
.errors li { margin: 2px 0; }

/* --- App shell (settings / admin) -------------------------------------- */
.container { max-width: 900px; margin: 0 auto; padding: 36px 24px 80px; }
.container h1 { font-size: 24px; margin-bottom: 24px; font-weight: 800; }

/* --- Tables ------------------------------------------------------------ */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
td { padding: 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
tr:hover td { background: rgba(255, 255, 255, 0.03); }

.tag {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px; letter-spacing: 0.4px;
}
.tag-active  { background: rgba(33, 208, 122, 0.15); color: var(--ok); }
.tag-pending { background: rgba(255, 176, 32, 0.15); color: var(--warn); }
.tag-admin   { background: rgba(0, 212, 255, 0.15); color: var(--cyan); }
.tag-locked  { background: rgba(255, 45, 155, 0.15); color: var(--pink); }

.stats { display: flex; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.stat {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 22px; min-width: 110px;
}
.stat .n { font-size: 26px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar input[type=text] { max-width: 260px; }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 50px; color: var(--muted); }

dl.kv { display: grid; grid-template-columns: 200px 1fr; gap: 12px 20px; font-size: 14px; }
dl.kv dt { color: var(--muted); }

@media (max-width: 640px) {
  dl.kv { grid-template-columns: 1fr; gap: 4px 0; }
  dl.kv dd { margin-bottom: 12px; }
}

/* ============================================================
   Chrome: Neo-Tokyo. Same cyan/pink/navy as the rest of the app —
   the palette is untouched; only the light, motion and edges are new.
   Decoration is all pseudo-elements: toggleLang rewrites textContent
   and would destroy any real child node.
   ============================================================ */
:root {
  --chrome-bg:   #16162b;
  --chrome-deep: #0f0f1f;
  --gothic: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic",
            "Noto Sans JP", Inter, -apple-system, sans-serif;
}

/* ---------- Bar ---------- */
header {
  position: relative;
  background: linear-gradient(180deg, var(--chrome-bg) 0%, var(--chrome-deep) 100%);
  padding: 0 24px;
  display: flex; align-items: stretch; justify-content: space-between;
  gap: 20px; min-height: 60px;
  border-bottom: none;
  overflow: hidden;
}
/* Scanlines — the CRT the whole city is filmed through. */
header::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background: repeating-linear-gradient(
    180deg, rgba(0, 212, 255, 0.035) 0px, rgba(0, 212, 255, 0.035) 1px,
    transparent 1px, transparent 3px);
}
/* Live wire along the bottom edge: a cyan→pink current that keeps moving. */
header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg,
    transparent 0%, #00d4ff 10%, #00d4ff 45%,
    rgba(0, 212, 255, 0.75) 62%, #00d4ff 82%, transparent 100%);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.5), 0 0 24px rgba(0, 212, 255, 0.2);
}

.brand-group { display: flex; align-items: center; gap: 20px; position: relative; z-index: 1; }

/* ---------- Wordmark ---------- */
header h1 {
  font-family: var(--gothic);
  font-size: 20px; font-weight: 800; letter-spacing: 0.16em;
  cursor: pointer; line-height: 1; white-space: nowrap;
  display: flex; align-items: center; text-transform: uppercase;
}
header h1 a { text-decoration: none; display: flex; align-items: center; }
header h1 span.r-col {
  color: #00d4ff;
  text-shadow: 0 0 14px rgba(0, 212, 255, 0.55);
  transition: text-shadow 0.4s ease;
}
/* SRS as a capsule: chamfered, lit from inside. */
header h1 span.k-col {
  color: #12101f; background: #ff2d9b;
  padding: 5px 10px 4px; margin-left: 9px;
  font-size: 14px; letter-spacing: 0.2em; font-weight: 800;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  box-shadow: 0 0 18px rgba(255, 45, 155, 0.55);
  transition: box-shadow 0.4s ease, transform 0.4s cubic-bezier(0.2, 0.9, 0.2, 1);
}
header h1:hover span.r-col { text-shadow: -1.5px 0 #ff2d9b, 1.5px 0 #00d4ff, 0 0 20px rgba(0, 212, 255, 0.8); }
header h1:hover span.k-col { transform: translateY(-1px); box-shadow: 0 0 28px rgba(255, 45, 155, 0.85); }

/* ---------- Nav ---------- */
header nav { display: flex; align-items: stretch; gap: 4px; flex-wrap: wrap; position: relative; z-index: 1; }

header nav .nav-btn,
header nav button,
.nav-home {
  position: relative;
  display: inline-flex; align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: none; border-radius: 0; margin: 8px 0;
  padding: 0 16px;
  font-family: var(--gothic);
  font-size: 13.5px; font-weight: 600;
  letter-spacing: 0.14em; text-indent: 0.14em;
  color: rgba(232, 232, 240, 0.5);
  text-decoration: none; white-space: nowrap; cursor: pointer;
  -webkit-appearance: none;
  /* Chamfered corners — HUD panel, not a pill. */
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  transition: color 0.3s ease, background 0.3s ease, text-shadow 0.3s ease;
}

/* Charge line that fires across the base on hover. */
header nav .nav-btn::after,
header nav button::after,
.nav-home::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, #00d4ff, #ff2d9b);
  transform: scaleX(0); transform-origin: left center;
  transition: transform 0.34s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.7);
}
/* Light bleeding up from that line. */
header nav .nav-btn::before,
header nav button::before,
.nav-home::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(0, 212, 255, 0.16) 100%);
  opacity: 0; transition: opacity 0.3s ease; pointer-events: none;
}

header nav .nav-btn:hover,
header nav button:hover,
.nav-home:hover {
  color: #e8e8f0; background: rgba(0, 212, 255, 0.07);
  text-decoration: none;
  /* Chromatic split — the signal not quite holding. */
  text-shadow: -1px 0 rgba(255, 45, 155, 0.9), 1px 0 rgba(0, 212, 255, 0.9);
}
header nav .nav-btn:hover::after,
header nav button:hover::after,
.nav-home:hover::after { transform: scaleX(1); }
header nav .nav-btn:hover::before,
header nav button:hover::before,
.nav-home:hover::before { opacity: 1; }

/* Current section: powered on. */
header nav .nav-btn.active,
header nav button.active,
.nav-home.active {
  color: #00d4ff; background: rgba(0, 212, 255, 0.12);
  text-shadow: 0 0 12px rgba(0, 212, 255, 0.7);
}
header nav .nav-btn.active::after,
header nav button.active::after,
.nav-home.active::after {
  transform: scaleX(1);
  background: linear-gradient(90deg, #00d4ff, #00d4ff);
}

/* Home is its own control but sits in exactly the same box as the section
   items — brand-group stretches so the 8px margins resolve to the same height. */
.brand-group { align-items: stretch; }
.nav-home { color: rgba(232, 232, 240, 0.75); background: rgba(0, 212, 255, 0.05); }
.brand-group .nav-home { margin-left: 4px; }

/* Section colours follow the app's own type palette: kanji pink, vocab purple. */
#nav-kanji.active {
  color: #ff2d9b; background: rgba(255, 45, 155, 0.12);
  text-shadow: 0 0 12px rgba(255, 45, 155, 0.7);
}
#nav-kanji.active::after {
  background: #ff2d9b;
  box-shadow: 0 0 10px rgba(255, 45, 155, 0.75);
}
#nav-vocabulary.active {
  color: #a855f7; background: rgba(168, 85, 247, 0.14);
  text-shadow: 0 0 12px rgba(168, 85, 247, 0.7);
}
#nav-vocabulary.active::after {
  background: #a855f7;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.75);
}

header nav form { display: inline; margin: 0; }

/* ---------- Footer ---------- */
.app-footer {
  position: static;
  margin-top: 56px; padding: 0 24px 32px;
  background: linear-gradient(180deg, transparent, rgba(15, 15, 31, 0.9));
}
.footer-row {
  max-width: 900px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  padding-top: 24px; position: relative;
}
/* Same current as the header, dimmed. */
.footer-row::before {
  content: ""; position: absolute; top: 0; left: 6%; right: 6%; height: 1px;
  background: linear-gradient(90deg,
    transparent, rgba(0, 212, 255, 0.5) 30%, rgba(255, 45, 155, 0.6) 50%,
    rgba(0, 212, 255, 0.5) 70%, transparent);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.25);
}

.foot-btn {
  position: relative;
  background: none; border: none; border-radius: 0;
  padding: 7px 18px; margin: 0;
  font-family: var(--gothic);
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.2em; text-indent: 0.2em;
  color: rgba(232, 232, 240, 0.35);
  text-decoration: none; white-space: nowrap; cursor: pointer;
  -webkit-appearance: none;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}
.foot-btn + .foot-btn::before,
.foot-form + .foot-btn::before,
.foot-btn + .foot-form .foot-btn::before {
  content: ""; position: absolute; left: 0; top: 50%;
  width: 1px; height: 11px; margin-top: -5.5px;
  background: rgba(0, 212, 255, 0.25);
}
.foot-btn::after {
  content: ""; position: absolute; left: 18px; right: 18px; bottom: 2px; height: 1px;
  background: linear-gradient(90deg, #00d4ff, #ff2d9b);
  transform: scaleX(0); transform-origin: left center;
  transition: transform 0.34s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.6);
}
.foot-btn:hover {
  color: #e8e8f0; text-decoration: none;
  text-shadow: -1px 0 rgba(255, 45, 155, 0.8), 1px 0 rgba(0, 212, 255, 0.8);
}
.foot-btn:hover::after { transform: scaleX(1); }
.foot-btn.active { color: #00d4ff; text-shadow: 0 0 10px rgba(0, 212, 255, 0.6); }
.foot-btn.active::after { transform: scaleX(1); background: #00d4ff; }

.foot-form { display: inline; margin: 0; }

/* The toggle is a readout, not a word. */
.lang-btn {
  font-family: Inter, "Helvetica Neue", Arial, sans-serif;
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.28em; text-indent: 0.28em;
  color: rgba(255, 45, 155, 0.55);
}
.lang-btn:hover { color: #ff2d9b; text-shadow: 0 0 12px rgba(255, 45, 155, 0.8); }
.lang-btn:hover::after { background: #ff2d9b; box-shadow: 0 0 8px rgba(255, 45, 155, 0.7); }

/* Footer sits at the bottom of short pages instead of mid-screen. */
body { display: flex; flex-direction: column; min-height: 100vh; }
/* `margin: 0 auto` suppresses flex stretch, so set the width explicitly. */
body > .container, body > .auth-wrap { flex: 1 0 auto; width: 100%; }
.app-footer { margin-top: auto; }
#app-wrap { display: flex; flex-direction: column; }
#app-wrap > .container { flex: 1 0 auto; width: 100%; }

/* ---------- Focus + motion ---------- */
header nav .nav-btn:focus-visible,
header nav button:focus-visible,
.nav-home:focus-visible,
.foot-btn:focus-visible {
  outline: 1px solid #00d4ff; outline-offset: 2px; color: #e8e8f0;
}

@media (prefers-reduced-motion: reduce) {
  header nav .nav-btn, header nav button, .nav-home, .foot-btn,
  header h1 span.k-col, header h1 span.r-col,
  header nav .nav-btn::after, header nav button::after, .nav-home::after, .foot-btn::after,
  header nav .nav-btn::before, header nav button::before, .nav-home::before {
    transition: none;
  }
}

@media (max-width: 760px) {
  header { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 14px 0; }
  .brand-group { gap: 12px; }
  header nav { width: 100%; padding-bottom: 8px; }
  header nav .nav-btn, header nav button, .nav-home { padding: 0 10px; font-size: 12.5px; margin: 4px 0; }
  .footer-row { flex-wrap: wrap; }
  .foot-btn { padding: 7px 13px; }
}


/* ---------- 土俵 Dohyō ---------- */
.h1-sub, .h2-sub { color: rgba(255,255,255,0.32); font-weight: 400; letter-spacing: 0.14em;
  font-size: 0.55em; margin-left: 10px; text-transform: uppercase; }
.dohyo-tabs { display: flex; gap: 6px; margin: -8px 0 30px; flex-wrap: wrap; }
.dohyo-tab {
  display: flex; flex-direction: column; gap: 2px; padding: 9px 18px; text-decoration: none;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(0,212,255,0.18);
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.dohyo-tab:hover { background: rgba(0,212,255,0.10); border-color: rgba(0,212,255,0.4); }
.dohyo-tab.active { background: rgba(0,212,255,0.16); border-color: rgba(0,212,255,0.55);
  box-shadow: 0 0 16px rgba(0,212,255,0.22); }
.dohyo-tab-ja { font-size: 14px; color: #e8e8f0; letter-spacing: 0.1em; }
.dohyo-tab-en { font-size: 10px; color: rgba(255,255,255,0.38); letter-spacing: 0.18em; text-transform: uppercase; }

.dohyo-board { margin-bottom: 38px; }
.dohyo-board h2 { font-size: 19px; margin-bottom: 4px; }
.board-note { margin: 0 0 14px; font-size: 13px; max-width: 62ch; }
tr.is-you { background: rgba(0,212,255,0.07); }
.rank { display: inline-block; min-width: 22px; text-align: center; font-weight: 700;
  padding: 2px 6px; font-size: 12px;
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px); }
.rank-1 { background: rgba(255,196,0,0.18); color: #ffc400; }
.rank-2 { background: rgba(200,200,220,0.16); color: #c8c8dc; }
.rank-3 { background: rgba(205,127,50,0.18); color: #cd7f32; }
.commitment-rules { text-align: left; max-width: 64ch; }
.commitment-rules ul { margin: 12px 0; padding-left: 20px; }
.commitment-rules li { margin-bottom: 7px; line-height: 1.6; }
.tag-failed { background: rgba(255,68,68,0.16); color: #ff6b6b; }
