:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e3e6ef;
  --text: #121826;
  --muted: #5f6b82;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --good: #0f9d58;
  --good-soft: #e5f6ed;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --bad: #c62828;
  --bad-soft: #fdecec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #151b24;
    --surface-2: #1c2430;
    --border: #273141;
    --text: #e8edf5;
    --muted: #93a0b5;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #1f2347;
    --good: #4ade80;
    --good-soft: #12301f;
    --warn: #fbbf24;
    --warn-soft: #33270c;
    --bad: #f87171;
    --bad-soft: #3a1717;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); margin: 4px 0 0; }
[hidden] { display: none !important; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 16px; }
.brand:hover { text-decoration: none; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.logo svg { fill: #fff; stroke: none; width: 18px; height: 18px; }
.tag { font-size: 12.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px; }

/* Hero */
.hero { text-align: center; padding: 56px 0 28px; }
.hero h1 { font-size: clamp(26px, 4.4vw, 40px); font-weight: 800; }
.lead { color: var(--muted); max-width: 620px; margin: 12px auto 28px; font-size: 16.5px; }

.search { display: flex; gap: 10px; max-width: 680px; margin: 0 auto; }
.search-field {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px;
  padding: 0 14px; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s;
}
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-field .ico { color: var(--muted); width: 20px; height: 20px; }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; height: 52px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; height: 55px; padding: 0 26px; font-size: 16px; border-radius: 12px; box-shadow: var(--shadow); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; }
.btn.sm { height: 36px; padding: 0 12px; font-size: 13.5px; }

.recent { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 16px auto 0; max-width: 680px; font-size: 13px; color: var(--muted); align-items: center; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* Options */
.options { max-width: 680px; margin: 18px auto 0; text-align: left; }
.options summary {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted);
  font-weight: 600; font-size: 14px; list-style: none; padding: 6px 10px; border-radius: 8px; user-select: none;
}
.options summary::-webkit-details-marker { display: none; }
.options summary:hover { color: var(--text); background: var(--surface-2); }
.opt-summary { font-weight: 400; font-size: 13px; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 600; }
.field.wide { grid-column: 1 / -1; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.field select, .field input[type=password], .field input[type=text] {
  height: 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 400; padding: 0 12px; min-width: 0;
}
.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; font-family: ui-monospace, Consolas, monospace !important; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* Alert */
.alert { max-width: 760px; margin: 0 auto 24px; padding: 14px 18px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent); font-weight: 500; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Progress */
.progress { padding: 24px; max-width: 760px; margin: 0 auto 32px; }
.progress-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.progress h2 { font-size: 19px; }
.steps { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14.5px; }
.steps li i { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); flex: none; position: relative; }
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.active i { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
.steps li.done { color: var(--text); }
.steps li.done i { background: var(--good); border-color: var(--good); }
.steps li.done i::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.steps li.skipped { opacity: .55; }
.steps li.skipped i { border-style: dashed; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #a78bfa); border-radius: 99px; transition: width .35s ease; }
.live { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 18px; }
.live div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.live b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.live span { font-size: 12.5px; color: var(--muted); }

/* Results */
#results { margin-bottom: 48px; }
.results-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.results-head h2 { font-size: 22px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; color: var(--muted); }
.filter input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 13.5px; width: 160px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile span { font-size: 13px; color: var(--muted); }

.note { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 12px 16px; font-size: 14px; margin-bottom: 16px; }
.note a { color: inherit; text-decoration: underline; font-weight: 600; }

.table-card { overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.c-rank { width: 48px; text-align: center !important; }
.c-num { width: 80px; text-align: right !important; font-variant-numeric: tabular-nums; }
.c-score { width: 190px; }
.c-crux { width: 130px; }
.rank { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
tr:nth-child(-n+3) .rank { background: var(--accent-soft); color: var(--accent); }
.page { min-width: 0; }
.page-title { font-weight: 600; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px; }
.page-url { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-url svg { width: 12px; height: 12px; }
.score { display: flex; align-items: center; gap: 10px; }
.score-bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 60px; }
.score-bar div { height: 100%; background: var(--accent); border-radius: 99px; }
.score b { font-variant-numeric: tabular-nums; width: 30px; text-align: right; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.yes { background: var(--good-soft); color: var(--good); }
.badge.no { background: var(--surface-2); color: var(--muted); }
.badge.na { color: var(--muted); padding-left: 0; }
.lcp { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.empty { text-align: center; color: var(--muted); padding: 32px; margin: 0; }

/* About */
.about { padding: 24px 0 48px; border-top: 1px solid var(--border); margin-top: 16px; }
.about h2 { font-size: 20px; margin: 16px 0 16px; }
.about-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.about article { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.about h3 { font-size: 15.5px; margin: 10px 0 6px; }
.about p { color: var(--muted); margin: 0; font-size: 14px; }
.num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; }
.faq { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 18px; margin-bottom: 10px; }
.faq summary { cursor: pointer; padding: 14px 0; font-weight: 600; }
.faq p, .faq ol { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.faq ol { padding-left: 20px; }
.faq[open] { box-shadow: var(--shadow); }

.foot { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); z-index: 50; }

/* Responsive */
@media (max-width: 820px) {
  .tiles, .live { grid-template-columns: repeat(2, 1fr); }
  .about-grid { grid-template-columns: 1fr; }
  .c-num.depth, .table th:nth-child(5) { display: none; }
  .page-title, .page-url { max-width: 300px; }
}
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 36px 0 20px; }
  .search { flex-direction: column; }
  .btn.primary { height: 50px; }
  .opt-grid { grid-template-columns: 1fr; }
  .progress-head { flex-direction: column; }
  .tag { display: none; }
  .toolbar { width: 100%; }
  .filter { flex: 1; }
  .filter input { width: 100%; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { display: grid; grid-template-columns: 40px 1fr; gap: 4px 10px; padding: 14px; border-bottom: 1px solid var(--border); }
  .table td { border: 0; padding: 0; }
  .table td.c-rank { grid-row: span 4; }
  .table td.c-num { text-align: left !important; font-size: 13px; color: var(--muted); }
  .table td.c-num::before { content: attr(data-label) ": "; }
  .table td.c-num.depth { display: none; }
  .c-score, .c-crux { width: auto; }
  .page-title, .page-url { max-width: calc(100vw - 110px); }
}
