:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1c2330;
  --muted: #5d6879;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --accent-soft: #e6ecfb;
  --ok: #1d7a46;
  --ok-soft: #e3f4ea;
  --warn: #9a6200;
  --warn-soft: #fdf1dc;
  --bad: #b42323;
  --bad-soft: #fbe7e7;
  --code-bg: #f3f4f7;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --surface: #1a1e26; --surface-2: #222833; --border: #313847; --text: #e4e8ef; --muted: #9aa4b5;
    --accent: #6d8ff0; --accent-text: #0d1220; --accent-soft: #23304f; --ok: #5cc98b; --ok-soft: #173525;
    --warn: #e7b04f; --warn-soft: #3a2d14; --bad: #f08585; --bad-soft: #3d1c1c; --code-bg: #20252f;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b; --surface: #1a1e26; --surface-2: #222833; --border: #313847; --text: #e4e8ef; --muted: #9aa4b5;
  --accent: #6d8ff0; --accent-text: #0d1220; --accent-soft: #23304f; --ok: #5cc98b; --ok-soft: #173525;
  --warn: #e7b04f; --warn-soft: #3a2d14; --bad: #f08585; --bad-soft: #3d1c1c; --code-bg: #20252f;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
code, pre, textarea.code { font-family: var(--mono); font-size: 13px; }
pre { background: var(--code-bg); padding: 10px 12px; border-radius: 6px; overflow: auto; margin: .5em 0; }
:not(pre) > code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* Buttons & inputs */
button, .btn {
  font: inherit; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: default; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover { filter: brightness(1.07); }
button.danger { color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; }
button.sm { padding: 4px 10px; font-size: 13px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  font: inherit; font-size: 14px; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
textarea.code { tab-size: 4; white-space: pre; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
label.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; color: var(--text); font-size: 14px; margin: 0; }
.field { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Layout */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border); min-height: 54px;
}
.topbar .brand { font-weight: 700; letter-spacing: -.01em; }
.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.notice { padding: 10px 14px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--accent-soft); color: var(--accent); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.markdown { overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown p, .markdown ul, .markdown ol { margin: .5em 0; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 6px; box-shadow: var(--shadow); z-index: 1000; font-size: 14px; max-width: calc(100% - 32px);
}

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 22px; max-width: 460px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(10, 14, 20, .5); }

.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.center-screen .card { width: 100%; max-width: 460px; }
