:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --text: #172033;
  --muted: #5b6578;
  --border: #dde3ec;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --accent-soft: #e6eefe;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --topbar: #0f1a2e;
  --topbar-text: #e8edf7;
  --code-bg: #0f1a2e;
  --code-text: #d7e3f7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #131c2e;
    --surface-2: #1a2438;
    --text: #e6ebf5;
    --muted: #97a3b8;
    --border: #26324a;
    --accent: #5b8cff;
    --accent-text: #0b1220;
    --accent-soft: #1c2a4a;
    --danger: #ff8a80;
    --danger-soft: #3a1d1d;
    --topbar: #070c17;
    --code-bg: #070c17;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}

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

.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px;
}
main.container { flex: 1; padding-top: 24px; padding-bottom: 32px; }

.topbar { background: var(--topbar); color: var(--topbar-text); }
.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  font-size: 17px;
}
.brand small { color: #8fa3c7; font-weight: 500; margin-left: 4px; }
.brand__mark {
  width: 22px;
  height: 22px;
  border: 3px solid #5b8cff;
  border-radius: 50%;
  position: relative;
}
.brand__mark::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 3px;
  background: #5b8cff;
  border-radius: 2px;
  right: -9px;
  bottom: -5px;
  transform: rotate(45deg);
}

.tabs { display: flex; gap: 4px; }
.tabs__item {
  color: #b9c6de;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 500;
}
.tabs__item:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.tabs__item.is-active { color: #fff; background: rgba(91, 140, 255, .25); }

.page-title { margin: 0 0 16px; font-size: 22px; font-weight: 600; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card--center { text-align: center; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field--grow { flex: 1 1 220px; margin-bottom: 0; }
label, .label { font-size: 13px; font-weight: 600; color: var(--muted); }

input, select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
#router { max-width: 420px; }

.row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented__item { cursor: pointer; }
.segmented__item input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented__item span {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
}
.segmented__item input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.segmented__item input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn--small { height: 28px; padding: 0 10px; font-size: 13px; }

.result { margin-top: 20px; }
.message {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.message--error { border-color: transparent; background: var(--danger-soft); color: var(--danger); font-weight: 500; }
.message--wait { display: flex; align-items: center; gap: 12px; color: var(--muted); }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.output { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); }
.output__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.output pre {
  margin: 0;
  padding: 16px;
  background: var(--code-bg);
  color: var(--code-text);
  font: 13px/1.45 var(--mono);
  overflow-x: auto;
  white-space: pre;
}

.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 20px;
  max-width: 360px;
  width: calc(100% - 32px);
}
.dialog::backdrop { background: rgba(10, 16, 28, .55); }
.dialog h2 { margin: 0 0 6px; font-size: 17px; }
.captcha { min-height: 78px; margin: 16px 0; display: flex; justify-content: center; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }
.muted { color: var(--muted); margin: 0; }

.notfound { font-size: 64px; margin: 8px 0; color: var(--accent); }

.footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  padding: 14px 0;
}

@media (max-width: 560px) {
  .page-title { font-size: 19px; }
  .card { padding: 16px; }
  .row .btn { width: 100%; }
  #router { max-width: none; }
}
