/* =========================================================
   Toolthy — shared design system
   ========================================================= */

:root {
  color-scheme: light;
  --page:        #f9f9f7;
  --surface:     #ffffff;
  --surface-2:   #fcfcfb;
  --text:        #0b0b0b;
  --text-2:      #52514e;
  --muted:       #898781;
  --hairline:    #e1e0d9;
  --border:      rgba(11,11,11,0.10);
  --baseline:    #c3c2b7;

  --brand:       #2a78d6;
  --brand-dark:  #184f95;
  --brand-ink:   #ffffff;
  --brand-wash:  #eaf2fc;

  --good:        #0ca30c;
  --good-text:   #006300;
  --warning:     #fab219;
  --serious:     #ec835a;
  --critical:    #d03b3b;
  --critical-wash: #fdeceb;
  --good-wash:   #eaf9ea;
  --warning-wash:#fff8e8;

  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 20px;
  --shadow-s: 0 1px 2px rgba(11,11,11,0.06);
  --shadow-m: 0 6px 20px rgba(11,11,11,0.08);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page:      #0d0d0d;
    --surface:   #17171614;
    --surface:   #19191818;
    --surface:   #1a1a19;
    --surface-2: #1f1f1e;
    --text:      #ffffff;
    --text-2:    #c3c2b7;
    --muted:     #898781;
    --hairline:  #2c2c2a;
    --border:    rgba(255,255,255,0.10);
    --baseline:  #383835;

    --brand:      #3987e5;
    --brand-dark: #86b6ef;
    --brand-ink:  #ffffff;
    --brand-wash: #14233a;

    --good:       #0ca30c;
    --good-text:  #0ca30c;
    --warning:    #fab219;
    --serious:    #ec835a;
    --critical:   #e66767;
    --critical-wash: #3a1a18;
    --good-wash:  #12291a;
    --warning-wash:#332711;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:      #0d0d0d;
  --surface:   #1a1a19;
  --surface-2: #1f1f1e;
  --text:      #ffffff;
  --text-2:    #c3c2b7;
  --muted:     #898781;
  --hairline:  #2c2c2a;
  --border:    rgba(255,255,255,0.10);
  --baseline:  #383835;
  --brand:      #3987e5;
  --brand-dark: #86b6ef;
  --brand-ink:  #ffffff;
  --brand-wash: #14233a;
  --good:       #0ca30c;
  --good-text:  #0ca30c;
  --warning:    #fab219;
  --serious:    #ec835a;
  --critical:   #e66767;
  --critical-wash: #3a1a18;
  --good-wash:  #12291a;
  --warning-wash:#332711;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--page);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 .5em; }
p { margin: 0 0 1em; color: var(--text-2); }
.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 760px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
/* Note: backdrop-filter lives on ::before (not directly on .site-header) because
   filter/backdrop-filter on an ancestor creates a new containing block for
   position:fixed descendants — that broke the mobile .main-nav (fixed) overlay,
   collapsing it to the header's own height instead of the full viewport. */
.site-header {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid var(--hairline);
}
.site-header::before {
  content: "";
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  z-index: -1;
}
.site-header .bar { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 15px; font-weight: 800; flex: none; }
.main-nav { display: flex; gap: 4px; margin-left: auto; }
.main-nav a { color: var(--text-2); font-weight: 600; font-size: 14.5px; padding: 8px 12px; border-radius: 8px; }
.main-nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.main-nav a.active { color: var(--brand); background: var(--brand-wash); }
.nav-toggle { display: none; }

@media (max-width: 860px) {
  .main-nav { position: fixed; inset: 64px 0 0 0; background: var(--surface); flex-direction: column; padding: 12px; gap: 2px; transform: translateY(-8px); opacity: 0; pointer-events: none; transition: .15s ease; overflow-y: auto; }
  .main-nav.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .main-nav a { padding: 14px 12px; font-size: 16px; border-bottom: 1px solid var(--hairline); border-radius: 0; }
  .nav-toggle { display: flex; align-items: center; justify-content: center; margin-left: auto; width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--hairline); background: var(--surface); cursor: pointer; }
  .nav-toggle svg { width: 18px; height: 18px; }
}

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--hairline); margin-top: 64px; padding: 40px 0 32px; color: var(--muted); font-size: 14px; }
.site-footer .cols { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 24px; margin-bottom: 28px; }
.site-footer h4 { color: var(--text); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--brand); }
.footer-bottom { border-top: 1px solid var(--hairline); padding-top: 20px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
@media (max-width: 760px) { .site-footer .cols { grid-template-columns: 1fr 1fr; } }

/* ---------- hero ---------- */
.hero { padding: 56px 0 40px; text-align: center; }
.hero h1 { font-size: clamp(28px, 4.4vw, 46px); }
.hero p.lead { font-size: 18px; max-width: 640px; margin: 0 auto 24px; }
.hero-tools { padding: 40px 0 20px; }

/* search / filter */
.search-box { max-width: 520px; margin: 0 auto 8px; position: relative; }
.search-box input { width: 100%; padding: 14px 16px 14px 44px; border-radius: 999px; border: 1px solid var(--hairline); background: var(--surface); color: var(--text); font-size: 15px; }
.search-box input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.search-box svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }

/* ---------- category / tool cards ---------- */
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 40px 0 16px; }
.section-title h2 { font-size: 22px; margin: 0; }
.section-title a { font-size: 14px; font-weight: 600; }

.cat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin: 24px 0 8px; }
.cat-card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-m); padding: 22px 18px; text-align: left; box-shadow: var(--shadow-s); transition: .15s ease; }
.cat-card:hover { border-color: var(--brand); box-shadow: var(--shadow-m); transform: translateY(-2px); text-decoration: none; }
.cat-card .icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 12px; }
.cat-card h3 { font-size: 16px; margin: 0 0 4px; color: var(--text); }
.cat-card p { font-size: 13.5px; margin: 0; color: var(--muted); }
@media (max-width: 980px) { .cat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .cat-grid { grid-template-columns: 1fr; } }

