:root {
  --paper: #f4f1e9;
  --paper-2: #ebe7dd;
  --ink: #17191d;
  --muted: #676b72;
  --line: #22252b;
  --line-soft: rgba(23, 25, 29, 0.24);
  --navy: #252447;
  --navy-2: #343260;
  --orange: #c85f2d;
  --orange-2: #da7541;
  --runtime: #4e4a71;
  --free: #f7f5ef;
  --danger: #a83d32;
  --success: #2b6b4d;
  --shadow: 0 16px 50px rgba(35, 31, 25, 0.11);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: #d8d4cb; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background:
    linear-gradient(rgba(255,255,255,.42), rgba(255,255,255,.42)),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(20,22,26,.025) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(20,22,26,.025) 39px 40px),
    #d9d5cb;
}

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

.page-shell {
  width: min(1600px, calc(100% - 28px));
  margin: 14px auto;
  min-height: calc(100vh - 28px);
  padding: 34px 46px 28px;
  background:
    linear-gradient(90deg, transparent 0 26px, rgba(28,29,33,.055) 26px 27px, transparent 27px calc(100% - 27px), rgba(28,29,33,.055) calc(100% - 27px) calc(100% - 26px), transparent calc(100% - 26px)),
    var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative;
}

.page-shell::before,
.page-shell::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  height: 10px;
  background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 72px);
  opacity: .55;
  pointer-events: none;
}
.page-shell::before { top: 0; }
.page-shell::after { bottom: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand-logo {
  height: 40px;
  width: auto;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .brand-logo { height: 32px; }
}

.header-vram {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.header-vram select {
  min-height: 40px;
  border: 1px solid var(--line-soft);
  background: rgba(255,255,255,.48);
  color: var(--ink);
  padding: 8px 10px;
  font: 500 12px/1.2 var(--mono);
  outline: none;
}
.header-vram select:focus { border-color: var(--orange); box-shadow: 0 0 0 2px rgba(200,95,45,.15); }
.header-vram .number-input { min-height: 40px; }
.header-vram .number-input input { width: 56px; }
.header-vram .range-input { width: 160px; }
@media (max-width: 700px) {
  .header-vram { width: 100%; }
  .header-vram .range-input { flex: 1; width: auto; }
}

.eyebrow {
  margin: 0 0 7px;
  font: 600 12px/1 var(--mono);
  letter-spacing: .16em;
  color: var(--muted);
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(31px, 4vw, 58px);
  line-height: .96;
  letter-spacing: -.045em;
  font-weight: 700;
}
h1 span { color: var(--orange); font-weight: 500; }

.promo-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 14px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  transition: background .15s ease;
}
.promo-banner:hover { background: var(--ink-soft, #1e2b23); }
.promo-copy { flex: 1; min-width: 200px; font-size: 14px; text-align: left; color: var(--orange); font-weight: 600; }
.promo-cta { font: 600 13px/1 var(--mono); flex-shrink: 0; }

.button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--paper);
  padding: 11px 15px;
  font: 600 13px/1 var(--mono);
  letter-spacing: .02em;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 3px 3px 0 rgba(23,25,29,.18); }
.button.secondary { background: transparent; color: var(--ink); }
.button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.icon-button {
  width: 40px; height: 40px; border: 1px solid var(--line); background: transparent; font-size: 28px; line-height: 1; cursor: pointer;
}

.panel {
  border: 1px solid var(--line);
  background: rgba(248, 246, 240, .84);
  position: relative;
}
.panel-label {
  position: absolute;
  top: -12px;
  left: 16px;
  padding: 2px 9px;
  background: var(--paper);
  border: 1px solid var(--line);
  font: 500 12px/1.4 var(--mono);
  letter-spacing: .04em;
}

.control-panel { padding: 28px 18px 18px; margin-bottom: 24px; }
.control-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
}
.field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font: 500 12px/1.2 var(--mono);
  letter-spacing: .02em;
  flex: 1 1 170px;
}
.field-model { flex: 2 1 320px; }
.field-half { flex: 0 0 140px; }
.field small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field small#modelDescription { display: block; white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.4; margin-top: 2px; }
.field input, .field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-soft);
  background: rgba(255,255,255,.48);
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 0;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--orange); box-shadow: 0 0 0 2px rgba(200,95,45,.15); }
.field-inline {
  flex: 1.6 1 300px;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.field-inline > span { flex-shrink: 0; }
.field-inline .range-input { flex: 1 1 auto; min-width: 90px; }
.number-input { display: flex; align-items: center; border: 1px solid var(--line-soft); background: rgba(255,255,255,.48); flex-shrink: 0; }
.number-input input { width: 76px; min-height: 34px; border: 0; background: transparent; padding: 4px 6px; text-align: right; }
.number-input span { padding-right: 8px; color: var(--muted); }
.context-input input { width: 90px; }

.combobox { position: relative; }
.combobox input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-soft);
  background: rgba(255,255,255,.48);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}
