:root {
  --bg: #f4f5f7; --panel: #ffffff; --fg: #1c1f23; --muted: #6b7178; --line: #e2e5e9;
  --accent: #2459c7; --accent-fg: #fff; --accent-soft: #e8efff;
  --warn: #b5650d; --warn-soft: #fff4e2; --err: #c0362c; --err-soft: #fdecea;
  --ok: #217a4a; --edited: #7b4ce0; --edited-soft: #f1ebff;
  --page: #ffffff; --page-fg: #111; --sel: #dbe6ff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --panel: #1d2024; --fg: #e5e7ea; --muted: #9aa1a9; --line: #2e3237;
    --accent: #6c9bff; --accent-fg: #0b1220; --accent-soft: #1d2a45;
    --warn: #f0a94e; --warn-soft: #3a2b16; --err: #ff7b70; --err-soft: #3c1f1c;
    --ok: #5cc98f; --edited: #b398ff; --edited-soft: #2b2342;
    --page: #202328; --page-fg: #e9eaec; --sel: #26365c;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 12px; background: var(--bg); padding: 0 3px; border-radius: 3px; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; letter-spacing: .2px; font-size: 16px; }
.brand span { color: var(--accent); }
.file { flex: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 3px 8px; font-size: 13px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 13px; }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); }

