/* ============================================================
   TorqueCode — design system
   ============================================================ */

:root {
  --bg: #0a0e13;
  --bg-soft: #0d131a;
  --panel: #111a23;
  --panel-2: #16222d;
  --panel-3: #1b2a36;
  --line: #233241;
  --line-soft: #1a2632;
  --text: #e9f0f7;
  --text-soft: #c3d0dc;
  --muted: #8ea2b4;
  --accent: #c8f751;
  --accent-ink: #15210a;
  --accent-text: #d3fb6b;
  --accent-soft: rgba(200, 247, 81, 0.12);
  --accent-line: rgba(200, 247, 81, 0.35);
  --info: #58c7f3;
  --warn: #f5b93c;
  --danger: #fb7185;
  --critical: #f2545b;
  --ok: #42d9a4;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.65);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Bahnschrift", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Cascadia Mono", "SF Mono", "Consolas", "Liberation Mono", monospace;
  --max: 1180px;
  --header-h: 72px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f7f9;
  --bg-soft: #eaf0f4;
  --panel: #ffffff;
  --panel-2: #f4f8fa;
  --panel-3: #eaf1f5;
  --line: #d7e1e8;
  --line-soft: #e4ebf0;
  --text: #0d1a23;
  --text-soft: #2b3d4a;
  --muted: #596d7c;
  --accent: #c3ef4e;
  --accent-ink: #182607;
  --accent-text: #3d620c;
  --accent-soft: rgba(101, 163, 13, 0.12);
  --accent-line: rgba(77, 124, 15, 0.3);
  --info: #0369a1;
  --warn: #a16207;
  --danger: #be123c;
  --critical: #b91c1c;
  --ok: #047857;
  --shadow: 0 20px 45px -24px rgba(16, 39, 55, 0.25);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(800px 500px at 85% -10%, rgba(200, 247, 81, 0.07), transparent 60%),
    radial-gradient(700px 500px at 0% 10%, rgba(88, 199, 243, 0.06), transparent 55%);
}

[data-theme="light"] body::before {
  background:
    radial-gradient(800px 500px at 85% -10%, rgba(101, 163, 13, 0.1), transparent 60%),
    radial-gradient(700px 500px at 0% 10%, rgba(3, 105, 161, 0.06), transparent 55%);
}

img,
svg {
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 0;
  font-weight: 700;
}

p {
  margin: 0;
}

ul, ol {
  margin: 0;
  padding: 0;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  font-weight: 700;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 12px;
}

.container {
  width: min(100% - 40px, var(--max));
  margin-inline: auto;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.eyebrow.no-rule::before {
  display: none;
}

.mono {
  font-family: var(--font-mono);
}

.muted {
  color: var(--muted);
}

.accent {
  color: var(--accent-text);
}

.nowrap {
  white-space: nowrap;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 650;
  font-size: 0.94rem;
  letter-spacing: 0.01em;
  text-align: center;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 30px -12px rgba(200, 247, 81, 0.55);
}

.btn-primary:hover {
  background: #d7ff6e;
}

[data-theme="light"] .btn-primary:hover {
  background: #b4e83c;
}

.btn-ghost {
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--accent-line);
  background: var(--panel-2);
}

.btn-sm {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.84rem;
  border-radius: 9px;
}

.btn .icon {
  flex: 0 0 auto;
}

.icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm {
  width: 15px;
  height: 15px;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  flex: 0 0 auto;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), #8fd12b);
  color: #101a07;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 6px 16px -8px rgba(200, 247, 81, 0.7);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.16rem;
  letter-spacing: -0.03em;
  line-height: 1.05;
  display: flex;
  flex-direction: column;
}

.brand-name small {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 3px;
}

.brand-name .accent {
  color: var(--accent-text);
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  position: relative;
  padding: 9px 13px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 550;
  color: var(--text-soft);
  transition: color 0.16s, background 0.16s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--panel-2);
}

.nav-link.is-active {
  color: var(--text);
}

.nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 13px;
  right: 13px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  transition: background 0.16s, color 0.16s, border-color 0.16s;
}

.icon-btn:hover {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--accent-line);
}

.theme-toggle .sun {
  display: none;
}

[data-theme="light"] .theme-toggle .sun {
  display: block;
}

