/* Operator console. Tokens first; dark follows the OS. No webfonts: the CSP allows 'self' only. */
:root {
  --bg: #f3f5f9; --panel: #ffffff; --raise: #eaeef5; --fg: #121826; --muted: #5d6882;
  --line: #d5dbe8; --accent: #0a6fd1; --accent-ink: #ffffff; --accent-soft: rgba(10, 111, 209, .09);
  --danger: #c22d3a; --ok: #12804a; --warn: #9a6200;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c111b; --panel: #121927; --raise: #1a2336; --fg: #e7ecf6; --muted: #8d99b4;
    --line: #243049; --accent: #54b6ff; --accent-ink: #06182b; --accent-soft: rgba(84, 182, 255, .10);
    --danger: #ff7a85; --ok: #55d69a; --warn: #f0b34a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c111b; --panel: #121927; --raise: #1a2336; --fg: #e7ecf6; --muted: #8d99b4;
  --line: #243049; --accent: #54b6ff; --accent-ink: #06182b; --accent-soft: rgba(84, 182, 255, .10);
  --danger: #ff7a85; --ok: #55d69a; --warn: #f0b34a;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
html { color-scheme: light dark; }
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 3px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--raise); padding: 1px 6px; border-radius: 5px; }

/* chrome */
header.top { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; padding: 0 28px;
  min-height: 56px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5; }
header.top::before { content: "sunfun"; font-weight: 750; letter-spacing: -.02em; font-size: 17px;
  padding-right: 22px; border-right: 1px solid var(--line); margin-right: -2px; line-height: 56px; }
header.top nav { display: flex; flex-wrap: wrap; gap: 0 4px; flex: 1; }
header.top nav a { color: var(--muted); text-decoration: none; padding: 17px 12px 15px;
  border-bottom: 2px solid transparent; font-weight: 550; }
header.top nav a:hover { color: var(--fg); }
header.top nav a:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent);
  outline-offset: 2px; border-radius: 6px; }
header.top .who { color: var(--muted); font-size: 13px; }
header.top [data-signout] { color: var(--muted); font-size: 13px; }
main { max-width: 1120px; margin: 0 auto; padding: 36px 28px 80px; }
h1 { font-size: 1.9rem; letter-spacing: -.03em; line-height: 1.15; margin: 0 0 22px; font-weight: 750; }
h2 { font-size: 1.05rem; letter-spacing: -.01em; margin: 0 0 4px; font-weight: 680; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 13.5px; }
.ok { color: var(--ok); } .err { color: var(--danger); }

/* cards */
section.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 22px 24px 24px; margin: 0 0 18px; }
section.card > h2 + .muted { margin-bottom: 16px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

/* the memorable part: every field has a margin note that lights up while the field has focus */
.field { display: grid; grid-template-columns: minmax(0, 27rem) minmax(0, 1fr); column-gap: 32px;
  align-items: start; margin: 0 0 14px; }
.field > label { grid-column: 1; grid-row: 1; margin: 0 0 5px; font-weight: 620; font-size: 13.5px;
  transition: color .15s; }
.field > input, .field > select, .field > textarea { grid-column: 1; grid-row: 2; }
.field:focus-within > label { color: var(--accent); }
.field { position: relative; }
.guide { position: absolute; top: 0; left: calc(27rem + 32px); right: 0; z-index: 1;
  padding: 2px 0 2px 20px; border-left: 2px solid var(--accent); font-size: 13px; line-height: 1.5;
  color: var(--muted); opacity: 0; transform: translateX(-8px); pointer-events: none;
  transition: opacity .18s ease, transform .18s ease; }
.guide::before { content: ""; position: absolute; left: -32px; top: 41px; width: 30px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent)); }
.guide b { color: var(--fg); font-weight: 620; display: block; margin-bottom: 3px; font-size: 13.5px; }
.guide ol, .guide ul { margin: 4px 0 0; padding-left: 18px; }
.guide li { margin: 2px 0; }
.field:focus-within .guide { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .guide, .field > label { transition: none; } }
@media (max-width: 820px) {
  .field { grid-template-columns: minmax(0, 1fr); }
  .guide { position: static; grid-column: 1; grid-row: 3; display: none; margin-top: 8px; padding: 8px 12px;
    background: var(--accent-soft); border-radius: 8px; border-left-width: 3px; transform: none; }
  .guide::before { display: none; }
  .field:focus-within .guide { display: block; }
}

/* inputs */
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent); }
input[type=password] { font-family: var(--mono); letter-spacing: .08em; }
textarea { min-height: 11em; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; resize: vertical; }
input:disabled, select:disabled, textarea[readonly] { opacity: .65; }

/* buttons */
button, .btn { font: inherit; font-weight: 620; padding: 9px 18px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer;
  margin-top: 10px; transition: filter .15s, transform .05s; }
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.secondary { background: transparent; color: var(--accent); margin-top: 0; padding: 5px 12px; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.secondary.danger { background: transparent; color: var(--danger); }

/* tables */
.scroll { overflow-x: auto; margin: 0 0 22px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 11px 16px;
  border-bottom: 1px solid var(--line); background: var(--raise); }
td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: top;
  overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--accent-soft); }
