/* Kokona Panel — Strinova-style HUD (cut corners, condensed italic headings) in
   Kokona's own colours, taken from her official art: the navy P.U.S. cape with its
   indigo-to-periwinkle lining, amber eyes and yellow tech accents, the emerald
   gem on her belt, and the pale straps that trail behind her. */

:root {
  color-scheme: dark;
  --bg: #070a17;
  --bg-raised: #0d1226;
  --panel-top: rgba(23, 30, 60, 0.93);
  --panel-bottom: rgba(12, 16, 35, 0.94);
  --field: rgba(6, 9, 22, 0.8);
  --line: rgba(154, 160, 242, 0.18);
  --line-strong: rgba(154, 160, 242, 0.36);
  --text: #eef0fb;
  --muted: #9ea5c8;
  --cape: #9aa0f2;
  --cape-deep: #3f5fe0;
  --cape-soft: rgba(154, 160, 242, 0.14);
  --amber: #f4b942;
  --sky: #5b9cff;
  --sky-soft: rgba(91, 156, 255, 0.12);
  --hair: #c8b9a6;
  --on-amber: #1a1305;
  --ok: #2fd39a;
  --warn: #f5a340;
  --danger: #ff5a6e;
  --cut: 14px;
  --font-body: "Segoe UI", system-ui, -apple-system, "Noto Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Bahnschrift, "DIN Alternate", "Barlow Condensed", "Roboto Condensed", "Arial Narrow", var(--font-body);
  --font-mono: "Cascadia Code", "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Night sky in her cape colours: the indigo lining glowing behind her, a warm amber trace low left. */
  background:
    radial-gradient(1000px 680px at 96% 4%, rgba(63, 95, 224, 0.26), transparent 64%),
    radial-gradient(820px 560px at 74% 104%, rgba(154, 160, 242, 0.14), transparent 64%),
    radial-gradient(760px 480px at -12% 112%, rgba(244, 185, 66, 0.07), transparent 60%),
    linear-gradient(180deg, #0a0e20 0%, #060915 100%);
  background-color: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font-body);
  overflow-x: hidden;
}

