/* Profile README - slate and teal, light and dark. */
:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-2: #eef2f4;
  --ink: #17202a;
  --muted: #5b6672;
  --line: #dde3e8;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #dcf3ef;
  --night: #1f2a37;
  --night-ink: #eefaf8;
  --gold: #b45309;
  --gold-soft: #fdf0dc;
  --ok: #1f7a4a;
  --ok-soft: #e3f3ea;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --warn: #8a5300;
  --warn-soft: #fff4de;
  --info: #2f4f8f;
  --info-soft: #e8eefa;
  --md-bg: #ffffff;
  --md-ink: #1f2328;
  --md-line: #d1d9e0;
  --md-code: #f6f8fa;
  --md-link: #0969da;
  --shadow: 0 1px 2px rgba(20, 30, 40, 0.06), 0 8px 24px rgba(20, 30, 40, 0.06);
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1418;
  --panel: #161e24;
  --panel-2: #1e2830;
  --ink: #e6edf2;
  --muted: #9aa8b4;
  --line: #2b3741;
  --accent: #5eead4;
  --accent-ink: #062a26;
  --accent-soft: #123a35;
  --night: #24323e;
  --night-ink: #eefaf8;
  --gold: #fbbf24;
  --gold-soft: #3a2c10;
  --ok: #6fd69d;
  --ok-soft: #173326;
  --bad: #ff8a80;
  --bad-soft: #3a1c1b;
  --warn: #ffc76b;
  --warn-soft: #3a2c14;
  --info: #a9c1f5;
  --info-soft: #1d2740;
  --md-bg: #0d1117;
  --md-ink: #e6edf3;
  --md-line: #3d444d;
  --md-code: #151b23;
  --md-link: #4493f8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}