[data-theme="light"] .theme-toggle .moon {
  display: none;
}

.menu-btn {
  display: none;
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  padding: clamp(48px, 7vw, 86px) 0 clamp(42px, 6vw, 64px);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: 0.35;
  mask-image: radial-gradient(ellipse 80% 70% at 60% 30%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 60% 30%, #000 20%, transparent 75%);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: clamp(32px, 5vw, 64px);
  align-items: center;
}

.hero-title {
  margin: 18px 0 20px;
  font-size: clamp(2.55rem, 5.4vw, 4.35rem);
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.hero-title .line-2 {
  display: block;
  color: var(--muted);
}

.hero-title em {
  font-style: normal;
  color: var(--accent-text);
  position: relative;
}

.hero-sub {
  max-width: 54ch;
  font-size: clamp(1rem, 1.2vw, 1.08rem);
  color: var(--muted);
  line-height: 1.65;
}

.hero-search {
  margin: 30px 0 16px;
}

.search-shell {
  position: relative;
  z-index: 5;
  max-width: 560px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: border-color 0.18s, box-shadow 0.18s;
}

.search-field:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
}

.search-field > .icon {
  flex: 0 0 auto;
  color: var(--muted);
  width: 20px;
  height: 20px;
}

.search-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--text);
}

.search-input::placeholder {
  color: var(--muted);
  font-family: var(--font);
  letter-spacing: 0;
  font-size: 0.92rem;
}

.search-input:focus {
  outline: none;
}

.search-suggest {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 330px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: none;
}

.search-suggest.is-open {
  display: block;
  animation: pop 0.14s ease-out;
}

.suggest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  color: var(--text);
}

.suggest-item:hover,
.suggest-item:focus-visible,
.suggest-item.is-active {
  background: var(--panel-2);
  outline: none;
}

.suggest-code {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 3px 7px;
  border-radius: 6px;
}

.suggest-title {
  font-size: 0.87rem;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest-empty {
  padding: 16px;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
}

.search-hints {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 13px;
  font-size: 0.78rem;
  color: var(--muted);
}

.hint-chip {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-soft);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.hint-chip:hover {
  border-color: var(--accent-line);
  color: var(--accent-text);
  background: var(--accent-soft);
}

.hero-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 26px;
  font-size: 0.84rem;
  color: var(--muted);
}

.hero-points span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.hero-points .icon {
  width: 15px;
  height: 15px;
  color: var(--accent-text);
}

/* Scanner visual */

.scanner-wrap {
  position: relative;
  max-width: 440px;
  margin-left: auto;
}

.scanner {
  position: relative;
  z-index: 2;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: linear-gradient(155deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.scanner::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(200, 247, 81, 0.07), transparent 38%);
}

.scanner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.scanner-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ok);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(66, 217, 164, 0.5);
  animation: pulse 2s infinite;
}

.scanner-body {
  padding: 22px 22px 18px;
}

.scanner-kicker {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.scanner-code {
  font-family: var(--font-mono);
  font-size: clamp(3.2rem, 7vw, 4.6rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--accent-text);
  margin: 6px 0 2px;
  text-shadow: 0 0 34px rgba(200, 247, 81, 0.28);
}

.scanner-title {
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  min-height: 2.4em;
}

.wave {
  display: block;
  width: 100%;
  height: 46px;
  margin: 12px 0 6px;
  overflow: visible;
}

.wave path {
  stroke: var(--accent);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 6 5;
  animation: dash 14s linear infinite;
  filter: drop-shadow(0 0 6px rgba(200, 247, 81, 0.45));
}

.scanner-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line-soft);
  margin-top: 8px;
}

.scanner-stat {
  padding: 12px 10px;
  border-right: 1px solid var(--line-soft);
  text-align: center;
}

.scanner-stat:last-child {
  border-right: 0;
}

.scanner-stat span {
  display: block;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}

.scanner-stat strong {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-soft);
}

.scanner-stat strong.hot {
  color: var(--warn);
}

.scanner-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-soft);
  font-size: 0.78rem;
  color: var(--muted);
}

.scanner-foot .fix-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
}

.float-chip {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  font-size: 0.76rem;
  color: var(--text-soft);
  animation: float 6s ease-in-out infinite;
}

.float-chip strong {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-text);
}