.tool-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tool-card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-m); padding: 18px; display: flex; gap: 12px; align-items: flex-start; box-shadow: var(--shadow-s); }
.tool-card:hover { border-color: var(--brand); text-decoration: none; box-shadow: var(--shadow-m); }
.tool-card .emoji { font-size: 22px; flex: none; width: 38px; height:38px; display:flex;align-items:center;justify-content:center; background: var(--brand-wash); border-radius: 10px;}
.tool-card h3 { font-size: 15px; margin: 0 0 2px; color: var(--text); }
.tool-card p { font-size: 13px; margin: 0; color: var(--muted); }
@media (max-width: 980px) { .tool-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .tool-grid { grid-template-columns: 1fr; } }

/* ---------- generic tool page layout ---------- */
.breadcrumbs { font-size: 13px; color: var(--muted); margin: 20px 0 4px; }
.breadcrumbs a { color: var(--muted); }
.tool-head { padding: 28px 0 8px; }
.tool-head h1 { font-size: clamp(24px, 3.4vw, 34px); margin-bottom: 8px; }
.tool-head p.sub { font-size: 16px; max-width: 680px; }

.panel { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-l); padding: 28px; box-shadow: var(--shadow-s); margin: 20px 0; }
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 18px; }

.dropzone { border: 2px dashed var(--hairline); border-radius: var(--radius-m); padding: 36px 20px; text-align: center; cursor: pointer; transition: .15s ease; background: var(--surface-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-wash); }
.dropzone .big { font-size: 34px; margin-bottom: 8px; }
.dropzone strong { color: var(--text); }
.dropzone small { color: var(--muted); display: block; margin-top: 4px; }

/* form controls */
label { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-2); margin: 0 0 6px; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=tel], input[type=url], input[type=password], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-s); border: 1px solid var(--hairline);
  background: var(--surface); color: var(--text); font-size: 15px; font-family: var(--font);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type=range] { width: 100%; accent-color: var(--brand); }
.field { margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 15px; padding: 12px 22px; border-radius: 999px; border: 1px solid transparent; cursor: pointer; font-family: var(--font); transition: .12s ease; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--hairline); }
.btn-secondary:hover { border-color: var(--brand); color: var(--brand); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--hairline); background: var(--surface); font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--text-2); }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- results / stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.stat-tile { background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-m); padding: 16px 18px; }
.stat-tile .label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.stat-tile .value { font-size: 26px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-tile .unit { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 3px; }
@media (max-width: 760px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.big-result { text-align: center; padding: 24px 0; }
.big-result .value { font-size: clamp(40px, 8vw, 68px); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--brand); }
.big-result .unit { font-size: 18px; color: var(--muted); font-weight: 700; }
.big-result .caption { color: var(--muted); font-size: 14px; margin-top: 6px; }

/* status badge + rows for "is my internet good enough" style checklists */
.status-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px; border-bottom: 1px solid var(--hairline); }
.status-row:last-child { border-bottom: none; }
.status-row .who { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.status-row .who .emoji { font-size: 18px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; padding: 5px 11px; border-radius: 999px; }
.badge-good { background: var(--good-wash); color: var(--good-text); }
.badge-warning { background: var(--warning-wash); color: #8a5a00; }
.badge-critical { background: var(--critical-wash); color: var(--critical); }
:root[data-theme="dark"] .badge-warning, @media (prefers-color-scheme: dark) { }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.meter { height: 8px; border-radius: 999px; background: var(--hairline); overflow: hidden; margin-top: 8px;}
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .5s ease; }

.progress-wrap { margin: 22px 0; }
.progress-label { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.progress-bar { height: 10px; border-radius: 999px; background: var(--hairline); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--brand), var(--brand-dark)); transition: width .2s linear; }

.callout { border-radius: var(--radius-m); padding: 16px 18px; font-size: 14.5px; border: 1px solid var(--hairline); background: var(--surface-2); }
.callout.good { background: var(--good-wash); border-color: transparent; color: var(--good-text); }
.callout strong { color: inherit; }

table.simple { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.simple th, table.simple td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--hairline); }
table.simple th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
table.simple td.num { font-variant-numeric: tabular-nums; font-weight: 600; }

.faq-item { border-bottom: 1px solid var(--hairline); padding: 16px 0; }
.faq-item h3 { font-size: 15.5px; margin-bottom: 6px; }
.faq-item p { margin: 0; font-size: 14.5px; }

.prose h2 { font-size: 20px; margin-top: 28px; }
.prose ul { color: var(--text-2); padding-left: 20px; }
.prose li { margin-bottom: 6px; }

.privacy-note { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-s); padding: 12px 14px; margin: 16px 0; }
.privacy-note svg { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--good); }

.download-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.qr-preview { display: flex; align-items: center; justify-content: center; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-m); padding: 24px; min-height: 260px; }
.qr-preview canvas, .qr-preview img, .qr-preview svg { max-width: 100%; }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.file-list { display: grid; gap: 8px; margin-top: 14px; }
.file-row { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-s); padding: 9px 12px; font-size: 13.5px; }
.file-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-row .size { color: var(--muted); flex: none; }
.file-row button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 4px; }
.file-row button:hover { color: var(--critical); }

.copy-field { display: flex; gap: 8px; }
.copy-field input { flex: 1; font-family: ui-monospace, monospace; }

.related { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
@media (max-width: 760px) { .related { grid-template-columns: 1fr; } }

.result-hidden { display: none; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--muted); }
.small { font-size: 13px; }
