:root {
  --ink: #1a2733;
  --muted: #5c6b7a;
  --accent: #107a57;
  --accent-soft: #e3f2ec;
  --warn: #c4790c;
  --danger: #b3372e;
  --bg: #f7f8fa;
  --card: #ffffff;
  --border: #dde3e9;
  --radius: 10px;
}

* { box-sizing: border-box; }
/* The hidden attribute must win over any author display rule (flex, block). */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  /* Japanese faces follow the Latin ones, so Japanese names and labels get
     Japanese glyph shapes (not Chinese fallbacks) whatever the page's lang. */
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, "Hiragino Sans",
        "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, "Noto Sans JP",
        "Noto Sans CJK JP", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.7rem 1.5rem; background: var(--card);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 650;
  font-size: 1.1rem; color: var(--ink); letter-spacing: 0.2px; }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 1rem; }
.usernav { display: flex; align-items: center; gap: 0.4rem; }
/* Right-justified icon cluster next to a section heading. */
.headtools { display: flex; align-items: center; gap: 0.25rem; }
.saved-flash { font-size: 0.85rem; }
.saved-flash.ok { color: var(--ok, #2e7d32); }
.saved-flash.err { color: var(--danger); }
.modelpicker { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.modelpicker select { width: auto; }
.modelpicker .kv { flex-basis: 100%; word-break: break-all; }
.editable { cursor: pointer; border-bottom: 1px dashed transparent; }
.editable:hover { border-bottom-color: var(--border); }
select.role-select { width: auto; padding: 0.15rem 0.3rem; font-size: 0.95em; }
.run-name-input { font: inherit; font-weight: inherit; padding: 0 0.2rem; }
.heuristics { border: 1px solid var(--border); border-radius: 8px;
  padding: 0.6rem 0.8rem; margin: 0.8rem 0; }
.heuristics legend { padding: 0 0.4rem; color: var(--muted); font-size: 0.9rem; }
.heuristics label { display: flex; align-items: flex-start; gap: 0.4rem;
  font-weight: 400; margin: 0.25rem 0; }
.heuristics label input { width: auto; margin-top: 0.15rem; }

/* ---- Interactive bbox editor ---- */
.editor-toolbar { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 0.6rem; }
.editor-toolbar .tool.active { background: var(--accent-soft); outline: 2px solid var(--accent); }
/* Layer toggles: compact inline labels, not the block form labels. */
.editor-toolbar label.layer { display: inline-flex; align-items: center; gap: .25rem; margin: 0;
  font-weight: 500; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.editor-toolbar label.layer input { margin: 0; }
.editor-toolbar #fcount { font-size: .85rem; white-space: nowrap; }
.editor-toolbar #save-btn { margin-top: 0; padding: .35rem .9rem; }
.helpicon { display: inline-flex; align-items: center; justify-content: center; width: 18px;
  height: 18px; border-radius: 50%; border: 1.5px solid var(--muted); color: var(--muted);
  font-size: .75rem; font-weight: 700; cursor: help; margin-left: auto; }
.srclist label { display: flex; gap: .5rem; align-items: baseline; font-weight: 400;
  margin: .3rem 0; }
.srclist label input { width: auto; margin: 0; }
.legend { display: flex; gap: 1.2rem; font-size: 0.85rem; color: var(--muted);
  margin-bottom: 0.6rem; align-items: center; }
.legend .swatch { display: inline-block; width: 16px; height: 11px; margin-right: 5px;
  vertical-align: middle; }
/* Bounded scroll viewport so a zoomed page can be panned in both axes
   (scrollbar/trackpad reach the overflow; drag-to-pan wired in JS). */
#pages { overflow: auto; max-height: 82vh; }
#pages.panning { cursor: grabbing; }
#pages.grab, #pages.grab .fbox, #pages.grab .handle { cursor: grab; }
.pagewrap { position: relative; margin-bottom: 1rem;
  width: calc(100% * var(--z, 1)); }
.pagewrap > img { width: 100%; display: block; border: 1px solid var(--border);
  border-radius: 6px; }
.zoomctl { display: inline-flex; align-items: center; gap: .25rem; }
.zoomctl #zoom-label { min-width: 3.2em; text-align: center; }
.ovl { position: absolute; inset: 0; }
.ovl.addmode { cursor: crosshair; }
.fbox { position: absolute; border: 1.5px solid #2a5db0; box-sizing: border-box; z-index: 2; }
.fbox.editable { cursor: move; }
/* Predicted label lives INSIDE the box, top-left corner. Translucent by
   default so the form shows through and dense labels don't collide;
   brightens on hover of the field, of the label, or when selected. */
.fbox .lbl { position: absolute; top: 0; left: 0; font-size: 10px;
  line-height: 13px; background: rgba(42,93,176,.5); color: #fff; padding: 0 4px;
  border-radius: 2px 0 3px 0; white-space: nowrap; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; opacity: .3; z-index: 4;
  pointer-events: auto; transition: opacity .1s, background .1s; }
.fbox:hover .lbl, .fbox .lbl:hover { opacity: 1; background: #2a5db0; }
.fbox.selected { border-color: #e67e22; z-index: 6; }
/* a box that sits on another field's box or runs off its page */
.fbox.geoerr { border-color: var(--danger, #c0392b); border-width: 2px;
  box-shadow: 0 0 0 1px rgba(192,57,43,.35); }
.fbox.geoerr .lbl { background: var(--danger, #c0392b); }
.fbox.selected .lbl { background: #e67e22; opacity: 1; }
.fbox.nobbox { border-style: dotted; opacity: 0.7; }
/* Fill hints drawn inside a field, in purple: comb cells (with the characters
   the form already prints), the boxes of a value's parts, the writing lines
   of a wrapped answer, and a tag with the format or the cell count. For the
   selected field the part boxes and line handles can be dragged. */
.fbox .hint-cell, .fbox .hint-part, .fbox .hint-line { position: absolute;
  box-sizing: border-box; pointer-events: none; }
.fbox .hint-cell { border: 1px dotted rgba(123,31,162,.7); font-size: 9px; line-height: 1;
  color: rgba(123,31,162,.9); display: flex; align-items: center; justify-content: center; }
.fbox .hint-cell.printed { background: rgba(123,31,162,.12); }
.fbox .hint-part { border: 1px dashed rgba(123,31,162,.9); }
.fbox .hint-option { position: absolute; border: 1px solid rgba(230,120,0,.9); border-radius: 40%;
  pointer-events: none; }
.fbox .hint-option.live { pointer-events: auto; cursor: move; z-index: 12; background: rgba(230,120,0,.08); }
/* a choice's options: faint until the choice is selected, like a write-in */
.fbox .hint-choice { position: absolute; box-sizing: border-box; border: 1.5px solid rgba(46,125,50,.9);
  border-radius: 3px; pointer-events: none; opacity: .45; }
.fbox .hint-choice .hint-part-name { background: rgba(46,125,50,.85); }
.fbox.selected .hint-choice, .fbox:hover .hint-choice { opacity: 1; }
.fbox .hint-choice.pick { pointer-events: auto; cursor: pointer; }
.fbox .hint-choice.live { pointer-events: auto; cursor: move; background: rgba(46,125,50,.08); z-index: 12; }
/* a write-in blank is faint like an unselected box's label, and full strength
   while its option is selected or hovered, so which option owns it shows */
.fbox .hint-specify { position: absolute; box-sizing: border-box; border: 1.5px dashed rgba(230,120,0,.95);
  background: rgba(230,120,0,.06); pointer-events: none; opacity: .3; }
.fbox .hint-link { opacity: .3; }
.fbox.selected .hint-specify, .fbox:hover .hint-specify, .fbox .hint-specify:hover,
.fbox.selected .hint-link, .fbox:hover .hint-link { opacity: 1; }
.fbox .hint-specify.pick { pointer-events: auto; cursor: pointer; }
.fbox .hint-specify .hint-part-name { background: rgba(200,100,0,.85); }
/* a write-in blank of the selected option: dragged and resized on the page */
.fbox .hint-specify.live { pointer-events: auto; cursor: move; background: rgba(230,120,0,.12); z-index: 12; }
.fbox .hint-link { position: absolute; pointer-events: none; border-color: rgba(230,120,0,.95); border-style: dashed; }
.fbox .hint-link.h { border-width: 1px 0 0 0; height: 0 !important; }
.fbox .hint-link.v { border-width: 0 0 0 1px; width: 0 !important; }
/* above the field's own resize handles, so a part's edge can be grabbed
   where it meets the field's edge; the part's grips sit just inside it */
.fbox .hint-part.live { pointer-events: auto; cursor: move; background: rgba(123,31,162,.05);
  z-index: 12; }
.fbox .hint-part-name { position: absolute; left: 0; top: -11px; font-size: 9px; line-height: 10px;
  padding: 0 2px; color: #fff; background: rgba(123,31,162,.7); border-radius: 2px;
  white-space: nowrap; pointer-events: none; }
.fbox .hint-line { border-bottom: 1px dashed rgba(123,31,162,.85); }
.fbox .hint-grip { position: absolute; pointer-events: auto; background: rgba(123,31,162,.85);
  z-index: 7; }
.fbox .hint-grip.e, .fbox .hint-grip.w { top: 5px; bottom: 5px; width: 4px; cursor: ew-resize; }
.fbox .hint-grip.e { right: 0; } .fbox .hint-grip.w { left: 0; }
.fbox .hint-grip.n, .fbox .hint-grip.s { left: 5px; right: 5px; height: 4px; cursor: ns-resize; }
.fbox .hint-grip.n { top: 0; } .fbox .hint-grip.s { bottom: 0; }
.fbox .hint-grip.ne, .fbox .hint-grip.nw, .fbox .hint-grip.se, .fbox .hint-grip.sw {
  width: 6px; height: 6px; border-radius: 1px; }
.fbox .hint-grip.ne { top: -1px; right: -1px; cursor: nesw-resize; }
.fbox .hint-grip.sw { bottom: -1px; left: -1px; cursor: nesw-resize; }
.fbox .hint-grip.nw { top: -1px; left: -1px; cursor: nwse-resize; }
.fbox .hint-grip.se { bottom: -1px; right: -1px; cursor: nwse-resize; }
.fbox .hint-grip.base { left: calc(50% - 8px); bottom: -3px; width: 16px; height: 6px;
  border-radius: 3px; cursor: ns-resize; }
.fbox .hint-grip.start { width: 6px; cursor: ew-resize; border-radius: 1px;
  clip-path: polygon(0 0, 100% 50%, 0 100%); }
.fbox .hint-tag { position: absolute; right: 0; bottom: 0; font-size: 9px; line-height: 11px;
  padding: 0 3px; background: rgba(123,31,162,.55); color: #fff; border-radius: 3px 0 0 0;
  pointer-events: none; opacity: .5; white-space: nowrap; }
.fbox:hover .hint-tag, .fbox.selected .hint-tag { opacity: 1; }
.gtbox { position: absolute; border: 1.5px dashed #2e7d32; box-sizing: border-box;
  pointer-events: none; z-index: 1; }
/* In the GT editor the original layer is right-clickable (adopt / restore);
   it sits under the editable boxes, so overlapping GT boxes still win. */
.gt-adopt .gtbox { pointer-events: auto; }
/* Click-to-accept candidates from deterministic geometry (editor.js). */
/* Candidates are teal: apart from the black print, the blue fields, the green
   GT, and the purple fill hints. */
.candbox { position: absolute; border: 1.5px dashed #00a3a3; background: rgba(0,163,163,.07);
  box-sizing: border-box; z-index: 1; cursor: copy; }
.candbox:hover { border-style: solid; background: rgba(0,163,163,.2); }
/* Editor body: page column plus the optional field-list panel. */
.editor-body { display: flex; gap: .8rem; align-items: flex-start; }
.editor-body #pages { flex: 1; min-width: 0; }
/* The field list is a fixed drawer on the right edge, so it can be wide enough
   to show long section paths in full without squeezing the page column. */
#fieldlist { position: fixed; top: 66px; right: 12px; bottom: 12px;
  width: min(560px, 42vw); background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.18);
  padding: .7rem .8rem .7rem 1rem; overflow: auto; z-index: 25; font-size: .85rem; }
.fl-resize { position: absolute; left: 0; top: 0; bottom: 0; width: 8px; cursor: ew-resize;
  border-radius: 10px 0 0 10px; }
.fl-resize:hover { background: var(--accent-soft); }
#fieldlist input[type=text] { width: 100%; margin-bottom: .3rem; padding: .3rem .5rem; }
#fieldlist #fl-summary { margin-bottom: .3rem; }
.fl-head { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .4rem; }
.fl-head .modal-x { font-size: 1.3rem; }
.fl-errtoggle { display: flex; align-items: center; gap: .35rem; font-weight: 400;
  color: var(--muted); margin: 0 0 .4rem; }
.fl-errtoggle input { width: auto; margin: 0; }
.fl-item { display: flex; gap: .4rem; align-items: baseline; padding: .15rem .3rem;
  cursor: pointer; border-radius: 4px; }
.fl-item:hover { background: var(--accent-soft); }
.fl-item.sel { background: #fdebd3; }
.fl-item .p { color: var(--muted); min-width: 1.4em; font-variant-numeric: tabular-nums; }
.fl-item .path { flex: 1; min-width: 0; word-break: break-word; }
.fl-item .t { color: var(--muted); font-size: .78rem; }
.fl-item .flag { color: var(--danger); font-weight: 600; font-size: .75rem; }
/* Align / equalize buttons, shown when two or more boxes are selected. */
.aligntools { display: inline-flex; gap: 2px; margin-left: .3rem; }
.aligntools button { margin: 0; padding: .15rem .45rem; font-size: .78rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); }
.aligntools .secbtn { padding: .15rem .55rem; margin-left: .25rem; }

/* GT label INSIDE the box, bottom-left corner (opposite the predicted one so
   the pair does not stack). Brightens on hover, or when the overlapping field
   is hovered/selected (.hi). */
.gtbox .lbl { position: absolute; bottom: 0; left: 0; font-size: 9px;
  line-height: 12px; color: #fff; background: rgba(46,125,50,.5);
  padding: 0 3px; border-radius: 0 3px 0 2px; white-space: nowrap; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; opacity: .3; z-index: 5;
  pointer-events: auto; transition: opacity .1s, background .1s; }
.gtbox .lbl:hover, .gtbox.hi .lbl { opacity: 1; background: #2e7d32; }
.handle { position: absolute; width: 9px; height: 9px; background: #fff;
  border: 1.5px solid #e67e22; box-sizing: border-box; z-index: 7; }
.handle.n { top: -5px; left: 50%; margin-left: -5px; cursor: ns-resize; }
.handle.s { bottom: -5px; left: 50%; margin-left: -5px; cursor: ns-resize; }
.handle.e { right: -5px; top: 50%; margin-top: -5px; cursor: ew-resize; }
.handle.w { left: -5px; top: 50%; margin-top: -5px; cursor: ew-resize; }
.handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.rubber { position: absolute; border: 2px dashed #e67e22; background: rgba(230,126,34,.08);
  pointer-events: none; z-index: 8; }
/* Rubber-band selection rectangle (select mode, empty-space drag). */
.selband { position: absolute; border: 1px dashed #2a5db0; background: rgba(42,93,176,.10);
  pointer-events: none; z-index: 8; }
/* ---- Source-cleanup image editor ---- */
.cleanpages .pagewrap { position: relative; margin-bottom: 1rem; width: calc(100% * var(--z, 1)); }
.cleanpages .pagewrap > img { width: 100%; display: block; border: 1px solid var(--border);
  border-radius: 6px; }
.cleancanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cleancanvas.editable { cursor: crosshair; }
.editor-toolbar .brushsize { display: inline-flex; align-items: center; gap: .35rem;
  font-weight: 500; }
.editor-toolbar .brushsize input { width: 120px; }
.cluster-pop { position: absolute; z-index: 40; width: 220px; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.2);
  padding: .5rem .6rem; }
.cluster-pop .cp-head { display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; font-size: .9rem; }
.cluster-pop .cp-x { background: none; border: 0; cursor: pointer; color: var(--muted);
  font-size: 1.2rem; line-height: 1; padding: 0 .2rem; margin: 0; }
.cluster-pop .cp-hint { margin: .2rem 0 .4rem; }
.cluster-pop .cp-swatches { display: flex; flex-wrap: wrap; gap: .4rem; }
.cluster-pop .cp-swatch { width: 30px; height: 30px; border-radius: 6px; padding: 0; margin: 0;
  border: 1px solid var(--border); cursor: pointer; }
.cluster-pop .cp-swatch.sel { outline: 3px solid var(--accent); outline-offset: 1px; }
.cluster-pop .cp-actions { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; }
.cluster-pop .cp-actions button { margin: 0; }
.cluster-pop .cp-actions #cp-apply { padding: .3rem .8rem; }
/* Region under the magic eraser, shown while choosing colours. */
.magic-marquee { position: absolute; z-index: 39; pointer-events: none;
  border: 2px dashed #8e44ad; background: rgba(142,68,173,.05); }
/* ---- Crop editor ---- */
.croppages .pagehead { display: flex; gap: 0.4rem; align-items: center; margin: 0 0 0.3rem;
  font-size: 0.85rem; flex-wrap: wrap; }
.croppages .pagewrap { position: relative; margin-bottom: 1rem; width: calc(100% * var(--z, 1)); }
.croppages .pagewrap > img { width: 100%; display: block; border: 1px solid var(--border);
  border-radius: 6px; }
.cropovl { position: absolute; inset: 0; cursor: crosshair; }
.cropmask { position: absolute; background: rgba(20,30,40,.38); pointer-events: none; }
.croprect { position: absolute; border: 2px solid #2a5db0; background: rgba(42,93,176,.04);
  cursor: move; box-sizing: border-box; }
.crophandle { position: absolute; width: 12px; height: 12px; background: #fff;
  border: 2px solid #2a5db0; box-sizing: border-box; z-index: 2; }
.crophandle.n { top: -6px; left: 50%; margin-left: -6px; cursor: ns-resize; }
.crophandle.s { bottom: -6px; left: 50%; margin-left: -6px; cursor: ns-resize; }
.crophandle.e { right: -6px; top: 50%; margin-top: -6px; cursor: ew-resize; }
.crophandle.w { left: -6px; top: 50%; margin-top: -6px; cursor: ew-resize; }
.crophandle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.crophandle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.crophandle.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.crophandle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
/* Snap guides: the edge a dragged box edge jumped to (editor.js snapping). */
.snapguide { position: absolute; pointer-events: none; z-index: 9; background: #e67e22;
  opacity: .75; }
.snapguide.x { top: 0; bottom: 0; width: 1px; margin-left: -0.5px; }
.snapguide.y { left: 0; right: 0; height: 1px; margin-top: -0.5px; }
.fpop, .ctxmenu { position: absolute; z-index: 30; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,.2); }
.fpop { padding: 0.7rem; width: 300px; }
/* The hints dialog: one checkbox per kind of hint; only checked kinds show. */
.fpop.hintpop { width: 380px; max-height: 80vh; overflow-y: auto; }
.fpop .hints { margin-top: 0.6rem; border-top: 1px solid var(--border); padding-top: 0.4rem; }
.fpop .hintkinds { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.fpop .hintkinds .chip { display: inline-flex; gap: 0.25rem; align-items: center; margin: 0;
  padding: 0.1rem 0.45rem; border: 1px solid var(--border); border-radius: 999px;
  font-size: 0.78rem; color: var(--ink); cursor: pointer; }
.fpop .hintsec { margin-top: 0.5rem; padding-top: 0.4rem; border-top: 1px dashed var(--border); }
.fpop .hintnote { font-size: 0.76rem; color: var(--muted); margin: 0.1rem 0 0.2rem; }
.fpop .partrow { margin: 0.3rem 0; padding: 0.3rem 0.4rem; border-left: 2px solid rgba(123,31,162,.5); }
.fpop .partrow .hintrow button { flex: 0 0 auto; }
.fpop input[type=range] { width: 100%; }
/* example text in an empty input must not read as a value */
.fpop input::placeholder { color: #b4b4b4; font-style: italic; opacity: 1; }
.fpop .hintrow { display: flex; gap: 0.5rem; }
.fpop .hintrow > span { flex: 1; min-width: 0; }
.fpop .hintrow input, .fpop .hintrow select { width: 100%; box-sizing: border-box; }
.fpop label.inline { display: flex; gap: 0.35rem; align-items: center; }
.fpop .hintinfo { font-size: 0.78rem; margin: 0.4rem 0 0; }
.fpop.wide { width: 330px; }
.fpop label { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 0.4rem; }
.ctxmenu button { display: block; width: 100%; text-align: left; background: none;
  border: 0; padding: 0.45rem 0.8rem; color: var(--ink); font: inherit; cursor: pointer; }
.ctxmenu button:hover { background: var(--accent-soft); }
.dirty-dot { color: var(--warn); font-weight: 700; }

.container { max-width: 1100px; margin: 1.6rem auto; padding: 0 1.2rem; }
.footer { text-align: center; padding: 2rem 0 1rem; font-size: 0.85rem; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem 1.4rem; margin-bottom: 1.2rem;
}
.card h2 { margin-top: 0.1rem; }
.auth-card { max-width: 400px; margin: 4rem auto; }

label { display: block; font-weight: 600; margin: 0.7rem 0 0.2rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
select, textarea {
  width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--border);
  border-radius: 6px; font: inherit; background: #fff;
}
textarea { display: block; box-sizing: border-box; resize: vertical; }
input[type=file] { margin: 0.4rem 0; }
button, .btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  padding: 0.5rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
  margin-top: 0.8rem;
}
button:hover { filter: brightness(1.07); }
button:disabled { opacity: 0.5; cursor: default; filter: none; }
button.link { background: none; color: var(--accent); padding: 0; margin: 0;
  font-weight: 500; }
form.inline { display: inline; }

.error { background: #fdecea; color: var(--danger); border: 1px solid #f2c7c3;
  border-radius: 6px; padding: 0.5rem 0.8rem; margin: 0.6rem 0; }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); }
th { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted); }

.chip { display: inline-block; padding: 0.1rem 0.6rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; background: var(--accent-soft);
  color: var(--accent); white-space: nowrap; }
/* Japanese breaks between any two characters, so a short heading would wrap
   mid-word in a narrow column ("ラウン|ド"); keep headings whole. */
:lang(ja) th { white-space: nowrap; }
.chip.uploaded, .chip.discovering, .chip.rediscovering { background: #fff4e0; color: var(--warn); }
.chip.failed, .chip.rejected { background: #fdecea; color: var(--danger); }
.chip.user_validating { background: #e7effc; color: #2a5db0; }
.chip.err { background: #fdecea; color: var(--danger); }
.errbadge { display: inline-block; padding: 0.02rem 0.4rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; background: #fdecea; color: var(--danger); }

.progress { background: var(--border); border-radius: 999px; height: 8px;
  overflow: hidden; margin: 0.6rem 0; }
.progress > div { background: var(--accent); height: 100%; transition: width 0.4s; }

.pagegrid { display: flex; flex-direction: column; gap: 1rem; }
.pageimg { width: 100%; border: 1px solid var(--border); border-radius: 6px; }
.fieldrow select { width: auto; }
.fieldrow input[type=text] { width: 100%; }
code { background: var(--accent-soft); padding: 0.05rem 0.35rem; border-radius: 4px;
  font-size: 0.86em; }

/* Icon buttons: colored when enabled, gray when disabled; hover shows a
   native tooltip via the title attribute. */
.iconbtn {
  background: none; border: 0; padding: 4px; margin: 0 2px; cursor: pointer;
  border-radius: 6px; line-height: 0; vertical-align: middle;
  color: var(--accent);
}
.iconbtn:hover { background: var(--accent-soft); }
.iconbtn svg { width: 20px; height: 20px; display: block; }
.iconbtn.danger { color: var(--danger); }
.iconbtn.warn { color: var(--warn); }
.iconbtn[disabled], .iconbtn.disabled {
  color: #9aa7b2; cursor: default; pointer-events: none;
}
.iconbtn.fileicon { display: inline-block; }
.iconbtn.fileicon input { display: none; }
.iconbtn.active { background: var(--accent-soft); outline: 2px solid var(--accent); }
th.exporthead { white-space: nowrap; }
th.exporthead .link { text-transform: none; letter-spacing: 0; font-size: 0.8rem; }

/* Lock bar: lock status on the left, "Approve for validation" pinned right on
   the same row. nowrap so a longer status ("You hold the editing lock") never
   pushes the approve control onto a second line. */
.lockbar { display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: nowrap; min-height: 40px; }
.lockbar .lockstatus { display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap; min-width: 0; }
.lockbar .approvebtn { display: flex; align-items: center; gap: 0.4rem;
  margin: 0; flex-shrink: 0; }
.lockbar .lockwarn { color: var(--danger); }
.lockbar-left { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; min-width: 0; }
.modebar-wrap { display: inline-flex; align-items: center; gap: .5rem; }
.formnav { display: inline-flex; }
.modebar { display: inline-flex; border: 1px solid var(--border); border-radius: 7px;
  overflow: hidden; flex: none; }
.modebar .modebtn { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .6rem;
  color: var(--muted); font-size: .85rem; font-weight: 500; }
.modebar .modebtn + .modebtn { border-left: 1px solid var(--border); }
.modebar .modebtn:hover { text-decoration: none; background: var(--bg); }
.modebar .modebtn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.modebar .modebtn svg { width: 16px; height: 16px; }
.lockbar form.inline { margin: 0; }
.rowlink { cursor: pointer; }
.rowlink:hover { background: var(--accent-soft); }

.scorecell { font-variant-numeric: tabular-nums; }
/* Keep row actions on one line: the column is wide enough for the icons. */
.actioncol { white-space: nowrap; width: 1%; }
td.actions .iconbtn { display: inline-block; }
.detail-section { margin: 0.8rem 0; }
.detail-section h3 { margin: 0.3rem 0; font-size: 0.95rem; }
.kv { color: var(--muted); font-size: 0.9rem; }
pre.mono { background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.6rem; overflow: auto; max-height: 260px;
  font-size: 0.82rem; }

/* Modals */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,30,40,.55);
  z-index: 20; }
.modal-card { background: var(--card); border-radius: var(--radius);
  max-width: 520px; margin: 8vh auto; padding: 1.4rem 1.6rem;
  box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal-card.wide { max-width: 720px; }
/* Every modal closes with a single X in its top-right corner. */
.modal-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 0.4rem; }
.modal-head h2 { margin: 0; }
.modal-x { background: none; border: 0; cursor: pointer; color: var(--muted);
  font-size: 1.4rem; line-height: 1; padding: 0 0.2rem; border-radius: 6px; }
.modal-x:hover { background: var(--accent-soft); color: var(--ink); }
/* The field-path cell must not stretch the detail table; clip long names. */
td.fieldname { max-width: 320px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
td.fieldname code { font-size: 0.82rem; }

/* Section header with a right-justified action */
.sec-head { display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 0.6rem; }
.sec-head h2 { margin: 0; }
/* Position of the current form within the project list, shown in the editor. */
.formidx { display: inline-block; font-size: 0.7em; font-weight: 600; color: var(--muted);
  background: var(--accent-soft); border-radius: 999px; padding: 0.05em 0.6em;
  vertical-align: middle; margin-right: 0.3rem; }

/* Table filter/pager toolbar */
.tabletools { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 0.6rem; }
.tabletools input, .tabletools select { width: auto; }
.pager { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.6rem;
  color: var(--muted); font-size: 0.9rem; }
.dropzone { border: 2px dashed var(--border); border-radius: 8px;
  padding: 1.4rem; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }

/* Floating tooltip (replaces slow native title tooltips; see base.html) */
.tip {
  position: absolute;
  z-index: 1000;
  white-space: pre-line;   /* tooltips may carry several lines */
  max-width: min(560px, 80vw);
  /* dotted paths have no spaces to wrap at; break them anywhere rather
     than let the text run past the background */
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 5px 9px;
  border-radius: 6px;
  background: #1f2733;
  color: #e8edf4;
  font-size: 0.8rem;
  line-height: 1.35;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* Cross-form alignment graph */
.algn-tools { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .5rem; }
.algn-body { display: flex; gap: .8rem; align-items: stretch; }
.algn-svg { flex: 1; min-width: 0; height: 640px; border: 1px solid var(--border); border-radius: 8px;
  background: #fbfcfe; cursor: grab; user-select: none; }
.algn-svg:active { cursor: grabbing; }
.algn-panel { width: 380px; flex: none; max-height: 640px; overflow-y: auto; overflow-x: hidden;
  border: 1px solid var(--border); border-radius: 8px; padding: 0 .8rem .6rem; font-size: .9rem;
  overflow-wrap: anywhere; }
.algn-panel code, .algn-panel li { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.algn-panel .algn-head { position: sticky; top: 0; background: var(--card, #fff); padding: .6rem 0 .3rem; z-index: 2; }
.algn-panel .actioncol { flex: none; white-space: nowrap; }
.algn-panel h3 { margin: 0; font-size: 1.05rem; }
.algn-panel h4 { margin: .8rem 0 .3rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.algn-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.algn-list { margin: 0; padding-left: 1.1rem; }
.algn-list li { margin: .15rem 0; }
.algn-actions { display: flex; flex-direction: column; gap: .35rem; align-items: flex-start; }
.algn-row { display: flex; align-items: center; gap: .35rem; flex-wrap: nowrap; margin: 0; }
.algn-row form.inline { display: inline-flex; }
.algn-row select, .algn-row input[type=text] { max-width: 220px; }
.algn-compact td, .algn-compact th { font-size: .85rem; vertical-align: top; }
.inline-details { display: inline; }
.inline-details summary { display: inline; cursor: pointer; color: var(--accent); }
.algn-gap { color: #b26a00; }
.algn-evidence td, .algn-evidence th { font-size: .78rem; vertical-align: top; }
.algn-link { stroke: #9aa7b8; stroke-opacity: .55; }
.algn-link.section { stroke: #7e57c2; stroke-dasharray: 3 3; }
.algn-link.suggest { stroke: #e67e22; stroke-dasharray: 6 4; stroke-width: 2.5; stroke-opacity: .9; }
.algn-link.child { stroke: #2a5db0; stroke-opacity: .35; }
.algn-link.hi { stroke-opacity: 1; stroke: #2a5db0; }
.algn-link.dim { stroke-opacity: .12; }
.algn-node { cursor: pointer; }
.algn-node circle { fill: #2a5db0; stroke: #fff; stroke-width: 2; }
.algn-node.proposed circle { fill: #fff; stroke: #2a5db0; stroke-dasharray: 3 2; }
.algn-node.rejected circle { fill: #ccc; stroke: #999; }
.algn-node.section circle { fill: #ede7f6; stroke: #7e57c2; }
.algn-node.selected circle { stroke: #e67e22; stroke-width: 3; }
.algn-node.dim { opacity: .25; }
.algn-node text { font-size: 11px; fill: #1f2733; paint-order: stroke; stroke: #fbfcfe; stroke-width: 3px; stroke-linejoin: round; }
.algn-node .gapdot { fill: #e67e22; stroke: #fff; stroke-width: 1; }
.algn-node.child circle { fill: #fff; stroke: #2a5db0; }
.algn-node.child.aspect circle { fill: #dbe6f8; }
.algn-node.child text { font-size: 10px; fill: #3a4a63; }
.algn-sw { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; margin-right: .25rem; }
.algn-sw.accepted { background: #2a5db0; }
.algn-sw.proposed { border: 2px dashed #2a5db0; }
.algn-sw.rejected { background: #ccc; }
.algn-sw.section { background: #ede7f6; border: 1px solid #7e57c2; }
.algn-details { padding: .5rem .9rem; }
.algn-details summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }

.algn-summary { margin: .2rem 0 .8rem; }
.badge { display: inline-block; min-width: 1.6em; padding: 0 .45em; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent); font-weight: 600; font-size: .8rem; text-align: center; text-decoration: none; }
.badge:hover { background: var(--accent); color: #fff; text-decoration: none; }
.algn-key code { cursor: pointer; }
.algn-key:hover code { text-decoration: underline; }
.algn-ctl { width: 220px; box-sizing: border-box; padding: .15rem .35rem; font-size: .85rem; }
.algn-lbl { width: 5.5em; }
.algn-row .iconbtn { padding: .15rem; }
.algn-scroll { max-height: 40vh; overflow: auto; }
.algn-sw.gap { background: #e67e22; }
.algn-compact .actioncol { white-space: nowrap; }
.algn-compact td { padding-top: .2rem; padding-bottom: .2rem; }

#algn-modal .modal-card.wide { width: min(96vw, 1100px); max-width: 96vw; }
#algn-modal-body { overflow-x: auto; max-height: 75vh; overflow-y: auto; }
#algn-modal-body table { width: 100%; }
#algn-modal-body code { white-space: normal; overflow-wrap: anywhere; }

/* Run page: set-level statistics */
.runsummary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin: .6rem 0 1rem; }
.runsummary .stat { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem; background: var(--bg); }
.runsummary .stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.runsummary .stat-value { font-size: 1.35rem; font-weight: 600; line-height: 1.3; }
.runsummary .stat-sub { font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }

/* ---- in-app help: rendered documentation ---- */
.help-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 800px) { .help-layout { grid-template-columns: 1fr; } }
.help-nav { position: sticky; top: 0.75rem; display: flex; flex-direction: column; gap: 0.15rem; }
.help-nav h2 { font-size: 0.95rem; margin: 0 0 0.4rem; }
.help-nav a { padding: 0.3rem 0.5rem; border-radius: 6px; color: inherit; text-decoration: none; }
.help-nav a:hover { background: var(--accent-soft); }
.help-nav a.active { background: var(--accent-soft); font-weight: 600; }
.prose { line-height: 1.55; max-width: 62rem; }
.prose h1 { font-size: 1.6rem; margin-top: 0; }
.prose h2 { font-size: 1.25rem; margin-top: 1.6rem; border-bottom: 1px solid var(--border); padding-bottom: 0.2rem; }
.prose h3 { font-size: 1.05rem; margin-top: 1.2rem; }
.prose p, .prose ul, .prose ol { margin: 0.6rem 0; }
.prose li { margin: 0.2rem 0; }
.prose pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.7rem 0.9rem; overflow-x: auto; font-size: 0.85rem; line-height: 1.4; }
.prose pre code { background: none; padding: 0; }
.prose table { width: auto; margin: 0.6rem 0; font-size: 0.92rem; }
.prose th { text-transform: none; letter-spacing: 0; font-size: 0.9rem; }
.prose td, .prose th { vertical-align: top; }
.prose blockquote { border-left: 3px solid var(--border); margin: 0.6rem 0; padding: 0.1rem 0.9rem; color: var(--muted); }
.prose img { max-width: 100%; }

/* Show English: the printed label and its translation in the field list */
.fl-item:has(.fl-label) { flex-wrap: wrap; }
.fl-item .fl-label { flex-basis: 100%; font-size: .8rem; color: var(--muted, #667); margin-left: 1.6rem; }
.fl-item .fl-label .en { display: block; color: var(--accent); }
.fl-item .fl-label .en::before { content: "EN "; font-size: .7rem; opacity: .7; }
.iconbtn.trbtn { width: auto; min-width: 2.2rem; padding: .15rem .45rem; border-radius: 6px; line-height: 1.2;
  font-size: .75rem; font-weight: 700; letter-spacing: .02em; border: 1px solid var(--line, #d0d7de); }
.iconbtn.trbtn.active { background: var(--accent-soft); color: var(--accent); }
.iconbtn.trbtn.busy { opacity: .5; cursor: progress; }
.poplabel { margin-bottom: .3rem; }

/* The form in English (form_english.js): a layer over each page that never
   takes the pointer, and a card beside the block pointed at. */
.enl { position: absolute; inset: 0; pointer-events: none; }
.enb { position: absolute; border: 1px dotted rgba(123, 31, 162, .35); border-radius: 2px; }
.enb.office { border-color: rgba(92, 107, 122, .45); }
.enb.lit { border: 1.5px solid #7b1fa2; background: rgba(123, 31, 162, .08); }
.encard { position: absolute; z-index: 40; pointer-events: none; max-width: 320px;
  background: var(--card); border: 1px solid #7b1fa2; border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18); padding: .4rem .6rem; font-size: .85rem; line-height: 1.35; }
.encard .en { color: #1d2733; }
.encard .src { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
.encard .tag { display: inline-block; font-size: .72rem; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 0 .4rem; margin-top: .2rem; }
.enwrap { position: relative; }

/* Project stages as tabs (project_tabs.html): the open tab sits on the page,
   a stage with nothing ready for it is greyed out and says why on hover. */
.project-title { margin-bottom: 0.4rem; }
.ptabs { display: flex; flex-wrap: wrap; gap: 0.2rem; border-bottom: 1px solid var(--border);
  margin-bottom: 1.2rem; }
.ptab { padding: 0.55rem 1rem; border: 1px solid transparent; border-bottom: 0;
  border-radius: 8px 8px 0 0; color: var(--muted); text-decoration: none; font-weight: 600;
  margin-bottom: -1px; white-space: nowrap; }
.ptab:hover, .ptab:focus-visible { color: var(--accent); background: var(--accent-soft); }
.ptab.active { color: var(--ink); background: var(--card); border-color: var(--border);
  border-bottom: 1px solid var(--card); }
.ptab.off, .ptab.off:hover { color: #a7b1bb; background: none; cursor: not-allowed; }
.subtabs { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: -0.4rem 0 1rem; }
.subtab { padding: 0.25rem 0.75rem; border-radius: 999px; color: var(--muted);
  text-decoration: none; font-size: 0.92rem; font-weight: 600; }
.subtab:hover, .subtab:focus-visible { color: var(--accent); background: var(--accent-soft); }
.subtab.active { color: var(--accent); background: var(--accent-soft); }
.rules-more { margin-top: 1rem; }
.run-rules { margin: 0 0 1rem; }
.rules-text { white-space: pre-wrap; background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.6rem 0.8rem; font-size: 0.85rem; max-height: 22rem; overflow: auto; }
.rules-more summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.rules-more[open] summary { margin-bottom: 0.4rem; }
.subnav { display: flex; flex-wrap: wrap; gap: 1.2rem; margin: 0 0 0.8rem; }
.subnav a { display: inline-flex; align-items: center; gap: 0.35rem; }
.subnav svg { width: 16px; height: 16px; }
.subnav .off { cursor: not-allowed; }
.innertabs .it[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Shared page parts: numbered step tabs, job chips, cards that fold, factors
   and rules (Semantic Discovery, fill sets). */
.subtab .step { font-size: 0.75rem; opacity: 0.75; margin-right: 0.3rem; }
.subtab-aside { margin-left: auto; display: inline-flex; gap: 1rem; align-items: center; font-size: 0.9rem; }
.chip.queued, .chip.running, .chip.waiting { background: #fff4e0; color: var(--warn); }
.chip.done { background: var(--accent-soft); color: var(--accent); }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2, details.card > summary h3 { display: inline; margin: 0; }
details.card > summary::before { content: "▸ "; color: var(--accent); }
details.card[open] > summary::before { content: "▾ "; }
details.card[open] > summary { margin-bottom: 0.6rem; }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.25rem; }
.subtab.off, .subtab.off:hover { color: #a7b1bb; background: none; cursor: not-allowed; }
/* text with an English translation on hover (en_tips.js) */
.en-tip.has-en { text-decoration: underline dotted #a7b1bb; text-underline-offset: 3px; cursor: help; }
.factor { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 0.6rem; padding: 0.5rem 0;
  border-bottom: 1px solid var(--border); }
.factor:last-child { border-bottom: 0; }
.values { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
button.value { margin: 0; background: var(--card); color: var(--ink); border: 1px solid var(--border);
  padding: 0.2rem 0.55rem; font-weight: 500; font-size: 0.9rem; display: inline-flex; flex-direction: column;
  align-items: flex-start; gap: 0.2rem; border-radius: 6px; }
button.value:hover { border-color: var(--accent); filter: none; }
button.value.off { opacity: 0.45; text-decoration: line-through; }
.rule { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.rule:last-child { border-bottom: 0; }
.rule.dropped { opacity: 0.5; }
.quote { font-size: 0.85rem; color: var(--muted); border-left: 2px solid var(--border); padding-left: 0.5rem; margin-top: 0.3rem; }
button.ghostbtn { background: none; color: var(--accent); border: 1px solid var(--accent); margin-top: 0; }
button.small, button.ghostbtn.small { padding: 0.15rem 0.6rem; font-size: 0.85rem; margin-top: 0; }
.chip.warnchip { background: #fff4e0; color: var(--warn); }
.popover { position: absolute; z-index: 30; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 0.8rem 1rem; width: min(26rem, 90vw); }
.popover label { font-weight: 500; }
.headtools button { margin-top: 0; }
.sit { display: inline-block; font-size: 0.86rem; margin-right: 0.6rem; }
.warnline { color: var(--warn); font-size: 0.88rem; margin-top: 0.2rem; }
.row-inline { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.row-inline button { margin-top: 0; }
.row-inline select { width: auto; }
.tablewrap { overflow-x: auto; }
.placed { border-top: 1px solid var(--border); margin-top: 0.6rem; padding-top: 0.4rem; }
.factor { grid-template-columns: 16rem minmax(0, 1fr); }

/* issue lists, legends, and colour swatches */
.attention .issue { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.35rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.attention .issue:last-child { border-bottom: 0; }
.sp { flex: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 0.8rem; font-size: 0.85rem; margin-top: 0.3rem; }
.sw { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 3px; vertical-align: -1px; margin-right: 0.25rem; }
#field-list { overflow: auto; flex: 1; }
.headtools .btn { margin-top: 0; }
/* inner tabs inside a tab */
.innertabs { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: -0.2rem 0 0.9rem; }
.innertabs .it { margin: 0; background: none; color: var(--muted); border: 1px solid var(--border); padding: 0.2rem 0.8rem;
  border-radius: 999px; font-weight: 600; font-size: 0.88rem; }
.innertabs .it.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }
.innertabs .it .n { font-weight: 500; margin-left: 0.2rem; }
.innertabs .it .n .open { color: var(--warn); }
/* long form titles under a factor wrap inside their column */
.factor > * { min-width: 0; }
.sec-head > button.link { white-space: nowrap; flex: 0 0 auto; }
table.plan tr.removed td { opacity: 0.4; text-decoration: line-through; }
table.plan tr.removed td:last-child { opacity: 1; text-decoration: none; }
.chip.cancelled { background: #eef1f4; color: var(--muted); }
.nowrap { white-space: nowrap; }
.tablewrap { overflow-x: auto; max-width: 100%; }
table.fill-written td { overflow-wrap: anywhere; word-break: break-word; }
table.fill-written td:first-child { max-width: 22rem; }
/* Form Fill: the source tabs and the shared options, laid out compactly */
.fill-src { margin: 0.4rem 0 0.6rem; }
.fill-opts { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; align-items: flex-end; margin: 0.6rem 0; }
label.fill-opt { display: inline-flex; flex-direction: column; gap: 0.2rem; width: auto; margin: 0; font-size: 0.9rem; }
label.fill-opt select, label.fill-opt input[type="number"] { width: auto; min-width: 6rem; }
label.fill-opt input[type="number"] { max-width: 7rem; }
.fill-byo { gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
#fill-card .innertabs { margin-bottom: 0.4rem; }

/* Enhance mode (enhance.html) */
.modebar .modebtn.disabled { color: var(--muted); opacity: .55; cursor: not-allowed; }

/* a page shown inside another's modal (?embed=1): no site chrome */
body.embed .topbar, body.embed .footer { display: none; }
body.embed main, body.embed .container { padding-top: 0.5rem; }

/* ---- The validation page: fields on the pages, a searchable list, the
   selected field's details, and the structure checks. ---- */
/* this page needs the whole width: the form beside its field list and details */
.container:has(.vgrid) { max-width: 1900px; }
.container:has(.vgrid) > .sec-head { flex-wrap: wrap; gap: .5rem; }
.container:has(.vgrid) .actioncol { display: inline-flex; flex-wrap: wrap; gap: .4rem; align-items: center;
  justify-content: flex-end; width: auto; white-space: normal; }
.vsummary { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; align-items: center; padding: .7rem 1rem; }
.vtypes { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.vchecksum { font-weight: 600; margin-left: auto; }
.vchecksum.ok { color: var(--accent); } .vchecksum.warn { color: var(--warn); } .vchecksum.bad { color: var(--danger); }
.vgrid { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) minmax(250px, 320px);
  gap: 1rem; align-items: start; }
/* narrower (a tablet, an unfolded phone): the list keeps the left column
   down both rows, so as it stays in view it never covers the details, which
   sit under the form */
@media (max-width: 1200px) { .vgrid { grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); }
  .vside { grid-row: 1 / span 2; }
  .vdetail { grid-column: 2; position: static !important; max-height: none !important; } }
@media (max-width: 760px) { .vgrid { grid-template-columns: 1fr; }
  .vside { position: static !important; max-height: 50vh !important; grid-row: auto; }
  .vdetail { grid-column: 1; } }
.vside, .vdetail { position: sticky; top: .8rem; max-height: calc(100vh - 1.6rem); display: flex;
  flex-direction: column; padding: .8rem; margin: 0; }
.vdetail { overflow: auto; display: block; }
.vmain { margin: 0; padding: .8rem; min-width: 0; }
.vsearch input { width: 100%; }
.vfilters { display: flex; flex-wrap: wrap; gap: .25rem; margin: .5rem 0; }
.vchip { margin: 0; padding: .1rem .55rem; font-size: .78rem; font-weight: 500; border-radius: 999px;
  background: var(--card); color: var(--ink); border: 1px solid var(--border); }
.vchip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.vlist { overflow: auto; flex: 1; min-height: 0; border-top: 1px solid var(--border); padding-top: .3rem; }
.vsec-head { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); padding: .5rem .3rem .15rem; position: sticky; top: 0; background: var(--card); }
.vsec-head .muted { font-weight: 400; }
button.vrow { display: flex; gap: .4rem; align-items: flex-start; width: 100%; margin: 0; padding: .3rem .35rem;
  text-align: left; background: none; color: var(--ink); font-weight: 400; border-radius: 6px; }
button.vrow:hover { background: var(--bg); filter: none; }
button.vrow.on { background: #fdf0e1; box-shadow: inset 3px 0 0 #e67e22; }
.vrow-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.vrow-path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; overflow-wrap: anywhere; }
.vrow-label { font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
.vrow-label .en, .vd-label .en, .vtip .en { color: #2a5db0; }
.vbadge { font-size: .7rem; background: rgba(123,31,162,.12); color: #7b1fa2; border-radius: 999px; padding: 0 .4rem; }
.vdot { width: .55rem; height: .55rem; border-radius: 50%; margin-top: .35rem; flex: none; }
.vdot.sev-error { background: var(--danger); } .vdot.sev-warning { background: var(--warn); }
/* a field's type, in the same colour on the list, the card, and its box */
.vtype { display: inline-block; font-size: .7rem; font-weight: 600; border-radius: 4px; padding: 0 .35rem;
  white-space: nowrap; color: #fff; background: #2a5db0; flex: none; }
.t-date { --tc: #00838f; } .t-number { --tc: #455a64; } .t-choice { --tc: #2e7d32; }
.t-checkbox, .t-radio { --tc: #e67800; } .t-signature { --tc: #7b1fa2; } .t-seal { --tc: #c62828; }
.t-text { --tc: #2a5db0; } .t-other { --tc: #5c6b7a; }
.vtype, .vchip.on.t-text, .vchip.on[class*="t-"] { background: var(--tc, #2a5db0); }
.vchip.on[class*="t-"] { color: #fff; border-color: var(--tc); }
.vtools { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; margin-bottom: .6rem; }
.vtools label { display: inline-flex; gap: .3rem; align-items: center; font-size: .88rem; }
.vtools .iconbtn, .vtools button { margin-top: 0; }
.vhint { font-size: .8rem; }
.vpages { overflow: auto; max-height: calc(100vh - 7rem); }
.vovl { position: absolute; inset: 0; }
.vbox { border-color: var(--tc, #2a5db0); border-width: 1.5px; cursor: pointer; transition: opacity .1s; }
.vbox:hover { box-shadow: 0 0 0 2px rgba(42,93,176,.25); background: rgba(42,93,176,.05); }
.vbox.sev-error { border-color: var(--danger); border-width: 2px; }
.vbox.selected { border-color: #e67e22; border-width: 2.5px; background: rgba(230,126,34,.08); z-index: 6; }
.vbox.flag { border-color: var(--danger); border-width: 2.5px; background: rgba(179,55,46,.08); z-index: 5; }
.vbox.dim { opacity: .5; }
.vbox .vpath { position: absolute; left: 0; top: -1.15em; font-size: 10px; line-height: 1.1em; white-space: nowrap;
  background: var(--tc, #2a5db0); color: #fff; padding: 0 3px; border-radius: 2px; display: none; pointer-events: none; }
.vpages.showpaths .vbox .vpath, .vbox.selected .vpath, .vbox:hover .vpath { display: block; }
.vbox .vfull { display: none; }
.vbox.selected .vfull, .vbox:hover .vfull { display: inline; }
.vbox.selected .vleaf, .vbox:hover .vleaf { display: none; }
.vbox.selected .vpath, .vbox:hover .vpath { z-index: 8; font-size: 11px; }
/* a choice's box spans its options: faint, the options carry it */
.vbox.vspan { border-style: dashed; border-width: 1px; background: none; }
.vbox.vspan.selected { border-width: 1.5px; }
.vbox .vpart { border: 1px dashed rgba(123,31,162,.9); }
.vbox .vpart.lit { background: rgba(123,31,162,.18); border-style: solid; }
.vbox .vpname { position: absolute; right: 0; bottom: 0; font-size: 9px; line-height: 1; padding: 1px 2px;
  background: rgba(123,31,162,.8); color: #fff; border-radius: 2px 0 0 0; pointer-events: none; }
/* part names crowd a page: shown on the field pointed at or selected, or
   on every field with the toggle */
.vbox .vpname { display: none; }
.vbox:hover .vpname, .vbox.selected .vpname, .vpages.partnames .vpname { display: block; }
.vbox .vsub { position: absolute; border: 1px dotted rgba(123,31,162,.7); box-sizing: border-box; }
.vbox .vopt { border: 1.5px solid rgba(46,125,50,.85); border-radius: 3px; }
.vbox .vspec { border: 1.5px dashed rgba(230,120,0,.9); }
.vbox .vcell { border: 1px dotted rgba(123,31,162,.6); }
.vpages.noboxes .vovl { display: none; }
.vtip { position: fixed; z-index: 30; max-width: 420px; background: #1f2b36; color: #fff; border-radius: 8px;
  padding: .5rem .7rem; font-size: .82rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); pointer-events: none; }
.vtip-path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; overflow-wrap: anywhere;
  margin-bottom: .25rem; }
.vtip-label { margin-top: .25rem; } .vtip .en { color: #9cc3ff; }
.vtip-parts { margin-top: .2rem; color: #d7dee5; } .vtip code { color: #f7d59c; background: none; }
.vd-head { display: flex; justify-content: space-between; align-items: center; }
.vd-path code { font-size: .82rem; overflow-wrap: anywhere; }
.vd-label { margin: .35rem 0 .5rem; font-weight: 600; }
.vd-table { width: 100%; font-size: .82rem; border-collapse: collapse; }
.vd-table th { text-align: left; color: var(--muted); font-weight: 500; padding: .15rem .4rem .15rem 0; vertical-align: top;
  white-space: nowrap; }
.vd-table td { padding: .15rem 0; overflow-wrap: anywhere; }
.vd-parts tr[data-part]:hover { background: rgba(123,31,162,.08); cursor: default; }
.vdetail h3 { font-size: .9rem; margin: .8rem 0 .3rem; }
.vd-checks, .vnotes { padding-left: 1.1rem; font-size: .85rem; }
.vd-checks li.sev-error { color: var(--danger); } .vd-checks li.sev-warning { color: var(--warn); }
.vflag { font-size: .72rem; font-weight: 600; border-radius: 4px; padding: 0 .35rem; }
.vflag.sev-error { background: #fdecea; color: var(--danger); } .vflag.sev-warning { background: #fff4e0; color: var(--warn); }
.vcheck summary { cursor: pointer; padding: .25rem 0; }
.vcheck ul { font-size: .85rem; margin: .2rem 0 .5rem; }
button.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--border); margin-top: 0; }
button.secondary:hover { border-color: var(--accent); filter: none; }
button.secondary.danger { color: var(--danger); }
button.secondary.danger:hover:not(:disabled) { border-color: var(--danger); }
button.primary { margin-top: 0; }
.actioncol button svg { width: 1em; height: 1em; vertical-align: -.12em; }

/* ---- The promotion dialog ---- */
.promo-card.modal-card.wide { max-width: min(980px, 96vw); margin: 4vh auto; max-height: 92vh; display: flex;
  flex-direction: column; }
.promo-body { overflow: auto; flex: 1; min-height: 0; }
.promo-sec { border-top: 1px solid var(--border); padding: .7rem 0; }
.promo-sec:first-child { border-top: 0; }
.promo-sec h3 { margin: 0 0 .45rem; font-size: 1rem; }
.promo-facts { display: grid; gap: .25rem; }
.promo-choices { display: grid; gap: .35rem; }
.promo-choices.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.promo-choice { display: block; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.promo-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.promo-choice.off { opacity: .55; cursor: default; }
.promo-tablewrap { overflow: auto; max-height: 40vh; margin-top: .6rem; }
.promo-table { width: 100%; font-size: .85rem; }
.promo-table tr.off { color: var(--muted); }
.promo-note { display: block; margin-top: .6rem; font-size: .9rem; }
.promo-note textarea { width: 100%; margin-top: .25rem; }
.promo-effect ul { margin: 0; padding-left: 1.2rem; }
.promo-accept { display: block; margin-top: .5rem; padding: .45rem .6rem; border: 1px solid var(--danger);
  border-radius: 8px; color: var(--danger); }
.promo-bad { color: var(--danger); font-weight: 600; } .promo-ok { color: var(--accent); }
.promo-checks { font-size: .85rem; } .promo-checks li.sev-error { color: var(--danger); }
.promo-paths { font-size: .8rem; max-height: 12rem; overflow: auto; }
.promo-foot { display: flex; gap: .6rem; align-items: center; justify-content: flex-end;
  border-top: 1px solid var(--border); padding-top: .7rem; }
.promo-foot .muted { margin-right: auto; font-size: .85rem; }
.promo-foot button { margin-top: 0; }
.small { font-size: .8rem; }
.err { color: var(--danger); }

/* touch screens: one finger drags the form, two pinch it (touch.js); the
   browser's own pinch and the long-press image menu stay off the form */
.touchpan { touch-action: pan-x pan-y; }
.touchpan .pagewrap img { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* a fill set, reviewed one document at a time */
.fs-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem 1rem; }
.fs-bar h2 { margin: 0; }
.fs-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 0.2rem; }
.fs-nav { display: inline-flex; align-items: center; gap: 0.3rem; }
.fs-nav input[type=number] { width: 4.5rem; padding: 0.3rem 0.4rem; text-align: center; }
.fs-title { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0.5rem; }
.fs-releases { margin: 0.6rem 0 0; font-size: 0.9rem; }
.fs-note { margin: 0.6rem 0 0; padding: 0.4rem 0.7rem; border-left: 3px solid var(--danger);
           background: #fdecea; border-radius: 4px; }
.fs-pages { margin: 0.8rem 0; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.fs-pages img { display: block; width: 100%; max-width: 1100px; height: auto;
                border: 1px solid var(--border); border-radius: 4px; }
.iconbtn.fs-ok { color: #1f7a3f; }
.fs-actions .iconbtn svg { width: 24px; height: 24px; }
.chip.pending { background: #fff4e0; color: var(--warn); }
.chip.approved { background: #e6f4ea; color: #1f7a3f; }
button.danger:not(.iconbtn) { background: var(--danger); }
@media (max-width: 640px) {
  .fs-bar { gap: 0.4rem 0.6rem; }
  .fs-title .muted { font-size: 0.85rem; }
  .fs-pages { margin: 0.6rem -0.6rem; }
}
.fs-linkrow input[type=text] { max-width: 40rem; font-size: 0.85rem; }

/* a story's case that carries reviewers' notes */
.casebtn.noted { border: 2px solid #800000; }
.casebtn .notecount { margin-left: 0.35rem; background: #800000; color: #fff; border-radius: 999px;
  font-size: 0.75rem; padding: 0 0.4rem; line-height: 1.3; }

/* the case review page inside the stories page's modal: its navigation only */
.rv-top.rv-embed .rv-crumbs, .rv-top.rv-embed .rv-sum { display: none; }
.rv-notes .rv-note-tools { margin-left: auto; display: inline-flex; gap: 0.2rem; }
.rv-notes .rv-note-tools .iconbtn svg { width: 14px; height: 14px; }
.rv-notes .rv-note textarea { width: 100%; }
.rv-confirm { font-size: 0.9rem; margin: 0.2rem 0 0.4rem; }
.rv-earlier { margin: 0.4rem 0; font-size: 0.9rem; }
.rv-earlier .rv-note.old { border-left-color: var(--border, #bbb); opacity: 0.85; }

/* the fill sets table: its icon column keeps its icons in one row */
table.fillsets td.acts, table.fillsets th.acts { width: 8.5rem; min-width: 8.5rem; white-space: nowrap; }
table.fillsets .acts-row { display: flex; align-items: center; gap: 0.25rem; flex-wrap: nowrap; }
table.fillsets .acts-row .iconbtn { display: inline-flex; }
.infopop { position: relative; display: inline-block; }
.infopop-card { position: absolute; right: 0; top: 2rem; z-index: 5; width: max-content; max-width: 22rem;
  white-space: normal; background: var(--panel, #fff); border: 1px solid var(--border, #ccc);
  border-radius: 6px; padding: 0.45rem 0.6rem; font-size: 0.85rem; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
