/* A manuscript on a desk: paper, ink, hairline rules, and one highlighter. No cards, no gradients. */
:root {
  color-scheme: light;
  --bg: #f5f2ea; --card: #f5f2ea; --box: #fbf9f4; --line: #ddd7c8; --line-2: #c4bca9;
  --text: #1c1b18; --muted: #4d483f; --faint: #6f695c;
  --accent: #1c1b18; --accent-hover: #000000; --accent-soft: #ebe6d8; --on-accent: #f5f2ea;
  --ins: #ffe27a; --ins-edge: #e9c63f; --ok: #2f6b3c; --warn: #a25a00; --danger: #b4321c; --pen: #b4321c;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Helvetica Neue", "Segoe UI", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #171613; --card: #171613; --box: #1d1c18; --line: #302e28; --line-2: #48453c;
    --text: #ebe6d9; --muted: #c2bcab; --faint: #9c9585;
    --accent: #ebe6d9; --accent-hover: #ffffff; --accent-soft: #2a2822; --on-accent: #171613;
    --ins: #5c4d0c; --ins-edge: #a88f1f; --ok: #86c193; --warn: #e0a252; --danger: #ef8a73; --pen: #ef8a73;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171613; --card: #171613; --box: #1d1c18; --line: #302e28; --line-2: #48453c;
  --text: #ebe6d9; --muted: #c2bcab; --faint: #9c9585;
  --accent: #ebe6d9; --accent-hover: #ffffff; --accent-soft: #2a2822; --on-accent: #171613;
  --ins: #5c4d0c; --ins-edge: #a88f1f; --ok: #86c193; --warn: #e0a252; --danger: #ef8a73; --pen: #ef8a73;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { display: flex; flex-direction: column; height: 100dvh; margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
a { color: inherit; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
kbd { font: 11px var(--sans); padding: 1px 5px; border: 1px solid var(--line-2); border-radius: 3px; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.topbar { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 1240px; margin: 0 auto; padding: 14px 32px; }
.brand { font: italic 500 22px/1 var(--serif); letter-spacing: -0.01em; text-decoration: none; }
.mark { display: inline-block; margin-right: 3px; color: var(--pen); font-style: normal; font-weight: 700; transform: translateY(5px); }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--text); background: var(--accent-soft); }

.account, .acct { display: flex; align-items: center; gap: 14px; }
.acct .pill { font-size: 13px; }
.primary.small { margin: 0; padding: 6px 12px; font-size: 13px; }
.menu { position: relative; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--text); border-radius: 50%; font: 500 14px var(--serif); cursor: pointer; list-style: none; }
.avatar::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: 38px; z-index: 10; display: grid; min-width: 220px; padding: 6px; background: var(--box); border: 1px solid var(--text); border-radius: 3px; }
.menu-list > * { padding: 7px 10px; font-size: 13px; text-align: left; }
.menu-email { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.menu-plan { font-weight: 600; }
.menu-list button { border: 0; border-radius: 2px; background: none; cursor: pointer; }
.menu-list button:hover { background: var(--accent-soft); }

.modal { width: min(440px, calc(100vw - 32px)); padding: 22px; border: 1px solid var(--text); border-radius: 3px; background: var(--box); color: var(--text); box-shadow: 0 24px 60px rgb(0 0 0 / .18); }
.modal::backdrop { background: rgb(20 18 12 / .5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin: 0; }
.modal-head h2 { font-size: 24px; }
.modal-note { margin: 6px 0 16px; color: var(--muted); font-size: 13px; }
.modal-note.test { margin: 14px 0 0; padding: 8px 10px; border-left: 2px solid var(--warn); color: var(--text); }
.plans { display: grid; border-top: 1px solid var(--line-2); }
.plan { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--line-2); background: none; text-align: left; cursor: pointer; }
.plan:hover { background: var(--accent-soft); }
.plan b { font: 500 17px var(--serif); }
.plan .price { grid-row: span 2; align-self: center; font: 500 17px var(--serif); font-variant-numeric: tabular-nums; }
.plan small { color: var(--muted); }

.wrap { display: flex; flex-direction: column; flex: 1; width: 100%; max-width: 1240px; min-height: 0; margin: 0 auto; padding: 4px 32px 24px; }
h1 { margin: 0 0 16px; font: 400 clamp(24px, 2.6vw, 32px)/1.15 var(--serif); letter-spacing: -0.015em; }
h1 em { box-shadow: inset 0 -0.34em 0 var(--ins); }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; border-top: 2px solid var(--text); border-bottom: 1px solid var(--text); }
.card { display: flex; flex-direction: column; gap: 14px; padding: 18px 0 20px; min-width: 0; min-height: 0; }
.card:first-child { padding-right: 32px; border-right: 1px solid var(--line-2); }
.card:last-child { padding-left: 32px; }
.card-head { display: flex; align-items: baseline; gap: 12px; min-height: 26px; }
h2 { margin: 0; font: 500 20px/1.2 var(--serif); letter-spacing: -0.01em; }
.card-head h2 { font: 700 12px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; }
.head-actions { display: flex; gap: 16px; }
.pill { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill.over { color: var(--danger); font-weight: 600; }
.card-head > :last-child { margin-left: auto; align-self: center; }

.box { position: relative; display: flex; flex: 1; min-height: 0; overflow: hidden; }
textarea, .output { flex: 1; width: 100%; margin: 0; padding: 2px 12px 2px 0; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); font: 17px/1.65 var(--serif); white-space: pre-wrap; overflow-wrap: anywhere; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
textarea::placeholder { color: var(--faint); }
textarea[readonly] { color: var(--muted); }
.output:empty::before { content: attr(data-empty); color: var(--faint); }
.output .ins { background: linear-gradient(transparent 12%, var(--ins) 12%, var(--ins) 92%, transparent 92%); -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.output .ai { text-decoration: underline wavy var(--pen); text-decoration-thickness: 1px; text-underline-offset: 4px; }
.output .waiting { color: var(--faint); font: italic 15px var(--serif); }
.caret { display: inline-block; width: 2px; height: 1.1em; margin-left: 1px; vertical-align: -.18em; background: var(--pen); animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.dragging .box { outline: 1px dashed var(--text); outline-offset: 6px; }

.output .sec { cursor: pointer; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.output .sec:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.output .sec.sel { background: color-mix(in srgb, var(--text) 8%, transparent); }
.sec-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-height: 30px; margin: -6px 0 -4px; padding: 4px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.sec-label { margin-right: auto; }
.versions { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-variant-numeric: tabular-nums; }
.icon-sm { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 2px; background: none; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; }
.icon-sm:hover:not(:disabled) { background: var(--accent-soft); color: var(--text); }
.icon-sm:disabled { opacity: .35; cursor: default; }
.issues li { cursor: pointer; }
.issues li:hover .value { text-decoration: underline; }
.output .kept { text-decoration: underline dotted var(--ok); text-decoration-thickness: 1.5px; text-underline-offset: 4px; }

.protect { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.protect-label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.protect-label svg { width: 13px; height: 13px; }
.terms { display: contents; }
.term { display: inline-flex; align-items: center; gap: 4px; max-width: 220px; padding: 1px 3px 1px 7px; border: 1px solid var(--line-2); border-radius: 2px; background: var(--box); color: var(--text); font: 14px var(--serif); }
.term span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term.absent { color: var(--faint); border-style: dashed; }
.term button { display: grid; place-items: center; width: 16px; height: 16px; padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; }
.term button:hover { color: var(--text); }
#term-input { flex: 1; min-width: 160px; padding: 4px 0; border: 0; border-bottom: 1px solid transparent; background: transparent; color: var(--text); font: inherit; outline: 0; }
#term-input:focus { border-bottom-color: var(--text); }

.card-foot { display: flex; align-items: center; gap: 12px; }
.hint { color: var(--muted); font-size: 13px; }
.primary { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; padding: 11px 26px; border: 0; border-radius: 2px; background: var(--accent); color: var(--on-accent); font: 500 17px/1.2 var(--serif); cursor: pointer; transition: background .12s; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.primary.stop { background: var(--pen); color: #fff; }
.link-btn { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; border: 0; background: none; color: var(--muted); font-size: 13px; cursor: pointer; }
.link-btn:hover:not(:disabled) { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.link-btn:disabled { opacity: .6; cursor: default; }
.actions { display: flex; justify-content: flex-end; gap: 18px; margin-top: -6px; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; }
.track { position: relative; width: 28px; height: 16px; border: 1px solid var(--text); border-radius: 999px; transition: background .15s; }
.track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--text); transition: transform .15s, background .15s; }
.switch input:checked + .track { background: var(--ins); }
.switch input:checked + .track::after { transform: translateX(12px); }
.switch input:focus-visible + .track { outline: 2px solid var(--text); outline-offset: 2px; }

.progress { height: 2px; margin: -6px 0 -4px; background: var(--line); overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--text); transition: width .3s; }

.notice { padding: 8px 0 8px 12px; border-left: 2px solid var(--line-2); font-size: 13px; color: var(--muted); }
.notice.warn { border-left-color: var(--warn); color: var(--text); }
.notice.error { border-left-color: var(--danger); color: var(--danger); }

.report { padding-top: 14px; border-top: 1px solid var(--line); }
.stat { display: grid; gap: 2px; min-width: 0; }
#ai-stat { margin-left: auto; text-align: right; }
#ai-stat + .ring { margin-left: 8px; }
.stat-label { font: 700 12px/1.4 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat-value { font: 400 26px/1.2 var(--serif); font-variant-numeric: tabular-nums; }
.stat-value.ok { color: var(--ok); }
.stat-value.warn { color: var(--warn); }
.stat-note { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.ring {
  --p: 0; display: grid; place-content: center; text-align: center; margin-left: auto;
  width: 68px; height: 68px; flex: none; border-radius: 50%;
  background: radial-gradient(closest-side, var(--bg) 88%, transparent 89%), conic-gradient(var(--text) calc(var(--p) * 1%), var(--line) 0);
}
.ring span { font: 500 17px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.ring small { font-size: 11px; color: var(--muted); }

.issues { display: grid; gap: 4px; margin: -4px 0 0; padding: 0; list-style: none; font-size: 13px; }
.issues li { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.issues .kind { flex: none; font: 600 10px var(--sans); text-transform: uppercase; letter-spacing: .1em; }
.issues .missing .kind { color: var(--warn); }
.issues .added .kind { color: var(--muted); }
.issues .value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 15px var(--serif); }
.issues .where { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }
.issues .more { color: var(--faint); font-size: 12px; }

@media (max-width: 860px) {
  body { height: auto; min-height: 100dvh; }
  main { grid-template-columns: 1fr; }
  .card:first-child { padding-right: 0; border-right: 0; border-bottom: 1px solid var(--line-2); }
  .card:last-child { padding-left: 0; }
  .box { flex: none; height: 300px; }
  .wrap { padding: 16px 18px 40px; }
  .topbar { padding: 14px 18px; }
}
@media (min-width: 861px) and (max-height: 560px) { body { height: auto; } .box { flex: none; height: 260px; } }
