/* ===== base.css ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  hanging-punctuation: first last;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
ul[role="list"], ol[role="list"] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6 { text-wrap: balance; line-height: 1.15; }
p, li, figcaption { text-wrap: pretty; }

::selection { background: color-mix(in oklab, var(--color-primary) 25%, transparent); color: var(--color-text); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; border-radius: var(--radius-sm); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

button { cursor: pointer; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }

a, button, [role="button"], input, select {
  transition: color var(--transition-interactive), background var(--transition-interactive),
    border-color var(--transition-interactive), box-shadow var(--transition-interactive);
}

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

/* ===== design tokens ===== */
:root {
  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.83rem + 0.2vw, 0.9375rem);
  --text-base: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.375rem);
  --text-xl: clamp(1.4rem, 1.2rem + 1vw, 2rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem;
  --space-12: 3rem; --space-16: 4rem; --space-20: 5rem; --space-24: 6rem;

  --radius-sm: 0.375rem; --radius-md: 0.5rem; --radius-lg: 0.75rem; --radius-xl: 1.25rem; --radius-full: 9999px;
  --transition-interactive: 160ms cubic-bezier(0.16,1,0.3,1);

  --content-wide: 1600px;

  --font-display: 'Cabinet Grotesk', 'General Sans', system-ui, sans-serif;
  --font-body: 'General Sans', 'Satoshi', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* Light mode — cool, technical palette derived from air conditioning / cooling domain */
:root, [data-theme="light"] {
  --color-bg: #f2f5f7;
  --color-surface: #ffffff;
  --color-surface-2: #fbfcfd;
  --color-surface-offset: #eaeff3;
  --color-surface-offset-2: #e1e8ed;
  --color-divider: #dde5ea;
  --color-border: #cfd9e0;

  --color-text: #101820;
  --color-text-muted: #5c6b78;
  --color-text-faint: #98a6b0;
  --color-text-inverse: #f5f9fb;

  --color-primary: #0a7ea6;
  --color-primary-hover: #086285;
  --color-primary-active: #064a66;
  --color-primary-highlight: #cfe9f2;

  --color-success: #1f7a4d;
  --color-success-highlight: #d3ecdd;
  --color-warning: #a15b12;
  --color-warning-highlight: #ecdccb;
  --color-error: #a02c3f;
  --color-error-highlight: #ecd3d8;

  --shadow-sm: 0 1px 2px oklch(0.2 0.02 220 / 0.06);
  --shadow-md: 0 6px 18px oklch(0.2 0.02 220 / 0.10);
  --shadow-lg: 0 18px 40px oklch(0.2 0.02 220 / 0.16);
}

[data-theme="dark"] {
  --color-bg: #0a1119;
  --color-surface: #101a24;
  --color-surface-2: #13202b;
  --color-surface-offset: #16232f;
  --color-surface-offset-2: #1b2b38;
  --color-divider: #223141;
  --color-border: #2a3c4c;

  --color-text: #dce6ec;
  --color-text-muted: #8ea0ac;
  --color-text-faint: #596976;
  --color-text-inverse: #0d151d;

  --color-primary: #4fc3e0;
  --color-primary-hover: #78d3e8;
  --color-primary-active: #9ce0f0;
  --color-primary-highlight: #1c3945;

  --color-success: #5fbf8b;
  --color-success-highlight: #1d3327;
  --color-warning: #d99a54;
  --color-warning-highlight: #3a2f1f;
  --color-error: #dd7a8d;
  --color-error-highlight: #3a2028;

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 6px 18px oklch(0 0 0 / 0.4);
  --shadow-lg: 0 18px 40px oklch(0 0 0 / 0.5);
}

/* ===== layout shell ===== */
.wrap { max-width: var(--content-wide); margin-inline: auto; padding-inline: clamp(1.25rem, 4vw, 3rem); }

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklab, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-divider);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; padding-block: var(--space-4); }
.brand { display: flex; align-items: center; gap: var(--space-3); text-decoration: none; color: var(--color-text); }
.brand svg { width: 30px; height: 30px; color: var(--color-primary); flex-shrink: 0; }
.brand span { font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); letter-spacing: -0.01em; }

.theme-toggle {
  width: 38px; height: 38px; border-radius: var(--radius-full);
  display: grid; place-items: center;
  background: var(--color-surface-offset); color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.theme-toggle:hover { color: var(--color-primary); border-color: var(--color-primary); }
.theme-toggle svg { width: 18px; height: 18px; }

/* hero */
.hero { padding-block: clamp(var(--space-12), 8vw, var(--space-20)) clamp(var(--space-10), 6vw, var(--space-16)); }
.hero h1 {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.015em;
  font-size: var(--text-xl); max-width: 30ch; margin-bottom: var(--space-5);
}
.hero p { color: var(--color-text-muted); max-width: 62ch; font-size: var(--text-base); line-height: 1.7; }
.hero .pill-row { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-8); }
.pill {
  font-size: var(--text-xs); font-weight: 600; padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full); background: var(--color-primary-highlight);
  color: var(--color-primary); border: 1px solid color-mix(in oklab, var(--color-primary) 30%, transparent);
}