a {
  color: var(--sky);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

h1 {
  font-size: clamp(1.75rem, 3.4vw, 2.6rem);
  font-style: italic;
  text-transform: uppercase;
}

h2 {
  font-size: 1.25rem;
  text-transform: uppercase;
}

h3 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

p {
  margin: 0;
}

code {
  font-family: var(--font-mono);
}

:focus-visible {
  outline: 2px solid var(--sky);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 20;
  padding: 10px 14px;
  background: var(--amber);
  color: var(--on-amber);
  font-weight: 700;
}

.skip-link:focus {
  top: 12px;
}

/* Backdrop: a faint HUD grid with three drifting ribbons, like the straps that trail behind Kokona. */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(154, 160, 242, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(154, 160, 242, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 78%);
}

.ribbon {
  position: absolute;
  left: -20%;
  width: 140%;
  height: 14px;
  transform-origin: center;
  animation: drift 18s ease-in-out infinite alternate;
}

.ribbon-a {
  top: 20%;
  background: linear-gradient(90deg, transparent 8%, rgba(236, 240, 250, 0.07) 30%, rgba(236, 240, 250, 0.16) 50%, rgba(236, 240, 250, 0.05) 72%, transparent 92%);
  border-top: 1px solid rgba(236, 240, 250, 0.08);
  transform: rotate(-8deg);
}

.ribbon-b {
  top: 60%;
  height: 22px;
  background: linear-gradient(90deg, transparent 10%, rgba(63, 95, 224, 0.12) 35%, rgba(154, 160, 242, 0.16) 55%, transparent 88%);
  transform: rotate(5deg);
  animation-duration: 24s;
}

.ribbon-c {
  top: 86%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  transform: rotate(-3deg);
  opacity: 0.22;
  animation-duration: 30s;
}

/* Inside the panel the wide ribbons stay out from behind text; the start page keeps all three. */
body:not(.is-home) .ribbon-a,
body:not(.is-home) .ribbon-b {
  display: none;
}

/* Kokona's official art, fixed so she stands just right of the 1240px content, her
   cape tucked a little behind the cards. When the margin is too narrow for her, she
   moves only as far as the window's right edge: clear on the start page and, on
   wide screens, beside the settings; quiet where she has to overlap them.
   (Percentages of a fixed element are of the viewport, without the scrollbar.) */
/* Very tall windows let her grow toward the art's native 1500px, so she still
   reaches up beside the cards instead of standing far below them. */
.splash {
  --splash-height: min(calc(100vh - 70px), max(1100px, calc(100vh - 660px)), 1500px);
  --splash-width: calc(var(--splash-height) * 1044 / 1500);
  position: fixed;
  z-index: -1;
  left: min(calc(50% + 540px), calc(100% - var(--splash-width)));
  bottom: 0;
  height: var(--splash-height);
  aspect-ratio: 1044 / 1500;
  background: url("kokona-splash.webp") center bottom / contain no-repeat;
  opacity: 0.17;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to top, transparent 0, #000 16%);
  mask-image: linear-gradient(to top, transparent 0, #000 16%);
}

.splash::before {
  content: "";
  position: absolute;
  inset: 8% -10% 10%;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(63, 95, 224, 0.42), rgba(154, 160, 242, 0.12) 55%, transparent);
}

.is-home .splash {
  opacity: 1;
  -webkit-mask-image: linear-gradient(to top, transparent 0, #000 14%), linear-gradient(to right, transparent 0, #000 26%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to top, transparent 0, #000 14%), linear-gradient(to right, transparent 0, #000 26%);
  mask-composite: intersect;
}

/* Wide screens leave a margin right of the 1240px content, so she can show there;
   the left fade hides the part that still reaches behind the cards. Instead of
   drifting to the window edge, she stays beside the cards with her cape tucked a
   little under them: 40% of the art on the start page (the cards are glass there),
   24% behind the settings. Below about 1900px the window edge still decides. */
@media (min-width: 1600px) {
  .is-home .splash {
    left: min(calc(50% + 580px - var(--splash-width) * 0.4), calc(100% - var(--splash-width)));
  }

  body:not(.is-home) .splash {
    left: min(calc(50% + 620px - var(--splash-width) * 0.24), calc(100% - var(--splash-width)));
  }

  body:not(.is-home) .splash {
    opacity: 0.5;
    -webkit-mask-image: linear-gradient(to top, transparent 0, #000 16%), linear-gradient(to right, transparent 0, #000 30%);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(to top, transparent 0, #000 16%), linear-gradient(to right, transparent 0, #000 30%);
    mask-composite: intersect;
  }
}

@media (min-width: 2100px) {
  body:not(.is-home) .splash {
    opacity: 0.8;
  }
}

@keyframes drift {
  from { translate: -4% 0; }
  to { translate: 4% -12px; }
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(8, 11, 26, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, var(--cape-deep), var(--cape) 22%, transparent 45%, transparent 70%, var(--amber));
  opacity: 0.75;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
}

.brand-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(63, 95, 224, 0.55), 0 0 18px rgba(63, 95, 224, 0.45);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-text strong {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-style: italic;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.brand-text small {
  margin-top: 4px;
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.32em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
}

.lang-switch button {
  min-width: 40px;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 700 0.75rem/1 var(--font-mono);
  letter-spacing: 0.1em;
  cursor: pointer;
}

.lang-switch button[aria-pressed="true"] {
  background: var(--amber);
  color: var(--on-amber);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
}

.user-chip img,
.avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--cape);
}

.avatar-fallback {
  display: inline-grid;
  place-items: center;
  background: var(--cape-soft);
  font-weight: 700;
  font-size: 0.8rem;
}

.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Layout */
.shell {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 40px) 48px;
}

.with-rail .shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.page:focus {
  outline: none;
}

.footer {
  padding: 20px 16px 28px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.footer .art-credit {
  margin-top: 4px;
  opacity: 0.75;
  font-size: 0.72rem;
}

/* Panels: the signature cut-corner frame */
.panel {
  position: relative;
  padding: 22px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}

.panel::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 64px;
  height: 2px;
  background: linear-gradient(90deg, var(--cape-deep), var(--cape));
}

.panel::after {
  content: "";
  position: absolute;
  right: 20px;
  bottom: 9px;
  width: 30px;
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--amber) 0 4px, transparent 4px 7px);
  opacity: 0.55;
}

