:root {
  --paper: #f2f1e9;
  --paper-strong: #fbfaf5;
  --ink: #17211e;
  --muted: #6f7974;
  --line: #d4d6ce;
  --orange: #f47a52;
  --orange-soft: #ffe0d4;
  --blue: #3e78f7;
  --blue-soft: #e8efff;
  --green: #00a77d;
  --green-soft: #ddf5ed;
  --yellow: #f7c94b;
  --violet: #7654e8;
  --shadow: 0 18px 46px rgb(32 43 39 / 9%);
  color-scheme: light;
  font-family: Inter, "Avenir Next", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgb(62 120 247 / 10%), transparent 28%),
    radial-gradient(circle at 96% 3%, rgb(244 122 82 / 14%), transparent 32%),
    var(--paper);
}

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

.page {
  width: min(1536px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 32px 40px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px 24px;
  margin-bottom: 20px;
}

.hero-title { grid-column: 1 / -1; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 8px;
  color: #3452a0;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .16em;
}

.eyebrow i {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--blue);
  border-radius: 5px;
}

.eyebrow i::before,
.eyebrow i::after {
  position: absolute;
  content: "";
  background: var(--orange);
  border-radius: 999px;
}

.eyebrow i::before { inset: 3px 3px auto; height: 3px; }
.eyebrow i::after { inset: 8px 3px auto; height: 3px; width: 7px; }

h1 {
  margin: 0;
  font-size: clamp(46px, 5.55vw, 86px);
  line-height: .94;
  letter-spacing: normal;
  text-wrap: balance;
}

.lead {
  grid-column: 1;
  margin: 0;
  color: var(--muted);
  font-size: clamp(16px, 1.55vw, 24px);
  font-weight: 800;
}

.lead code {
  color: #d95531;
  background: transparent;
  font-family: inherit;
  font-weight: 900;
}

.hero-actions {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: end;
}

