/* Under the Limit - ruled notebook paper, a red editing pencil, a blue one for what comes in. */
:root {
  --bg: #f4efe4; --paper: #fffdf7; --paper2: #f8f3e8; --ink: #20263a; --ink2: #3c4256; --muted: #6f6a5e; --rule: #e2d9c6; --rule2: #ece4d3;
  --red: #c0392b; --red-soft: #f7ddd7; --blue: #2b5ea8; --blue-soft: #dde8f8; --green: #2f7a4f; --green-soft: #dcefe2; --amber: #a86a12; --amber-soft: #f6e8cc;
  --blk0: #2f3b5c; --blk1: #4a5a85; --blk2: #5d6c98; --blk3: #3c4a72; --hatch: #c0392b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 0 rgba(32, 38, 58, .04), 0 6px 18px -12px rgba(32, 38, 58, .25);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #15161b; --paper: #1d1f26; --paper2: #24262e; --ink: #ece6d8; --ink2: #cfc8b8; --muted: #9c9686; --rule: #343743; --rule2: #2b2d36;
  --red: #ff7b67; --red-soft: #4a2420; --blue: #8db4ff; --blue-soft: #1f2d48; --green: #7fd29e; --green-soft: #1c3527; --amber: #f0b45a; --amber-soft: #3d2f17;
  --blk0: #5d6ea6; --blk1: #4b5b90; --blk2: #3e4c7c; --blk3: #6f80b8; --hatch: #ff7b67;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 20px -14px rgba(0, 0, 0, .8);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); overflow-x: hidden; }
a { color: var(--blue); }
.hidden { display: none !important; }
.small { font-size: 13px; } .muted { color: var(--muted); } .mono { font-family: var(--mono); }
.warn { color: var(--red); } .okc { color: var(--green); }
button { font: inherit; }

/* Header */
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--rule); }
.back { font-size: 13px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: 19px; }
.logo { width: 22px; height: 22px; fill: var(--ink); } .logo .tip { fill: var(--red); }
.session { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); font-size: 13px; text-decoration: none; cursor: pointer; line-height: 1.2; }
.pill:hover { border-color: var(--ink2); }
.pill.solid { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pill.solid:hover { background: var(--ink2); }
.pill.ghost { background: transparent; cursor: default; }
.pill.tiny { padding: 3px 9px; font-size: 12px; }
.pill.big { padding: 11px 20px; font-size: 15px; font-weight: 600; }
.pill:disabled { opacity: .45; cursor: not-allowed; }

/* Lanes */
.lanes { display: flex; gap: 0; max-width: 1180px; margin: 14px auto 0; padding: 0 16px; }
.lane { flex: 1; text-align: left; border: 1px solid var(--rule); background: var(--paper2); color: var(--ink2); padding: 10px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.lane:first-child { border-radius: 10px 0 0 10px; } .lane:last-child { border-radius: 0 10px 10px 0; border-left: 0; }
.lane b { font-size: 15px; } .lane span { font-size: 12px; color: var(--muted); }
.lane.on { background: var(--paper); color: var(--ink); box-shadow: inset 0 -3px 0 var(--red); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 40px; }
.hero { padding: 26px 0 12px; }
.kicker { margin: 0; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; color: var(--red); font-weight: 700; }
.hero h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(30px, 5vw, 48px); line-height: 1.08; margin: 8px 0 10px; letter-spacing: -.01em; }
.hero h1 em { font-style: italic; color: var(--ink2); text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 6px; }
.lede { max-width: 760px; color: var(--ink2); margin: 0 0 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips-label { font-size: 13px; color: var(--muted); }
.chip { border: 1px dashed var(--ink2); background: transparent; color: var(--ink); border-radius: 6px; padding: 6px 11px; font-size: 13px; cursor: pointer; }
.chip.on { border-style: solid; background: var(--ink); color: var(--paper); }

/* Cards */
.card { background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; padding: 18px; margin-top: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-family: var(--serif); font-weight: 600; font-size: 22px; margin: 0 0 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card h3 { font-size: 15px; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card h3.sub { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 16px; }
.step { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--red); color: var(--red); font: 700 14px var(--sans); }
.desk { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.budget { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow-y: auto; }

/* Draft */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.segbtn { border: 0; border-right: 1px solid var(--rule); background: var(--paper2); color: var(--ink2); padding: 7px 12px; font-size: 13px; cursor: pointer; }
.segbtn:last-child { border-right: 0; }
.segbtn.on { background: var(--ink); color: var(--paper); }
.limitrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 4px; }
.limitrow .lbl { margin: 0; }
.limitrow input { width: 92px; }
.lbl { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; color: var(--ink2); }
input[type="text"], input[type="number"], textarea { width: 100%; font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; }
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--blue) 50%, transparent); outline-offset: 1px; }
#draft { font: 17px/1.75 var(--serif); padding: 14px 16px; min-height: 360px; resize: vertical;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.75em - 1px), var(--rule2) calc(1.75em - 1px), var(--rule2) 1.75em); background-attachment: local; background-position: 0 13px; }
.drop { border: 1px dashed transparent; border-radius: 10px; }
.drop.over { border-color: var(--blue); background: var(--blue-soft); }
.drop-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.draftcount { margin: 6px 0 0; font: 600 14px var(--sans); }
.draftcount.over { color: var(--red); } .draftcount.fits { color: var(--green); }
.filebtn { font-size: 13px; color: var(--blue); cursor: pointer; text-decoration: underline; }
.filebtn input { display: none; }
.more { margin-top: 12px; border-top: 1px dashed var(--rule); padding-top: 8px; }
.more summary { cursor: pointer; font-size: 14px; color: var(--ink2); }
.notes { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 4px; }
.notes li { font-size: 13px; padding: 6px 10px; border-radius: 6px; border-left: 3px solid var(--rule); background: var(--paper2); }
.notes li.warn { border-left-color: var(--red); color: var(--ink); background: var(--red-soft); }
.notes li.note { border-left-color: var(--amber); background: var(--amber-soft); }
.notes li.ok { border-left-color: var(--green); background: var(--green-soft); }

