/* Fonts load via a <link> in the document head, not @import, so they don't
   block this stylesheet from rendering. */

:root {
  --canvas: #e9ece8;
  --panel: #ffffff;
  --well: #f1f3f0;
  --paper: #ffffff;
  --ink: #182230;
  --muted: #5c6670;
  --rule: #c8cec6;
  --rule-soft: #dde1da;
  --accent: #2f4bd6;
  --accent-ink: #1f34a8;
  --accent-soft: #e6eafb;
  --on-accent: #ffffff;
  --ok: #1f6b4e;
  --err: #b3261e;
  --seg-idle: #4c565f;   /* meets AA against the segmented control's own background */
  --shadow: 0 1px 2px rgba(24,34,48,.08), 0 8px 24px rgba(24,34,48,.08);
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --radius: 6px;
  --max: 1180px;
  --tap: 44px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #14181c;
    --panel: #1b2026;
    --well: #0f1316;
    --ink: #e6eaee;
    --muted: #94a0aa;
    --rule: #2d353d;
    --rule-soft: #242c33;
    --accent: #8aa4ff;
    --accent-ink: #a6b9ff;
    --accent-soft: #1e2740;
    --on-accent: #10151d;
    --ok: #6ed3a8;
    --err: #ff9b93;
    --seg-idle: #9aa6b0;
    --shadow: 0 2px 4px rgba(0,0,0,.45), 0 14px 34px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --canvas: #14181c;
    --panel: #1b2026;
    --well: #0f1316;
    --ink: #e6eaee;
    --muted: #94a0aa;
    --rule: #2d353d;
    --rule-soft: #242c33;
    --accent: #8aa4ff;
    --accent-ink: #a6b9ff;
    --accent-soft: #1e2740;
    --on-accent: #10151d;
    --ok: #6ed3a8;
    --err: #ff9b93;
    --seg-idle: #9aa6b0;
    --shadow: 0 2px 4px rgba(0,0,0,.45), 0 14px 34px rgba(0,0,0,.4);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
button { font: inherit; cursor: pointer; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 600; letter-spacing: -0.011em; }
h1 { font-size: clamp(1.6rem, 5.5vw, 2.5rem); max-width: 22ch; text-wrap: balance; }
h2 { font-size: clamp(1.3rem, 3.5vw, 1.5rem); text-wrap: balance; }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1em; max-width: 68ch; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--rule); background: var(--canvas); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 1.05rem; flex-shrink: 0; }
.brand svg { width: 26px; height: 26px; }
.nav { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.nav::-webkit-scrollbar { display: none; }
.nav a { display: flex; align-items: center; padding: 8px 12px; min-height: 38px; border-radius: var(--radius); color: var(--muted); text-decoration: none; white-space: nowrap; font-size: .95rem; border: 1px solid transparent; }
.nav a:hover { color: var(--ink); background: var(--rule-soft); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--panel); border-color: var(--rule); }

/* ---------- intro ---------- */
.intro { padding: 32px 0 18px; }
.intro p { color: var(--muted); font-size: 1.05rem; max-width: 60ch; }

/* ---------- tool ---------- */
.tool {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "tabs   tabs"
    "editor actions"
    "editor preview";
  grid-template-rows: auto auto 1fr;
  gap: 14px 18px;
  align-items: stretch;
}
.tool-tabs { grid-area: tabs; display: none; }
#editor-pane { grid-area: editor; }
.tool-actions { grid-area: actions; }
.preview-pane { grid-area: preview; }

