:root, [data-theme="light"] {
  --bg: #f5f8f7; --panel: #ffffff; --ink: #14231f; --muted: #52625d; --line: #d9e3df; --soft: #ecf2ef;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #ccfbf1; --bad: #b3261e; --ok: #1e7b4b; --warn-bg: #fff4dc;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
}
[data-theme="dark"] {
  --bg: #121615; --panel: #1a201e; --ink: #e9f0ed; --muted: #a2b1ab; --line: #2c3633; --soft: #222a27;
  --accent: #5eead4; --accent-ink: #042f2e; --accent-soft: #134e4a; --bad: #f28b82; --ok: #7ccf9e; --warn-bg: #2d2717;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; overflow-x: hidden; }
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .bad { color: var(--bad); } .strong { font-weight: 600; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { color: var(--accent); flex: none; }
.brand strong { white-space: nowrap; }
.sep { color: var(--muted); }
.sum-t { font-weight: 600; }
.topactions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.backlink { text-decoration: none; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.credits { font-size: .86rem; color: var(--muted); }
.topup { font-size: .86rem; }

button { font: inherit; cursor: pointer; border-radius: 10px; min-height: 40px; }
button:disabled { cursor: not-allowed; opacity: .55; }
.primary { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); padding: 8px 18px; font-weight: 600; }
.primary:hover:not(:disabled) { filter: brightness(1.07); }
.primary.big { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; font-size: 1.05rem; min-height: 48px; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); padding: 6px 12px; }
.ghost:hover:not(:disabled) { background: var(--soft); }
.ghost.sq { width: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.ghost.strong { font-weight: 600; border-color: var(--accent); color: var(--accent); }
.quiet { background: none; border: none; color: var(--accent); padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px; }
.small { min-height: 36px; }
.linkbtn { background: none; border: none; color: var(--accent); padding: 4px 0; min-height: 32px; text-align: left; font-weight: 600; }

main { max-width: 1120px; margin: 0 auto; padding: 0 16px 40px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.hero { padding: 22px 0 8px; max-width: 760px; }
h1 { font-size: clamp(1.55rem, 4.6vw, 2.25rem); line-height: 1.15; margin: 0 0 8px; letter-spacing: -.01em; }
.lede { margin: 0 0 10px; color: var(--muted); font-size: 1.04rem; }
.perks { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 12px; }
.perks li { font-size: .82rem; background: var(--accent-soft); color: var(--ink); padding: 3px 10px; border-radius: 999px; }
.editor { padding: 10px; }
.editor.drag { outline: 2px dashed var(--accent); outline-offset: 2px; }
textarea, input[type=text], input[type=url], select { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
textarea { width: 100%; padding: 10px 12px; resize: vertical; min-height: 150px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95rem; line-height: 1.45; tab-size: 2; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.editor-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 0; }
.chipbtn { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .9rem; min-height: 40px; }
.chipbtn:hover, .chipbtn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.msg { margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--soft); }
.msg.bad { background: var(--warn-bg); color: var(--ink); border-left: 3px solid var(--bad); }

.work { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; margin-top: 16px; align-items: start; scroll-margin-top: 64px; }
.viewer { padding: 10px; min-width: 0; grid-row: span 2; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segbtn { background: transparent; border: none; border-radius: 0; color: var(--ink); padding: 6px 12px; min-height: 40px; }
.segbtn + .segbtn { border-left: 1px solid var(--line); }
.segbtn[aria-pressed="true"] { background: var(--accent-soft); font-weight: 600; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); }
select { padding: 6px 8px; min-height: 40px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 2px 0; }
.stats div { display: flex; align-items: baseline; gap: 6px; }
.stats dd { margin: 0; font-weight: 700; } .stats dt { color: var(--muted); font-size: .86rem; }
.notes { margin: 8px 0 0; padding: 8px 12px 8px 28px; background: var(--warn-bg); border-radius: 10px; font-size: .9rem; }

.exports { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.exp-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.exp-grid .ghost { flex: 1 1 auto; }
.more summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.more label.inline { display: flex; justify-content: space-between; margin: 6px 0; }

.ai { padding: 12px 14px; }
.ai summary { cursor: pointer; font-weight: 600; list-style-position: inside; padding: 4px 0; min-height: 36px; }
.badge { font-size: .74rem; font-weight: 500; background: var(--soft); color: var(--muted); border-radius: 999px; padding: 2px 8px; margin-left: 4px; }
.hint { font-size: .88rem; color: var(--muted); margin: 8px 0; }
.hint.bad { color: var(--bad); }
.warn-soft { background: var(--warn-bg); color: var(--ink); padding: 8px 10px; border-radius: 8px; }
.ai input[type=text] { width: 100%; padding: 8px 10px; min-height: 40px; margin: 4px 0 8px; }
.ai-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.progress { margin-top: 10px; padding: 10px; background: var(--soft); border-radius: 10px; }
.progresshead { display: flex; justify-content: space-between; }
.steps { margin: 6px 0 0; padding-left: 20px; font-size: .9rem; color: var(--muted); }
.steps li.on { color: var(--ink); font-weight: 600; }
.steps li.done { color: var(--ok); }
.steps li.done::marker { content: "\2713  "; }
.report { margin-top: 10px; font-size: .9rem; }
.report p { margin: 6px 0; }
.report ul { margin: 4px 0 8px; padding-left: 20px; }

.history { margin-top: 16px; padding: 14px; }
.h3 { font-size: 1.05rem; margin: 0 0 4px; }
.historylist { list-style: none; padding: 0; margin: 8px 0 0; }
.historylist li { padding: 4px 0; border-top: 1px solid var(--line); }

.about { margin-top: 32px; max-width: 760px; }
.about h2 { font-size: 1.2rem; margin: 22px 0 8px; }
.howlist { padding-left: 20px; } .howlist li { margin: 6px 0; }
.qa dt { font-weight: 600; margin-top: 12px; } .qa dd { margin: 4px 0 0; color: var(--muted); }
.foot { border-top: 1px solid var(--line); padding: 18px 16px 30px; text-align: center; color: var(--muted); font-size: .88rem; }
.foot p { margin: 4px 0; }

/* docs pages */
.doc { max-width: 900px; padding-top: 18px; }
.doc h1 { font-size: 1.8rem; } .doc h2 { margin-top: 28px; } .doc h3 { margin-top: 20px; }
.doc table { border-collapse: collapse; width: 100%; font-size: .9rem; display: block; overflow-x: auto; }
.doc th, .doc td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.doc pre { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: .84rem; line-height: 1.45; margin: 0; }
.codegroup { margin: 10px 0 18px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tab { background: var(--panel); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 4px 10px; min-height: 34px; font-size: .84rem; }
.tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.statebox { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--panel); }
.statebox p { margin: 4px 0; }
.tokenrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.tokenbox { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; word-break: break-all; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); width: 100%; }
.mini { background: var(--panel); border: 1px solid var(--line); color: var(--ink); padding: 6px 12px; border-radius: 10px; }

@media (max-width: 860px) {
  .work { grid-template-columns: minmax(0, 1fr); }
  .viewer { grid-row: auto; }
}
@media (max-width: 480px) {
  .topbar { padding: 8px 12px; }
  .hero { padding-top: 14px; }
  .lede { font-size: .98rem; }
  .dropzone textarea { min-height: 96px; }
}
#exportMsg:empty { display: none; }

/* first action */
label.field { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); margin: 0 0 8px; }
label.field input[type=text], label.field select, label.field textarea { width: 100%; padding: 8px 10px; min-height: 40px; color: var(--ink); font-size: 1rem; }
label.field input[type=file] { font: inherit; font-size: .9rem; color: var(--ink); min-height: 40px; }
.dropzone { padding: 16px; display: flex; flex-direction: column; align-items: stretch; gap: 6px; border: 1px solid var(--line); }
.dropzone label.field { margin: 0; }
.dropzone textarea { min-height: 104px; font-size: .9rem; }
.droprow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 4px; }
.droprow .primary { width: 100%; min-height: 48px; font-size: 1.05rem; }
.pickrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* result */
.viewer .exports { padding: 4px 4px 10px; border-bottom: 1px solid var(--line); }
.side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.details { padding: 14px; }
.checkcard { padding: 14px; }
.h4 { font-size: .95rem; margin: 16px 0 4px; }
.verdict { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--soft); border-left: 4px solid var(--muted); }
.verdict strong { font-size: 1.12rem; overflow-wrap: anywhere; }
.verdict.v-fix { background: var(--warn-bg); border-left-color: var(--bad); }
.verdict.v-warn { border-left-color: #c58a00; }
.verdict.v-good { border-left-color: var(--ok); }
.stats dd.bad { color: var(--bad); }
.checks { list-style: none; margin: 10px 0 0; padding: 0; font-size: .9rem; }
.checks li { padding: 6px 10px 6px 30px; border-radius: 8px; margin: 4px 0; position: relative; background: var(--soft); overflow-wrap: anywhere; }
.checks li::before { position: absolute; left: 10px; top: 6px; font-weight: 700; }
.checks li.ok::before { content: "\2713"; color: var(--ok); }
.checks li.warn { background: var(--warn-bg); } .checks li.warn::before { content: "!"; color: #a05a00; }
.checks li.bad { background: var(--warn-bg); border-left: 3px solid var(--bad); } .checks li.bad::before { content: "!"; color: var(--bad); }
label.check { display: flex; gap: 8px; align-items: flex-start; font-size: .92rem; padding: 6px 0; min-height: 40px; cursor: pointer; }
label.check input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.ai textarea { min-height: 110px; font-family: inherit; margin: 4px 0 8px; }
.airesult { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.aidoc { margin-top: 6px; font-size: .92rem; overflow-wrap: anywhere; }
.aidoc p { margin: 6px 0; } .aidoc ul { margin: 4px 0 8px; padding-left: 20px; }
.historylist li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
#loadMsg, #aiMsg, #exportMsg, .report li, .report p { overflow-wrap: anywhere; }

/* tables */
.tablewrap { max-height: 460px; overflow: auto; overscroll-behavior: contain; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; }
.plantable { width: 100%; border-collapse: collapse; font-size: .86rem; }
.plantable th, .plantable td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.plantable thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; white-space: nowrap; }
.plantable td.name { min-width: 8em; font-weight: 600; }
.plantable td.url { min-width: 12em; overflow-wrap: anywhere; word-break: break-all; font-size: .8rem; }
.plantable td.url .mono { display: block; margin-bottom: 4px; }
.plantable tr.used td { background: var(--accent-soft); }
.tag { display: inline-block; margin-left: 6px; font-size: .7rem; font-weight: 700; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); vertical-align: 1px; }
.tag.soft { background: var(--panel); color: var(--ink); border: 1px solid var(--line); font-weight: 600; }
.mini { min-height: 32px; font-size: .8rem; padding: 3px 10px; }

@media (max-width: 860px) { .work { grid-template-columns: minmax(0, 1fr); } .viewer { grid-row: auto; } }
@media (max-width: 640px) {
  .hero .lede { font-size: .95rem; margin-bottom: 8px; }
  .dropzone { padding: 12px; }
  .plantable { font-size: .8rem; }
  .tablewrap { max-height: 60vh; }
  .phone { border-width: 6px; }
}

/* raise calculator */
.payrow { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 10px; }
.readas:empty { display: none; }
.readas { margin: 0; }
.pickrow.three { grid-template-columns: 1fr 1fr 1fr; }
.plantable th[scope=row] { font-weight: 600; white-space: nowrap; }
.plantable td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.plantable tr.total td { border-top: 2px solid var(--line); font-weight: 600; }
.bars { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 4px; }
.barrow { display: grid; grid-template-columns: 11em minmax(0, 1fr) 4.5em; gap: 8px; align-items: center; font-size: .9rem; }
.bartrack { height: 14px; background: var(--soft); border-radius: 7px; overflow: hidden; }
.barfill { display: block; height: 100%; border-radius: 7px; background: var(--muted); }
.barfill.good { background: var(--ok); } .barfill.bad { background: var(--bad); } .barfill.warn { background: #c58a00; }
.barfill.pace { background: var(--muted); } .barfill.ask { background: var(--accent); }
.barval { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.rangebar { position: relative; height: 54px; margin: 10px 4px 4px; }
.rangebar .band { position: absolute; top: 22px; height: 12px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 6px; }
.rangebar .midline { position: absolute; top: 16px; height: 24px; width: 2px; background: var(--accent); }
.rangebar .dot { position: absolute; top: 0; transform: translateX(-50%); font-size: .72rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); white-space: nowrap; }
.rangebar .dot::after { content: ""; position: absolute; left: 50%; top: 100%; width: 2px; height: 22px; background: currentColor; }
.rangebar .dot.now { color: var(--muted); } .rangebar .dot.after { color: #a05a00; top: 34px; } .rangebar .dot.after::after { top: auto; bottom: 100%; height: 10px; }
.rangebar .dot.ask { color: var(--accent); }
.emailbody { white-space: pre-wrap; background: var(--soft); border-radius: 10px; padding: 10px 12px; margin: 4px 0 8px; }
label.field input[inputmode] { width: 100%; padding: 8px 10px; min-height: 40px; color: var(--ink); font-size: 1rem; font: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
@media (max-width: 480px) { .barrow { grid-template-columns: 8.5em minmax(0, 1fr) 4.2em; font-size: .84rem; } .pickrow.three { grid-template-columns: 1fr; } }
.plantable td:first-child, .plantable th:first-child { white-space: nowrap; }
@media (max-width: 480px) { .plantable th, .plantable td { padding: 6px 4px; font-size: .76rem; } .plantable thead th { white-space: normal; } }