/* Budget */
.bigcount { margin: 0; font-family: var(--serif); display: flex; align-items: baseline; gap: 6px; }
.cnum { font: 600 44px/1 var(--serif); font-variant-numeric: tabular-nums; }
.cnum.over { color: var(--red); } .cnum.fits { color: var(--green); }
.cnum.lim { font-size: 26px; color: var(--muted); font-weight: 500; }
.slash { font-size: 26px; color: var(--muted); }
.overline { margin: 4px 0 6px; font-size: 13px; }
.overline.over { color: var(--red); } .overline.fits { color: var(--green); }
.stackwrap { width: 100%; overflow: hidden; }
#stackSvg { display: block; max-width: 100%; height: auto; }
#stackSvg .jar { fill: var(--paper2); stroke: var(--rule); }
#stackSvg .blk { cursor: pointer; outline: none; }
#stackSvg .b0 .blk-r { fill: var(--blk0); } #stackSvg .b1 .blk-r { fill: var(--blk1); } #stackSvg .b2 .blk-r { fill: var(--blk2); } #stackSvg .b3 .blk-r { fill: var(--blk3); }
#stackSvg .blk:hover .blk-r, #stackSvg .blk:focus .blk-r { fill: var(--blue); }
#stackSvg .blk-t { fill: #fff; font: 600 11px var(--sans); pointer-events: none; }
#stackSvg .ghost { fill: var(--paper); opacity: .65; }
#stackSvg .hatch-bg { fill: transparent; } #stackSvg .hatch-ln { stroke: var(--hatch); stroke-width: 2.4; }
#stackSvg .over { pointer-events: none; }
#stackSvg .limit { stroke: var(--red); stroke-width: 2; stroke-dasharray: 5 3; }
#stackSvg .limit-t { fill: var(--red); font: 600 11px var(--sans); }
#stackSvg .lab { fill: var(--ink2); font: 12px var(--sans); }
#stackSvg .lab-id { font-weight: 700; fill: var(--ink); } #stackSvg .lab-pct { fill: var(--muted); }
.finds { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.find { font-size: 13px; line-height: 1.4; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; }
.find .pill { margin-left: auto; }
.find q { font-family: var(--serif); font-size: 14px; }
.find.k-brochure q { color: var(--amber); } .find.k-cliche q, .find.k-formula q, .find.k-tidy-moral q { color: var(--red); }
.hid { font: 700 11px var(--mono); color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 0 4px; }
.fq del, .ba del { color: var(--red); text-decoration-thickness: 1.5px; }
.fq ins, .ba ins { color: var(--blue); text-decoration: none; border-bottom: 1.5px solid var(--blue); }
.none { color: var(--muted); font-size: 13px; font-style: italic; list-style: none; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }

/* Ask */
.suggest { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 10px; }
.stamp { display: inline-block; font: 700 12px var(--sans); letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; border-radius: 4px; border: 2px solid currentColor; transform: rotate(-2deg); }
.stamp.small { font-size: 10px; padding: 2px 6px; border-width: 1.5px; }
.v-fits, .v-yours { color: var(--green); } .v-tight, .v-mixed { color: var(--amber); } .v-restructure, .v-generic { color: var(--red); } .v-none { color: var(--muted); }
.gate { font-size: 13px; background: var(--paper2); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.runrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }

/* Progress */
.ptitle { font-weight: 600; margin: 0 0 8px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 3px; }

.steps .step { display: block; width: auto; height: auto; border: 0; border-radius: 0; font: 14px var(--sans); color: var(--muted); }
.steps .step.done { color: var(--green); } .steps .step.active { color: var(--ink); font-weight: 600; }
.step-ic { display: inline-block; width: 14px; font-family: var(--mono); }
.raw { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px var(--mono); max-height: 360px; overflow: auto; background: var(--paper2); padding: 10px; border-radius: 8px; }

/* Results */
.rhead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.rhead h2 { margin: 0; }
.summary { font-family: var(--serif); font-size: 17px; color: var(--ink2); margin: 10px 0; }
.cutbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; background: var(--paper2); border-radius: 10px; margin: 8px 0 6px; position: sticky; top: 56px; z-index: 5; border: 1px solid var(--rule); }
.aftercount { margin: 0; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.aftercount .cnum { font-size: 30px; } .aftercount .cnum.lim, .aftercount .slash { font-size: 18px; }
del.key { color: var(--red); } ins.key { color: var(--blue); text-decoration: none; border-bottom: 1.5px solid var(--blue); }
.essay { font: 17px/1.8 var(--serif); background: var(--paper); border: 1px solid var(--rule2); border-radius: 10px; padding: 14px 16px; overflow-wrap: anywhere; }
.essay .dp { margin: 0 0 12px; } .essay .dp:last-child { margin-bottom: 0; }
.pid { font: 700 10px var(--mono); color: var(--muted); border: 1px solid var(--rule); border-radius: 3px; padding: 0 3px; margin-right: 6px; vertical-align: 2px; }
.cut { font: inherit; color: inherit; background: none; border: 0; padding: 0 1px; margin: 0; cursor: pointer; border-radius: 3px; display: inline; text-align: left; }
.cut:hover { background: var(--paper2); outline: 1px dashed var(--rule); }
.cut del { color: var(--red); text-decoration-thickness: 1.5px; background: var(--red-soft); }
.cut ins { color: var(--blue); text-decoration: none; border-bottom: 1.5px solid var(--blue); background: var(--blue-soft); margin-left: 2px; }
.cut sup { font: 700 9px var(--mono); color: var(--muted); margin-left: 1px; }
.cut.off del { text-decoration: none; background: none; color: inherit; border-bottom: 1px dotted var(--muted); }
.cut.off ins { display: none; }
.cut.k-drop-sentence.on del { background: color-mix(in srgb, var(--red-soft) 70%, var(--paper)); }
.gone { color: var(--red); font-family: var(--sans); }
.tablewrap { overflow-x: auto; }
table.cuts { width: 100%; border-collapse: collapse; font-size: 14px; }
table.cuts th { text-align: left; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--rule); padding: 6px; }
table.cuts td { border-bottom: 1px dashed var(--rule2); padding: 7px 6px; vertical-align: top; }
table.cuts td.ba { font-family: var(--serif); overflow-wrap: anywhere; }
table.cuts tr.off td.ba { opacity: .55; } table.cuts tr.bad td { background: var(--red-soft); }
table.cuts td.kind { font-size: 12px; white-space: nowrap; color: var(--ink2); }
table.cuts td.k-drop-sentence { color: var(--red); font-weight: 600; }
.arrow { color: var(--muted); }
.why { display: block; font-family: var(--sans); }
.lines { padding-left: 18px; margin: 0; display: grid; gap: 6px; }
.lines q { font-family: var(--serif); }
.acts { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--rule); }
.recon h3 { color: var(--muted); }
.marked mark.vm { background: var(--amber-soft); color: inherit; border-bottom: 2px solid var(--amber); padding: 0 1px; border-radius: 2px; }
.marked mark.i-stock-phrase, .marked mark.i-formula, .marked mark.i-tidy-moral { background: var(--red-soft); border-bottom-color: var(--red); }
.marked mark sup { font: 700 9px var(--mono); color: var(--muted); margin-left: 2px; }
.vlines { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.vl { border-left: 3px solid var(--amber); padding: 6px 10px; background: var(--paper2); border-radius: 0 8px 8px 0; }
.vl.i-stock-phrase, .vl.i-formula, .vl.i-tidy-moral { border-left-color: var(--red); }
.vl-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.issue { font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink2); }
.cf { font-size: 11px; color: var(--red); border: 1px solid var(--red); border-radius: 999px; padding: 0 6px; }
.vl q { display: block; font-family: var(--serif); font-size: 15px; margin: 4px 0; }
.vl p { margin: 2px 0; }
.vl .ask { font-family: var(--serif); font-style: italic; color: var(--blue); }
.vl .ask::before { content: "Ask yourself: "; font-style: normal; font-family: var(--sans); font-size: 12px; font-weight: 700; color: var(--muted); }
.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--blue); } 100% { box-shadow: none; } }