.float-chip.one {
  top: 22px;
  right: -18px;
}

.float-chip.two {
  bottom: 46px;
  left: -26px;
  animation-delay: -2.6s;
}

.float-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}

.float-chip .dot.ok {
  background: var(--ok);
}

/* ---------- Stats strip ---------- */

.stat-strip {
  border-block: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--panel) 45%, transparent);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.stat {
  padding: 24px 26px;
  border-right: 1px solid var(--line-soft);
}

.stat:first-child {
  padding-left: 0;
}

.stat:last-child {
  border-right: 0;
}

.stat-value {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
}

.stat-value .accent {
  color: var(--accent-text);
}

.stat-label {
  margin-top: 7px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Sections ---------- */

.section {
  padding: clamp(52px, 7vw, 84px) 0;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

.section-title {
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  letter-spacing: -0.035em;
  margin-top: 10px;
}

.section-sub {
  max-width: 58ch;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.96rem;
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent-text);
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.16s, gap 0.16s;
}

.link-arrow:hover {
  border-color: var(--accent-line);
  gap: 10px;
}

.link-arrow .icon {
  width: 15px;
  height: 15px;
}

/* ---------- Code cards ---------- */

.code-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.code-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 19px 19px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  text-align: left;
  color: inherit;
  width: 100%;
}

.code-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--sev-color, var(--line));
  opacity: 0.8;
}

.code-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-line);
  box-shadow: var(--shadow);
}

.code-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.code-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}

.code-badge::before {
  content: "";
  width: 3px;
  height: 15px;
  border-radius: 2px;
  background: var(--sev-color, var(--muted));
}

.sev-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sev-color, var(--muted));
  background: color-mix(in srgb, var(--sev-color, var(--muted)) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--sev-color, var(--muted)) 28%, transparent);
}

.sev-pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.sev-low { --sev-color: var(--ok); }
.sev-medium { --sev-color: var(--info); }
.sev-high { --sev-color: var(--warn); }
.sev-critical { --sev-color: var(--critical); }

.code-card h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.012em;
  line-height: 1.32;
  margin-bottom: 7px;
  min-height: 2.6em;
}

.code-card h3 a {
  color: inherit;
}

.stretched-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.stretched-link:focus-visible {
  outline: none;
}

.stretched-link:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
  border-radius: var(--radius-sm);
}

.code-card .save-btn {
  position: relative;
  z-index: 2;
}

.code-card .card-sys {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.76rem;
  color: var(--muted);
}

.card-foot .cost {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-soft);
}

.save-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.save-btn:hover {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.save-btn.is-saved {
  color: var(--accent-text);
}

.save-btn.is-saved svg {
  fill: currentColor;
}

/* ---------- Anatomy ---------- */

.anatomy-wrap {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: clamp(30px, 5vw, 60px);
  align-items: center;
}

.anatomy {
  display: flex;
  gap: 8px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px),
    var(--panel);
  background-size: 22px 22px, 22px 22px, auto;
  justify-content: center;
}

.anatomy-cell {
  flex: 1;
  max-width: 104px;
  text-align: center;
}

.anatomy-char {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 3.5vw, 2.1rem);
  font-weight: 700;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.anatomy-cell:first-child .anatomy-char {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 8px 24px -12px rgba(200, 247, 81, 0.8);
}

.anatomy-label {
  margin-top: 9px;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.4;
}

.anatomy-notes {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.anatomy-note {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: var(--panel);
}

.anatomy-note .letter {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent-text);
  width: 26px;
}

.anatomy-note h3 {
  font-size: 0.88rem;
  font-family: var(--font);
  font-weight: 650;
  margin-bottom: 2px;
}

.anatomy-note p {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- Tips ---------- */

.tips-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.tip-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: transform 0.18s, border-color 0.18s;
}

.tip-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-line);
}

.tip-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-text);
}

.tip-icon .icon {
  width: 20px;
  height: 20px;
}