td a { font-weight: 620; text-decoration: none; }

.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line); background: var(--raise); }
#msg { min-height: 0; margin: 0 0 14px; }
#msg:empty { display: none; }
#msg p { margin: 0; padding: 11px 16px; border-radius: 10px; border: 1px solid var(--line);
  border-left: 4px solid var(--accent); background: var(--panel); }
#msg p.err { border-left-color: var(--danger); }
#msg p.ok { border-left-color: var(--ok); }
details summary { cursor: pointer; }
.login { max-width: 420px; margin: 12vh auto 0; padding: 0 20px; text-align: center; }
.login h1 { font-size: 1.5rem; }
@media (max-width: 600px) { main { padding: 22px 14px 60px; } header.top { padding: 0 14px; } section.card { padding: 18px 16px; } }

/* theme switch: System / Light / Dark (links, not buttons: it changes nothing on the server) */
.theme { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.theme a { padding: 3px 10px; color: var(--muted); font-size: 12.5px; font-weight: 600;
  text-decoration: none; }
.theme a + a { border-left: 1px solid var(--line); }
.theme a:hover { color: var(--fg); }
.theme a[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.login .theme { margin-bottom: 18px; }

/* chat picker */
form.inline { display: inline-block; margin: 2px 6px 2px 0; }
.badge.ok { border-color: var(--ok); }
.badge.warn { border-color: var(--warn); color: var(--warn); }
.setup { border-left: 4px solid var(--accent); }

/* anchors that look like the primary button */
a.btn { display: inline-block; text-decoration: none; margin-top: 0; line-height: 1.4; }
a.btn:hover { filter: brightness(1.08); }
a.btn.secondary { background: transparent; color: var(--accent); padding: 8px 16px; }
a.btn[aria-disabled="true"] { background: var(--raise); border-color: var(--line); color: var(--muted);
  cursor: not-allowed; filter: none; }

/* bot page tabs: plain links, the current one is marked with aria-current="page" */
nav.tabs { margin: 0 0 22px; border-bottom: 1px solid var(--line); overflow-x: auto;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
nav.tabs ul { display: flex; gap: 2px; margin: 0; padding: 0; list-style: none; min-width: max-content; }
nav.tabs a { display: block; padding: 10px 14px; color: var(--muted); text-decoration: none;
  font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 6px 6px 0 0;
  transition: color .15s, background-color .15s; }
nav.tabs a:hover { color: var(--fg); background: var(--accent-soft); }
nav.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
nav.tabs a:focus-visible { outline-offset: -2px; }

/* key facts */
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 22px; margin: 12px 0 0; }
dl.facts dt { color: var(--muted); font-weight: 600; font-size: 13.5px; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { dl.facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
  dl.facts dd { margin-bottom: 10px; } }
@media (prefers-reduced-motion: reduce) { nav.tabs a { transition: none; } }

/* setup wizard */
nav.stepper { margin: 0 0 24px; }
nav.stepper ol { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0;
  padding: 0; list-style: none; counter-reset: none; }
.step-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel); color: var(--muted); text-decoration: none;
  font-weight: 600; min-width: 0; transition: border-color .15s, background-color .15s; }
a.step-link:hover { border-color: var(--accent); color: var(--fg); }
.step-n { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); font-size: 13px; font-weight: 700; color: var(--muted); }
.step-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step.done .step-n { background: var(--ok); border-color: var(--ok); color: var(--panel); }
.step.current .step-n { border-color: var(--accent); color: var(--accent); }
.step.todo .step-link { opacity: .65; }
.step.viewing .step-link { border-color: var(--accent); background: var(--accent-soft); color: var(--fg);
  box-shadow: 0 0 0 1px var(--accent); }
@media (max-width: 700px) {
  nav.stepper ol { grid-template-columns: repeat(4, max-content); overflow-x: auto; padding-bottom: 4px; }
  .step-t { white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { .step-link { transition: none; } }

section.wiz h3 { font-size: .95rem; margin: 20px 0 6px; }
.wiz-big { font-size: 1.05rem; }
ol.wiz-steps { padding-left: 20px; }
ol.wiz-steps li { margin: 0 0 12px; }
ol.wiz-steps .btn { margin: 0 8px 0 6px; }
.wiz-link { grid-template-columns: minmax(0, 36rem); margin-top: 6px; }
.wiz-nav { margin: 18px 0 0; }
details.wiz-help, details.advanced { margin: 14px 0 0; }
details.advanced { margin-top: 18px; }
details summary { font-weight: 600; }
details > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
ul.plain { list-style: none; padding: 0; margin: 0 0 12px; }
ul.plain li { margin: 0 0 8px; }

/* radio cards */
fieldset.choices { margin: 0 0 20px; }
fieldset.choices legend { font-weight: 650; padding: 0; margin: 0 0 2px; }
fieldset.choices > .muted { margin-bottom: 8px; }
label.choice { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; margin: 0 0 8px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); cursor: pointer;
  transition: border-color .15s, background-color .15s; max-width: 40rem; }
label.choice:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
label.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
label.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
label.choice input { margin-top: 4px; accent-color: var(--accent); flex: none; }
.choice-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { label.choice { transition: none; } }