/* controls panel */
.controls {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-sm);
  padding: clamp(var(--space-6), 4vw, var(--space-10)); margin-bottom: clamp(var(--space-10), 8vw, var(--space-16));
}
.controls-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-10) var(--space-10); }
.controls-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-8); gap: var(--space-4); flex-wrap: wrap; }
.controls-header h2 { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; margin-bottom: var(--space-2); }
.controls-header p { color: var(--color-text-muted); font-size: var(--text-sm); }

.room-size-box {
  grid-column: 1 / -1;
  display: flex; align-items: flex-end; gap: var(--space-8); flex-wrap: wrap;
  padding-bottom: var(--space-8); margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-divider);
}
.field-group { display: flex; flex-direction: column; gap: var(--space-2); }
.field-group label { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field-group input[type="number"] {
  width: 90px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  border: 1px solid var(--color-border); background: var(--color-surface-2); color: var(--color-text);
  font-size: var(--text-base); font-family: var(--font-mono);
}
.field-group input[type="number"]:focus { border-color: var(--color-primary); }
.room-area-readout { font-size: var(--text-sm); color: var(--color-text-muted); }
.room-area-readout strong { color: var(--color-primary); font-family: var(--font-mono); font-weight: 700; }
.reset-btn {
  margin-left: auto; font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-4);
  display: inline-flex; align-items: center; gap: var(--space-2);
}
.reset-btn:hover { color: var(--color-primary); border-color: var(--color-primary); background: var(--color-primary-highlight); }
.reset-btn svg { width: 14px; height: 14px; }

.slider-field { display: flex; flex-direction: column; gap: var(--space-3); }
.slider-label-row { display: flex; align-items: center; justify-content: space-between; }
.slider-label-row label { font-size: var(--text-sm); font-weight: 600; }
.slider-label-row .val { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-primary); font-weight: 700; min-width: 3ch; text-align: right; }
.slider-hint { font-size: var(--text-xs); color: var(--color-text-faint); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  border-radius: var(--radius-full); background: var(--color-surface-offset-2);
  outline-offset: 4px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--color-primary); border: 3px solid var(--color-surface);
  box-shadow: var(--shadow-sm); cursor: pointer; margin-top: -6px;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: var(--color-primary);
  border: 3px solid var(--color-surface); box-shadow: var(--shadow-sm); cursor: pointer;
}

/* table section */
.table-section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-6); flex-wrap: wrap; gap: var(--space-3); }
.table-section-header h2 { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; }
.result-count { font-size: var(--text-sm); color: var(--color-text-muted); }

.table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--color-border); border-radius: var(--radius-xl);
  background: var(--color-surface); box-shadow: var(--shadow-sm); position: relative;
}
table.rank-table { min-width: 980px; }

/* Keep rank + model visible while scrolling horizontally, especially on mobile */
table.rank-table th:nth-child(1), table.rank-table td:nth-child(1) {
  position: sticky; left: 0; z-index: 3;
}
table.rank-table th:nth-child(2), table.rank-table td:nth-child(2) {
  position: sticky; left: var(--rank-col-width, 60px); z-index: 3;
  box-shadow: 6px 0 10px -6px oklch(0.2 0.02 220 / 0.18);
}
table.rank-table thead th:nth-child(1), table.rank-table thead th:nth-child(2) { background: var(--color-surface-offset); }
table.rank-table tbody td:nth-child(1), table.rank-table tbody td:nth-child(2) { background: var(--color-surface); }
table.rank-table tbody tr:hover td:nth-child(1), table.rank-table tbody tr:hover td:nth-child(2) { background: var(--color-surface-offset); }
table.rank-table tbody tr.top-rank td:nth-child(1), table.rank-table tbody tr.top-rank td:nth-child(2) { background: var(--color-primary-highlight); }

.scroll-hint {
  display: none; align-items: center; gap: var(--space-2); justify-content: center;
  font-size: var(--text-xs); color: var(--color-text-faint); padding: var(--space-2) 0 var(--space-4);
}
.scroll-hint svg { width: 13px; height: 13px; animation: hint-shift 1.6s ease-in-out infinite; }
@keyframes hint-shift { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
table.rank-table thead th {
  text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 700; color: var(--color-text-muted); padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--color-border); background: var(--color-surface-offset);
  position: sticky; top: 0;
  white-space: nowrap;
}
table.rank-table tbody td { padding: var(--space-4) var(--space-4); border-bottom: 1px solid var(--color-divider); font-size: var(--text-sm); vertical-align: middle; line-height: 1.5; }
table.rank-table tbody tr:last-child td { border-bottom: none; }
table.rank-table tbody tr:hover { background: var(--color-surface-offset); }
table.rank-table tbody tr.top-rank { background: color-mix(in oklab, var(--color-primary-highlight) 55%, transparent); }
table.rank-table tbody tr.top-rank:hover { background: color-mix(in oklab, var(--color-primary-highlight) 80%, transparent); }

