:root {
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #20211f;
  --muted: #666b63;
  --line: #dcded7;
  --accent: #2f6f73;
  --accent-dark: #204e52;
  --accent-soft: #dbeaea;
  --amber: #b36b2c;
  --active-ink: #ffffff;
  --shadow: 0 18px 60px rgba(32, 33, 31, 0.08);
  --grid-line: rgba(32, 33, 31, 0.035);
  --grid-line-2: rgba(32, 33, 31, 0.03);
  --header-bg: rgba(247, 247, 244, 0.92);
  --panel-bg: rgba(255, 255, 255, 0.86);
  --control-bg: rgba(255, 255, 255, 0.72);
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171815;
  --panel: #20221f;
  --ink: #eeeee7;
  --muted: #afb4aa;
  --line: #3a3d36;
  --accent: #78aeb1;
  --accent-dark: #9fc8ca;
  --accent-soft: #263f40;
  --amber: #d59a62;
  --active-ink: #111310;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
  --grid-line: rgba(238, 238, 231, 0.045);
  --grid-line-2: rgba(238, 238, 231, 0.035);
  --header-bg: rgba(23, 24, 21, 0.92);
  --panel-bg: rgba(32, 34, 31, 0.88);
  --control-bg: rgba(32, 34, 31, 0.78);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #171815;
    --panel: #20221f;
    --ink: #eeeee7;
    --muted: #afb4aa;
    --line: #3a3d36;
    --accent: #78aeb1;
    --accent-dark: #9fc8ca;
    --accent-soft: #263f40;
    --amber: #d59a62;
    --active-ink: #111310;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
    --grid-line: rgba(238, 238, 231, 0.045);
    --grid-line-2: rgba(238, 238, 231, 0.035);
    --header-bg: rgba(23, 24, 21, 0.92);
    --panel-bg: rgba(32, 34, 31, 0.88);
    --control-bg: rgba(32, 34, 31, 0.78);
  }
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(var(--grid-line-2) 1px, transparent 1px),
    var(--bg);
  background-size: 42px 42px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 240px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.98rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.header-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.case-tabs,
.view-tabs,
.theme-control {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
  overflow-x: auto;
}

.case-tab,
.view-tab,
.reset-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
}

.case-tab,
.view-tab {
  padding: 0 14px;
  white-space: nowrap;
}

.case-tab:hover,
.case-tab:focus-visible,
.view-tab:hover,
.view-tab:focus-visible {
  background: var(--accent-soft);
}

.case-tab.is-active,
.view-tab.is-active {
  color: var(--active-ink);
  background: var(--accent);
}

.theme-control {
  flex: 0 0 auto;
  padding-left: 10px;
}

.theme-control span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.theme-control select {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.layout,
.about-layout {
  display: grid;
  width: min(1180px, calc(100% - 32px));
  margin: 34px auto 56px;
}

.layout {
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: clamp(22px, 4vw, 48px);
  align-items: start;
}

.about-layout {
  grid-template-columns: minmax(0, 820px);
  justify-content: center;
}

.is-hidden {
  display: none;
}

.summary-panel {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.15;
}

h1 {
  margin-bottom: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.1rem, 5vw, 4.4rem);
  font-weight: 500;
}

h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 500;
}

h3 {
  margin: 0;
  font-size: 1.05rem;
}

.case-goal,
.method-note,
.score-note,
.slider-description {
  color: var(--muted);
}

.case-goal {
  max-width: 46ch;
  margin-bottom: 0;
}

.score-card,
.calculator-panel,
.about-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
}

.score-card {
  padding: 24px;
}

.score-label,
.score-scale {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

#score-value {
  display: block;
  margin: 2px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 8vw, 5.6rem);
  font-weight: 500;
  line-height: 1;
}

meter {
  width: 100%;
  height: 12px;
  margin: 20px 0 12px;
}

meter::-webkit-meter-bar {
  border: 0;
  border-radius: 999px;
  background: #e7e8e2;
}

meter::-webkit-meter-optimum-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--amber), var(--accent));
}

meter::-moz-meter-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--amber), var(--accent));
}

.method-note {
  padding-left: 16px;
  border-left: 3px solid var(--accent);
  font-size: 0.94rem;
}

.calculator-panel,
.about-panel {
  padding: clamp(18px, 3vw, 30px);
}

.about-panel {
  font-size: 1.03rem;
}

.about-panel h1 {
  max-width: 12ch;
}

.about-panel h2 {
  margin-top: 34px;
  margin-bottom: 12px;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
}

.about-panel p,
.about-panel li {
  max-width: 72ch;
}

.about-panel a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.about-panel li + li {
  margin-top: 10px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.reset-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.reset-button:hover,
.reset-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.groups {
  display: grid;
  gap: 24px;
}

.group {
  display: grid;
  gap: 14px;
}

.group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.group-score {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.slider-list {
  display: grid;
  gap: 10px;
}

.slider-row {
  display: grid;
  grid-template-columns: minmax(150px, 230px) 1fr 48px;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.slider-copy {
  min-width: 0;
}

.slider-title {
  display: block;
  font-weight: 700;
}

.slider-description {
  display: block;
  margin-top: 2px;
  font-size: 0.88rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.slider-value {
  color: var(--accent-dark);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

@media (max-width: 860px) {
  .site-header,
  .layout,
  .toolbar,
  .group-header {
    align-items: stretch;
  }

  .site-header {
    position: static;
    flex-direction: column;
  }

  .brand,
  .header-controls,
  .case-tabs,
  .view-tabs {
    width: 100%;
  }

  .header-controls {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .case-tabs {
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
    margin-top: 24px;
  }

  .summary-panel {
    position: static;
  }

  .toolbar,
  .group-header {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .slider-row {
    grid-template-columns: 1fr 48px;
  }

  .slider-copy {
    grid-column: 1 / -1;
  }
}