.tip-card h3 {
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.tip-card p {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.6;
}

.tip-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.tag.impact {
  color: var(--accent-text);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* ---------- CTA band ---------- */

.cta-band {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 26px;
  padding: clamp(30px, 5vw, 48px);
  border: 1px solid var(--accent-line);
  border-radius: 24px;
  background:
    radial-gradient(600px 200px at 90% 0%, rgba(200, 247, 81, 0.16), transparent 70%),
    var(--panel);
}

[data-theme="light"] .cta-band {
  background:
    radial-gradient(600px 200px at 90% 0%, rgba(101, 163, 13, 0.14), transparent 70%),
    var(--panel);
}

.cta-band::after {
  content: "P0171";
  position: absolute;
  right: 30px;
  bottom: -30px;
  font-family: var(--font-mono);
  font-size: 150px;
  font-weight: 700;
  color: var(--text);
  opacity: 0.035;
  pointer-events: none;
  letter-spacing: -0.05em;
}

.cta-band h2 {
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  max-width: 22ch;
}

.cta-band p {
  margin-top: 8px;
  color: var(--muted);
  max-width: 52ch;
  font-size: 0.92rem;
}

/* ---------- Page hero (inner pages) ---------- */

.page-hero {
  padding: clamp(34px, 5vw, 56px) 0 32px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 55%, transparent), transparent);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.breadcrumb a:hover {
  color: var(--accent-text);
}

.breadcrumb .sep {
  opacity: 0.5;
}

.page-title {
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  letter-spacing: -0.04em;
  margin-top: 12px;
}

.page-sub {
  max-width: 66ch;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.98rem;
}

.page-hero-with-side {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
}

.hero-mini-panel {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.hero-mini-panel .big {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent-text);
}

.hero-mini-panel .small {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- Library toolbar ---------- */

.library {
  padding: 32px 0 72px;
}

.library-toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  padding: 16px 0;
  margin-bottom: 22px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.toolbar-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-search {
  flex: 1 1 300px;
  min-width: 0;
}

.toolbar-search .search-field {
  box-shadow: none;
  padding: 5px 6px 5px 14px;
  border-radius: 11px;
  background: var(--panel-2);
}

.toolbar-search .search-input {
  height: 36px;
  font-size: 0.88rem;
}

.toolbar-search .search-input::placeholder {
  font-size: 0.86rem;
}

.toolbar-search .btn {
  min-height: 36px;
}

.kbd-hint {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 4px;
}

.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--panel-2);
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted);
}

.select-wrap {
  position: relative;
  flex: 0 0 auto;
}

.select-wrap select {
  appearance: none;
  height: 38px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  font-size: 0.82rem;
  color: var(--text-soft);
  cursor: pointer;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.chip-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--bg-soft);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
}

.chip:hover {
  color: var(--text);
}

.chip.is-active {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .chip.is-active {
  background: #fff;
}

.chip .letter {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--accent-text);
}

.chip .count {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  font-size: 0.8rem;
  color: var(--text-soft);
  user-select: none;
  cursor: pointer;
}

.toggle input {
  appearance: none;
  width: 30px;
  height: 17px;
  margin: 0;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.16s;
}

.toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.16s, background 0.16s;
}

.toggle input:checked {
  background: var(--accent);
}

.toggle input:checked::after {
  transform: translateX(13px);
  background: var(--accent-ink);
}

.result-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  font-size: 0.83rem;
  color: var(--muted);
}

.result-line strong {
  color: var(--text);
  font-weight: 650;
}

.result-line .clear-filters {
  border: 0;
  background: none;
  padding: 0;
  font-size: 0.8rem;
  color: var(--accent-text);
  border-bottom: 1px solid transparent;
}

.result-line .clear-filters:hover {
  border-color: var(--accent-line);
}

.code-grid.library-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.library-grid .code-card {
  padding: 16px 16px 13px;
}

.library-grid .code-card h3 {
  font-size: 0.92rem;
  min-height: 2.5em;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 60px 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: center;
}

.empty-state .empty-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.empty-state h3 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.empty-state p {
  max-width: 44ch;
  margin: 0 auto 18px;
  font-size: 0.88rem;
  color: var(--muted);
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 8, 12, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  /* Show/hide instantly so the dialog is visible and focusable even when
     the browser throttles CSS transitions in a background tab. */
}

.modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: relative;
  width: min(100%, 880px);
  max-height: min(88vh, 900px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.8);
  transform: translateY(14px) scale(0.985);
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.modal-backdrop.is-open .modal {
  transform: translateY(0) scale(1);
}

