:root {
  color-scheme: light;
  --bg: #f5f8fc;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #0d2342;
  --muted: #5f7088;
  --line: #dce5f0;
  --line-strong: #c7d5e5;
  --primary: #1264e8;
  --primary-dark: #084ebc;
  --primary-soft: #eaf2ff;
  --cyan: #089dc0;
  --green: #098a52;
  --green-soft: #e9f8f0;
  --amber: #a45b00;
  --amber-soft: #fff4dd;
  --red: #c33a35;
  --red-soft: #fff0ef;
  --violet: #7150ce;
  --shadow: 0 14px 38px rgba(28, 58, 94, 0.08);
  --radius: 16px;
  --radius-small: 10px;
  --max-width: 1440px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
svg { display: block; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  transform: translateY(-150%);
  border-radius: 8px;
  background: var(--text);
  color: white;
  padding: 10px 14px;
}
.skip-link:focus { transform: translateY(0); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(210, 222, 236, 0.9);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}
.header-inner {
  width: min(calc(100% - 40px), var(--max-width));
  min-height: 74px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand strong { display: block; font-size: 18px; letter-spacing: -0.02em; }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 12px; }
.github-button,
.primary-button,
.secondary-button,
.text-button {
  border: 0;
  cursor: pointer;
  font-weight: 700;
}
.github-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 14px;
  background: white;
  text-decoration: none;
  font-size: 14px;
}
.github-button:hover { border-color: #93a8c0; background: var(--surface-soft); }
.github-button svg { width: 19px; height: 19px; fill: currentColor; }

main { width: min(calc(100% - 40px), var(--max-width)); margin: 0 auto; }
.hero { padding: 46px 2px 28px; }
.eyebrow,
.section-kicker {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.hero h1,
.content-heading h2,
.formula-section h2 {
  margin: 0;
  letter-spacing: -0.045em;
  line-height: 1.1;
}
.hero h1 { font-size: clamp(34px, 5vw, 56px); }
.hero > p:last-child { max-width: 790px; margin: 15px 0 0; color: var(--muted); font-size: clamp(16px, 2vw, 20px); }

.calculator-shell {
  display: grid;
  grid-template-columns: minmax(360px, 0.72fr) minmax(560px, 1.28fr);
  gap: 18px;
  align-items: start;
}
.results-column { min-width: 0; display: grid; gap: 18px; }
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.input-panel { padding: 24px; }
.result-panel, .chart-panel { padding: 24px; }
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.panel-heading h2 { margin: 0; font-size: 22px; letter-spacing: -0.025em; }
.text-button { padding: 7px 0; background: transparent; color: var(--primary); font-size: 13px; }
.text-button:hover { color: var(--primary-dark); }

.form-section { padding: 21px 0; border-top: 1px solid var(--line); }
.form-section:first-of-type { padding-top: 0; border-top: 0; }
.form-section h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 15px;
  font-size: 15px;
}
.form-section h3 > span {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
}
.form-grid { display: grid; gap: 13px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-width { grid-column: 1 / -1; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span:first-child { font-size: 12.5px; font-weight: 700; }
.field small,
.field-note { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 43px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: white;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.input-with-unit:focus-within,
select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(18, 100, 232, 0.12); outline: none; }
.input-with-unit input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 9px 11px;
  background: transparent;
  color: var(--text);
  font-weight: 650;
}
.input-with-unit b {
  display: flex;
  align-items: center;
  border-left: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 0 10px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
select {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: white;
  color: var(--text);
  padding: 9px 34px 9px 11px;
  font-weight: 650;
}
.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
  margin: 0 0 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: grid;
  place-items: center;
  min-height: 37px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.segmented input:checked + span { background: white; color: var(--primary); box-shadow: 0 2px 8px rgba(23, 55, 91, 0.09); }
.estimator { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); padding: 15px; }
.estimate-output {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 43px;
  grid-column: 1 / -1;
  border-radius: 9px;
  background: var(--primary-soft);
  padding: 9px 12px;
  color: var(--primary-dark);
}
.estimate-output span { font-size: 12px; font-weight: 700; }
.estimate-output strong { font-size: 18px; }
.form-error { margin: 2px 0 14px; border: 1px solid #f2bbb8; border-radius: 10px; background: var(--red-soft); color: #8d2723; padding: 11px 13px; font-size: 13px; }
.form-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 10px;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary-button { background: var(--primary); color: white; box-shadow: 0 8px 18px rgba(18, 100, 232, 0.22); }
.primary-button:hover { background: var(--primary-dark); }
.primary-button:disabled { opacity: 0.65; cursor: wait; }
.secondary-button { border: 1px solid var(--line-strong); background: white; color: var(--text); }
.secondary-button:hover { border-color: #8da5be; background: var(--surface-soft); }
.primary-button svg,
.secondary-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.compact { min-height: 40px; padding: 0 12px; font-size: 12px; }

.status-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 16px;
  background: var(--surface-soft);
}
.status-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: white; font-size: 20px; }
.status-label { display: block; margin-bottom: 2px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.status-card strong { display: block; font-size: 18px; }
.status-card p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.status-card.is-success { border-color: #9dd8bc; background: var(--green-soft); }
.status-card.is-success .status-icon { color: var(--green); }
.status-card.is-warning { border-color: #f0ce8c; background: var(--amber-soft); }
.status-card.is-warning .status-icon { color: var(--amber); }
.status-card.is-danger { border-color: #f1b2af; background: var(--red-soft); }
.status-card.is-danger .status-icon { color: var(--red); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
}
.metric { min-width: 0; padding: 17px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metric:nth-child(3n) { border-right: 0; }
.metric:nth-last-child(-n + 3) { border-bottom: 0; }
.metric span, .metric small { display: block; color: var(--muted); }
.metric span { min-height: 34px; font-size: 11.5px; font-weight: 700; }
.metric strong { display: block; margin: 2px 0; color: var(--primary); font-size: clamp(19px, 2vw, 26px); letter-spacing: -0.025em; white-space: nowrap; }
.metric.hot strong { color: var(--red); }
.metric small { font-size: 10.5px; }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.action-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 15px; background: var(--surface-soft); }
.action-icon { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.action-card small { display: block; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; }
.action-card strong { display: block; margin-top: 3px; font-size: 15px; }
.action-card p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.warning-list { display: grid; gap: 8px; margin-top: 13px; }
.notice { border-radius: 10px; padding: 10px 12px; background: var(--primary-soft); color: #234e86; font-size: 12px; }
.notice.warning { background: var(--amber-soft); color: #7a4907; }
.notice.danger { background: var(--red-soft); color: #842c28; }

.chart-note { color: var(--muted); font-size: 11px; }
.charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chart-card { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface-soft); }
.full-chart { grid-column: 1 / -1; }
.chart-title { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 9px; }
.chart-title strong { font-size: 13px; }
.chart-title span { color: var(--muted); font-size: 10.5px; text-align: right; }
.chart { width: 100%; min-height: 220px; overflow: hidden; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: #dfe8f2; stroke-width: 1; }
.chart .axis-label { fill: #718197; font-size: 10px; }
.chart .legend-label { fill: #43546b; font-size: 10px; font-weight: 700; }
.chart .target-line { stroke: #a45b00; stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .point-marker { stroke: white; stroke-width: 2; }
.chart-empty { display: grid; place-items: center; min-height: 210px; color: var(--muted); font-size: 12px; }

.content-section,
.formula-section,
.faq-section { margin-top: 68px; }
.content-heading { max-width: 760px; margin-bottom: 22px; }
.content-heading h2,
.formula-section h2 { font-size: clamp(28px, 3vw, 42px); }
.content-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.content-grid article { border: 1px solid var(--line); border-radius: var(--radius); background: white; padding: 25px; }
.content-number { color: var(--primary); font-size: 12px; font-weight: 800; }
.content-grid h3 { margin: 24px 0 8px; font-size: 18px; }
.content-grid p, .formula-section p { margin: 0; color: var(--muted); font-size: 14px; }
.formula-section { display: grid; grid-template-columns: 1fr minmax(320px, 0.7fr); gap: 28px; align-items: center; border-radius: 22px; background: #0d2342; color: white; padding: clamp(28px, 5vw, 54px); }
.formula-section p { margin-top: 13px; color: #bfd0e3; max-width: 650px; }
.formula-card { border: 1px solid rgba(255,255,255,.16); border-radius: 16px; background: rgba(255,255,255,.08); padding: 25px; }
.formula-card strong { display: block; color: #8ac2ff; font-size: clamp(25px, 3vw, 40px); }
.formula-card span { display: block; margin-top: 7px; color: #d5e2ef; font-size: 13px; }
.faq-list { display: grid; gap: 10px; }
.faq-list details { border: 1px solid var(--line); border-radius: 12px; background: white; padding: 0 18px; }
.faq-list summary { cursor: pointer; padding: 17px 0; font-weight: 750; }
.faq-list p { margin: -4px 0 17px; color: var(--muted); font-size: 14px; }
.site-footer { width: min(calc(100% - 40px), var(--max-width)); margin: 68px auto 0; border-top: 1px solid var(--line); padding: 24px 0 34px; color: var(--muted); text-align: center; font-size: 12px; }
.noscript { position: fixed; inset: auto 16px 16px; z-index: 100; border-radius: 10px; background: var(--red); color: white; padding: 12px 15px; }

@media (max-width: 1120px) {
  .calculator-shell { grid-template-columns: minmax(320px, 0.82fr) minmax(460px, 1.18fr); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(n) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-last-child(1) { border-bottom: 0; }
  .metric:nth-last-child(2) { border-bottom: 0; }
  .metric:last-child { grid-column: 1 / -1; border-right: 0; }
}

@media (max-width: 900px) {
  main, .header-inner, .site-footer { width: min(calc(100% - 28px), var(--max-width)); }
  .calculator-shell { grid-template-columns: 1fr; }
  .input-panel { order: 1; }
  .results-column { order: 2; }
  .content-grid { grid-template-columns: 1fr; }
  .formula-section { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  main, .header-inner, .site-footer { width: min(calc(100% - 20px), var(--max-width)); }
  .header-inner { min-height: 64px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand strong { font-size: 14px; }
  .brand small { display: none; }
  .github-button { width: 42px; padding: 0; justify-content: center; font-size: 0; }
  .hero { padding-top: 34px; }
  .hero h1 { font-size: 35px; }
  .input-panel, .result-panel, .chart-panel { padding: 17px; }
  .two-columns, .action-grid, .charts-grid { grid-template-columns: 1fr; }
  .full-chart { grid-column: auto; }
  .result-heading { align-items: center; }
  .result-heading .compact { width: 42px; padding: 0; font-size: 0; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { padding: 14px; }
  .metric span { min-height: 38px; }
  .metric strong { font-size: 19px; }
  .form-actions { grid-template-columns: 1fr; }
  .formula-section { border-radius: 16px; }
  .chart-title { display: block; }
  .chart-title span { display: block; margin-top: 2px; text-align: left; }
}

@media (max-width: 420px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric:nth-child(n) { grid-column: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .segmented { grid-template-columns: 1fr; }
}

@media print {
  body { background: white; }
  .site-header, .hero, .input-panel, .chart-panel, .content-section, .formula-section, .faq-section, .site-footer, .result-heading button { display: none !important; }
  main { width: 100%; }
  .calculator-shell { display: block; }
  .result-panel { border: 0; box-shadow: none; padding: 0; }
  .result-panel::before { content: "Thermoelectric Cooler Calculator — Design Result"; display: block; margin-bottom: 20px; font-size: 24px; font-weight: 800; }
}
