:root {
  color-scheme: dark;
  --bg: #08111c;
  --surface: #0d1926;
  --surface-2: #122235;
  --text: #e9f0f6;
  --muted: #91a2b4;
  --line: rgba(154, 178, 199, 0.17);
  --accent: #7ee0b8;
  --accent-2: #6bb7ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #edf2f4;
  --text: #13202b;
  --muted: #637484;
  --line: rgba(40, 65, 85, 0.14);
  --accent: #087a57;
  --accent-2: #176fb7;
  --shadow: 0 24px 70px rgba(31, 54, 71, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 75% 4%, rgba(53, 116, 150, 0.18), transparent 26rem),
    radial-gradient(circle at 15% 28%, rgba(43, 126, 96, 0.12), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
  transition: background-color .25s ease, color .25s ease;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }
button:disabled, select:disabled, input:disabled { opacity: .56; cursor: not-allowed; }
.site-header, main, footer { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }
.site-header {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 720; letter-spacing: -.02em; }
.brand-mark {
  width: 31px; height: 31px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 9px;
  color: var(--accent); background: var(--surface);
}
nav { display: flex; align-items: center; gap: 24px; font-size: .9rem; color: var(--muted); }
nav a:hover { color: var(--text); }
.theme-toggle {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.hero { padding: 122px 0 112px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 18px; color: var(--accent); font: 700 .72rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .17em; }
h1 { max-width: 820px; margin: 0; font-size: clamp(3.2rem, 8vw, 6.7rem); line-height: .98; letter-spacing: -.066em; }
h1 span { color: var(--muted); }
.hero-copy { max-width: 640px; margin: 34px 0 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.22rem); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 38px; }
.button { display: inline-flex; align-items: center; min-height: 46px; padding: 0 20px; border-radius: 10px; font-weight: 670; font-size: .92rem; }
.button.primary { background: var(--accent); color: #062319; }
.button.secondary { border: 1px solid var(--line); background: var(--surface); }
.button.danger { border: 1px solid rgba(255, 115, 115, .35); background: rgba(255, 91, 91, .08); color: #ff9c9c; }
button.button { cursor: pointer; border-width: 1px; border-style: solid; border-color: transparent; }
.status-line { margin-top: 70px; display: flex; align-items: center; gap: 10px; color: var(--muted); font: .75rem ui-monospace, monospace; text-transform: uppercase; letter-spacing: .08em; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 15%, transparent); }
.divider { color: var(--line); }
.section { padding: 96px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 24px; }
.section-heading { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 40px; margin-bottom: 42px; }
h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -.045em; line-height: 1.08; }
.section-heading > p { margin: 0; color: var(--muted); max-width: 450px; justify-self: end; }
.article-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.article-card {
  min-height: 310px; padding: 28px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}
.article-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 42%, var(--line)); }
.article-card.featured { grid-row: span 2; min-height: 636px; background: linear-gradient(145deg, var(--surface-2), var(--surface)); box-shadow: var(--shadow); }
.article-meta { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font: .72rem ui-monospace, monospace; letter-spacing: .06em; text-transform: uppercase; }
.article-meta span { color: var(--accent); }
.article-card h3 { margin: auto 0 14px; font-size: clamp(1.45rem, 2.8vw, 2.45rem); line-height: 1.18; letter-spacing: -.035em; }
.article-card p { margin: 0; color: var(--muted); }
.article-card a { margin-top: 26px; font-size: .9rem; font-weight: 700; }
.article-card a span { color: var(--accent); }
.project-list { border-top: 1px solid var(--line); }
.project-list article {
  display: grid; grid-template-columns: 60px 1fr auto; gap: 24px; align-items: center;
  padding: 28px 8px; border-bottom: 1px solid var(--line);
}
.project-index { color: var(--muted); font: .75rem ui-monospace, monospace; }
.project-list h3 { margin: 0; font-size: 1.25rem; }
.project-list p { margin: 4px 0 0; color: var(--muted); }
.tag { padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font: .7rem ui-monospace, monospace; }
.speedtest-shell { display: grid; grid-template-columns: 1fr; align-items: stretch; }
.speedtest-console {
  min-width: 0;
  border: 1px solid var(--line); border-radius: 18px; padding: 30px;
  background: var(--surface);
}
.speed-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.speed-metric { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.speed-metric > span { color: var(--muted); font: .72rem ui-monospace, monospace; text-transform: uppercase; letter-spacing: .08em; }
.speed-metric div { display: flex; align-items: baseline; gap: 7px; margin-top: 7px; }
.speed-metric strong { overflow: hidden; text-overflow: ellipsis; font-size: clamp(1.65rem, 3vw, 2.35rem); line-height: 1; letter-spacing: -.055em; }
.speed-metric small { color: var(--muted); font: .68rem ui-monospace, monospace; }
.speedtest-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; }
.speedtest-controls label { display: flex; min-width: 0; flex-direction: column; gap: 8px; color: var(--muted); font-size: .78rem; }
.speedtest-controls select, .speedtest-controls input {
  width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--surface-2); color: var(--text); font: inherit;
}
.speedtest-controls input { padding: 7px; }
.speedtest-controls input::file-selector-button {
  margin-right: 9px; padding: 6px 9px; border: 0; border-radius: 6px;
  background: var(--accent); color: #062319;
  font: 700 .72rem/1.2 ui-sans-serif, system-ui, sans-serif; cursor: pointer;
}
.speedtest-controls small { min-height: 1.2em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.speedtest-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.speedtest-actions .button { min-height: 42px; padding-inline: 15px; }
.speed-progress { height: 8px; overflow: hidden; margin-top: 26px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.speed-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .12s linear; }
.speedtest-status { display: flex; justify-content: space-between; gap: 18px; margin-top: 11px; color: var(--muted); font: .75rem ui-monospace, monospace; }
.speedtest-status span:first-child { overflow-wrap: anywhere; }
.speedtest-status span:last-child { flex: none; color: var(--accent); }
.about { display: grid; grid-template-columns: 1fr 1fr; gap: 70px; }
.about-copy { color: var(--muted); font-size: 1.08rem; }
.about-copy p:first-child { margin-top: 0; }
footer { min-height: 150px; display: flex; justify-content: space-between; align-items: center; gap: 24px; color: var(--muted); font-size: .82rem; }

@media (max-width: 720px) {
  .site-header { height: 70px; }
  nav a { display: none; }
  .hero { padding: 88px 0 80px; }
  .status-line { flex-wrap: wrap; margin-top: 50px; }
  .section { padding: 72px 0; }
  .section-heading, .about { grid-template-columns: 1fr; gap: 24px; }
  .section-heading > p { justify-self: start; }
  .article-grid { grid-template-columns: 1fr; }
  .article-card.featured { min-height: 430px; grid-row: auto; }
  .project-list article { grid-template-columns: 36px 1fr; }
  .tag { display: none; }
  .speedtest-shell { grid-template-columns: 1fr; }
  .speedtest-console { padding: 22px; }
  .speedtest-controls { grid-template-columns: 1fr; }
  footer { padding: 40px 0; flex-direction: column; align-items: flex-start; justify-content: center; }
}

@media (max-width: 470px) {
  .speed-metrics { grid-template-columns: 1fr; }
  .speedtest-actions { display: grid; grid-template-columns: 1fr; }
  .speedtest-actions .button { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