.modal-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 22px 24px 20px;
  border-bottom: 1px solid var(--line-soft);
  background:
    radial-gradient(500px 160px at 0% 0%, var(--accent-soft), transparent 70%),
    var(--panel);
}

.modal-code {
  font-family: var(--font-mono);
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--accent-text);
}

.modal-head-main {
  flex: 1;
  min-width: 0;
}

.modal-title {
  font-size: clamp(1.1rem, 2.4vw, 1.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 7px;
  line-height: 1.25;
}

.modal-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.modal-tags .btn {
  min-height: 32px;
  font-size: 0.76rem;
}

.modal-tags .btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-text);
}

.modal-tags .btn[aria-pressed="true"] .icon {
  fill: currentColor;
}

.modal-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--muted);
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--accent-line);
}

.modal-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
}

.modal-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line-soft);
}

.meta-cell {
  padding: 13px 14px;
  background: var(--panel-2);
}

.meta-cell span {
  display: block;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.meta-cell strong {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
}

.meta-cell strong.good {
  color: var(--ok);
}

.meta-cell strong.warn {
  color: var(--warn);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.detail-block {
  margin-bottom: 24px;
}

.detail-block:last-child {
  margin-bottom: 0;
}

.detail-block h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}

.detail-block h3 .icon {
  width: 14px;
  height: 14px;
  color: var(--accent-text);
}

.detail-block p {
  font-size: 0.89rem;
  line-height: 1.65;
  color: var(--text-soft);
}

.check-list {
  display: grid;
  gap: 7px;
  list-style: none;
}

.check-list li {
  position: relative;
  padding-left: 19px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-soft);
}

.check-list li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.55em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.fix-steps {
  counter-reset: fix;
  display: grid;
  gap: 10px;
  list-style: none;
}

.fix-steps li {
  counter-increment: fix;
  position: relative;
  padding: 11px 12px 11px 43px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-soft);
}

.fix-steps li::before {
  content: counter(fix, decimal-leading-zero);
  position: absolute;
  left: 12px;
  top: 11px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent-text);
}

.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.related-link {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text-soft);
  transition: border-color 0.15s, color 0.15s;
}

.related-link:hover {
  border-color: var(--accent-line);
  color: var(--accent-text);
}

.modal-aside {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

.safety-note {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--warn) 7%, transparent);
  font-size: 0.79rem;
  line-height: 1.55;
  color: var(--text-soft);
}

.safety-note .icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--warn);
}

/* ---------- Tips page ---------- */

.tips-layout {
  padding: 34px 0 76px;
}

.tips-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.progress-wrap {
  flex: 1 1 260px;
  max-width: 360px;
}

.progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--panel-3);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  transition: width 0.4s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.tips-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.tip-detail {
  display: flex;
  flex-direction: column;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color 0.18s;
}

.tip-detail:hover {
  border-color: var(--accent-line);
}

.tip-detail {
  scroll-margin-top: calc(var(--header-h) + 24px);
}

.tip-detail.is-done {
  border-color: color-mix(in srgb, var(--ok) 40%, var(--line));
  background: color-mix(in srgb, var(--ok) 3%, var(--panel));
}

.tip-detail-head {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 11px;
}

.tip-detail-head .tip-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
}

.tip-detail-head h3 {
  font-size: 1.02rem;
  line-height: 1.3;
  padding-top: 2px;
}

.tip-detail > p {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.62;
  margin-bottom: 14px;
}

.tip-why {
  margin: 0 0 15px;
  padding: 11px 13px;
  border-left: 2px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-soft);
}

.tip-why strong {
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 3px;
}

.tip-detail-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 13px;
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.tip-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tip-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 0.76rem;
  font-weight: 550;
  color: var(--text-soft);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tip-check:hover {
  border-color: var(--accent-line);
}

.tip-check.is-done {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.tip-check .box {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 3.5px;
}

.tip-check .box .icon {
  width: 10px;
  height: 10px;
  stroke-width: 3;
  opacity: 0;
}

.tip-check.is-done .box .icon {
  opacity: 1;
}

/* Calculator */

.calc {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 0;
  margin-top: 34px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  overflow: hidden;
}

.calc-form {
  padding: clamp(22px, 3.5vw, 32px);
  border-right: 1px solid var(--line);
}

.calc-form h3 {
  font-size: 1.25rem;
  margin-bottom: 5px;
}

.calc-form > p {
  font-size: 0.83rem;
  color: var(--muted);
  margin-bottom: 20px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-soft);
}

