:root {
  --primary: #1f6feb;
  --bg: #f5f6f8; --panel: #ffffff; --text: #1b1f24; --muted: #5b6573; --line: #d8dde4;
  --ok: #1a7f37; --okbg: #dafbe1; --warn: #9a6700; --warnbg: #fff8c5; --err: #cf222e; --errbg: #ffebe9;
  --code: #eef1f5; --shadow: 0 1px 2px rgba(0, 0, 0, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --panel: #161b22; --text: #e6edf3; --muted: #9aa5b1; --line: #30363d;
    --ok: #3fb950; --okbg: #12261a; --warn: #d29922; --warnbg: #2b2209; --err: #ff7b72; --errbg: #2d1315;
    --code: #21262d; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg); color: var(--text);
}
h1 { font-size: 1.4rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.25rem; margin: 0 0 .5rem; }
h3 { font-size: 1.05rem; margin: 0 0 .5rem; }
a { color: var(--primary); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .92em; }
code { background: var(--code); padding: .05em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.offscreen { position: fixed; left: -9999px; top: 0; }
.empty { color: var(--muted); padding: .75rem 0; }

/* layout */
.top { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between;
  padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; }
.chips, .who, .row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 1rem; }
.chip { background: var(--code); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .6rem; font-size: .85rem; }
.chip.warn { background: var(--warnbg); color: var(--warn); border-color: var(--warn); }
.layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 1rem; padding: 1rem; max-width: 1400px; margin: 0 auto; }
.side { display: flex; flex-direction: column; gap: .15rem; align-self: start; position: sticky; top: 1rem; }
.side a { padding: .5rem .75rem; border-radius: 6px; text-decoration: none; color: var(--text); }
.side a:hover { background: var(--code); }
.side a.active { background: var(--primary); color: #fff; }
.content > * + * { margin-top: 1rem; }
.center { min-height: 70vh; display: grid; place-items: center; padding: 1rem; }
.narrow { width: min(420px, 100%); text-align: center; }
.logo { max-height: 56px; max-width: 200px; }
.logo.sm { max-height: 28px; }
#banners { padding: 0 1rem; max-width: 1400px; margin: .5rem auto 0; display: grid; gap: .5rem; }

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; box-shadow: var(--shadow); }
.card.result { border-color: var(--primary); }
.alert { padding: .6rem .9rem; border-radius: 6px; border: 1px solid; margin: .25rem 0; }
.alert.err { background: var(--errbg); color: var(--err); border-color: var(--err); }
.alert.warn { background: var(--warnbg); color: var(--warn); border-color: var(--warn); }
.alert.ok { background: var(--okbg); color: var(--ok); border-color: var(--ok); }
.alert.info { background: var(--code); border-color: var(--line); }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; background: var(--code); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--okbg); color: var(--ok); border-color: var(--ok); }
.badge.warn { background: var(--warnbg); color: var(--warn); border-color: var(--warn); }
.btn { font: inherit; cursor: pointer; padding: .45rem .9rem; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); text-decoration: none; display: inline-block; }
.btn:hover:not(:disabled) { border-color: var(--primary); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.small { padding: .2rem .6rem; font-size: .85rem; }
.btn.big { padding: .7rem 1.4rem; font-size: 1rem; }
.field { display: grid; gap: .25rem; margin: .5rem 0; text-align: left; }
.field > span { font-weight: 600; font-size: .9rem; }
.field small { color: var(--muted); }
.check { display: flex; gap: .4rem; align-items: center; margin: .5rem 0; }
input, select, textarea { font: inherit; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); width: 100%; min-width: 0; }
input[type=checkbox] { width: auto; }
.row > input, .row > select { width: auto; flex: 1 1 14rem; }
input.search { max-width: 22rem; margin: .25rem 0 .5rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: .5rem 0 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.form-err { color: var(--err); min-height: 1.2em; font-size: .9rem; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
th { font-size: .8rem; color: var(--muted); white-space: nowrap; }
td.actions { white-space: nowrap; }

/* dialog + toasts */
dialog.modal { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); width: min(440px, calc(100vw - 2rem)); padding: 1.25rem; }
dialog.modal::backdrop { background: rgba(0, 0, 0, .5); }
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 20; max-width: min(420px, calc(100vw - 2rem)); }
.toast { display: flex; gap: .5rem; justify-content: space-between; padding: .6rem .9rem; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 4px 12px rgba(0, 0, 0, .2); }
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--err); }
.toast .x { background: none; border: 0; color: inherit; cursor: pointer; font-size: 1.1rem; line-height: 1; }

/* responsive */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; padding: .75rem; }
  .side { flex-direction: row; overflow-x: auto; position: static; padding-bottom: .25rem; }
  .side a { white-space: nowrap; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; left: -9999px; }
  tr { border: 1px solid var(--line); border-radius: 6px; margin-bottom: .6rem; padding: .25rem .5rem; }
  td { border: 0; display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 0; }
  td::before { content: attr(data-label); color: var(--muted); flex: 0 0 auto; }
  td.actions::before { content: none; }
}

/* portal */
.landing { max-width: 760px; margin: 0 auto; padding: 1.5rem 1rem; display: grid; gap: 1rem; }
.hero { text-align: center; }
.portal { max-width: 760px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.info-card h2 { font-size: 1.1rem; }
.info-card summary { cursor: pointer; font-weight: 600; }
ul.plain { margin: 0; padding-left: 1.2rem; }
ol.steps { margin: .5rem 0 0; padding-left: 1.4rem; display: grid; gap: .35rem; }
.org { font-weight: 600; }
.code-big { font-size: 1.8rem; letter-spacing: .05em; word-break: break-all; user-select: all; margin: .25rem 0; }
#help-out { margin-top: 1rem; }