.combobox input:focus { border-color: var(--orange); box-shadow: 0 0 0 2px rgba(200,95,45,.15); }
.combobox-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 15;
}
.combobox-list[hidden] { display: none; }
.combobox-option { padding: 8px 12px; font: 500 12px/1.3 var(--mono); cursor: pointer; }
.combobox-option:hover, .combobox-option.active { background: rgba(200,95,45,.12); }
.combobox-empty { padding: 8px 12px; color: var(--muted); font: 500 12px/1.3 var(--mono); }
.range-input {
  appearance: none;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
}
.range-input::-webkit-slider-runnable-track { height: 3px; background: var(--line); }
.range-input::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; margin-top: -6px; background: var(--paper); border: 2px solid var(--orange); border-radius: 50%; }
.range-input::-moz-range-track { height: 3px; background: var(--line); }
.range-input::-moz-range-thumb { width: 14px; height: 14px; background: var(--paper); border: 2px solid var(--orange); border-radius: 50%; }

.hero-panel { padding: 32px 28px 24px; margin-bottom: 24px; overflow: hidden; }
.hero-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.tier { margin-bottom: 5px; color: var(--orange); font: 600 12px/1.2 var(--mono); letter-spacing: .12em; }
.hero-heading h2 { margin: 0; font-size: clamp(26px, 3.2vw, 46px); line-height: 1.05; letter-spacing: -.03em; }
.fit-chip { border: 1px solid var(--success); color: var(--success); padding: 8px 11px; font: 600 12px/1 var(--mono); letter-spacing: .1em; }
.fit-chip.warning { color: var(--orange); border-color: var(--orange); }
.fit-chip.danger { color: var(--danger); border-color: var(--danger); }

.budget-rule { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-bottom: 18px; font: 500 13px/1 var(--mono); }
.budget-rule::before, .budget-rule::after { content: ""; height: 1px; background: var(--line); }
.rule-end { display: none; }