.segmented button {
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.segmented button.is-active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.calc-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  overflow: hidden;
}

.field-input input {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 11px;
  border: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text);
}

.field-input input:focus {
  outline: none;
}

.field-input .unit {
  flex: 0 0 auto;
  padding: 0 11px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-left: 1px solid var(--line-soft);
  height: 24px;
  display: grid;
  place-items: center;
}

.field-input:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.range-field {
  margin-top: 16px;
}

.range-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.range-head strong {
  font-size: 0.76rem;
  color: var(--accent-text);
  letter-spacing: 0.02em;
}

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--range-pct, 30%), var(--panel-3) var(--range-pct, 30%));
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--panel-3);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent-line);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
}

.calc-out {
  display: flex;
  flex-direction: column;
  padding: clamp(22px, 3.5vw, 32px);
  background:
    radial-gradient(500px 260px at 100% 0%, var(--accent-soft), transparent 70%),
    var(--bg-soft);
}

.calc-out > .eyebrow {
  font-size: 9px;
}

.calc-big {
  margin: 12px 0 2px;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 3.7rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--accent-text);
}

.calc-big small {
  font-size: 0.38em;
  letter-spacing: 0;
  color: var(--muted);
  font-family: var(--font);
  font-weight: 500;
}

.calc-caption {
  font-size: 0.83rem;
  color: var(--muted);
  margin-bottom: 22px;
}

.calc-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: var(--line);
}

.calc-stat {
  padding: 12px 14px;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
}

.calc-stat span {
  display: block;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}

.calc-stat strong {
  font-size: 0.92rem;
  font-weight: 650;
}

.calc-note {
  display: flex;
  gap: 7px;
  margin-top: 14px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--muted);
}

.calc-note .icon {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  margin-top: 1px;
}

/* Myth / facts */

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 30px;
}

.fact {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
}

.fact .fact-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: 8px;
}

.fact h4,
.fact h3 {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 650;
  margin-bottom: 5px;
}

.fact p {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ---------- About ---------- */

.about-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: clamp(30px, 5vw, 64px);
  align-items: start;
}

.about-copy p {
  max-width: 64ch;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.75;
}

.about-signoff {
  font-family: var(--font-mono);
  font-size: 9.5px !important;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-text) !important;
}

.about-panel {
  padding: clamp(22px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(360px 180px at 100% 0%, var(--accent-soft), transparent 70%),
    var(--panel);
}

.about-panel h3 {
  margin: 10px 0 16px;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.about-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.about-value {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  transition: border-color 0.18s;
}

.about-value:hover {
  border-color: var(--accent-line);
}

.about-value .num {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.about-value h3 {
  margin-top: 9px;
  font-size: 1.02rem;
  letter-spacing: -0.015em;
}

.about-value p {
  margin-top: 7px;
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--muted);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line-soft);
  background: var(--bg-soft);
  padding: 46px 0 26px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1.2fr;
  gap: 34px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--line-soft);
}

.footer-brand p {
  max-width: 34ch;
  margin-top: 14px;
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.6;
}