.layout { display: grid; grid-template-columns: 360px 1fr; height: calc(100vh - 53px); }
.side { overflow: auto; border-right: 1px solid var(--line); background: var(--panel); padding: 12px 14px 24px; }
.block { margin-bottom: 18px; }
.block-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; }
.row select { flex: 1; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.small-actions { margin-top: 6px; gap: 14px; flex-wrap: wrap; }

.lvl { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; }
.lvl.unused { opacity: .7; }
.lvl:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.lvl-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.lvl-title { font-weight: 600; font-size: 13px; }
.count { font-size: 11px; color: var(--muted); }
.example { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--accent); white-space: pre; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.tpl { width: 100%; font-family: var(--mono); font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.tpl:focus { outline: none; border-color: var(--accent); }
.tpl.bad { border-color: var(--err); background: var(--err-soft); }
.lvl-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 2px 9px; font-size: 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-fg); }
.seg-label { font-size: 12px; color: var(--muted); }
.reset-lvl { margin-left: auto; font-size: 12px; }
.tokens { display: none; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.lvl:focus-within .tokens { display: flex; }
.tokens button { font-family: var(--mono); font-size: 11px; border: 1px dashed var(--line); background: none; border-radius: 4px; padding: 1px 5px; cursor: pointer; color: var(--muted); }
.tokens button:hover { color: var(--accent); border-color: var(--accent); }
.msg { font-size: 12px; margin-top: 5px; }
.msg .e { color: var(--err); display: block; }
.msg .w { color: var(--warn); display: block; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin: 4px 0 8px; }
.help { font-size: 12.5px; color: var(--muted); }
.help p { margin: 0 0 8px; }

.work { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; align-items: center; gap: 2px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.tab-spacer { flex: 1; }
.pill { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-size: 11px; text-align: center; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.legend { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 8px; }
.sw.flagged { background: var(--warn); }
.sw.edited { background: var(--edited); }

.selbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 14px; background: var(--accent-soft); border-bottom: 1px solid var(--line); font-size: 13px; }
.selbar select { padding: 3px 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--panel); margin-left: 4px; }
.selbar .hint { color: var(--muted); font-size: 12px; margin-left: auto; }

.pane { flex: 1; overflow: auto; min-height: 0; }
.page { background: var(--page); color: var(--page-fg); width: 647px; max-width: 100%; position: relative; margin: 18px auto 60px; padding: 40px 48px; border: 1px solid var(--line); border-radius: 4px;
        font: 13.5px/1.4 Arial, Helvetica, sans-serif; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.para { position: relative; margin: 0 0 6px; cursor: pointer; border-radius: 3px; padding-top: 1px; padding-bottom: 1px; white-space: normal; }
.para:hover { background: color-mix(in srgb, var(--sel) 45%, transparent); }
.para.sel { background: var(--sel); }
.para .lbl { display: inline-block; text-indent: 0; white-space: pre; }
.para .lbl.gap { padding-right: 10px; }
.para.d0, .para.d1 { margin-top: 12px; }
.para.none { color: var(--muted); }
.para.table { color: var(--muted); font-size: 12px; }
.para.flagged::before, .para.edited::before { content: ""; position: absolute; left: -14px; top: 3px; bottom: 3px; width: 4px; border-radius: 2px; background: var(--warn); }
.para.edited::before { background: var(--edited); }
.para .tag { font: 10px system-ui, sans-serif; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; margin-left: 6px; text-indent: 0; display: inline-block; vertical-align: 1px; }
.para .lbl.changed { color: var(--accent); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 16px 0; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.tablewrap { padding: 12px 16px 40px; overflow-x: auto; }
.grid { border-collapse: collapse; width: 100%; background: var(--panel); font-size: 13px; }
.grid th, .grid td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid th { position: sticky; top: 0; background: var(--panel); font-weight: 600; }
.grid td.mono { font-family: var(--mono); font-size: 12px; white-space: pre; }
.grid tr { cursor: pointer; }
.grid tr:hover td { background: var(--accent-soft); }
.kind { font-size: 11px; padding: 1px 6px; border-radius: 3px; background: var(--bg); white-space: nowrap; }
.kind.renumbered { background: var(--warn-soft); color: var(--warn); }
.kind.level { background: var(--edited-soft); color: var(--edited); }
.kind.removed { background: var(--err-soft); color: var(--err); }
.warnlist { list-style: none; margin: 0; padding: 12px 16px 40px; }
.warnlist li { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 4px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer; font-size: 13px; }
.warnlist li.detect { border-left-color: var(--muted); }
.warnlist .pid { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-right: 6px; }

.empty { display: grid; place-items: center; height: calc(100vh - 53px); padding: 16px; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 48px 56px; text-align: center; background: var(--panel); max-width: 480px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.toast { position: fixed; right: 16px; bottom: 16px; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.15); font-size: 13px; z-index: 20; }
.toast .t-title { font-weight: 600; margin-bottom: 4px; }
.toast.err { border-left: 4px solid var(--err); }
.toast.ok { border-left: 4px solid var(--ok); }
.toast a { color: var(--accent); margin-right: 12px; }
.toast .close { position: absolute; top: 6px; right: 8px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .pane { overflow: visible; }
  .page { margin: 12px auto; padding: 20px 16px; }
  .legend, .selbar .hint { display: none; }
}

/* sidebar tabs and formatting panel */
.side-tabs { display: flex; margin: -4px 0 14px; border-bottom: 1px solid var(--line); }
.side-tab { flex: 1 1 auto; white-space: nowrap; border: 0; background: none; padding: 8px 6px; margin-bottom: -1px; cursor: pointer;
  color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; font-size: 13px; text-align: center; }
.side-tab:hover { color: var(--fg); }
.side-tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.tiny { font-size: 12px; margin: 8px 0 0; }
.targets { display: flex; flex-wrap: wrap; gap: 5px; }
.tchip { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 3px 9px; font-size: 12px; cursor: pointer; position: relative; }
.tchip.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.tchip.has::after { content: ""; position: absolute; top: 2px; right: 2px; width: 6px; height: 6px; border-radius: 3px; background: var(--edited); }
.fgroup { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 10px; }
.fgroup-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.frow { display: grid; grid-template-columns: 118px 1fr; align-items: center; gap: 6px 8px; margin: 5px 0; font-size: 13px; }
.frow > label { color: var(--muted); }
.fctl { display: flex; align-items: center; gap: 6px; min-width: 0; }
.fctl input[type=text], .fctl input[type=number], .fctl select { width: 100%; min-width: 0; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); }
.fctl input.setv, .fctl select.setv { border-color: var(--edited); background: var(--edited-soft); }
.fctl .x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 13px; visibility: hidden; }
.fctl .x.show { visibility: visible; }
.tri { border: 1px solid var(--line); background: var(--panel); border-radius: 5px; min-width: 34px; padding: 2px 7px; cursor: pointer; font-size: 12px; }
.tri.on { background: var(--edited); color: #fff; border-color: var(--edited); }
.tri.off { text-decoration: line-through; color: var(--err); border-color: var(--err); }
.tri.mixed { border-style: dashed; }
.note { grid-column: 2; font-size: 11px; color: var(--muted); margin-top: -2px; }
.rules { margin: 0 0 8px; padding-left: 16px; font-size: 12.5px; }
.rules li { margin-bottom: 3px; }
.para.pb { margin-top: 26px; }
.para.pb::after { content: "page break"; position: absolute; left: -48px; right: -48px; top: -17px; border-top: 1px dashed var(--muted); font: 10px system-ui, sans-serif; color: var(--muted); text-align: center; text-indent: 0; line-height: 0; padding-top: 0; }
.pagesbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; font-size: 13px; flex-wrap: wrap; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 0 16px 40px; }
.pages img { width: 100%; max-width: 680px; background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.stale { color: var(--warn); }

.check-line { display: flex; gap: 7px; align-items: flex-start; font-size: 13px; margin: 6px 0; cursor: pointer; }
.check-line input { margin-top: 2px; }
.styles-box { background: var(--accent-soft); border-color: transparent; }
.title-result { font-size: 12px; color: var(--accent); margin-top: 6px; overflow-wrap: anywhere; }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 10px; padding: 18px; width: min(420px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal-msg { margin-bottom: 12px; white-space: pre-line; }
.modal-input { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.kind.fixed { background: var(--accent-soft); color: var(--accent); }

/* header & footer */
.hf-area { font: 11px/1.35 Arial, Helvetica, sans-serif; color: var(--page-fg); }
.hf-area:empty { display: none; }
.hf-header { margin: -22px 0 22px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.hf-footer { margin: 22px 0 -22px; padding-top: 8px; border-top: 1px dashed var(--line); }
.hf-area.kept { color: var(--muted); }
.hf-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; min-height: 1.35em; }
.hf-row > :nth-child(2) { text-align: center; }
.hf-row > :nth-child(3) { text-align: right; }
.hf-rule { border-bottom: 1px solid currentColor; margin: 2px 0 4px; }
.hf-rule.double { border-bottom: 3px double currentColor; }
.hf-rule.dotted { border-bottom-style: dotted; } .hf-rule.dashed { border-bottom-style: dashed; }
.hf-tag { position: absolute; left: 8px; font: 10px system-ui, sans-serif; color: var(--muted); }
.hfblock { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 14px; }
.hfblock-title { font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.radio-line { display: flex; gap: 7px; align-items: center; font-size: 13px; margin: 4px 0; cursor: pointer; }
.kept-text { font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 6px; padding: 6px 8px; margin: 6px 0; white-space: pre-wrap; }
.hrow { border: 1px solid var(--line); border-radius: 7px; padding: 7px; margin: 7px 0; background: var(--panel); }
.hrow-head { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.hrow-head .sp { flex: 1; }
.iconbtn { border: 1px solid var(--line); background: var(--panel); border-radius: 5px; padding: 0 6px; cursor: pointer; font-size: 12px; line-height: 20px; }
.iconbtn:disabled { opacity: .35; cursor: default; }
.seg-edit { margin: 4px 0; }
.seg-edit .seg-top { display: grid; grid-template-columns: 52px 1fr auto; gap: 6px; align-items: center; }
.seg-edit .seg-top span { font-size: 12px; color: var(--muted); }
.seg-edit input[type=text] { width: 100%; min-width: 0; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); font-size: 13px; }
.seg-fmt { display: none; flex-wrap: wrap; gap: 5px; align-items: center; margin: 5px 0 2px 58px; }
.seg-edit.open .seg-fmt { display: flex; }
.seg-fmt input[type=text] { width: 110px; } .seg-fmt input[type=number] { width: 56px; padding: 3px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); }
.aa { border: 1px solid var(--line); background: var(--panel); border-radius: 5px; font-size: 11px; padding: 1px 6px; cursor: pointer; }
.aa.has { border-color: var(--edited); color: var(--edited); }
.field-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.field-chips button { font-family: var(--mono); font-size: 11px; border: 1px dashed var(--line); background: none; border-radius: 4px; padding: 1px 5px; cursor: pointer; color: var(--muted); }
.field-chips button:hover { color: var(--accent); border-color: var(--accent); }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
/* title options */
.title-now { font-size: 12px; margin: 2px 0 6px; overflow-wrap: anywhere; }
.num-spaces { font-size: 13px; margin: 8px 0 4px; }
.num-gaps { display: flex; align-items: center; gap: 2px; margin: 6px 0 4px; font-family: var(--mono); font-size: 15px; }
.num-gaps .pair { padding: 2px 1px; }
.num-gaps .gap-fixed { width: 14px; }
.gap-btn { border: 1px dashed var(--line); background: none; color: var(--muted); border-radius: 4px; width: 22px; height: 24px; padding: 0; cursor: pointer; font-family: var(--mono); font-size: 12px; }
.gap-btn:hover { border-color: var(--accent); color: var(--accent); }
.gap-btn.on { border-style: solid; border-color: var(--edited); background: var(--edited-soft); color: var(--edited); }
/* header/footer: fields hint, logos */
.chip-hint { font-size: 12px; color: var(--warn); background: var(--warn-soft); border-radius: 6px; padding: 6px 8px; margin: 2px 0 6px; }
@keyframes flash { 0%, 100% { box-shadow: none; } 30%, 70% { box-shadow: 0 0 0 3px var(--accent); } }
.seg-edit input.flash { animation: flash 1.2s ease 1; }
.seg-btns { display: flex; gap: 4px; }
.seg-edit .seg-top { grid-template-columns: 52px 1fr auto; }
.seg-logo { display: flex; align-items: center; gap: 8px; margin: 5px 0 2px 58px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.seg-logo img { height: 26px; max-width: 90px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 3px; }
.seg-logo input { width: 62px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }
.hf-logo { vertical-align: bottom; height: auto; margin-right: 4px; }
/* page & file */
.subhead { font-size: 12px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.margin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.margin-grid label { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.margin-grid input { width: 100%; min-width: 0; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); }
.margin-grid input.setv { border-color: var(--edited); background: var(--edited-soft); }
.layout-problems { color: var(--err); font-size: 12px; margin-top: 6px; }
.page { width: var(--page-w, 647px); padding-left: var(--pad-l, 48px); padding-right: var(--pad-r, 48px); }
@media (max-width: 900px) { .page { padding-left: 16px; padding-right: 16px; } }
/* spec template */
@keyframes pulse { 0%, 100% { box-shadow: none; } 30%, 70% { box-shadow: 0 0 0 3px var(--accent); } }
.block.pulse { animation: pulse 1.4s ease 1; border-radius: 8px; }
/* export: format picker joined to the button */
.export-group { display: flex; }
.export-group select { border: 1px solid var(--accent); border-right: 0; border-radius: 6px 0 0 6px; background: var(--panel); color: var(--fg); padding: 0 6px; font: inherit; font-size: 13px; cursor: pointer; }
.export-group .btn { border-radius: 0 6px 6px 0; }
/* batch */
.batch { padding: 18px 24px 40px; max-width: 1280px; margin: 0 auto; }
.batch-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.batch-head h1 { font-size: 20px; margin: 0 0 4px; }
.batch-head p { margin: 0; max-width: 720px; }
.batch-grid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.batch-list { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.batch-list .tablewrap { padding: 0 0 6px; }
.batch-tools { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.batch-empty { padding: 28px 16px; text-align: center; }
.batch-side { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.batch .grid tr { cursor: default; }
.batch .grid tr.master td { background: var(--accent-soft); }
.batch .grid .fname { font-weight: 600; overflow-wrap: anywhere; }
.batch .status.done { color: var(--ok); }
.batch .status.failed, .batch .status.bad { color: var(--err); }
.batch .status.working, .batch .status.waiting { color: var(--muted); }
.master-pick { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.row-actions { white-space: nowrap; }
.batch-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.batch-note { margin-top: 10px; display: grid; gap: 6px; justify-items: start; font-size: 13px; }
#batchBtn.active { border-color: var(--accent); color: var(--accent); }
@media (max-width: 900px) {
  .batch { padding: 12px 16px 32px; }
  .batch-grid { grid-template-columns: 1fr; }
  .batch-head { flex-direction: column; }
}
.batch .grid .tiny, .batch .grid td.tiny { margin: 0; }
.batch .grid .spec-cell { min-width: 200px; }
.batch .grid .saves { min-width: 120px; overflow-wrap: anywhere; }
.batch .grid td.status { min-width: 110px; overflow-wrap: anywhere; }
.disclaimer { border: 1px solid var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 10px 12px; }
.disclaimer .block-title { color: var(--warn); }
.disclaimer p { font-size: 12.5px; margin: 6px 0 0; line-height: 1.45; }
/* highlight of the level / header / footer being edited */
.para.hl { background: color-mix(in srgb, var(--accent) 13%, transparent); box-shadow: -4px 0 0 var(--accent); }
.para.hl.sel { background: var(--sel); }
.hf-area.hl { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.hf-area { transition: background .15s; }
a.brand { color: inherit; text-decoration: none; cursor: pointer; }
a.brand { display: inline-block; }
a.brand:hover, a.brand:focus-visible { animation: jiggle .45s ease-in-out; }
@keyframes jiggle {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-4deg); }
  40% { transform: rotate(3.5deg); }
  60% { transform: rotate(-2.5deg); }
  80% { transform: rotate(1.5deg); }
}
@media (prefers-reduced-motion: reduce) { a.brand:hover, a.brand:focus-visible { animation: none; } }
.batch .grid.no-master th:first-child, .batch .grid.no-master td:first-child { display: none; }
.batch .grid.no-master tr.master td { background: none; }
.tiny-link { font-size: 12px; display: inline-block; margin-top: 6px; }
/* account menu (hosted app) */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary::after { content: " ▾"; color: var(--muted); }
.user-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.user-pop .tiny { margin: 0; overflow-wrap: anywhere; }
.user-pop a, .user-pop .link { justify-self: start; }
/* sign-in, invite, account and admin pages */
.auth-body { min-height: 100vh; background: var(--bg); }
.auth-wrap { max-width: 440px; margin: 40px auto; padding: 0 16px; display: grid; gap: 16px; }
.auth-wrap.wide { max-width: 980px; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; display: grid; gap: 12px; }
.auth-card h1 { font-size: 20px; margin: 0; }
.auth-card h2 { font-size: 16px; margin: 0; }
.auth-card p { margin: 0; }
.auth-card label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.auth-card input, .auth-card select { font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); width: 100%; }
.auth-card .btn.primary { justify-content: center; padding: 9px 14px; }
.auth-card .grid tr { cursor: default; }
.auth-card .grid form { margin: 0; }
.auth-error { color: var(--err); background: var(--err-soft); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.auth-ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border-radius: 6px; padding: 8px 10px; font-size: 13px; display: grid; gap: 6px; }
.auth-ok input.copy { font-family: var(--mono); font-size: 12px; }
.inline-form { display: grid; grid-template-columns: 1fr 140px auto; gap: 10px; align-items: end; }
@media (max-width: 640px) { .inline-form { grid-template-columns: 1fr; } }
.user-pop a, .auth-card a, .auth-wrap > p > a { color: var(--accent); text-decoration: none; }
.user-pop a:hover, .auth-card a:hover, .auth-wrap > p > a:hover { text-decoration: underline; }
/* account banner (hosted app) */
.account-banner { padding: 7px 16px; font-size: 13px; background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.account-banner.warn { background: var(--warn-soft); color: var(--fg); }
.account-banner a, .account-banner .link { color: var(--accent); font-weight: 600; }
.account-banner .sep { display: inline-block; width: 12px; }
.account-banner:not([hidden]) + .layout { height: calc(100vh - 53px - 34px); }
/* public pages */
.top .pub-nav { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.pub-nav a { color: var(--fg); text-decoration: none; }
.pub-nav a.btn.primary { color: var(--accent-fg); }
.pub-foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 16px 32px; }
.pub-foot a { color: var(--muted); }
.hero { text-align: center; padding: 30px 8px 10px; display: grid; gap: 14px; justify-items: center; }
.hero h1 { font-size: clamp(26px, 4vw, 38px); margin: 0; line-height: 1.15; max-width: 760px; }
.hero .lead { font-size: 16px; color: var(--muted); max-width: 680px; margin: 0; line-height: 1.5; }
.hero .price { font-weight: 600; margin: 0; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.hero-cta .btn { padding: 10px 18px; text-decoration: none; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.features > div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.features h3 { margin: 0 0 6px; font-size: 15px; }
.features p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.auth-card label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.auth-card label.check input { width: auto; margin-top: 3px; }
.plan-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.plan-buttons form { margin: 0; }
.legal h1 { font-size: 22px; } .legal h2 { font-size: 16px; margin-top: 10px; } .legal p { line-height: 1.5; }
.auth-card .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.inline-form { grid-template-columns: 1fr 170px 110px auto; }
@media (max-width: 760px) { .inline-form { grid-template-columns: 1fr; } }
.hero-cta a.btn { color: var(--fg); }
.hero-cta a.btn.primary { color: var(--accent-fg); }
.features { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }
