:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, .08);
  --field: #f5f5f7;
  --accent: #1f8fb8;
  --accent-soft: rgba(31, 143, 184, .12);
  --ok: #1f9d55;
  --ok-soft: rgba(52, 199, 89, .14);
  --bad: #d70015;
  --bad-soft: rgba(255, 59, 48, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(0, 0, 0, .06);
  --radius: 22px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --card: #1c1c1e;
    --fg: #f5f5f7;
    --muted: #a1a1a6;
    --line: rgba(255, 255, 255, .1);
    --field: #2c2c2e;
    --accent: #4cc2e6;
    --accent-soft: rgba(76, 194, 230, .16);
    --ok: #30d158;
    --ok-soft: rgba(48, 209, 88, .16);
    --bad: #ff6961;
    --bad-soft: rgba(255, 105, 97, .16);
    --shadow: 0 0 0 1px rgba(255, 255, 255, .06);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3 { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif; margin: 0; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 14px; }

.nav { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); }
.nav-inner { max-width: 820px; margin: 0 auto; padding: 0 16px; height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.brand img { border-radius: 6px; }
.nav-note { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.nav-note svg { width: 15px; height: 15px; }
.nav-note { margin-left: auto; }
.lang-toggle { appearance: none; flex: none; font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; cursor: pointer; }
.lang-toggle:hover { color: var(--fg); background: var(--field); }
.lang-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

main { max-width: 820px; margin: 0 auto; padding: 0 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }

.hero { text-align: center; padding: 56px 0 20px; }
.hero h1 { font-size: clamp(36px, 6.4vw, 56px); line-height: 1.06; letter-spacing: -.028em; font-weight: 700; }
.hero p { max-width: 600px; margin: 18px auto 0; font-size: clamp(17px, 2.2vw, 20px); color: var(--muted); letter-spacing: -.01em; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.step { padding: 24px; display: grid; gap: 20px; min-width: 0; }
.step-head { display: flex; gap: 14px; align-items: flex-start; }
.step-head h2 { font-size: 21px; letter-spacing: -.015em; }
.num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: 15px; }

.btn { appearance: none; border: 0; border-radius: 99px; padding: 11px 22px; font: inherit; font-size: 16px; font-weight: 500; cursor: pointer; background: var(--field); color: var(--fg); display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn svg { width: 19px; height: 19px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn:disabled { opacity: .4; cursor: default; }
.btn:not(:disabled):hover { filter: brightness(1.06); }

.pick, .actions { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; }

.folder-name { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
details { font-size: 14px; color: var(--muted); }
details summary { cursor: pointer; }
details ul { margin: 6px 0 0; padding-left: 18px; max-height: 220px; overflow: auto; }
details li { overflow-wrap: anywhere; }

.field { display: grid; gap: 8px; min-width: 0; }
.field label { font-size: 14px; font-weight: 600; }
select, input[type=number], input[type=text], input[type=date], input[type=search] { font: inherit; font-size: 16px; color: var(--fg); background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; min-width: 0; }
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }


input[type=checkbox] { accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; cursor: pointer; font-size: 15px; }
.check input { width: 18px; height: 18px; margin: 0; flex: none; }

.tips { padding: 8px 4px 0; color: var(--muted); font-size: 15px; }
.tips h3 { font-size: 17px; color: var(--fg); margin-bottom: 8px; }
.tips ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* Back to the HT Labs home page (wired by i18n.js) */
.home-link { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px 5px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1; letter-spacing: 0; white-space: nowrap; text-decoration: none; }
.home-link:hover { color: var(--fg); border-color: currentColor; text-decoration: none; }
.home-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.home-link svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 480px) { .home-link span { display: none; } .home-link { padding: 5px 7px; } .nav-note { display: none; } }

.grad { background: linear-gradient(90deg, #3a8fe0, #1fb89a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.foot { text-align: center; padding: 32px 16px 48px; font-size: 13px; color: var(--muted); }
.foot p { margin: 0; }
.foot a { color: var(--accent); text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.bar { height: 8px; border-radius: 99px; background: var(--field); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.notice { padding: 14px 16px; border-radius: 14px; font-size: 15px; overflow-wrap: anywhere; }
.notice.ok { background: var(--ok-soft); }
.notice.warn { background: rgba(255, 159, 10, .14); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }

/* NetTest */
:root { --warn: #b36b00; --warn-soft: rgba(255, 159, 10, .16); --wifi: #8e5bd8; }
@media (prefers-color-scheme: dark) { :root { --warn: #ffb340; --wifi: #b48cf0; } }
.label { font-size: 14px; font-weight: 600; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; background: var(--field); padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere; }
a { color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.seg { display: flex; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 7px 4px; border-radius: 9px; font-size: 15px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.seg input:checked + span { background: var(--card); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg input:disabled + span { opacity: .5; }

.gauge { background: var(--field); border-radius: 18px; padding: 16px 18px 14px; display: grid; gap: 6px; }
.gauge-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.phase { font-weight: 600; font-size: 15px; }
.big { font-size: clamp(44px, 9vw, 64px); font-weight: 700; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.big .unit { font-size: 20px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
#spark { width: 100%; height: 70px; display: block; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 600px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.metric { border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; display: grid; gap: 2px; min-width: 0; }
.m-label { font-size: 13px; color: var(--muted); }
.m-val { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.m-val b { font-size: 24px; color: var(--fg); font-weight: 650; letter-spacing: -.01em; }

.quality { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 600px) { .quality { grid-template-columns: minmax(0, 1fr); } }
.q { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 15px; padding: 8px 12px; border-radius: 12px; background: var(--field); }
.badge { font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.badge.good { background: var(--ok-soft); color: var(--ok); }
.badge.fair { background: var(--warn-soft); color: var(--warn); }
.badge.poor { background: var(--bad-soft); color: var(--bad); }

.cmp { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.cmp-col { border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: grid; gap: 8px; min-width: 0; }
.cmp-col h3 { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.cmp-col h3 small { font-size: 13px; font-weight: 400; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.wired { background: var(--accent); }
.dot.wifi { background: var(--wifi); }
.dot.mobile { background: var(--ok); }
.cmp-row { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; font-variant-numeric: tabular-nums; }
.cmp-row span:first-child { color: var(--muted); }
.cmp-row .better { color: var(--ok); font-weight: 600; }
.verdict { background: var(--accent-soft); border-radius: 14px; padding: 14px 16px; font-size: 15px; display: grid; gap: 6px; }
.verdict p { margin: 0; }

.step > * { min-width: 0; }
.table-wrap { overflow-x: auto; margin: 0 -4px; position: relative; }
.hist { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.hist th, .hist td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.hist th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.hist .num-col { text-align: right; }
.hist .kind { display: inline-flex; align-items: center; gap: 7px; }
.hist td .note { color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
.hist td .src { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; }
.x-btn { appearance: none; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 8px; display: grid; place-items: center; }
.x-btn:hover { color: var(--bad); background: var(--bad-soft); }
.x-btn svg { width: 16px; height: 16px; }

.list { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 15px; }
.cmd { display: flex; align-items: center; gap: 10px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 14px; }
.cmd code { background: none; padding: 0; flex: 1; font-size: 14px; }
.small-btn { padding: 7px 14px; font-size: 14px; background: var(--card); }
.num svg { width: 17px; height: 17px; }