.footer-col h3 {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.footer-col ul {
  list-style: none;
  display: grid;
  gap: 8px;
}

.footer-col a {
  font-size: 0.84rem;
  color: var(--text-soft);
}

.footer-col a:hover {
  color: var(--accent-text);
}

.footer-note {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.6;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 22px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.disclaimer {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 0.76rem;
  line-height: 1.55;
  color: var(--muted);
}

.disclaimer strong {
  color: var(--text-soft);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 400;
  transform: translate(-50%, 20px);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 17px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast .icon {
  width: 15px;
  height: 15px;
  color: var(--accent-text);
}

/* ---------- Animations ---------- */

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(66, 217, 164, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(66, 217, 164, 0); }
}

@keyframes dash {
  to { stroke-dashoffset: -220; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@keyframes pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.reveal {
  opacity: 0;
  transform: translateY(16px);
}

.reveal.is-in {
  animation: fadeUp 0.6s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}

/* ---------- Responsive ---------- */

@media (min-width: 861px) and (max-width: 960px) {
  .nav { gap: 2px; }
  .nav-link { padding: 9px 10px; font-size: 0.87rem; }
  .nav-link.is-active::after { left: 10px; right: 10px; }
}

@media (max-width: 1024px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .scanner-wrap {
    margin: 10px auto 0;
    width: 100%;
    max-width: 480px;
  }

  .float-chip.one { right: 4px; }
  .float-chip.two { left: 4px; }

  .code-grid { grid-template-columns: repeat(2, 1fr); }
  .code-grid.library-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
  .hero-mini-panel { display: none; }
}

@media (max-width: 860px) {
  .nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    z-index: 90;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 12px 20px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    box-shadow: var(--shadow);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s, transform 0.18s;
  }

  .nav.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .nav-link {
    padding: 12px;
    font-size: 0.96rem;
  }

  .nav-link.is-active::after {
    left: 12px;
    right: auto;
    width: 18px;
    bottom: 8px;
  }

  .menu-btn {
    display: inline-grid;
  }

  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat { padding: 20px; border-bottom: 1px solid var(--line-soft); }
  .stat:first-child { padding-left: 20px; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(3), .stat:nth-child(4) { border-bottom: 0; }

  .anatomy-wrap { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; }
  .tip-card:nth-child(3) { display: none; }

  .calc { grid-template-columns: 1fr; }
  .calc-form { border-right: 0; border-bottom: 1px solid var(--line); }

  .tips-list { grid-template-columns: 1fr; }

  .detail-grid { grid-template-columns: 1fr; gap: 0; }

  .modal-meta { grid-template-columns: repeat(2, 1fr); }

  .code-grid.library-grid { grid-template-columns: repeat(2, 1fr); }

  .facts { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  :root { --header-h: 64px; }

  .container { width: calc(100% - 32px); }

  .brand-name small { display: none; }

  .hero { padding-top: 34px; }

  .hero-title { font-size: clamp(2.2rem, 10vw, 3rem); }

  .hero-points { gap: 6px 16px; font-size: 0.78rem; }

  .search-field {
    flex-wrap: wrap;
    padding: 7px;
  }

  .search-field > .icon { display: none; }

  .search-input {
    flex: 1 1 100%;
    padding-left: 9px;
  }

  .search-field .btn {
    flex: 1 1 100%;
  }

  .float-chip { display: none; }

  .scanner-body { padding: 18px; }

  .stats { grid-template-columns: 1fr 1fr; }

  .stat-value { font-size: 1.5rem; }

  .section { padding: 44px 0; }

  .section-head { flex-direction: column; align-items: flex-start; gap: 12px; }

  .code-grid,
  .code-grid.library-grid { grid-template-columns: 1fr; }

  .library-grid .code-card h3,
  .code-card h3 { min-height: 0; }

  .tips-grid { grid-template-columns: 1fr; }
  .tip-card:nth-child(3) { display: flex; }

  .cta-band { padding: 24px; }
  .cta-band::after { font-size: 100px; }

  .footer-grid { grid-template-columns: 1fr 1fr; gap: 26px; }

  .footer-brand { grid-column: 1 / -1; }

  .modal-backdrop { padding: 0; align-items: flex-end; }

  .modal {
    width: 100%;
    max-height: 94vh;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
  }

  .modal-head { padding: 18px 18px 16px; }
  .modal-body { padding: 18px; }

  .toolbar-search { flex-basis: 100%; }
  .kbd-hint { display: none; }

  .anatomy { padding: 18px; gap: 6px; }
  .anatomy-label { font-size: 7px; }

  .calc-fields { grid-template-columns: 1fr; }
  .calc-stats { grid-template-columns: 1fr 1fr; }

  .about-values { grid-template-columns: 1fr; }
  .about-value { padding: 20px; }

  .toast { left: 16px; right: 16px; bottom: 16px; transform: translateY(16px); justify-content: center; }
  .toast.is-visible { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

@media print {
  .site-header, .site-footer, .hero::before, .float-chip, .modal-backdrop, .search-shell, .library-toolbar { display: none !important; }
  body { background: #fff; color: #000; }
  .code-card { break-inside: avoid; border-color: #ccc; }
}