.hud-tag {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.hud-index {
  margin-bottom: 8px;
  color: var(--cape);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
}

.lead {
  max-width: 68ch;
  margin-top: 8px;
  color: var(--muted);
  font-size: 1.02rem;
}

.muted {
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.fine-print {
  color: var(--muted);
  font-size: 0.8rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.page-head h1 {
  margin-top: 6px;
}

/* Buttons: slanted parallelograms */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  min-height: 40px;
  padding: 0.7em 1.5em;
  border: 0;
  font: 700 0.85rem/1 var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  transition: transform 0.15s ease, filter 0.15s ease, background-color 0.15s ease;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.btn:focus-visible {
  outline: none;
  background: var(--sky);
  color: #06112a;
}

.btn-primary {
  background: var(--amber);
  color: var(--on-amber);
}

.btn-ghost {
  background: rgba(154, 160, 242, 0.12);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.btn-danger {
  background: rgba(255, 90, 110, 0.16);
  color: #ffd3dc;
  box-shadow: inset 0 0 0 1px rgba(255, 90, 110, 0.5);
}

.btn-small {
  min-height: 36px;
  padding: 0.5em 1.1em;
  font-size: 0.76rem;
}

.btn-large {
  min-height: 52px;
  padding: 1em 2em;
  font-size: 1rem;
}

.discord-glyph {
  width: 22px;
  height: 22px;
}

.button-row,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Flash messages and callouts */
.flashes {
  display: grid;
  gap: 10px;
}

.flash {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(15, 18, 36, 0.92);
  border: 1px solid var(--line);
  border-left: 3px solid var(--sky);
}

.flash-ok { border-left-color: var(--ok); }
.flash-error { border-left-color: var(--danger); }
.flash-warning { border-left-color: var(--warn); }

.flash-mark {
  flex: none;
  width: 8px;
  height: 8px;
  background: currentColor;
  transform: rotate(45deg);
  color: var(--sky);
}

.flash-ok .flash-mark { color: var(--ok); }
.flash-error .flash-mark { color: var(--danger); }
.flash-warning .flash-mark { color: var(--warn); }

.callout {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--sky);
  background: linear-gradient(var(--sky-soft), var(--sky-soft)), var(--bg-raised);
}

.callout p + p {
  margin-top: 6px;
}

.callout-error {
  border-left-color: var(--danger);
  background: linear-gradient(rgba(255, 90, 110, 0.1), rgba(255, 90, 110, 0.1)), var(--bg-raised);
}

.callout-warning {
  border-left-color: var(--warn);
  background: linear-gradient(rgba(245, 163, 64, 0.1), rgba(245, 163, 64, 0.1)), var(--bg-raised);
}

/* Home */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 40px;
  align-items: center;
  padding: clamp(12px, 4vw, 40px) 0;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.display {
  font-size: clamp(2.2rem, 5.6vw, 4.2rem);
  line-height: 0.98;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
  margin-top: 6px;
}

/* The art itself is the fixed .splash layer; this column keeps it clear and
   carries a character-select nameplate at her feet. */
.hero-visual {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  align-self: stretch;
  min-height: 420px;
}

.nameplate {
  position: relative;
  padding: 14px 18px 12px 26px;
  text-align: right;
  background: linear-gradient(90deg, transparent, rgba(7, 10, 23, 0.72) 30%);
}

.nameplate::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cape-deep) 30%, var(--cape));
}

.nameplate::after {
  content: "";
  position: absolute;
  right: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: var(--amber);
}

.nameplate-role {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
}

.nameplate-name {
  margin-top: 2px;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 4.4vw, 3.6rem);
  font-style: italic;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-shadow: 0 0 28px rgba(63, 95, 224, 0.75);
}

.nameplate-alt {
  margin-top: 6px;
  color: var(--hair);
  font-size: 0.95rem;
  letter-spacing: 0.3em;
}

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

/* On the start page the cards are glass, so Kokona stays visible behind them. */
.is-home .feature {
  background: linear-gradient(180deg, rgba(23, 30, 60, 0.62), rgba(12, 16, 35, 0.74));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.feature h2 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.feature p:last-child {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Server list */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.server-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 18px 18px 18px 22px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  border: 1px solid var(--line);
  color: var(--text);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.server-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--line-strong);
  transition: background 0.18s ease;
}

.server-card:hover,
.server-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(154, 160, 242, 0.55);
  background: linear-gradient(180deg, rgba(30, 38, 80, 0.95), var(--panel-bottom));
  text-decoration: none;
}

.server-card:hover::before,
.server-card:focus-visible::before {
  background: var(--cape);
}

.server-index {
  position: absolute;
  top: 8px;
  right: 22px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
}

.server-icon {
  width: 56px;
  height: 56px;
  object-fit: cover;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}

.server-initials {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--cape-deep), var(--cape));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}

