
:root {
  --bg: #f4f7f8; --surface: #ffffff; --sunk: #eef2f4; --fg: #16232b; --muted: #5b6b75; --line: #d8e0e4;
  --accent: #0f7a73; --accent-fg: #ffffff; --accent-soft: #dcf0ee; --danger: #b42318; --danger-soft: #fdecea;
  --font: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f171c; --surface: #16222a; --sunk: #121c22; --fg: #e3ecf0; --muted: #94a6b0; --line: #2a3a44;
    --accent: #4cc3b8; --accent-fg: #0f171c; --accent-soft: #143633; --danger: #ff8a80; --danger-soft: #3a1d1b; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.9em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; height: 52px;
  padding: 0 max(16px, env(safe-area-inset-left)); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 15px; color: var(--fg); white-space: nowrap; }
.brand em { font-style: normal; color: var(--accent); }
.brand:hover { text-decoration: none; }
.search { flex: 1; max-width: 420px; }
.search input { width: 100%; font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--sunk); color: var(--fg); }
.spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.me img, .avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); }
.me form { margin: 0; }
.linkbtn { font: inherit; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; }
.linkbtn:hover { color: var(--fg); }

.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 52px); }
.side { border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.side h4 { margin: 14px 8px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.side a { display: flex; justify-content: space-between; gap: 8px; padding: 5px 8px; border-radius: 6px; color: var(--fg); }
.side a:hover { background: var(--sunk); text-decoration: none; }
.side a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side a span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.main { padding: 20px max(20px, env(safe-area-inset-right)) 40px 24px; min-width: 0; }
.main h1 { font-size: 20px; margin: 0 0 16px; display: flex; gap: 8px; align-items: baseline; }
.main h1 small { color: var(--muted); font-weight: 400; font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; color: var(--fg); transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.paper { height: 120px; overflow: hidden; border-radius: 6px; background: var(--sunk); border: 1px solid var(--line); padding: 12px 14px;
  font-size: 11px; line-height: 1.45; color: var(--muted); position: relative; }
.paper b { display: block; color: var(--fg); font-size: 12.5px; margin-bottom: 4px; }
.paper::after { content: ""; position: absolute; inset: auto 0 0 0; height: 36px; background: linear-gradient(transparent, var(--sunk)); }
.card h3 { margin: 0; font-size: 14px; line-height: 1.3; }
.meta { color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.chip.plain { background: var(--sunk); color: var(--muted); font-weight: 500; }

.empty { max-width: 640px; background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 24px; }
.empty h2 { margin: 0 0 6px; font-size: 17px; }
pre { background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; font: 12.5px/1.5 var(--mono); }

/* viewer */
.vbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px max(16px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); background: var(--surface); }
.crumbs { display: flex; gap: 6px; align-items: baseline; min-width: 0; flex: 1; }
.crumbs a { color: var(--muted); }
.crumbs strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
select, .btn { font: inherit; font-size: 13px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--fg); cursor: pointer; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn.danger { color: var(--danger); }
.view { display: grid; grid-template-columns: minmax(0, 1fr) 300px; height: calc(100vh - 52px - 51px); }
.view.wide { grid-template-columns: minmax(0, 1fr) 0; }
.view.wide .panel { display: none; }
.stage { padding: 14px; min-width: 0; }
.stage iframe { width: 100%; height: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.panel { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 18px; }
.panel h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.versions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.versions a { display: block; padding: 7px 9px; border-radius: 7px; border: 1px solid var(--line); color: var(--fg); }
.versions a:hover { border-color: var(--accent); text-decoration: none; }
.versions a.on { border-color: var(--accent); background: var(--accent-soft); }
.versions small { display: block; color: var(--muted); }
.soon { font-size: 12.5px; color: var(--muted); background: var(--sunk); border-radius: 8px; padding: 10px 12px; }

/* forms, tables */
.page { max-width: 860px; margin: 0 auto; padding: 28px max(16px, env(safe-area-inset-left)); }
.page h1 { font-size: 22px; margin: 0 0 6px; }
.lede { color: var(--muted); margin: 0 0 20px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); background: var(--sunk); }
tr.revoked td { color: var(--muted); text-decoration: line-through; }
tr.revoked td:last-child { text-decoration: none; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 16px 0 24px; }
.row input { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--fg); min-width: 220px; }
.notice { border-radius: 10px; padding: 14px 16px; margin: 0 0 20px; background: var(--accent-soft); }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.secret { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.secret code { flex: 1; background: var(--surface); padding: 8px 10px; border-radius: 6px; overflow-x: auto; white-space: nowrap; border: 1px solid var(--line); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login-card h1 { margin: 0; font-size: 20px; }
.login-card p { margin: 0; color: var(--muted); }
.gh { display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 8px; background: var(--fg); color: var(--bg); font-weight: 600; }
.gh:hover { text-decoration: none; opacity: .9; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; }
  .side h4 { width: 100%; margin: 6px 8px 0; }
  .view { grid-template-columns: 1fr; grid-template-rows: 70vh auto; height: auto; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .me span { display: none; }
}
@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card:hover { transform: none; } }