a { color: var(--accent); }
.hidden { display: none !important; }
code { font-family: var(--mono); font-size: .86em; background: var(--panel-2); border-radius: 4px; padding: .05rem .3rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
h1, h2, h3 { line-height: 1.2; }
ul.plain { list-style: none; padding: 0; margin: 0; }

button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent; padding: .55rem 1rem; color: var(--ink); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.primary:hover:not(:disabled) { filter: brightness(1.07); }
button.ghost, a.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.ghost:hover:not(:disabled), a.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.small { padding: .3rem .65rem; font-size: .85rem; }
button.icon { padding: .35rem .6rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- Header ---------------------------------------------------------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap;
  padding: .65rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.backlink { text-decoration: none; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.sep { color: var(--line); }
.appname { white-space: nowrap; }
.logo { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; border-radius: 7px;
  background: var(--night); color: var(--accent); font-size: .75rem; margin-right: .2rem; }
.topactions { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.linkbtn { text-decoration: none; border-radius: 10px; padding: .35rem .7rem; font-size: .9rem; }
.count { display: inline-block; min-width: 1.3rem; text-align: center; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: .78rem; font-weight: 700; padding: 0 .35rem; margin-left: .2rem; }
.credits { font-size: .88rem; color: var(--muted); }
.topup { font-size: .88rem; font-weight: 600; text-decoration: none; }

/* ---- Hero and examples ----------------------------------------------------- */
main { max-width: 1180px; margin: 0 auto; padding: 0 16px 3rem; }
.hero { padding: 2rem 0 .6rem; }
.hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.5rem); margin: 0 0 .5rem; letter-spacing: -.01em; }
.lede { font-size: 1.07rem; color: var(--muted); max-width: 46rem; margin: 0 0 .7rem; }
.pitch { margin: 0; font-size: .94rem; }
.pill { display: inline-block; background: var(--night); color: var(--night-ink); border-radius: 999px; padding: .12rem .6rem; font-size: .8rem;
  font-weight: 650; margin-right: .35rem; }
.examples { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin: 1rem 0 1.2rem; }
.exlabel { font-size: .88rem; color: var(--muted); margin-right: .2rem; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .8rem; font-size: .88rem; }
.chip:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

/* ---- Progress -------------------------------------------------------------------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-top: 1.1rem; }
.progresshead { display: flex; justify-content: space-between; gap: 1rem; }
.steps { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .3rem; }
.stage { display: flex; gap: .55rem; align-items: center; color: var(--muted); font-size: .92rem; }
.stagedot { display: inline-flex; width: 1.4rem; height: 1.4rem; border-radius: 999px; align-items: center; justify-content: center;
  border: 1px solid var(--line); font-size: .75rem; }
.stage.done { color: var(--ink); }
.stage.done .stagedot { background: var(--ok); border-color: var(--ok); color: #fff; }
.stage.now { color: var(--ink); font-weight: 650; }
.stage.now .stagedot { border-color: var(--accent); color: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px var(--accent-soft); } }
@media (prefers-reduced-motion: reduce) { .stage.now .stagedot { animation: none; } }

/* ---- Footer, toasts, docs ---------------------------------------------------------- */
.foot { max-width: 1180px; margin: 0 auto; padding: 1.2rem 16px 2.5rem; color: var(--muted); font-size: .86rem; border-top: 1px solid var(--line); }
.foot p { margin: .3rem 0; }
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .4rem; z-index: 20; max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 10px; padding: .55rem .8rem;
  box-shadow: var(--shadow); font-size: .9rem; transition: opacity .5s; }
.toast.err { border-left-color: var(--bad); }
.toast.gone { opacity: 0; }
.doc { max-width: 900px; }
.doc pre, pre.block { overflow-x: auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; font-family: var(--mono); font-size: .82rem; }
.codegroup { margin: .6rem 0 1.2rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .35rem; }
.tab { font-size: .8rem; padding: .25rem .6rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.tab[aria-selected="true"] { background: var(--night); color: var(--night-ink); border-color: var(--night); }
.errtable { width: 100%; border-collapse: collapse; font-size: .9rem; display: block; overflow-x: auto; }
.errtable th, .errtable td { border-bottom: 1px solid var(--line); padding: .4rem .5rem; text-align: left; vertical-align: top; }
.statebox { border: 1px solid var(--line); border-radius: 8px; padding: .8rem;
  background: var(--panel-2); margin: .75rem 0 1.25rem; }
.tokenrow { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .5rem 0; }
.tokenbox { flex: 1 1 20rem; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: .55rem .7rem; font-size: .82rem; word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.mini { background: transparent; color: var(--ink); padding: .3rem .6rem; font-size: .82rem; }
.mini:hover:enabled { background: var(--panel-2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.mini { border: 1px solid var(--line); border-radius: 8px; }
.statebox p { margin: .3rem 0; }
.tab.active { background: var(--night); color: var(--night-ink); border-color: var(--night); }
.doc h1 { margin-top: 1.5rem; }

/* ---- App: two columns, form left, sticky preview right ---------------------------- */
.pill.alt { background: var(--accent); color: var(--accent-ink); margin-left: .5rem; }
.chip.quiet { color: var(--muted); border-style: dashed; }
.layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 1.2rem; align-items: start; }
.formcol .card:first-child, .previewcol .card:first-child { margin-top: 0; }
.previewcol { position: sticky; top: 4.2rem; max-height: calc(100vh - 5rem); overflow: auto; padding-bottom: .5rem; }
.form fieldset { border: 0; border-top: 1px solid var(--line); margin: 0; padding: .9rem 0 .2rem; }
.form fieldset:first-child { border-top: 0; padding-top: 0; }
.form legend { font-weight: 700; font-size: .95rem; padding: 0; margin-bottom: .45rem; }
.form label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: .6rem; }
.form label.check, .form label.inline { display: inline-flex; align-items: center; gap: .35rem; font-weight: 500; margin: 0; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input[type="text"], input[type="search"], textarea, select {
  display: block; width: 100%; margin-top: .25rem; font: inherit; font-size: .95rem; color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: .5rem .65rem; }
textarea { resize: vertical; min-height: 2.6rem; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.form label.inline select { display: inline-block; width: auto; margin: 0; padding: .3rem .4rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .7rem; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 .7rem; margin-top: .7rem; }
.cardsrow { display: flex; flex-wrap: wrap; gap: .45rem .9rem; align-items: center; margin: .1rem 0 .8rem; font-size: .88rem; }
.cardsrow .lbl { font-weight: 600; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel-2); }
.seg button { border-radius: 0; border: 0; border-right: 1px solid var(--line); padding: .4rem .8rem; background: transparent; font-size: .88rem; }
.seg button:last-child { border-right: 0; }
.seg button[aria-checked="true"] { background: var(--night); color: var(--night-ink); font-weight: 650; }
.seg.small button { padding: .2rem .6rem; font-size: .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chips.parsed { margin: -.25rem 0 .5rem; }
.tchip { font-size: .76rem; border-radius: 6px; padding: .1rem .45rem; background: var(--panel-2); border: 1px solid var(--line); display: inline-flex; gap: .3rem; align-items: center; }
.tchip .sw { width: .6rem; height: .6rem; border-radius: 2px; display: inline-block; }
.tchip.unknown { border-style: dashed; color: var(--muted); }
.warnings { list-style: none; padding: 0; margin: .3rem 0 0; display: grid; gap: .3rem; }
.warnings li { font-size: .84rem; background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: .3rem .6rem; }
.clip { font-size: .84rem; background: var(--info-soft); color: var(--info); border-radius: 8px; padding: .35rem .6rem; }
.runbox { border-top: 1px solid var(--line); margin-top: .8rem; padding-top: .8rem; }
.runlead { margin: 0 0 .55rem; font-size: .9rem; }
.runrow { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.meter { font-size: .84rem; color: var(--muted); }
.gate { margin-top: .5rem; font-size: .88rem; background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: .4rem .65rem; }
.gate p { margin: 0; }

/* ---- Preview ----------------------------------------------------------------- */
.pvhead { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.pvtabs { margin: 0; }
.srcbadge { font-size: .76rem; font-weight: 700; border-radius: 999px; padding: .15rem .6rem; background: var(--panel-2); color: var(--muted); }
.srcbadge.ai { background: var(--accent-soft); color: var(--accent); }
.wordsswitch { display: flex; align-items: center; gap: .5rem; margin: -.2rem 0 .6rem; }
.empty { color: var(--muted); font-size: .92rem; text-align: center; padding: 2rem 1rem; border: 1px dashed var(--line); border-radius: 10px; }
.mdbody { background: var(--md-bg); color: var(--md-ink); border: 1px solid var(--md-line); border-radius: 10px; padding: 1rem 1.2rem;
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif; overflow-wrap: anywhere; }
.mdbody > :first-child { margin-top: 0; }
.mdbody h1, .mdbody h2 { border-bottom: 1px solid var(--md-line); padding-bottom: .3em; }
.mdbody h1 { font-size: 1.7em; margin: .6em 0 .5em; }
.mdbody h2 { font-size: 1.3em; margin: 1.2em 0 .6em; }
.mdbody h3 { font-size: 1.1em; margin: 1em 0 .5em; }
.mdbody p, .mdbody ul, .mdbody ol { margin: 0 0 .8em; }
.mdbody ul, .mdbody ol { padding-left: 1.6em; }
.mdbody a { color: var(--md-link); text-decoration: none; }
.mdbody a:hover { text-decoration: underline; }
.mdbody code { background: var(--md-code); }
.mdbody [data-align="center"] { text-align: center; }
.mdbody [data-align="right"] { text-align: right; }
.mdbody img { max-width: 100%; vertical-align: middle; }
.mdbody img.badge { margin: 1px 1px; }
.mdbody hr { border: 0; border-top: 1px solid var(--md-line); }
.mdsrc { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: .8rem; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: .8rem; margin: 0; max-height: 60vh; overflow: auto; }
.sections { display: grid; gap: .5rem; }
.secrow { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; display: grid; gap: .35rem; }
.secrow .sechead { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.secrow pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: .75rem; color: var(--muted); max-height: 7.5rem; overflow: auto; }
.exportrow { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin-top: .8rem; }
.howto { margin-top: .8rem; font-size: .9rem; }
.howto summary { cursor: pointer; font-weight: 600; }
.howto ol { padding-left: 1.3rem; margin: .4rem 0; }
.howto .howlink { margin-left: .4rem; font-weight: 600; }

/* ---- Result notes and revise --------------------------------------------------- */
.resultmsg { background: var(--info-soft); color: var(--info); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .6rem; }
.recon { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .3rem; }
.recon li { font-size: .85rem; border-radius: 8px; padding: .3rem .6rem; }
.recon li.fixed { background: var(--ok-soft); color: var(--ok); }
.recon li.check { background: var(--warn-soft); color: var(--warn); }
.recon li.info, .recon li.none { background: var(--panel-2); color: var(--muted); }
#suggestWrap h3 { font-size: .9rem; margin: .8rem 0 .3rem; color: var(--muted); }
.suggest { margin: 0; padding-left: 1.2rem; font-size: .9rem; }
.revisebar { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.revisebar label { font-weight: 650; font-size: .9rem; }
.reviserow { display: flex; gap: .5rem; margin: .35rem 0 .45rem; }
.reviserow input { margin: 0; flex: 1; min-width: 0; }
.mini-chip { font-size: .78rem; padding: .2rem .6rem; }
pre.raw { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: .8rem; background: var(--panel-2); padding: .7rem; border-radius: 10px; }

/* ---- History ------------------------------------------------------------------ */
.history { margin-top: 1.4rem; }
.histhead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem; align-items: center; }
.histhead h2 { margin: 0; font-size: 1.1rem; }
.histhead input { max-width: 240px; margin: 0; }
.histlist { list-style: none; padding: 0; margin: .7rem 0 0; display: grid; gap: .4rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.histitem { display: flex; gap: .4rem; align-items: stretch; }
.histopen { flex: 1; text-align: left; background: var(--panel-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.histopen:hover:not(:disabled) { border-color: var(--accent); }
.histopen span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
li.none { color: var(--muted); font-size: .9rem; }

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .previewcol { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 560px) {
  .backlink { display: none; }
  .brand .sep { display: none; }
  .row2, .row3 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: .85rem; }
  .mdbody { padding: .8rem; }
  .reviserow { flex-direction: column; }
  .pill.alt { margin-left: 0; }
}
@media print {
  .topbar, .examples, .formcol, .exportrow, .howto, .toasts, .foot, .history, #resultCard, #progressPanel, .pvhead, .wordsswitch { display: none !important; }
  .layout { display: block; }
  .previewcol { position: static; max-height: none; overflow: visible; }
  .card { box-shadow: none; border: 0; }
}