.server-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.server-meta strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.02rem;
}

.server-go {
  color: var(--amber);
  font-size: 1.3rem;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
}

.badge-cape {
  background: var(--cape-soft);
  color: var(--cape);
}

.badge-sky {
  background: var(--sky-soft);
  color: var(--sky);
}

.empty-state {
  display: grid;
  gap: 12px;
}

.checklist {
  margin: 0;
  padding-left: 1.2em;
  color: var(--muted);
}

.checklist li + li {
  margin-top: 4px;
}

/* Server rail */
.rail {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.rail-back {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.rail-guild {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rail-guild img,
.rail-guild .server-initials {
  flex: none;
  width: 52px;
  height: 52px;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}

.rail-guild div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}

.rail-guild strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
}

.rail-group {
  margin: 12px 0 2px;
  padding: 0 14px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  opacity: 0.75;
}

.rail-group:first-child {
  margin-top: 0;
}

.rail-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rail-nav a:hover {
  color: var(--text);
  text-decoration: none;
  background: rgba(154, 160, 242, 0.06);
}

.rail-nav a[aria-current="page"] {
  color: var(--text);
  background: linear-gradient(90deg, var(--cape-soft), transparent);
}

.rail-nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--cape);
}

.rail-index {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

/* Overview */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
}

.stat-label {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.stat-value {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
}

.stat-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.stat-online .pulse {
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(47, 211, 154, 0.6);
  animation: pulse 2s ease-out infinite;
}

.stat-offline .pulse {
  background: var(--danger);
}

@keyframes pulse {
  to { box-shadow: 0 0 0 10px rgba(47, 211, 154, 0); }
}

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

.card-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: start;
}

.nav-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.nav-card:hover,
.nav-card:focus-visible {
  border-color: rgba(154, 160, 242, 0.55);
  transform: translateY(-2px);
  text-decoration: none;
}

.nav-card-wide {
  grid-column: 1 / -1;
}

.nav-card p:not(.hud-index) {
  color: var(--muted);
  font-size: 0.92rem;
}

.facts {
  display: grid;
  gap: 6px;
  margin: 4px 0 0;
}

.facts div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
}

.facts dt {
  color: var(--muted);
  font-size: 0.88rem;
}

.facts dd {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

/* Forms */
.form-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-card form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 420px;
}

.field > span:not(.visually-hidden) {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

select,
input[type="text"],
input[type="number"],
input[type="search"] {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--field);
  color: var(--text);
  font: inherit;
}

select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23f4b942' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}

select option {
  background: var(--bg-raised);
  color: var(--text);
}

select option:disabled {
  color: #6b7397;
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(91, 156, 255, 0.18);
}

.segmented {
  display: inline-flex;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line-strong);
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.segmented span {
  display: block;
  padding: 10px 18px;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--amber);
  color: var(--on-amber);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--sky);
  outline-offset: -2px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--cape);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.form-card .inline-form {
  flex-direction: row;
  align-items: flex-end;
}

.inline-form .field {
  flex: 1 1 220px;
  width: auto;
}

.gain-form .field {
  max-width: 260px;
}

form.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

/* Switches */
.switch-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 6px 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.switch-track {
  position: relative;
  flex: none;
  width: 40px;
  height: 20px;
  background: rgba(154, 160, 242, 0.18);
  border: 1px solid var(--line-strong);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  transition: background 0.15s ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 6px;
  width: 12px;
  height: 12px;
  background: var(--muted);
  transition: left 0.15s ease, background 0.15s ease;
}

.switch[aria-checked="true"] .switch-track {
  background: var(--cape-soft);
  border-color: var(--cape);
}

.switch[aria-checked="true"] .switch-thumb {
  left: 22px;
  background: var(--cape);
}

.switch[aria-checked="false"] .switch-label {
  color: var(--muted);
}

.family-groups {
  display: grid;
  gap: 22px;
}

.family-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

/* Destinations */
.destination-list {
  display: grid;
  gap: 4px;
}

.destination {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px dashed var(--line);
}

.destination-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.destination-label small {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  background: currentColor;
  transform: rotate(45deg);
}

.status-ok {
  color: var(--ok);
}

.status-warning {
  color: var(--warn);
}

/* Chips */
.chip-list,
.grant-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.grant {
  display: inline-flex;
  align-items: stretch;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 4px 10px;
  background: rgba(154, 160, 242, 0.1);
  border: 1px solid var(--line);
  font-size: 0.88rem;
}