.button,
.support-chip {
  min-height: 46px;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.support-chip {
  display: inline-flex;
  align-items: center;
  padding: 0 15px;
  color: #245a49;
  background: var(--green-soft);
  border: 1px solid #9bd9c6;
}

.button {
  padding: 0 18px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: white;
  box-shadow: 0 4px 12px rgb(30 38 35 / 5%);
}

.button:hover { transform: translateY(-1px); }
.button--quiet { background: var(--paper-strong); }
.button--dark { color: white; background: var(--ink); border-color: var(--ink); }
.button--coral { color: white; background: var(--orange); border-color: var(--orange); }

.studio {
  display: grid;
  grid-template-columns: minmax(350px, 440px) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.control-card,
.preview-card,
.output-card {
  overflow: hidden;
  background: rgb(251 250 245 / 94%);
  border: 1px solid #d7d7cf;
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.result-stack { display: grid; gap: 18px; min-width: 0; }

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head--wide { padding-inline: 24px; }
.panel-head--wide > div { margin-right: auto; }

.panel-head p {
  margin: 0 0 2px;
  color: #a54c36;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: .12em;
}

.panel-head h2 {
  margin: 0;
  font-size: clamp(17px, 1.35vw, 22px);
  line-height: 1.12;
}

.section-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  color: white;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 950;
}

.section-mark--orange { background: var(--orange); }
.section-mark--blue { background: var(--blue); }
.section-mark--coral { background: var(--orange); }

.control-section {
  padding: 22px 20px;
  border-bottom: 1px solid var(--line);
}

.control-section:last-child { border-bottom: 0; }

.control-title,
.range-control label,
.toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.control-title { margin-bottom: 14px; }

.control-title span,
.range-control small,
.toggle-row small,
.viewport-control label span,
.formula-note > span {
  display: block;
  margin-bottom: 3px;
  color: #a54c36;
  font-size: 9px;
  font-weight: 950;
  letter-spacing: .12em;
}

.control-title h3,
.range-control b,
.toggle-row b {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.control-title output,
.range-control output,
#presetOutput {
  color: #5b45c5;
  font-size: 11px;
  font-weight: 900;
}

.segmented {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 4px;
  background: #ebeae4;
  border: 1px solid #d1d2cb;
  border-radius: 13px;
}

.segmented button {
  position: relative;
  z-index: 1;
  min-height: 40px;
  padding: 0 10px;
  cursor: pointer;
  border: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 900;
}

.segment-indicator {
  position: absolute;
  z-index: 0;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: white;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgb(24 32 29 / 9%);
  translate: var(--indicator-x, 0) 0;
  transition: translate 260ms cubic-bezier(.2,.75,.25,1);
}

.hint {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.preset-grid button {
  display: grid;
  place-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 92px;
  padding: 10px 4px 8px;
  cursor: pointer;
  border: 1px solid #d6d7d0;
  border-radius: 14px;
  background: white;
}

.preset-grid button[aria-pressed="true"] {
  background: var(--orange-soft);
  border-color: var(--orange);
  box-shadow: inset 0 0 0 1px var(--orange);
}

.preset-grid span { font-size: 10px; font-weight: 900; }
.preset-grid small { color: var(--muted); font-size: 8px; font-weight: 800; }

.preset-icon {
  position: relative;
  display: block;
  width: 36px;
  height: 30px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: var(--blue-soft);
}

.preset-icon::before,
.preset-icon::after { position: absolute; content: ""; }
.preset-icon::before { inset: 5px 5px auto; height: 7px; background: var(--blue); border-radius: 3px; }
.preset-icon::after { left: 5px; right: 9px; bottom: 5px; height: 3px; background: var(--ink); border-radius: 999px; }
.preset-icon--compact { width: 40px; height: 24px; }
.preset-icon--article { width: 38px; height: 32px; border-radius: 12px 12px 6px 6px; }
.preset-icon--dashboard { background: linear-gradient(90deg, var(--blue-soft) 0 46%, white 46% 54%, var(--orange-soft) 54%); }

.range-section { display: grid; gap: 22px; }
.range-control { display: grid; gap: 10px; }
.range-control label { align-items: end; }
.range-control label span { min-width: 0; }
.range-control output { flex: 0 0 auto; }

input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 0;
  cursor: pointer;
  appearance: none;
  background: linear-gradient(90deg, var(--orange) var(--range-fill, 50%), #dadbd4 var(--range-fill, 50%));
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  width: 17px;
  height: 17px;
  appearance: none;
  background: white;
  border: 4px solid var(--orange);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgb(35 42 39 / 20%);
}

.toggle-row { align-items: center; cursor: pointer; }
.toggle-row span { display: grid; }
.toggle-row em { margin-top: 3px; color: var(--muted); font-size: 10px; font-style: normal; font-weight: 700; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row i { position: relative; flex: 0 0 auto; width: 48px; height: 28px; background: #d9dad4; border-radius: 999px; transition: background 180ms ease; }
.toggle-row i::after { position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; content: ""; background: white; border-radius: 50%; box-shadow: 0 2px 7px rgb(30 38 35 / 18%); transition: translate 180ms ease; }
.toggle-row input:checked + i { background: var(--green); }
.toggle-row input:checked + i::after { translate: 20px 0; }
.toggle-row input:focus-visible + i { outline: 3px solid rgb(62 120 247 / 30%); outline-offset: 2px; }

.compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  color: #3152a5;
  background: var(--blue-soft);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: .08em;
  white-space: nowrap;
}

.compare-chip i { width: 18px; height: 9px; border: 2px solid var(--blue); border-radius: 50%; }

.viewport-control {
  display: grid;
  grid-template-columns: auto minmax(130px, .7fr) minmax(180px, 1.4fr);
  align-items: center;
  gap: 10px 16px;
  padding: 16px 22px;
  background: #f0f0ea;
  border-bottom: 1px solid var(--line);
}

.viewport-presets { display: flex; gap: 5px; }
.viewport-presets button {
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 900;
}
.viewport-presets button[aria-pressed="true"] { color: var(--ink); background: white; border-color: #d4d5ce; box-shadow: 0 2px 8px rgb(30 38 35 / 7%); }

.viewport-control label { display: flex; align-items: end; justify-content: space-between; gap: 10px; }
.viewport-control label span { margin: 0; }
.viewport-control label output { color: var(--blue); font-size: 14px; font-weight: 950; }
.viewport-control > input[type="range"] { --range-color: var(--blue); background: linear-gradient(90deg, var(--blue) var(--range-fill, 100%), #d5d7d2 var(--range-fill, 100%)); }
.viewport-control > input[type="range"]::-webkit-slider-thumb { border-color: var(--blue); }

.ruler {
  grid-column: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: -4px;
  color: #909892;
  font-size: 8px;
  font-weight: 800;
}
.ruler i { flex: 1; height: 1px; background: #c9ccc7; }

.comparison-stack {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  background:
    linear-gradient(rgb(27 34 31 / 5%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(27 34 31 / 5%) 1px, transparent 1px),
    #f8f8f3;
  background-size: 24px 24px;
}

.comparison {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr) 148px;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 14px;
  background: rgb(255 255 255 / 88%);
  border: 1px solid #d6d8d2;
  border-radius: 17px;
}

.comparison--fluid { background: rgb(232 239 255 / 91%); border-color: #a9bdf7; }

.comparison > header { min-width: 0; }
.comparison > header > div > span { display: block; margin-bottom: 3px; color: #9a4f3b; font-size: 9px; font-weight: 950; letter-spacing: .1em; }
.comparison > header h3 { margin: 0 0 10px; font-size: 17px; white-space: nowrap; }
.comparison > header code { color: var(--blue); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }

.status-badge { display: inline-flex; padding: 6px 9px; color: #26705a; background: var(--green-soft); border-radius: 999px; font-size: 9px; font-weight: 950; letter-spacing: .08em; }
.status-badge[data-state="warning"] { color: #a13926; background: var(--orange-soft); }
.status-badge--fluid { color: #3152a5; background: white; }

.viewport-shell {
  position: relative;
  min-width: 0;
  overflow: hidden;
  height: 164px;
  background: white;
  border: 1px solid #d6d8d2;
  border-radius: 13px;
}

.viewport-shell::before,
.viewport-shell::after {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  width: 1px;
  content: "";
  background: rgb(62 120 247 / 26%);
  pointer-events: none;
}
.viewport-shell::before { left: 8px; }
.viewport-shell::after { right: 8px; }

.demo-canvas {
  position: absolute;
  top: 11px;
  left: 50%;
  width: 1080px;
  height: 184px;
  padding: 10px;
  transform: translateX(-50%) scale(var(--canvas-scale, .5));
  transform-origin: top center;
  transition: width 180ms ease, transform 180ms ease;
}

.demo-grid { display: grid; gap: var(--demo-gap, 20px); height: 100%; }

.demo-card {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 8px 11px;
  min-width: 0;
  min-height: 96px;
  padding: 12px;
  overflow: hidden;
  background: white;
  border: 2px solid var(--ink);
  border-radius: 14px;
  box-shadow: 5px 5px 0 rgb(23 33 30 / 10%);
}

.demo-card::before { grid-row: 1 / span 2; width: 46px; height: 46px; content: ""; background: var(--card-color); border: 2px solid var(--ink); border-radius: 11px; }
.demo-card strong { align-self: end; min-width: 0; overflow: hidden; font-size: 16px; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
.demo-card span { align-self: start; height: 7px; width: min(82px, 70%); background: #ccd0ca; border-radius: 999px; }
.demo-card:nth-child(4n + 1) { --card-color: var(--orange); }
.demo-card:nth-child(4n + 2) { --card-color: var(--blue); }
.demo-card:nth-child(4n + 3) { --card-color: var(--yellow); }
.demo-card:nth-child(4n + 4) { --card-color: var(--green); }
.demo-card[data-warning="true"] { background: #fff2ed; border-color: #c14a32; box-shadow: 5px 5px 0 rgb(193 74 50 / 13%); }
.demo-card[data-ghost="true"] { opacity: .32; background: transparent; border-style: dashed; box-shadow: none; }

.comparison footer { min-width: 0; }
.comparison footer span { display: block; color: var(--muted); font-size: 9px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.comparison footer b { display: block; margin: 3px 0 6px; font-size: 20px; }
.comparison footer p { margin: 0; color: var(--muted); font-size: 10px; font-weight: 700; line-height: 1.45; }

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 18px 18px;
}

.metric-row > div { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 0 7px; min-width: 0; padding: 12px 14px; background: white; border: 1px solid var(--line); border-radius: 13px; }
.metric-row span { grid-column: 1 / -1; color: #3b5aa8; font-size: 8px; font-weight: 950; letter-spacing: .1em; }
.metric-row strong { font-size: 22px; line-height: 1; }
.metric-row small { color: var(--muted); font-size: 8px; font-weight: 800; }

.panel-head--dark { color: white; background: #101a17; border-color: #2e3733; }
.panel-head--dark p { color: var(--orange); }
.panel-head--dark .button { margin-left: auto; }

.output-card { background: #101a17; }
.output-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(230px, .7fr); gap: 14px; padding: 16px; }
.code-pane { min-width: 0; height: 290px; overflow: auto; background: #07100d; border: 1px solid #34403b; border-radius: 15px; }
pre { margin: 0; padding: 19px 20px; }
pre code { color: #f3f5ef; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; line-height: 1.65; white-space: pre; }

.formula-note { display: flex; flex-direction: column; min-width: 0; padding: 19px; color: #e8ece8; background: #192720; border: 1px solid #385044; border-radius: 15px; }
.formula-note > span { color: var(--yellow); }
.formula-note > strong { margin: 3px 0 12px; font-size: 27px; }
.formula-note > p { margin: 0; color: #b9c3bd; font-size: 12px; font-weight: 700; line-height: 1.65; }
.formula-note > div { margin-top: auto; padding: 13px; background: #0b1511; border-radius: 11px; }
.formula-note small { display: block; margin-bottom: 5px; color: #91a39a; font-size: 8px; font-weight: 900; letter-spacing: .1em; }
.formula-note code { color: var(--yellow); font-size: 12px; font-weight: 850; overflow-wrap: anywhere; }

button:focus-visible,
input:focus-visible { outline: 3px solid rgb(62 120 247 / 32%); outline-offset: 2px; }

@media (max-width: 1120px) {
  .page { padding-inline: 22px; }
  .hero { grid-template-columns: 1fr; }
  .hero-actions { grid-column: 1; grid-row: auto; flex-wrap: wrap; }
  .studio { grid-template-columns: minmax(320px, 380px) minmax(0, 1fr); }
  .comparison { grid-template-columns: 135px minmax(0, 1fr); }
  .comparison footer { grid-column: 1 / -1; display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 8px; }
  .comparison footer b { margin: 0; }
  .viewport-control { grid-template-columns: 1fr 1fr; }
  .viewport-control > input[type="range"] { grid-column: 1 / -1; }
  .ruler { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .page { padding: 18px 14px 32px; }
  h1 { font-size: clamp(42px, 10.5vw, 68px); }
  .studio { grid-template-columns: 1fr; }
  .control-card { order: 1; }
  .result-stack { order: 0; }
  .output-layout { grid-template-columns: 1fr; }
  .formula-note { min-height: 220px; }
}

@media (max-width: 560px) {
  .page { padding-inline: 10px; }
  .hero { margin-bottom: 14px; }
  h1 { font-size: clamp(39px, 13vw, 58px); line-height: .96; }
  .lead { font-size: 15px; }
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .support-chip { grid-column: 1 / -1; justify-content: center; }
  .button { padding-inline: 12px; }
  .control-card, .preview-card, .output-card { border-radius: 18px; }
  .panel-head, .panel-head--wide { min-height: 68px; padding: 13px 14px; }
  .section-mark { width: 38px; height: 38px; }
  .compare-chip { display: none; }
  .control-section { padding: 18px 14px; }
  .preset-grid { grid-template-columns: repeat(2, 1fr); }
  .preset-grid button { min-height: 82px; }
  .viewport-control { grid-template-columns: 1fr; padding: 14px; }
  .viewport-control > input[type="range"], .ruler { grid-column: 1; }
  .comparison-stack { padding: 10px; }
  .comparison { grid-template-columns: 1fr; gap: 10px; padding: 11px; }
  .comparison > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .comparison > header h3 { margin: 0; }
  .comparison footer { grid-column: 1; grid-template-columns: auto auto; }
  .comparison footer p { grid-column: 1 / -1; }
  .metric-row { grid-template-columns: repeat(2, 1fr); padding: 0 10px 10px; }
  .metric-row > div { padding: 10px; }
  .output-layout { padding: 10px; }
  .code-pane { height: 250px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