.memory-stage { position: relative; padding-bottom: 72px; }
.memory-bar {
  height: clamp(118px, 13vw, 180px);
  display: flex;
  border: 2px solid var(--line);
  background: var(--free);
  overflow: hidden;
  position: relative;
}
.segment {
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width .35s ease;
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,.45);
}
.segment span { color: rgba(255,255,255,.86); font: 600 11px/1 var(--mono); letter-spacing: .08em; white-space: nowrap; opacity: 0; transition: opacity .2s ease; }
.segment[data-show-label="true"] span { opacity: 1; }
.segment.weights { background: linear-gradient(90deg, var(--navy), var(--navy-2)); }
.segment.kv { background: linear-gradient(90deg, #b95027, var(--orange-2)); }
.segment.overhead { background: var(--runtime); }
.segment.free {
  background: repeating-linear-gradient(135deg, rgba(23,25,29,.46) 0 2px, transparent 2px 11px), var(--free);
  border-right: 0;
}
.segment.free span { color: var(--ink); background: rgba(244,241,233,.82); padding: 4px 7px; }
.segment.overflow {
  display: none;
  background: repeating-linear-gradient(135deg, var(--danger) 0 8px, #c85e51 8px 16px);
  border-right: 0;
}
.budget-marker {
  display: none;
  position: absolute;
  top: -8px;
  bottom: -8px;
  width: 0;
  border-left: 2px dashed var(--danger);
  z-index: 4;
  pointer-events: none;
}
.budget-marker span {
  position: absolute;
  top: -22px;
  left: 5px;
  color: var(--danger);
  font: 600 9px/1 var(--mono);
  white-space: nowrap;
}
.memory-callouts { position: relative; height: 68px; }
.callout {
  position: absolute;
  top: 10px;
  transform: translateX(-50%);
  text-align: center;
  font: 500 12px/1.25 var(--mono);
  white-space: nowrap;
}
.callout::before { content: ""; display: block; margin: 0 auto 7px; width: 1px; height: 18px; background: var(--line); }
.callout strong { display: block; font-weight: 600; }
.callout small { color: var(--muted); }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.metric-strip article { padding: 15px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; }
.metric-strip span { display: block; color: var(--muted); font: 500 11px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.metric-strip strong { display: block; margin: 7px 0 3px; font: 600 clamp(22px, 2.3vw, 33px)/1 var(--mono); letter-spacing: -.04em; }
.metric-strip small { color: var(--muted); }

.analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.spec-panel { padding: 26px 14px 10px; }
.spec-list { margin: 0; }
.spec-list > div { display: grid; grid-template-columns: minmax(150px, .8fr) 1.2fr; gap: 18px; padding: 13px 10px; border-bottom: 1px solid var(--line-soft); }
.spec-list > div:last-child { border-bottom: 0; }
.spec-list dt { font: 600 13px/1.35 var(--mono); }
.spec-list dd { margin: 0; color: #33363d; font: 400 13px/1.45 var(--mono); overflow-wrap: anywhere; }

.lower-grid { grid-template-columns: 1.55fr .75fr; }
.chart-panel, .notes-panel { padding: 30px 24px 20px; }
.chart-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.chart-heading h3 { margin-bottom: 4px; font-size: 18px; }
.chart-heading p { max-width: 680px; margin-bottom: 0; color: var(--muted); font-size: 13px; }
.legend { display: flex; gap: 14px; white-space: nowrap; color: var(--muted); font: 500 11px/1 var(--mono); }
.legend span { display: flex; gap: 6px; align-items: center; }
.line { width: 20px; height: 2px; background: var(--orange); display: inline-block; }
.budget-line { background: var(--navy); border-top: 1px dashed var(--navy); }
#contextChart { width: 100%; height: auto; min-height: 250px; margin-top: 12px; overflow: visible; }

.freshness-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.freshness-dot { width: 10px; height: 10px; background: var(--success); border-radius: 50%; box-shadow: 0 0 0 4px rgba(43,107,77,.13); }
.freshness-dot.stale { background: var(--orange); box-shadow: 0 0 0 4px rgba(200,95,45,.13); }
.freshness-dot.old { background: var(--danger); box-shadow: 0 0 0 4px rgba(168,61,50,.13); }
.freshness-row strong, .freshness-row small { display: block; }
.freshness-row small { margin-top: 2px; color: var(--muted); }
.notes-panel > p { color: #3e4148; line-height: 1.55; }
.source-list { display: grid; gap: 8px; margin: 18px 0; }
.source-link { display: flex; justify-content: space-between; gap: 12px; color: var(--ink); text-decoration: none; padding: 9px 10px; border: 1px solid var(--line-soft); font: 500 12px/1.3 var(--mono); }
.source-link:hover { border-color: var(--orange); }
.source-link span:last-child { color: var(--muted); }
.method-note { padding-top: 14px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--muted) !important; }

footer { display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font: 500 11px/1.3 var(--mono); letter-spacing: .06em; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--paper);
  padding: 11px 15px;
  font: 500 12px/1.2 var(--mono);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1000px) {
  .page-shell { padding: 30px 26px 24px; }
  .lower-grid { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .page-shell { width: calc(100% - 12px); margin: 6px auto; padding: 24px 14px 20px; }
  .topbar, .hero-heading, .chart-heading { flex-direction: column; }
  .analysis-grid { grid-template-columns: 1fr; }
  .field-inline { flex-direction: column; align-items: stretch; }
  .field-half { flex: 1 1 100%; max-width: none; }
  .metric-strip { grid-template-columns: 1fr; }
  .memory-stage { padding-bottom: 95px; }
  .callout { font-size: 10px; white-space: normal; width: 100px; }
  .spec-list > div { grid-template-columns: 1fr; gap: 5px; }
  footer { flex-direction: column; }
}