.role-chip small {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.role-missing {
  color: var(--muted);
  border-style: dashed;
}

.role-dot {
  flex: none;
  width: 10px;
  height: 10px;
}

.chip-remove {
  min-width: 32px;
  border: 1px solid var(--line);
  border-left: 0;
  background: rgba(255, 90, 110, 0.12);
  color: #ffd3dc;
  font-size: 1rem;
  cursor: pointer;
}

.chip-remove:hover {
  background: rgba(255, 90, 110, 0.3);
}

/* Permissions */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-inline {
  max-width: 360px;
}

.command-list {
  display: grid;
  gap: 12px;
}

.command-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 18px 20px;
}

.command-row[hidden] {
  display: none;
}

.command-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
}

.command-head h2 {
  font-size: 1rem;
  text-transform: none;
}

.command-head code {
  color: var(--cape);
  font-size: 1rem;
}

.command-head p {
  color: var(--muted);
  font-size: 0.9rem;
}

.grant-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.grant-form .field {
  flex: 1 1 200px;
  max-width: 300px;
}

/* Repeating rows: "+" adds a row, × removes one (both need JavaScript). */
.multi-form,
.form-card form.multi-form {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 10px;
}

.multi {
  display: grid;
  gap: 8px;
}

.multi-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.multi-row .field {
  flex: 1 1 240px;
  width: auto;
  max-width: 420px;
}

.multi-row .field-number {
  flex: 0 1 200px;
}

.multi-row + .multi-row {
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.multi-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.multi-actions .field {
  flex: 0 1 260px;
  width: auto;
}

.row-remove {
  flex: none;
  width: 40px;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 90, 110, 0.12);
  color: #ffd3dc;
  font-size: 1.1rem;
  cursor: pointer;
}

.row-remove:hover {
  background: rgba(255, 90, 110, 0.3);
}

.btn[hidden],
.row-remove[hidden] {
  display: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Edit views: a head row with the card's state, a field grid, and one action row */
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 16px;
}

.state {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  background: rgba(154, 160, 242, 0.1);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}

.state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.state-on {
  background: rgba(47, 211, 154, 0.12);
  color: var(--ok);
}

.state-warn {
  background: rgba(245, 163, 64, 0.12);
  color: var(--warn);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 16px 18px;
  width: 100%;
}

.form-grid .field {
  max-width: none;
}

.field-wide {
  grid-column: 1 / -1;
}

fieldset.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.field > legend {
  margin-bottom: 6px;
  padding: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.field-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.counter {
  margin-left: auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.counter.is-over {
  color: var(--danger);
}

textarea,
input[type="url"] {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--field);
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 84px;
  line-height: 1.5;
  resize: vertical;
}

textarea:focus,
input[type="url"]:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(91, 156, 255, 0.18);
}

::placeholder {
  color: #6b7397;
  opacity: 1;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
}

input[type="color"] {
  width: 64px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--field);
  cursor: pointer;
}

.color-field code {
  color: var(--muted);
  font-size: 0.85rem;
}

.form-card form > .toggle + .toggle {
  margin-top: -4px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  width: 100%;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.form-actions .hint {
  flex: 1 1 260px;
  margin: 0;
}

.danger-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 90, 110, 0.22);
  background: rgba(255, 90, 110, 0.05);
}

.form-card form.danger-row {
  flex-direction: row;
  align-items: center;
}

.danger-row .hint {
  flex: 1 1 240px;
}

.empty-note {
  padding: 14px 16px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
}

/* Switch-style checkboxes (the checkbox itself stays the form control) */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.toggle input {
  position: relative;
  flex: none;
  width: 42px;
  height: 22px;
  margin: 0;
  border: 1px solid var(--line-strong);
  background: rgba(154, 160, 242, 0.16);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.toggle input::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 7px;
  width: 12px;
  height: 12px;
  background: var(--muted);
  transition: left 0.15s ease, background 0.15s ease;
}

.toggle input:checked {
  border-color: var(--cape);
  background: rgba(154, 160, 242, 0.32);
}

.toggle input:checked::before {
  left: 23px;
  background: var(--amber);
}

.toggle input:focus-visible + .toggle-text > span {
  color: var(--sky);
  text-decoration: underline;
}

.toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-text small {
  color: var(--muted);
  font-size: 0.78rem;
}

/* Quick links to a long page's cards */
.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -8px;
}

