:root {
  --ink: #18211f;
  --muted: #68706d;
  --paper: #f6f3ed;
  --card: #fffefa;
  --line: #d9d6ce;
  --orange: #e96933;
  --teal: #168b83;
  --violet: #7658c7;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--paper); font-family: Manrope, system-ui, sans-serif; }
button, input { font: inherit; }
button { color: inherit; }
.topbar { height: 72px; padding: 0 clamp(22px, 4vw, 64px); display: flex; align-items: center; border-bottom: 1px solid var(--line); background: rgba(246,243,237,.92); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { display: flex; align-items: end; gap: 2px; width: 25px; height: 25px; padding: 4px; border: 1px solid var(--ink); border-radius: 50%; transform: rotate(-8deg); }
.brand-mark i { display: block; width: 4px; border-radius: 3px; background: var(--ink); }
.brand-mark i:nth-child(1) { height: 8px; } .brand-mark i:nth-child(2) { height: 16px; } .brand-mark i:nth-child(3) { height: 11px; }
.tagline { margin-left: 20px; padding-left: 20px; border-left: 1px solid var(--line); color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.icon-button { margin-left: auto; width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; transition: .2s; }
.icon-button:hover { border-color: var(--ink); background: white; transform: rotate(-8deg); }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
main { max-width: 1440px; margin: auto; padding: clamp(36px, 5vw, 72px) clamp(22px, 4vw, 64px) 50px; }
.intro { display: grid; grid-template-columns: 1.2fr .8fr; align-items: end; gap: 50px; margin-bottom: 38px; }
.eyebrow, .step-label { margin: 0 0 12px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 11px; font-weight: 500; letter-spacing: .12em; }
h1 { margin: 0; max-width: 700px; font-size: clamp(43px, 5.2vw, 76px); line-height: .97; letter-spacing: -.055em; }
h1 em { color: var(--teal); font-family: Georgia, serif; font-weight: 400; }
.intro-copy { max-width: 470px; margin: 0 0 5px; color: var(--muted); font-size: 16px; line-height: 1.7; }
.workspace { display: grid; grid-template-columns: minmax(400px, .82fr) minmax(480px, 1.18fr); min-height: 590px; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--card); box-shadow: 0 24px 70px rgba(35,31,24,.07); }
.definition-card, .graph-card { padding: clamp(25px, 3vw, 42px); }
.definition-card { border-right: 1px solid var(--line); }
.card-heading { display: flex; justify-content: space-between; align-items: start; }
.card-heading h2 { margin: 0; font-size: 24px; letter-spacing: -.035em; }
.text-button { border: 0; border-bottom: 1px solid var(--ink); background: none; padding: 3px 0; font-size: 12px; cursor: pointer; }
.piecewise-editor { display: grid; grid-template-columns: 58px 34px 1fr; align-items: center; min-height: 300px; margin: 16px 0 20px; }
.fx-label { font-family: Georgia, serif; font-size: 21px; white-space: nowrap; }
.fx-label span { font-size: 29px; font-style: italic; }
.brace { align-self: stretch; display: flex; align-items: center; overflow: visible; font-family: Georgia, serif; font-size: 224px; font-weight: 200; line-height: 1; transform: scaleX(.45); transform-origin: center; }
.rules { display: grid; gap: 22px; padding-left: 4px; }
.rule { --color: var(--orange); position: relative; display: grid; grid-template-columns: minmax(100px, 1fr) auto; align-items: center; gap: 12px; color: var(--color); }
.rule::before { content: ''; position: absolute; left: -16px; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.expression-wrap { position: relative; }
.expression { width: 100%; min-width: 0; padding: 9px 8px 8px; color: inherit; border: 0; border-bottom: 1.5px solid currentColor; border-radius: 0; outline: none; background: transparent; font-family: "DM Mono", monospace; font-size: 18px; }
.expression::placeholder { color: color-mix(in srgb, currentColor 45%, transparent); }
.expression:focus { background: color-mix(in srgb, currentColor 5%, transparent); }
.condition { display: flex; align-items: center; gap: 4px; font-family: "DM Mono", monospace; font-size: 13px; white-space: nowrap; }
.bound { width: 42px; padding: 6px 2px; border: 0; border-bottom: 1px solid currentColor; color: inherit; background: transparent; outline: none; text-align: center; }
.bound:disabled { width: 23px; border: 0; opacity: .8; }
.ineq { min-width: 24px; height: 28px; padding: 0 3px; border: 1px solid transparent; border-radius: 5px; color: inherit; background: color-mix(in srgb, currentColor 9%, transparent); font-family: "DM Mono", monospace; font-weight: 600; cursor: pointer; }
.ineq:hover { border-color: currentColor; }
.hint-box { display: flex; gap: 12px; padding: 15px 16px; border: 1px solid #d9d6ce; border-radius: 10px; background: #f7f5ef; }
.hint-box svg { flex: 0 0 19px; width: 19px; fill: none; stroke: var(--orange); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.hint-box p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.hint-box strong { color: var(--ink); }
.message { min-height: 18px; margin-top: 10px; color: #b24e27; font-size: 11px; }
.graph-card { display: flex; flex-direction: column; min-width: 0; background: #fbfaf6; }
.graph-heading { align-items: center; }
.graph-controls { display: flex; align-items: center; gap: 9px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; }
.icon-button.small { margin: 0; width: 30px; height: 30px; border-radius: 8px; font-size: 18px; }
.icon-button.small:hover { transform: none; }
.canvas-wrap { position: relative; flex: 1; min-height: 430px; margin-top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
canvas { display: block; width: 100%; height: 100%; }
.empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; transition: opacity .2s; }
.empty-state.hidden { opacity: 0; }
.empty-icon { width: 50px; height: 50px; margin-bottom: 13px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--teal); font-size: 22px; }
.empty-state strong { font-size: 13px; } .empty-state small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 15px; color: var(--muted); font-size: 10px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border: 2px solid var(--ink); border-radius: 50%; }
.dot.closed { background: var(--ink); }
.line { width: 15px; border-top: 1px solid var(--ink); } .line.dashed { border-top-style: dashed; }
.notice { display: flex; align-items: center; gap: 25px; margin-top: 22px; padding: 18px 24px; border-radius: 11px; color: #e9f4f1; background: #183f3b; }
.notice span { flex: none; font-family: "DM Mono", monospace; color: #8ec0b9; font-size: 10px; letter-spacing: .1em; }
.notice p { margin: 0; font-size: 13px; }

@media (max-width: 960px) {
  .intro { grid-template-columns: 1fr; gap: 20px; }
  .workspace { grid-template-columns: 1fr; }
  .definition-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .canvas-wrap { min-height: 470px; }
}
@media (max-width: 560px) {
  .tagline { display: none; }
  main { padding-inline: 13px; }
  .definition-card, .graph-card { padding: 23px 16px; }
  .piecewise-editor { grid-template-columns: 47px 21px 1fr; }
  .brace { font-size: 205px; }
  .rule { grid-template-columns: 1fr; gap: 3px; }
  .condition { justify-content: flex-end; }
  .notice { align-items: flex-start; flex-direction: column; gap: 8px; }
}
