:root {
  --bg:    #0b0c0e;
  --bg-1:  #101214;
  --bg-2:  #15181c;
  --bg-3:  #1c2026;
  --line:  #22262c;
  --line-2:#2f343c;
  --fg:    #ededea;
  --fg-2:  #a9adb0;
  --fg-3:  #8c9096;
  --fg-4:  #6b7077;
  --fg-dim:  var(--fg-2);
  --fg-mute: var(--fg-4);

  --acc-green:   oklch(0.82 0.17 148);
  --acc-amber:   oklch(0.82 0.17  72);
  --acc-cyan:    oklch(0.82 0.17 205);
  --acc-magenta: oklch(0.82 0.17 335);

  --acc: var(--acc-green);
  --acc-dim:    color-mix(in oklab, var(--acc) 22%, var(--bg));
  --acc-dimmer: color-mix(in oklab, var(--acc) 10%, var(--bg));

  --ok:   var(--acc);
  --load: oklch(0.82 0.17 72);
  --err:  oklch(0.72 0.19 24);
  --pend: var(--fg-4);

  --row-py: 0.7rem;
  --row-px: 1rem;
  --gap:    1rem;
  --fs:     15px;
  --fs-s:   13px;
  --fs-xs:  12px;

  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas,
          'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', monospace;
  --sans: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

[data-accent="amber"]   { --acc: var(--acc-amber); }
[data-accent="cyan"]    { --acc: var(--acc-cyan); }
[data-accent="magenta"] { --acc: var(--acc-magenta); }

* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--fg); }
body {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--fs);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--acc-dim); color: var(--fg); }
a { color: var(--acc); text-decoration: none; }
a:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ── TOP BAR ── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 0 clamp(1rem, 3vw, 2rem);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  height: 54px;
}
.tb-brand {
  display: flex; align-items: center; gap: 0.7rem;
  color: var(--fg); text-decoration: none;
  letter-spacing: 0.02em;
}
.tb-brand:hover { text-decoration: none; }
.tb-brand img { height: 22px; image-rendering: auto; filter: saturate(0.9); }
.tb-brand .wordmark { font-weight: 600; letter-spacing: 0.01em; }
.tb-brand .dim { color: var(--fg-4); }

.tb-nav {
  display: flex; gap: 0.1rem; align-items: center;
  font-size: var(--fs-s);
}
.tb-nav a {
  padding: 0.45rem 0.7rem;
  color: var(--fg-3);
  letter-spacing: 0.04em;
  text-transform: lowercase;
  border-radius: 2px;
  text-decoration: none;
  font-family: var(--sans);
}
.tb-nav a:hover { color: var(--fg); background: var(--bg-2); text-decoration: none; }
.tb-nav a.active { color: var(--acc); }
.tb-star {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: 1px solid var(--line-2);
  padding: 0.35rem 0.7rem;
  margin-left: 0.5rem;
  color: var(--fg-2);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.tb-star:hover { border-color: var(--acc); color: var(--acc); text-decoration: none; }
.tb-star .star { color: var(--acc-amber); }

/* ── PAGE ── */
.page {
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 3vw, 2rem) 4rem;
}

/* ── HEADER ── */
.header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.5rem 2rem;
  padding: 1rem 0 1.25rem;
}
.header h1 { white-space: nowrap; }
.header .mark {
  display: flex; align-items: center; gap: 0.75rem;
}
.header .mark img { height: 46px; }
.header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.header .h-meta {
  font-size: var(--fs-xs);
  color: var(--fg-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.header .h-meta .cjk {
  text-transform: none;
  letter-spacing: 0.05em; color: var(--fg-3); font-size: var(--fs-s);
}
.header .subtitle {
  color: var(--fg-3); font-size: var(--fs-s);
  justify-self: end; text-align: right; max-width: 32ch;
}
.header .subtitle .prompt { color: var(--acc); }

/* ── CARD (base layout — used by multiple pages) ── */
.card {
  position: relative;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 4px;
  padding: 0.9rem 1rem 0.9rem 1.05rem;
  display: flex; flex-direction: column; gap: 0.55rem;
  transition: border-color .15s; min-height: 132px;
}
.card::before {
  content: ""; position: absolute;
  left: -1px; top: -1px; bottom: -1px; width: 3px;
  background: var(--line-2); border-radius: 3px 0 0 3px;
}
.card:hover { border-color: var(--line-2); }

/* ── FOOTER ── */
.footer {
  margin-top: 2.5rem; padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  color: var(--fg-4); font-size: var(--fs-xs);
  line-height: 1.7;
}
.footer p { margin: 0 0 0.3rem; }
.footer a { color: var(--fg-dim); border-bottom: 1px dotted var(--fg-mute); }
.footer a:hover { color: var(--acc); border-bottom-color: var(--acc); text-decoration: none; }

/* ── DIALOG ── */
dialog {
  background: var(--bg-1); color: var(--fg);
  border: 1px solid var(--line-2);
  padding: 0; max-width: 640px; width: calc(100vw - 2rem);
  font-family: var(--mono);
}
dialog::backdrop { background: rgba(0,0,0,0.72); }
.dlg-hd {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  font-size: var(--fs-s); color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.dlg-hd .title { color: var(--fg); text-transform: none; letter-spacing: 0.02em; }
.dlg-bd {
  padding: 1rem; max-height: 60vh; overflow: auto;
  font-size: var(--fs-s); color: var(--fg-2); line-height: 1.7; word-break: break-all;
}
.dlg-ft {
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 0.5rem;
  background: var(--bg-1);
}

/* focus */
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* Alpine cloak */
[x-cloak] { display: none !important; }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .topbar {
    height: auto; padding: 0.5rem 0.75rem;
    grid-template-columns: 1fr; gap: 0.4rem;
  }
  .tb-nav { flex-wrap: wrap; justify-content: flex-start; gap: 0.1rem; font-size: var(--fs-xs); }
  .tb-nav a { padding: 0.35rem 0.5rem; }
  .tb-star { margin-left: 0; padding: 0.3rem 0.55rem; }

  .header {
    grid-template-columns: 1fr;
    gap: 1rem; padding: 0.5rem 0 1rem;
  }
  .header h1 { white-space: normal; font-size: 1.1rem; line-height: 1.2; }
  .header .mark img { height: 36px; }
  .header .subtitle { justify-self: start; text-align: left; font-size: var(--fs-xs); max-width: none; }
}