.jump a {
  padding: 6px 14px;
  background: rgba(154, 160, 242, 0.08);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}

.jump a:hover,
.jump a:focus-visible {
  background: var(--cape-soft);
  color: var(--text);
  text-decoration: none;
}

[id] {
  scroll-margin-top: 84px;
}

/* Collapsible editors for lists (subscriptions, ticket systems, shop items) */
.editor-list {
  display: grid;
  gap: 10px;
}

.editor {
  border: 1px solid var(--line);
  background: rgba(6, 9, 22, 0.45);
  transition: border-color 0.15s ease;
}

.editor[open] {
  border-color: var(--line-strong);
  background: rgba(6, 9, 22, 0.6);
}

.editor-off .editor-title strong {
  color: var(--muted);
}

.editor > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
}

.editor > summary::-webkit-details-marker {
  display: none;
}

.editor > summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--amber);
  border-bottom: 2px solid var(--amber);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.editor[open] > summary::after {
  transform: rotate(45deg);
}

.editor > summary:hover {
  background: rgba(154, 160, 242, 0.05);
}

.editor-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.editor-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.editor-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px 16px;
  border-top: 1px dashed var(--line);
}

/* Role checklists */
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr));
  gap: 2px 14px;
  max-height: 228px;
  padding: 8px 12px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  background: var(--field);
}

.check-grid label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 32px;
  cursor: pointer;
}

.check-grid input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--cape);
}

.check-grid span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Simple row lists (banners) */
.row-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.row-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 12px 0;
  border-top: 1px dashed var(--line);
}

.row-main {
  display: flex;
  flex: 1 1 220px;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.row-main small {
  color: var(--muted);
}

.token-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.token-list .hint {
  margin-right: 4px;
}

.token {
  padding: 3px 8px;
  border: 1px solid transparent;
  background: rgba(154, 160, 242, 0.1);
  color: var(--cape);
  font-size: 0.78rem;
  cursor: pointer;
}

.token:hover,
.token:focus-visible {
  border-color: var(--cape);
  background: var(--cape-soft);
}

/* Welcome editor with a live preview beside it */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.preview-card {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.embed-preview {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  overflow: hidden;
  border-radius: 4px;
  background: #2b2d31;
  color: #dbdee1;
}

.embed-bar {
  display: block;
  width: 4px;
  height: 100%;
}

.embed-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 14px;
}

.embed-text {
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.embed-image {
  display: grid;
  place-items: center;
  min-height: 110px;
  border: 1px dashed rgba(219, 222, 225, 0.25);
  color: #949ba4;
  font-size: 0.8rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-align: left;
  text-transform: uppercase;
}

.data-table td {
  padding: 10px;
  border-bottom: 1px dashed var(--line);
  vertical-align: middle;
}

.numeric {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-actions {
  text-align: right;
}

/* Error pages */
.error-panel {
  display: grid;
  gap: 12px;
  max-width: 640px;
}

body.fatal {
  display: grid;
  place-items: center;
  padding: 16px;
}

.fatal-card {
  max-width: 560px;
  padding: 28px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--danger);
}

.fatal-card h1 {
  margin: 8px 0 12px;
}

/* Responsive */
@media (max-width: 1000px) {
  .stat-grid,
  .feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .with-rail .shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .rail {
    position: static;
  }

  .rail-group {
    display: none;
  }

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

  .preview-card {
    position: static;
  }

  .rail-nav {
    flex-direction: row;
    overflow-x: auto;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }

  .rail-nav a {
    flex: none;
  }

  .rail-nav a[aria-current="page"]::before {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: -1px;
    width: auto;
    height: 3px;
  }
}

@media (max-width: 760px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-visual {
    display: none;
  }

  /* On phones she stands behind the text, so the art steps back further. */
  .splash {
    --splash-height: min(calc(100vh - 70px), 760px);
    left: auto;
    right: -18vw;
  }

  .is-home .splash {
    opacity: 0.3;
  }

  .card-grid,
  .destination {
    grid-template-columns: minmax(0, 1fr);
  }

  .user-name,
  .brand-text small {
    display: none;
  }
}

@media (max-width: 520px) {
  .stat-grid,
  .feature-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar {
    gap: 8px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .user-chip {
    display: none;
  }

  .brand-text strong {
    font-size: 1.1rem;
  }
}

/* A short window cannot hold the whole section list, so the rail scrolls with the page. */
@media (min-width: 1001px) and (max-height: 800px) {
  .rail {
    position: static;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