.pane { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
#editor-pane { min-height: 580px; }

.pane-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--rule-soft); flex-wrap: wrap; }
.pane-bar .label { font-weight: 500; margin-right: auto; padding-left: 4px; }
.pane-bar .count { color: var(--muted); font: 400 .8rem/1 var(--mono); padding-right: 6px; font-variant-numeric: tabular-nums; }
.pane-hint { padding: 0 14px 8px; color: var(--muted); font-size: .82rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--rule); background: var(--panel); color: var(--ink); font-size: .92rem; line-height: 1.2; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 500; }
.btn-primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-quiet { border-color: transparent; color: var(--muted); background: none; padding: 8px 10px; }
.btn-quiet:hover { color: var(--ink); background: var(--rule-soft); border-color: transparent; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.seg { display: inline-flex; background: var(--rule-soft); border-radius: var(--radius); padding: 2px; gap: 2px; }
.seg button { border: 0; background: none; color: var(--seg-idle); padding: 6px 10px; min-height: 32px; border-radius: 4px; font-size: .88rem; }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

#editor { flex: 1; width: 100%; min-height: 500px; resize: none; border: 0; padding: 16px 18px; background: var(--panel); color: var(--ink); font: 14.5px/1.65 var(--mono); tab-size: 2; overscroll-behavior: contain; }
#editor:focus { outline: none; }
#editor-pane:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#editor::placeholder { color: var(--muted); opacity: .75; }
.pane.dragover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.tool-actions { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; }
.actions .spacer { flex: 1; min-width: 0; }
.status { font-size: .86rem; color: var(--muted); padding: 0 12px 9px; min-height: 1.25em; }
.status:empty { padding-bottom: 0; min-height: 0; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

.preview-pane { background: var(--well); }
.preview-pane .pane-bar { background: var(--panel); }
.sheet-scroll { flex: 1; overflow: auto; padding: 20px; max-height: 620px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet { background: var(--paper); color: #1c1c1c; margin: 0 auto; max-width: 720px; min-height: 440px; padding: 40px 44px; box-shadow: var(--shadow); font: 15px/1.65 var(--sans); }
.sheet.empty { display: flex; align-items: center; justify-content: center; color: #767f88; text-align: center; padding: 40px 24px; }
.sheet h1, .sheet h2, .sheet h3, .sheet h4 { line-height: 1.25; margin: 1.4em 0 .5em; max-width: none; letter-spacing: 0; color: #111; }
.sheet h1 { font-size: 1.9em; margin-top: 0; }
.sheet h2 { font-size: 1.45em; border-bottom: 1px solid #ddd; padding-bottom: .2em; }
.sheet h3 { font-size: 1.15em; }
.sheet p, .sheet ul, .sheet ol, .sheet pre, .sheet table, .sheet blockquote { margin: 0 0 1em; max-width: none; }
.sheet code { font-family: var(--mono); font-size: .88em; background: #f3f3f3; padding: .1em .35em; border-radius: 3px; }
.sheet pre { background: #f6f6f6; padding: 12px 14px; border-radius: 4px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
.sheet pre code { background: none; padding: 0; }
.sheet blockquote { border-left: 4px solid #ccc; padding: .2em 1em; color: #555; }
.sheet table { border-collapse: collapse; width: 100%; }
.sheet th, .sheet td { border: 1px solid #ccc; padding: 6px 10px; text-align: left; }
.sheet th { background: #f2f2f2; }
.sheet img { max-width: 100%; }
.sheet hr { border: 0; border-top: 1px solid #ccc; margin: 2em 0; }
.sheet a { color: #0b5cad; }
.sheet.mode-txt { font-family: var(--mono); font-size: 13.5px; white-space: pre-wrap; }
.sheet.mode-html { font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; color: #333; }

/* ---------- format cards ---------- */
.formats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 26px 0 8px; }
.formats a { display: block; padding: 14px 16px; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.formats a:hover { border-color: var(--accent); }
.formats a[aria-current="page"] { border-color: var(--accent); background: var(--accent-soft); }
.formats strong { display: block; font-weight: 600; }
.formats span { color: var(--muted); font-size: .9rem; }

/* ---------- content ---------- */
.section { padding: 40px 0 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.steps li { counter-increment: step; padding-top: 10px; border-top: 2px solid var(--ink); }
.steps li::before { content: counter(step); display: block; font: 500 .9rem var(--mono); color: var(--muted); margin-bottom: 6px; }
.steps h3 { margin-bottom: .3em; }
.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.6em; }
.prose h3 { margin-top: 1.4em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .35em; }
.prose code { font-family: var(--mono); font-size: .9em; background: var(--panel); border: 1px solid var(--rule-soft); padding: .05em .35em; border-radius: 3px; overflow-wrap: anywhere; }
.compare { width: 100%; border-collapse: collapse; margin: 1em 0 2em; font-size: .95rem; background: var(--panel); }
.compare th, .compare td { border: 1px solid var(--rule); padding: 8px 10px; text-align: left; vertical-align: top; }
.compare th { background: var(--rule-soft); font-weight: 600; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 1.5em; }

/* ---------- FAQ ---------- */
.faq details { border-top: 1px solid var(--rule); max-width: 72ch; }
.faq details:last-of-type { border-bottom: 1px solid var(--rule); }
.faq summary { cursor: pointer; font-weight: 500; list-style: none; display: flex; justify-content: space-between; gap: 16px; padding: 14px 2px; min-height: var(--tap); align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; color: var(--muted); font-family: var(--mono); font-size: 1.15em; }
.faq details[open] summary::after { content: '\2013'; }
.faq details p { margin: 0 0 14px; color: var(--ink); }

/* ---------- ads ---------- */
.ad-slot { margin: 34px auto; max-width: 728px; text-align: center; }
.ad-slot .ad-label { display: block; font-size: .7rem; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.ad-slot ins, .ad-slot .ad-box { display: block; min-height: 280px; }
.ad-slot.is-preview .ad-box { display: grid; place-items: center; min-height: 280px; border: 1px dashed var(--rule); border-radius: var(--radius); background: var(--rule-soft); color: var(--muted); font-size: .85rem; }
@media (max-width: 600px) { .ad-slot ins, .ad-slot .ad-box, .ad-slot.is-preview .ad-box { min-height: 250px; } }
.tool ins.adsbygoogle, .tool .ad-slot { display: none !important; }

/* ---------- footer ---------- */
.site-footer { margin-top: 56px; border-top: 1px solid var(--rule); padding: 26px 0 40px; color: var(--muted); font-size: .92rem; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; }
.site-footer a { color: var(--muted); display: inline-flex; align-items: center; min-height: 30px; }
.site-footer .copy { margin-left: auto; }

.legal { padding: 36px 0; max-width: 72ch; }
.legal h2 { margin-top: 1.6em; font-size: 1.25rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- mobile ---------- */
@media (max-width: 880px) {
  .wrap { padding: 0 16px; }

  /* Header: brand and theme on one line, formats scrolling beneath. */
  .site-header .wrap { flex-wrap: wrap; padding-top: 10px; padding-bottom: 4px; min-height: 0; gap: 6px; }
  .brand { font-size: 1rem; }
  .brand svg { width: 24px; height: 24px; }
  .nav { order: 3; margin: 2px -16px 0; padding: 0 16px 6px; width: calc(100% + 32px); gap: 4px; }
  .nav a { font-size: .9rem; padding: 7px 11px; min-height: 36px; }

  /* Hero: shorter, so the tool sits close to the top. */
  .intro { padding: 20px 0 14px; }
  .intro h1 { font-size: clamp(1.45rem, 6.2vw, 1.9rem); margin-bottom: .35em; }
  .intro p { font-size: .95rem; line-height: 1.55; margin-bottom: 0; }

  /* One pane at a time. */
  .tool { grid-template-columns: 1fr; grid-template-areas: "tabs" "editor" "preview" "actions"; gap: 12px; }
  .tool-tabs { display: block; }
  .tool-tabs .seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; padding: 3px; }
  .tool-tabs .seg button { min-height: 42px; font-size: .95rem; font-weight: 500; }
  .tool[data-view="write"] .preview-pane, .tool[data-view="preview"] #editor-pane { display: none; }

  #editor-pane { min-height: 0; }
  #editor { font-size: 16px; line-height: 1.65; min-height: 44vh; padding: 16px; }
  .pane-bar { padding: 8px; gap: 4px; }
  .pane-bar .label { display: none; }
  .pane-bar .count { margin-right: auto; padding-left: 6px; }
  .pane-bar .btn-quiet { padding: 9px 10px; min-height: 40px; }
  .pane-hint { display: none; }

  .preview-pane .pane-bar { padding: 8px; }
  .preview-pane .seg { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .preview-pane .seg button { min-height: 40px; }

  /* Page setup gets its own two-column block instead of a squeezed strip. */
  .page-setup .field { flex-direction: column; align-items: stretch; gap: 5px; }
  .page-setup .field span { font-size: .75rem; letter-spacing: .02em; }
  .page-setup select { width: 100%; min-height: 42px; }
  .page-setup .seg-icon { display: grid; grid-template-columns: 1fr 1fr; }
  .page-setup .seg-icon button { min-height: 38px; justify-content: center; }
  .page-info { grid-column: 1 / -1; margin: 0; text-align: center; font-size: .8rem; }

  .sheet-scroll { padding: 12px; max-height: none; }
  .sheet { box-shadow: 0 1px 3px rgba(0,0,0,.14); }
  .notice { padding: 10px 12px; }

  /* Export bar: primary action full width, the rest paired underneath. */
  .tool-actions {
    position: sticky; bottom: 0; z-index: 5;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -6px 20px rgba(0,0,0,.12);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
  .actions .spacer { display: none; }
  .actions .btn { min-height: var(--tap); font-size: .93rem; }
  .actions .btn-primary { grid-column: 1 / -1; min-height: 50px; font-size: 1rem; }
  .status { text-align: center; padding: 0 14px 10px; }

  .formats { grid-template-columns: 1fr; gap: 8px; margin-top: 22px; }
  .formats a { padding: 13px 15px; }
  .grid-3, .steps { grid-template-columns: 1fr; gap: 24px; }
  .section { padding: 32px 0 4px; }
  .prose h2 { margin-top: 1.4em; }
  .site-footer .copy { margin-left: 0; width: 100%; }
}

@media (max-width: 380px) { .actions { grid-template-columns: 1fr; } }

/* Hover styling only where a real pointer exists, so taps don't leave
   buttons stuck looking hovered on touch screens. */
@media (hover: none) {
  .btn:hover:not(:disabled), .formats a:hover { border-color: var(--rule); }
  .btn-quiet:hover { background: none; }
  .btn-primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
  .nav a:hover { background: none; color: var(--muted); }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a, .formats a, .seg button { transition: border-color .12s, background-color .12s, color .12s, transform .08s; }
}

@media print { .site-header, .site-footer, .tool, .formats, .ad-slot { display: none !important; } }


/* ---------------- component refinements ---------------- */

.theme-btn { flex-shrink: 0; padding: 8px; min-width: 38px; }
.theme-btn svg { width: 17px; height: 17px; }
.theme-btn[data-theme-state="dark"] svg circle { fill: currentColor; }
.theme-btn[data-theme-state="system"] { opacity: .8; }

/* buttons: slightly softer, with a real pressed state and a clear primary */
.btn {
  font-weight: 450;
  box-shadow: 0 1px 0 rgba(16, 24, 32, .03);
}
.btn-primary { box-shadow: 0 1px 2px rgba(47, 75, 214, .28); }
.btn-quiet { box-shadow: none; }

/* segmented controls */
.seg { border: 1px solid transparent; }
.seg button { font-weight: 450; }
.seg-icon button { padding: 6px 10px; display: inline-flex; align-items: center; }
.seg-icon svg { width: 16px; height: 16px; }

/* page setup strip */
.page-setup-wrap { border-bottom: 1px solid var(--rule-soft); background: var(--panel); }
.page-setup-wrap > summary {
  display: none; cursor: pointer; list-style: none;
  padding: 12px; font-size: .9rem; align-items: center; gap: 10px;
}
.page-setup-wrap > summary::-webkit-details-marker { display: none; }
.page-setup-wrap > summary::after { content: '+'; margin-left: auto; color: var(--muted); font-family: var(--mono); }
.page-setup-wrap[open] > summary::after { content: '\2013'; }
.page-setup-wrap > summary .page-info { margin-left: auto; }
.page-setup-wrap[open] > summary .page-info { display: none; }
.page-setup {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--panel);
}
body:not(.preview-is-doc) .page-setup-wrap { display: none; }
.page-setup .field { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.page-setup select {
  font: inherit; font-size: .85rem; color: var(--ink); background: var(--panel);
  border: 1px solid var(--rule); border-radius: 5px; padding: 5px 8px; min-height: 32px;
}
.page-setup select:hover { border-color: var(--muted); }
.page-info { margin-left: auto; font: 400 .78rem/1 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }

.notice {
  margin: 0; padding: 8px 12px; font-size: .82rem; color: var(--muted);
  background: var(--rule-soft); border-bottom: 1px solid var(--rule-soft);
}
.notice::before { content: 'Note — '; color: var(--ink); font-weight: 500; }

/* paged preview: the sheet is a real page at true proportions, scaled to fit */
.sheet-wrap { transform-origin: top left; margin: 0 auto; }
.sheet-wrap.is-paged .sheet { max-width: none; }
.sheet-scroll { display: block; }
.preview-is-doc .sheet-scroll { background: var(--well); }
.sheet .table-wrap { overflow-x: auto; margin: 0 0 1em; }
.sheet .table-wrap table { margin: 0; }
.sheet .img-missing { display: inline-block; padding: 6px 10px; border: 1px dashed #bbb; color: #777; font-size: .85em; }
.sheet input[type=checkbox] { margin-right: .45em; }
/* Task lists: :has() is unsupported in older engines, so the marker is hidden
   on the list item itself, which degrades to a normal bullet rather than breaking. */
.sheet li:has(> input[type=checkbox]) { list-style: none; margin-left: -1.1em; }
.sheet pre { max-width: 100%; }

/* focus rings that follow the component shape */
.seg button:focus-visible { outline-offset: -2px; }
.page-setup select:focus-visible { outline-offset: 1px; }

@media (max-width: 880px) {
  .theme-btn { order: 2; margin-left: auto; min-height: 40px; }
  /* Page setup folds away on a phone; the summary keeps the paper and page
     count visible without spending half the screen on controls. */
  .page-setup-wrap > summary { display: flex; min-height: var(--tap); }
  .page-setup-wrap > summary .ps-title { font-weight: 500; }
  .page-setup { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 12px 14px; }
  .page-setup .field { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
  .page-setup .field span { font-size: .75rem; text-align: left; }
  .page-setup select { width: 100%; min-height: 42px; }
  .page-setup .seg-icon { display: grid; grid-template-columns: 1fr 1fr; }
  .page-setup .seg-icon button { min-height: 38px; justify-content: center; }
  .page-setup > .js-page-info { display: none; }
}

/* ---------------- GEO / content blocks ---------------- */

.crumbs { display: flex; gap: 8px; align-items: center; padding: 14px 0 0; font-size: .85rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }

.quick {
  border-left: 3px solid var(--accent); background: var(--panel);
  padding: 16px 18px; margin: 0 0 18px; border-radius: 0 var(--radius) var(--radius) 0;
}
.quick p { margin: 0; }
.quick .quick-label {
  font-size: .78rem; font-weight: 600; color: var(--accent);
  margin-bottom: 6px; letter-spacing: .02em;
}

.byline { font-size: .87rem; color: var(--muted); margin: 0 0 20px; }
.byline .sep { padding: 0 6px; }

.facts caption { text-align: left; font-weight: 600; padding-bottom: 8px; color: var(--ink); }
.facts th[scope="row"] { width: 34%; background: var(--rule-soft); font-weight: 500; }
@media (max-width: 600px) { .facts th[scope="row"] { width: 42%; } }

/* ---------------- new tools ---------------- */

.tool-single { grid-template-columns: 1fr 1fr; grid-template-areas: "editor preview"; }
.tool-single > .pane:first-child { grid-area: editor; }
.tool-single > .pane:last-child, .tool-single .out-pane { grid-area: preview; }
.tool-single .dropzone { grid-area: editor; }
.tool-single .stage { grid-area: preview; }

/* table grid */
.grid-wrap { overflow: auto; padding: 12px; }
.grid-table { border-collapse: separate; border-spacing: 0; width: 100%; }
.grid-table th, .grid-table td { padding: 0; }
.grid-controls th { padding-bottom: 6px; text-align: center; white-space: nowrap; }
.grid-table .row-label {
  width: 30px; color: var(--muted); font: 400 .75rem var(--mono);
  text-align: center; padding-right: 6px;
}
.grid-table input {
  width: 100%; min-width: 90px; font: inherit; font-size: .92rem;
  padding: 9px 10px; border: 1px solid var(--rule-soft); border-radius: 4px;
  background: var(--canvas); color: var(--ink); margin: 2px;
}
.grid-table input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); background: var(--panel); }
.grid-table .header-row input { font-weight: 600; background: var(--rule-soft); }
.align-btn, .del-btn {
  border: 1px solid transparent; background: none; color: var(--muted);
  border-radius: 4px; cursor: pointer; line-height: 1;
}
.align-btn { padding: 4px 8px; font-size: .95rem; }
.align-btn:hover { color: var(--ink); background: var(--rule-soft); }
.del-btn { padding: 2px 7px; font-size: 1rem; }
.del-btn:hover { color: var(--err); background: var(--rule-soft); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.check input { accent-color: var(--accent); }
.import-box { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.import-box textarea {
  width: 100%; font: 13px/1.5 var(--mono); padding: 10px; border-radius: var(--radius);
  border: 1px solid var(--rule); background: var(--canvas); color: var(--ink); resize: vertical;
}
.import-box .btn { align-self: flex-start; }

/* shared code output */
.code-out {
  flex: 1; margin: 0; padding: 16px; overflow: auto; min-height: 320px;
  font: 13px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word;
  background: var(--panel); color: var(--ink); border: 0; border-top: 1px solid var(--rule-soft);
  border-radius: 0 0 var(--radius) var(--radius); width: 100%; resize: none;
}
.code-out:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent-soft); }
.out-pane { background: var(--panel); }

/* html-to-markdown input */
#html-in {
  flex: 1; width: 100%; min-height: 340px; resize: none; border: 0; padding: 16px;
  background: var(--panel); color: var(--ink); font: 13px/1.6 var(--mono);
  border-top: 1px solid var(--rule-soft);
}
#html-in:focus { outline: none; }
#html-pane:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#html-pane.dragover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* viewer dropzone */
.dropzone {
  display: grid; place-items: center; min-height: 420px; cursor: pointer;
  border: 2px dashed var(--rule); border-radius: var(--radius); background: var(--panel);
  padding: 32px 20px; text-align: center;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.dropzone.has-file { min-height: 0; padding: 18px; }
.drop-title { font-size: 1.15rem; font-weight: 600; margin-bottom: .3em; }
.drop-title code { font-family: var(--mono); font-size: .95em; background: var(--rule-soft); padding: .1em .35em; border-radius: 3px; }
.drop-sub { color: var(--muted); margin-bottom: 1.2em; max-width: 42ch; }
.drop-note { color: var(--muted); font-size: .82rem; margin: 1.2em 0 0; }
.dropzone.has-file .drop-sub, .dropzone.has-file .drop-note { display: none; }
.stage { background: var(--well); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.stage .pane-bar { background: var(--panel); }
.stage .sheet-scroll { max-height: 620px; }
.stage .sheet { min-height: 320px; }
#source { padding: 24px; margin: 0; }

/* formatting toolbar */
.format-bar {
  display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 8px;
  border-bottom: 1px solid var(--rule-soft); background: var(--panel);
}
.fb {
  border: 1px solid transparent; background: none; color: var(--muted);
  padding: 6px 9px; min-height: 32px; border-radius: 4px; font-size: .85rem; line-height: 1;
}
.fb:hover { color: var(--ink); background: var(--rule-soft); }
.fb-sep { width: 1px; background: var(--rule-soft); margin: 4px 5px; }

@media (max-width: 880px) {
  .tool-single { grid-template-columns: 1fr; grid-template-areas: "editor" "preview"; }
  .tool-single .stage { grid-area: preview; }
  .grid-table input { min-width: 76px; font-size: 16px; padding: 10px 8px; }
  .code-out, #html-in { min-height: 240px; font-size: 13px; }
  .dropzone { min-height: 300px; padding: 24px 16px; }
  .format-bar { gap: 1px; padding: 5px; }
  .fb { padding: 8px; min-height: 40px; }
  .stage .sheet-scroll { max-height: none; }
}

/* [hidden] must win over the component's own display */
.import-box[hidden], .stage[hidden], .notice[hidden] { display: none !important; }

@media (max-width: 880px) {
  /* the paste-from-spreadsheet hint is the whole point of the table tool */
  .tool-single .pane-hint { display: block; padding: 0 12px 10px; }
  .grid-wrap { padding: 8px 6px 12px; }
  .align-btn { padding: 9px 12px; font-size: 1.05rem; min-height: 40px; }
  .del-btn { padding: 8px 11px; min-height: 40px; }
  .grid-controls th { padding-bottom: 2px; }
  .grid-table .row-label { width: 22px; }
  .grid-table input { min-width: 92px; }
  .import-box { padding: 0 12px 12px; }
  .import-box textarea { font-size: 16px; }
  .stage .pane-bar { gap: 4px; }
  #source { padding: 16px; }
}

/* ---------------- tool grid, grouped by job ---------------- */

.tool-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
  margin: 30px 0 8px; padding-top: 4px;
}
.grid-heading { grid-column: 1 / -1; margin: 0; font-size: 1.25rem; }
.tool-group h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 2px; font-weight: 600; }
.tool-group .group-sub { font-size: .85rem; color: var(--muted); margin: 0 0 10px; }
.tool-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tool-group a {
  display: block; padding: 12px 14px; background: var(--panel);
  border: 1px solid var(--rule); border-radius: var(--radius);
  color: var(--ink); text-decoration: none;
}
.tool-group a:hover { border-color: var(--accent); }
.tool-group a[aria-current="page"] { border-color: var(--accent); background: var(--accent-soft); }
.tool-group strong { display: block; font-weight: 600; font-size: .97rem; }
.tool-group span { color: var(--muted); font-size: .86rem; line-height: 1.45; display: block; margin-top: 2px; }

@media (max-width: 880px) {
  .tool-grid { grid-template-columns: 1fr; gap: 20px; margin-top: 24px; }
  .grid-heading { font-size: 1.15rem; }
  .tool-group a { padding: 13px 14px; }
}

/* restore-draft banner */
.restore-bar { display:flex; flex-wrap:wrap; align-items:center; gap:10px; padding:10px 14px; margin-bottom:12px;
  background: var(--accent-soft); border:1px solid var(--accent); border-radius: var(--radius); font-size:.92rem; }
.restore-bar span { flex:1; min-width: 200px; }
@media (max-width: 880px) { .restore-bar { padding: 12px; } .restore-bar .btn { min-height: 40px; } }

/* copy-for-chat menu */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 150px; background: var(--panel);
  border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; display: grid; }
.menu-list button { text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 4px; font: inherit; color: var(--ink); min-height: 38px; }
.menu-list button:hover { background: var(--rule-soft); }
/* privacy proof */
.privacy-proof { margin: 0; padding: 0 12px 9px; font-size: .8rem; color: var(--muted); }
.privacy-proof::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--ok); vertical-align: 1px; }
.privacy-proof[data-state="notice"]::before { background: #d9a400; }
/* shortcut sheet */
.sheet-modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; }
.sheet-modal[hidden] { display: none !important; }
.sheet-modal-card { background: var(--panel); color: var(--ink); border-radius: 10px; padding: 22px 24px; max-width: 640px; width: 100%; box-shadow: var(--shadow); }
.sheet-modal-card h2 { margin-top: 0; }
.sc td { padding: 8px 10px; font-size: .92rem; vertical-align: middle; }
.sc td:nth-child(odd) { white-space: nowrap; width: 1%; }
kbd { font: .85em var(--mono); background: var(--rule-soft); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; }
.sc-note { color: var(--muted); font-size: .85rem; }
@media (max-width: 880px) {
  .sc tr { display: grid; grid-template-columns: auto 1fr; }
  .menu-list { left: auto; right: 0; }
  #sync-toggle { display: none; }   /* one pane at a time on phones; nothing to sync */
}