/* History, footer, toasts */
.hist { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.hrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--rule2); border-radius: 8px; }
.hinfo { flex: 1; min-width: 180px; display: flex; flex-direction: column; }
.foot { max-width: 1180px; margin: 10px auto 30px; padding: 0 16px; font-size: 13px; color: var(--muted); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 40; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); transition: opacity .5s; }
.toast.err { background: var(--red); color: #fff; }
.toast a { color: inherit; font-weight: 700; }
.toast.gone { opacity: 0; }

/* Docs pages */
.doc { max-width: 900px; margin: 0 auto; padding: 24px 16px 40px; overflow-wrap: anywhere; }
.doc h1 { font-family: var(--serif); font-weight: 500; }
.doc h2 { font-family: var(--serif); margin-top: 30px; }
.doc pre { background: var(--paper2); border: 1px solid var(--rule); border-radius: 8px; padding: 12px; overflow-x: auto; font: 12.5px/1.5 var(--mono); max-width: 100%; white-space: pre; overflow-wrap: normal; }
.doc code { font-family: var(--mono); font-size: .92em; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; display: block; overflow-x: auto; }
.doc th, .doc td { border: 1px solid var(--rule); padding: 6px 8px; text-align: left; vertical-align: top; }
.codegroup { margin: 10px 0 16px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.tab { font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink2); cursor: pointer; }
.tab.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.statebox { border: 1px solid var(--rule); border-radius: 10px; padding: 12px; background: var(--paper); }
.tokenrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.tokenbox { font: 13px var(--mono); padding: 10px; border: 1px dashed var(--rule); border-radius: 8px; background: var(--paper2); width: 100%; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .desk { grid-template-columns: minmax(0, 1fr); }
  .budget { position: static; max-height: none; }
}
@media (max-width: 560px) {
  .bar { gap: 8px; padding: 8px 12px; } .back { display: none; }
  .lanes { padding: 0 12px; } .lane { padding: 8px 10px; } .lane b { font-size: 14px; }
  .wrap { padding: 0 12px 30px; }
  .card { padding: 14px; }
  .cnum { font-size: 38px; }
  #draft { font-size: 16px; min-height: 300px; }
  .essay { font-size: 16px; padding: 12px; }
  table.cuts th:nth-child(3), table.cuts td.kind { display: none; }
  .cutbar { top: 50px; }
  .pill.big { width: 100%; justify-content: center; }
}
