/* The base stylesheet: the reset, the tokens, the font stack, the form controls,
   the admin tables. Every page loads it, then glass.css (the glass material) and
   then whichever page stylesheet applies — doc.css, landing.css, download.css.

   Kept hand-written and dependency-free so the server has no build step and works
   with no network. */

:root {
  --bg: #f6f7f9;
  --fg: #1c2024;
  --dim: #6b7280;
  --line: #dfe3e8;
  --card: #ffffff;
  --accent: #2563eb;
  /* Text drawn *on* --accent. It has to be a token because it flips with the mode:
     white on the dark-mode blue #6ea8fe is 2.4:1, which is why the 下载 buttons used
     to be unreadable in dark mode. Same pair as landing.css uses. */
  --accent-fg: #ffffff;
  --danger: #b91c1c;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  /* The content column, and its minimum inset from the window edge. `main` is centred
     on it and the header bar above is inset by the same amount, so the two rules have
     to agree — hence tokens rather than the same numbers written twice. */
  --col: 1200px;
  --gutter: 24px;
}

/* Written twice, like glass.css's dark palette and for the same reason: a media
   query cannot be in a selector list, and the theme button on `/` writes an
   attribute rather than a media query. Keep the two bodies identical —
   landing.test.ts fetches this file and compares them. The `:not(...)` is what
   lets an explicit light choice hold on a machine set to dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181d;
    --fg: #e6e8eb;
    --dim: #9aa1ab;
    --line: #2c3038;
    --card: #1e2127;
    --accent: #6ea8fe;
    --accent-fg: #0d1117;
    --danger: #f87171;
  }
}

/* The explicit choice from the theme button (html.ts). These are app.css's tokens
   and glass.css has its own half of the same palette — the button flips both,
   which is only true because both files carry this rule. */
:root[data-theme="dark"] {
  --bg: #16181d;
  --fg: #e6e8eb;
  --dim: #9aa1ab;
  --line: #2c3038;
  --card: #1e2127;
  --accent: #6ea8fe;
  --accent-fg: #0d1117;
  --danger: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

body.center {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

code, .mono, .num { font-family: var(--mono); font-size: 12px; }
code { background: color-mix(in srgb, var(--fg) 8%, transparent); padding: 1px 5px; border-radius: 4px; }

/* ---------- login ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px 30px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card h1 { margin: 0; font-size: 17px; }
.card .sub { margin: 0; color: var(--dim); font-size: 13px; }

.card label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--dim);
}

input, textarea {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
}

input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Multi-line fields are the one place `resize: both` would break a layout that
   is a fixed column, so the handle is off and a height is given instead. */
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }

button {
  font: inherit;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }

button.ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--line);
  padding: 5px 10px;
}

button.danger { color: var(--danger); }

.err {
  margin: 0;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
}

/* ---------- release table ---------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  /* The bar stays full-bleed — its bottom border should reach both window edges — but
     its contents move in to sit over the centred column below. `100%` is the body
     width, not 100vw, so a scrollbar can't skew the maths. */
  padding: 16px max(var(--gutter), calc((100% - var(--col)) / 2 + var(--gutter)));
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

header h1 { margin: 0; font-size: 16px; }

.who { display: flex; align-items: center; gap: 12px; color: var(--dim); }

/* `max-width` alone only pulls the right edge in, so every page sat against the left
   of the window on a wide screen; `margin: 0 auto` is what actually centres it. */
main { padding: var(--gutter); max-width: var(--col); margin: 0 auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 12px;
  font-weight: 600;
  color: var(--dim);
  background: color-mix(in srgb, var(--fg) 4%, transparent);
}

tbody tr:last-child td { border-bottom: 0; }

td.ver { font-weight: 600; font-family: var(--mono); }
td.num { text-align: right; }
td.notes { white-space: pre-wrap; max-width: 320px; }

a { color: var(--accent); }

td form { display: inline; }

.empty, .flash, .foot {
  color: var(--dim);
  font-size: 13px;
}

.empty { padding: 20px 0; }
.flash { margin: 0 0 14px; }
.foot { margin-top: 18px; }

.card .alt { margin: 0; font-size: 12px; text-align: center; color: var(--dim); }

/* ---------- narrow column ---------- */

/* A single column of prose or a form reads badly at the admin table's 1200px.
   Narrowing `--col` rather than `main` is deliberate: the header reads the same
   token, so the bar's contents narrow with the content instead of drifting out of
   line. Used by the market entry form (`marketFormPage`). */
body:has(main.narrow) { --col: 720px; }

/* `.card .sub` (login) is more specific and keeps its own sizing. */
.sub { color: var(--dim); font-size: 13px; margin: 0 0 16px; }

/* ---------- sync keys ---------- */

.newkey { display: flex; gap: 8px; margin: 0 0 14px; }
.newkey input { width: 280px; }

.mini-btn { padding: 3px 8px; font-size: 12px; }
.ghost-link { color: var(--accent); margin-right: 8px; font-size: 13px; }

/* Selecting the cell should grab the whole key, since the clipboard API is
   unavailable on a plain-http LAN address and the copy path may have to fall
   back to a manual Ctrl+C. */
.keycell { white-space: nowrap; }
.keyval { user-select: all; margin-right: 8px; }

/* ---------- extension market ---------- */

.newrow { margin: 0 0 14px; }

.newbtn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  text-decoration: none;
}

.newbtn:hover { filter: brightness(1.08); }

/* One field per row, two where the pair is naturally short (命令 + 端口). The
   form is a fixed column, so nothing here depends on the viewport. */
.mform { display: flex; flex-direction: column; gap: 16px; }

.mform label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--dim);
}

.mform-pair { display: flex; gap: 14px; }
.mform-pair label { flex: 1 1 0; min-width: 0; }

/* The one field that is a checkbox: label and box on one line, box first. */
.mform label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--fg);
}
.mform label.check input { flex: 0 0 auto; }

.mform .hint { font-size: 12px; color: var(--dim); line-height: 1.5; }
.mform .hint code { font-size: 11px; }

/* The divider between a form's Chinese fields and its English ones. It is a
   heading and not a fieldset because the fields are siblings either way and the
   form is a column — all this has to do is draw the line. */
.mform-sec {
  margin: 12px 0 -4px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}
/* The sentence under that divider: not a hint on one field, so it cannot use
   .hint's place inside a label. */
.mform-note { margin: -8px 0 0; font-size: 12px; color: var(--dim); line-height: 1.6; }

.mform-actions { display: flex; align-items: center; gap: 14px; }

.mform-del { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 16px; }


td.tight { white-space: nowrap; }
.dim { color: var(--dim); }

.dot-on {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  margin-right: 5px;
  vertical-align: 1px;
}

/* ---------- statistics ---------- */

/* Four windows side by side, wrapping to two rows before they get too narrow to
   read. Each is a label and three label/number pairs; `b` is the number and is
   mono so the digits line up between windows, which is the only reason these are
   comparable at a glance. */
.tiles { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 22px; }

.tile {
  flex: 1 1 170px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 12px 14px;
}

.tile h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--dim);
}

.tile p {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 0;
}

.tile b { font-family: var(--mono); font-size: 17px; font-weight: 600; }
.tile span { font-size: 12px; color: var(--dim); }

/* A section heading inside the admin column. Not `h2` alone: landing.css styles
   `.sec h2` for the glass pages, and this page loads neither. */
.sh {
  margin: 22px 0 10px;
  font-size: 14px;
  font-weight: 600;
}