.rank-num { font-family: var(--font-mono); font-weight: 700; color: var(--color-text-muted); font-size: var(--text-sm); }
.top-rank .rank-num { color: var(--color-primary); }
.medal { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 700; background: var(--color-primary); color: var(--color-text-inverse); }

.model-cell { max-width: 200px; }
.model-cell strong { display: block; font-weight: 700; margin-bottom: var(--space-1); }
.model-cell .brand-tag { display: block; font-size: var(--text-xs); color: var(--color-text-muted); margin-bottom: var(--space-2); }
.model-cell a.src-link { font-size: var(--text-xs); color: var(--color-text-faint); text-decoration: none; }
.model-cell a.src-link:hover { color: var(--color-primary); text-decoration: underline; }

.mono { font-family: var(--font-mono); }
.price-cell { font-weight: 700; font-family: var(--font-mono); }
.muted { color: var(--color-text-muted); }
.faint { color: var(--color-text-faint); font-style: italic; }

.fit-badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-size: var(--text-xs); font-weight: 700; padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}
.fit-good { background: var(--color-success-highlight); color: var(--color-success); }
.fit-ok { background: var(--color-warning-highlight); color: var(--color-warning); }
.fit-bad { background: var(--color-error-highlight); color: var(--color-error); }

.score-cell { display: flex; align-items: center; gap: var(--space-2); min-width: 120px; }
.score-bar-track { flex: 1; height: 8px; border-radius: var(--radius-full); background: var(--color-surface-offset-2); overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: var(--radius-full); background: linear-gradient(90deg, var(--color-primary), color-mix(in oklab, var(--color-primary) 60%, white)); transition: width 220ms cubic-bezier(0.16,1,0.3,1); }
.score-num { font-family: var(--font-mono); font-weight: 700; font-size: var(--text-sm); min-width: 3ch; text-align: right; }

.buy-btn {
  display: inline-flex; align-items: center; gap: var(--space-1); white-space: nowrap;
  font-size: var(--text-xs); font-weight: 700; padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md); background: var(--color-primary); color: var(--color-text-inverse);
  text-decoration: none;
}
.buy-btn:hover { background: var(--color-primary-hover); }
.buy-btn svg { width: 12px; height: 12px; }

/* methodology + footer */
.methodology {
  margin-top: clamp(var(--space-10), 8vw, var(--space-16)); padding: clamp(var(--space-6), 4vw, var(--space-10)); border-radius: var(--radius-xl);
  background: var(--color-surface-offset); border: 1px solid var(--color-divider);
}
.methodology h3 { font-family: var(--font-display); font-size: var(--text-base); font-weight: 700; margin-bottom: var(--space-4); }
.methodology > p { margin-bottom: var(--space-2); }
.method-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-8); margin-block: var(--space-8); align-items: start; }
.method-item { display: flex; flex-direction: column; gap: var(--space-2); }
.methodology dt { font-size: var(--text-sm); font-weight: 700; color: var(--color-primary); }
.methodology dd { font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.6; }
.methodology p { font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.6; }

.sources-list { margin-top: var(--space-5); font-size: var(--text-xs); color: var(--color-text-faint); }
.sources-list a { color: var(--color-text-muted); }

footer.site-footer { margin-top: clamp(var(--space-12), 8vw, var(--space-20)); padding-block: clamp(var(--space-8), 6vw, var(--space-10)); border-top: 1px solid var(--color-divider); }
footer.site-footer p { font-size: var(--text-xs); color: var(--color-text-faint); max-width: 70ch; line-height: 1.6; }
footer.site-footer p + p { margin-top: var(--space-3); }

@media (max-width: 720px) {
  .hero h1 { font-size: var(--text-xl); }
  .room-size-box { flex-direction: column; align-items: stretch; gap: var(--space-5); }
  .room-size-box .field-group input[type="number"] { width: 100%; }
  .reset-btn { margin-left: 0; width: 100%; justify-content: center; }
  .controls-header { flex-direction: column; align-items: stretch; }
  .scroll-hint { display: flex; }

  /* Bigger touch targets for sliders on touch screens */
  input[type="range"] { height: 8px; }
  input[type="range"]::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -8px; }
  input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; }

  .buy-btn { padding: var(--space-3) var(--space-3); }
  table.rank-table thead th, table.rank-table tbody td { padding: var(--space-4); }
}

@media (max-width: 420px) {
  .pill { font-size: 0.7rem; padding: var(--space-1) var(--space-3); }
}
