/* Tesera's client styles (#24): the approved item 2 mockups' mockup.css at 9a275f9, with the mockup-only
   state picker removed and the app's additions at the end.
   Start point: KaiZai's warm paper, near-black ink, restrained indigo; Newsreader for
   manuscript titles and prose, Inter for controls. Whitespace and type group content;
   hairlines only where they help. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: block; src: url(fonts/inter.woff2) format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 700; font-display: block; src: url(fonts/newsreader.woff2) format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 400 700; font-display: block; src: url(fonts/newsreader-italic.woff2) format("woff2"); }

:root {
  --paper: #f9f9f7; --ink: #0b0b0b; --indigo: #274c9f;
  --muted: #55554f; --line: #e2e1db; --wash: #f1f0ec; --tint: #eaeef7;
  --err: #a3221b; --err-wash: #fbeceb; --ok: #1d6a39; --ok-wash: #e9f3ec;
  --ins: #e2f0e5; --ins-line: #1d6a39; --del: #f7e4e2; --del-ink: #8c1c16;
  --late: #8a4b00;
  --serif: "Newsreader", Georgia, serif; --sans: "Inter", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.5 var(--sans); }
a { color: var(--indigo); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0 0 12px; }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.label { font: 600 11px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* The mockup's own state picker: one small toggle, closed by default, not part of the design. */

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1px solid #c9c8c0; border-radius: 6px; background: transparent; color: var(--ink); font: 500 14px/1 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--wash); }
.btn.primary { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.btn.quiet { border-color: transparent; color: var(--ink); padding: 0 10px; }
.btn.quiet:hover { background: var(--wash); }
.btn.link { border: 0; padding: 0; min-height: 0; color: var(--indigo); text-decoration: underline; font-weight: 500; background: none; }
.btn.danger { color: var(--err); border-color: #e0b4b1; }
.btn.danger-solid { background: var(--err); border-color: var(--err); color: #fff; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .6; cursor: default; }
.btn .ic { font-size: 15px; line-height: 1; }

/* Top bar: wordmark, project, the five project links, search */
.topbar { display: flex; align-items: center; gap: 20px; height: 60px; padding: 0 28px; border-bottom: 1px solid var(--line); }
.wordmark { font: 600 21px/1 var(--serif); color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.wordmark::after { content: "."; color: var(--indigo); }
.ptitle { font: 500 16px/1.2 var(--serif); color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbsep { color: #b4b3ab; }
.pnav { display: flex; gap: 22px; margin-left: 12px; }
.pnav a { color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14px; padding: 19px 0 17px; border-bottom: 2px solid transparent; }
.pnav a:hover { color: var(--ink); }
.pnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--indigo); }
.searchbox { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border: 1px solid #c9c8c0; border-radius: 6px; background: #fff; min-width: 260px; }
.searchbox input { border: 0; outline: 0; font: 14px var(--sans); background: transparent; flex: 1; min-width: 0; color: var(--ink); }

/* Page frame */
.page { max-width: 1040px; margin: 0 auto; padding: 40px 28px 80px; }
.page.narrow { max-width: 640px; }
.ph { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.ph h1 { font: 600 34px/1.15 var(--serif); letter-spacing: -.01em; }
.ph .sub { color: var(--muted); margin: 6px 0 0; }
.section-h { display: flex; align-items: baseline; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin: 36px 0 4px; }
.section-h h2 { font: 600 13px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* Notices: errors get their own red treatment; success stays quiet green */
.notice { border-left: 4px solid var(--indigo); background: var(--tint); padding: 12px 16px; border-radius: 0 6px 6px 0; margin: 0 0 20px; }
.notice.err { border-left-color: var(--err); background: var(--err-wash); }
.notice.err strong:first-child { color: var(--err); }
.notice.ok { border-left-color: var(--ok); background: var(--ok-wash); }
.notice strong:first-child { display: block; margin-bottom: 2px; }
.notice .row { margin-top: 10px; }

/* Loading skeletons */
.sk { height: 12px; border-radius: 4px; background: linear-gradient(90deg, #ebeae5, #f3f2ee, #ebeae5); }
.sk.t { height: 22px; }

/* Empty states */
.empty { text-align: center; padding: 56px 24px; border: 1px dashed #cfcec6; border-radius: 10px; }
.empty h2 { font: 600 24px/1.2 var(--serif); margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto 18px; }

/* Menus and dialogs */
.rel { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 220px; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(11, 11, 11, .10); }
.menu.left { left: 0; right: auto; }
.menu button, .menu a { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 5px; font: 14px var(--sans); color: var(--ink); text-decoration: none; cursor: pointer; }
.menu button:hover, .menu a:hover { background: var(--wash); }
.menu .danger { color: var(--err); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu .kbd { float: right; color: var(--muted); font-size: 12px; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(11, 11, 11, .32); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { width: 100%; max-width: 460px; background: var(--paper); border-radius: 10px; padding: 24px; box-shadow: 0 16px 48px rgba(0, 0, 0, .2); }
.dialog h2 { font: 600 22px/1.25 var(--serif); margin-bottom: 10px; }
.dialog .foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }

/* Form fields */
.field { display: block; margin-bottom: 18px; }
.field > span:first-child, .field legend { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.field input[type=text], .field input[type=number], .field input[type=date], .field select, .field textarea { width: 100%; height: 40px; padding: 0 12px; border: 1px solid #c4c3bb; border-radius: 6px; background: #fff; font: 15px var(--sans); color: var(--ink); }
.field .hint { display: block; color: var(--muted); font-size: 13px; margin-top: 5px; }
.field.bad input { border-color: var(--err); box-shadow: 0 0 0 1px var(--err); }
.field .errtext { display: block; color: var(--err); font-size: 13px; font-weight: 500; margin-top: 5px; }
.field .errtext::before { content: "⚠ "; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
/* Choice cards: the selected style follows the radio's own checked state, so the two always agree. */
.choices { display: grid; gap: 10px; }
.choices.three { grid-template-columns: repeat(3, 1fr); }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid #c9c8c0; border-radius: 8px; background: #fff; cursor: pointer; }
.choice input { margin: 3px 0 0; accent-color: var(--indigo); width: 16px; height: 16px; flex: none; }
.choice:has(input:checked) { border-color: var(--indigo); box-shadow: 0 0 0 1px var(--indigo); background: var(--tint); }
.choice b { display: block; font-weight: 600; }
.choice .d { display: block; color: var(--muted); font-size: 13px; }
input[type=checkbox] { accent-color: var(--indigo); width: 16px; height: 16px; }

/* ---------- Screen 2: project list ---------- */
.resume { display: grid; grid-template-columns: 1fr auto; gap: 8px 40px; align-items: end; padding: 32px 0 34px; border-bottom: 1px solid var(--line); }
.resume .title { font: 600 40px/1.1 var(--serif); letter-spacing: -.015em; color: var(--ink); text-decoration: none; }
.resume .where { margin: 10px 0 0; color: var(--muted); }
.resume .excerpt { grid-column: 1; font: italic 400 19px/1.55 var(--serif); color: #2b2b28; margin: 18px 0 0; max-width: 620px; }
.resume .acts { grid-column: 2; grid-row: 1 / span 3; align-self: center; display: flex; gap: 8px; align-items: center; }
.resume .prog { grid-column: 1 / -1; display: flex; gap: 14px; align-items: center; margin-top: 14px; color: var(--muted); font-size: 13px; }
.bar { flex: none; width: 160px; height: 4px; background: #e3e2dc; border-radius: 2px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--indigo); }
.others { list-style: none; margin: 0; padding: 0; }
.others li { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.others .t { font: 500 19px/1.3 var(--serif); color: var(--ink); text-decoration: none; }
.others .t:hover { text-decoration: underline; }
.others .m { color: var(--muted); font-size: 13px; margin-top: 2px; }
.others .grow { flex: 1; min-width: 0; }
.others li.arch .t { color: var(--muted); }
.iconbtn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--ink); font-size: 18px; cursor: pointer; flex: none; }
.iconbtn:hover { background: var(--wash); }
.listfoot { display: flex; align-items: center; gap: 12px; padding: 14px 0; color: var(--muted); font-size: 13px; }

/* ---------- Screen 3: setup ---------- */
.titlefield input[type=text] { height: 52px; font: 500 22px var(--serif); }
.optional { margin-top: 10px; padding-top: 20px; border-top: 1px solid var(--line); }
.optional .two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.optional .field > span:first-child { font-weight: 500; color: var(--muted); }
.formfoot { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.dangerzone { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }

/* ---------- Screen 4: outline (binder and outliner) ---------- */
.outline { list-style: none; margin: 0; padding: 0; }
.outline ul { list-style: none; margin: 0; padding: 0; }
.onode { display: grid; grid-template-columns: 20px 1fr auto; gap: 0 12px; align-items: baseline; padding: 10px 8px; border-radius: 6px; }
.onode .grip { color: #a9a8a0; cursor: grab; font-size: 13px; }
.onode .wc { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.onode .syn { grid-column: 2 / 3; font: italic 400 16px/1.45 var(--serif); color: var(--muted); margin-top: 2px; }
.onode .name { color: var(--ink); text-decoration: none; }
.onode a.name:hover { text-decoration: underline; }
.onode .name.muted { color: var(--muted); }
.onode .kind { color: var(--muted); font: 500 13px var(--sans); margin-right: 10px; }
.opart > .onode { margin-top: 18px; padding-bottom: 6px; border-bottom: 1px solid var(--line); border-radius: 0; }
.opart > .onode .name { font: 600 24px/1.25 var(--serif); }
.opart > .onode .kind { display: block; font: 600 11px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 2px; }
.ochap > .onode .name { font: 500 19px/1.35 var(--serif); }
.osec > .onode { padding-top: 6px; padding-bottom: 6px; }
.osec > .onode .name { font: 400 15px/1.4 var(--sans); }
.outline .lvl2 { margin-left: 28px; }
.outline .lvl3 { margin-left: 30px; border-left: 1px solid var(--line); padding-left: 6px; }
.onode.sel { background: var(--tint); box-shadow: inset 3px 0 0 var(--indigo); }
.onode .tools { grid-column: 3; grid-row: 1; display: flex; gap: 6px; align-items: center; }
.onode.sel .wc { display: none; }
.onode .editname { font: 500 19px var(--serif); height: 36px; padding: 0 10px; border: 1px solid var(--indigo); border-radius: 5px; background: #fff; width: 100%; max-width: 420px; }
.onode .editsyn { grid-column: 2 / 4; margin-top: 8px; width: 100%; font: italic 16px/1.45 var(--serif); padding: 8px 10px; border: 1px solid #c4c3bb; border-radius: 5px; background: #fff; }
.onode .editfoot { grid-column: 2 / 4; display: flex; gap: 8px; margin-top: 8px; }
.results { list-style: none; margin: 0 0 28px; padding: 0; }
.results li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.results .where { font-size: 13px; color: var(--muted); }
.results a { font: 500 18px var(--serif); color: var(--ink); }
.results .ctx { font: 400 16px/1.5 var(--serif); margin-top: 2px; }
mark { background: #fbe9a6; color: inherit; padding: 0 2px; border-radius: 2px; }

/* ---------- Screen 5: editor ---------- */
.ws { display: grid; grid-template-columns: 280px 1fr; min-height: calc(100vh - 60px); }
.binder { border-right: 1px solid var(--line); padding: 24px 16px 24px 24px; }
.binder .label { margin: 18px 0 6px 8px; }
.binder .label:first-child { margin-top: 0; }
.binder a { display: flex; gap: 8px; justify-content: space-between; padding: 6px 8px; border-radius: 5px; color: var(--ink); text-decoration: none; font: 400 16px/1.3 var(--serif); }
.binder a.sec { font: 400 14px/1.3 var(--sans); padding-left: 24px; color: #2f2f2c; }
.binder a span:last-child { color: var(--muted); font: 12px var(--sans); font-variant-numeric: tabular-nums; padding-top: 2px; }
.binder a:hover { background: var(--wash); }
.binder a[aria-current] { background: var(--tint); box-shadow: inset 3px 0 0 var(--indigo); font-weight: 600; }
.binder .none { margin: 2px 8px; font-size: 13px; color: var(--muted); }
.binder .total { margin: 22px 8px 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.edmain { display: flex; flex-direction: column; min-width: 0; }
.edstrip { display: flex; align-items: center; gap: 8px; padding: 12px 28px; min-height: 56px; }
.edstrip .where { color: var(--muted); font-size: 13px; }
.save { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.save.saved { color: var(--ok); }
.save.saving { color: var(--muted); }
.save.failed { color: #fff; background: var(--err); }
.fmtbar { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; padding: 6px 8px; margin: 0 28px; border: 1px solid var(--line); border-radius: 8px; background: #fff; align-self: center; }
.fmtbar button { min-width: 36px; height: 34px; border: 0; background: none; border-radius: 5px; font: 500 14px var(--sans); color: var(--ink); cursor: pointer; padding: 0 8px; }
.fmtbar button:hover { background: var(--wash); }
.fmtbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.manuscript { width: 100%; max-width: 680px; margin: 0 auto; padding: 28px 28px 48px; font: 400 21px/1.65 var(--serif); }
.manuscript .chap { font: 600 11px/1.4 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.manuscript h1 { font: 600 38px/1.15 var(--serif); letter-spacing: -.01em; margin-bottom: 28px; }
.manuscript p { margin: 0 0 18px; }
.manuscript ul { margin: 0 0 18px; padding-left: 26px; }
.manuscript blockquote { margin: 0 0 18px; padding-left: 20px; border-left: 2px solid #cfcec6; font-style: italic; }
.manuscript .fn { margin-top: 36px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 16px; color: var(--muted); max-width: 320px; }
.manuscript .fn { max-width: none; }
.manuscript .placeholder { color: var(--muted); font-style: italic; }
.caret { display: inline-block; width: 2px; height: 1.05em; background: var(--indigo); vertical-align: -3px; margin-left: 1px; }
.edfoot { position: sticky; bottom: 0; display: flex; gap: 18px; flex-wrap: wrap; align-items: center; padding: 10px 28px; border-top: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: 13px; margin-top: auto; }
.edfoot strong { color: var(--ink); font-weight: 600; }
.edbar, .phonebar, .drawer-only { display: none; }
.drawer { position: fixed; inset: 0; z-index: 45; background: rgba(11, 11, 11, .32); }
.drawer .panel { position: absolute; left: 0; top: 0; bottom: 0; width: min(330px, 88vw); background: var(--paper); overflow-y: auto; padding: 16px 12px 24px 16px; box-shadow: 8px 0 32px rgba(0, 0, 0, .15); }
.drawer .panel .head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.drawer .panel nav.pjump { display: grid; gap: 2px; margin: 4px 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.drawer .panel nav.pjump a { padding: 8px; color: var(--ink); text-decoration: none; font-weight: 500; border-radius: 5px; }
.drawer .panel nav.pjump a[aria-current] { background: var(--tint); }
.drawer .binder { border: 0; padding: 0; }

/* ---------- Screen 7: versions ---------- */
.vgrid { display: grid; grid-template-columns: 1fr 300px; gap: 48px; align-items: start; }
.cmphead { padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.cmphead .pair { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font: 500 19px/1.35 var(--serif); }
.cmphead .pair .d { font: 13px var(--sans); color: var(--muted); }
.cmphead .arrow { color: var(--muted); font-family: var(--sans); }
.cmphead .sum { margin-top: 6px; color: var(--muted); font-size: 13px; }
.passage { margin: 22px 0 0; }
.passage .where { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.passage .txt { font: 400 19px/1.65 var(--serif); }
ins { background: var(--ins); text-decoration: underline 2px var(--ins-line); text-underline-offset: 4px; }
del { background: var(--del); color: var(--del-ink); text-decoration: line-through 1.5px; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 26px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.afterread { margin-top: 20px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 9px 10px; border-radius: 6px; align-items: center; }
.hist li + li { border-top: 1px solid var(--line); }
.hist .n { font-size: 14px; font-weight: 500; }
.hist .n.auto { font-weight: 400; color: var(--muted); }
.hist .w { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hist li.sel { background: var(--tint); box-shadow: inset 3px 0 0 var(--indigo); border-top-color: transparent; }
.hist li.sel + li { border-top-color: transparent; }
.hist .tag { font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--indigo); text-transform: uppercase; margin-left: 6px; }
.hist .cur { font-size: 12px; font-weight: 600; color: var(--indigo); }

/* ---------- Screen 10: progress ---------- */
.lead { display: grid; grid-template-columns: 1.2fr 1fr; gap: 48px; padding: 8px 0 30px; border-bottom: 1px solid var(--line); }
.lead .big { font: 600 46px/1.05 var(--serif); letter-spacing: -.015em; }
.lead .big small { font: 400 17px var(--sans); color: var(--muted); letter-spacing: 0; }
.lead .nextms { font: 500 26px/1.2 var(--serif); margin: 6px 0 6px; }
.late { color: var(--late); font-weight: 600; }
.wide.bar { width: 100%; height: 6px; margin: 14px 0 8px; }
.ms { list-style: none; margin: 0; padding: 0; }
.ms li { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.ms li .grow { flex: 1; }
.ms .done { color: var(--muted); text-decoration: line-through; }
.ms .when { font-size: 13px; color: var(--muted); }
.counts { width: 100%; border-collapse: collapse; font-size: 14px; }
.counts th { text-align: left; font: 600 11px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 8px 0; border-bottom: 1px solid var(--line); }
.counts td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.counts .n { text-align: right; font-variant-numeric: tabular-nums; padding-left: 16px; }
.counts .pt td:first-child { font: 600 16px var(--serif); }
.counts .ch td:first-child { padding-left: 20px; }
.counts .tot td { font-weight: 600; border-bottom: 0; border-top: 2px solid var(--ink); }
.counts a { color: var(--ink); }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: start; }
.addms { display: grid; grid-template-columns: 1fr 170px auto; gap: 10px; align-items: end; padding: 14px 0; border-bottom: 1px solid var(--line); }
.addms .field { margin: 0; }

/* ---------- Screen 11: export ---------- */
.summary { font: 400 21px/1.5 var(--serif); padding: 18px 20px; border-radius: 8px; background: #fff; border: 1px solid var(--line); margin-bottom: 30px; }
.summary b { font-weight: 600; color: var(--indigo); }
.summary.bad { border-color: var(--err); }
.picks { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 28px; }
.picks .choices { gap: 8px; }
.parts { margin: 10px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.parts label { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 14px; }
.parts .in { padding-left: 24px; }
.parts .pt { font: 600 15px var(--serif); }
.exportfoot { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }

/* ---------- Phone, 390 px ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; gap: 4px 12px; padding: 12px 16px 0; }
  .topbar .ptitle { flex: 1; min-width: 0; }
  .topbar .spacer { display: none; }
  .topbar .searchbox { display: none; }
  .topbar .searchbtn { display: inline-flex; }
  .pnav { order: 5; width: 100%; margin: 4px 0 0; gap: 0; justify-content: space-between; }
  .pnav a { padding: 10px 0 9px; font-size: 14px; }
  .page { padding: 24px 16px 72px; }
  .ph { margin-bottom: 18px; }
  .ph h1 { font-size: 28px; }
  .resume { grid-template-columns: 1fr; padding: 20px 0 24px; }
  .resume .title { font-size: 30px; }
  .resume .excerpt { font-size: 17px; margin-top: 12px; }
  .resume .acts { grid-column: 1; grid-row: auto; margin-top: 16px; }
  .resume .menu { left: 0; right: auto; }
  .resume .prog { margin-top: 10px; flex-wrap: wrap; }
  .choices.three { grid-template-columns: 1fr; }
  .optional .two { grid-template-columns: 1fr; gap: 0; }
  .outline .lvl2 { margin-left: 12px; }
  .outline .lvl3 { margin-left: 14px; }
  .onode { grid-template-columns: 1fr auto; padding: 10px 6px; }
  .onode .grip { display: none; }
  .onode .syn, .onode .editsyn, .onode .editfoot { grid-column: 1 / -1; }
  .onode .tools { grid-column: 1 / -1; grid-row: auto; margin-top: 8px; }
  .onode .tools .menu { left: 0; right: auto; }
  .opart > .onode .name { font-size: 21px; }
  /* Editor on a phone: one bar on top (where, saved), the passage, one bar at the bottom */
  body.editor .topbar, body.editor .binder.desk, body.editor .edstrip, body.editor .edfoot { display: none; }
  .ws { display: block; min-height: 0; }
  .edbar { display: flex; position: sticky; top: 0; z-index: 5; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--paper); }
  .edbar .loc { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .edbar .loc b { color: var(--ink); font: 600 14px var(--serif); }
  .phonebar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; align-items: center; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--paper); font-size: 13px; color: var(--muted); }
  .phonebar .menu { top: auto; bottom: calc(100% + 4px); }
  .fmtbar { margin: 0; position: fixed; left: 8px; right: 8px; bottom: 58px; z-index: 6; justify-content: space-between; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
  .fmtbar button { min-width: 34px; padding: 0 6px; }
  .manuscript { padding: 22px 20px 96px; font-size: 19px; line-height: 1.6; }
  .manuscript h1 { font-size: 30px; margin-bottom: 18px; }
  .edmain .notice { margin: 12px 12px 0; }
  .vgrid, .lead, .twocol, .picks { grid-template-columns: 1fr; gap: 28px; }
  .lead .big { font-size: 38px; }
  .addms { grid-template-columns: 1fr; }
  .summary { font-size: 18px; padding: 14px 16px; }
  .searchbox { min-width: 0; }
}
@media (min-width: 721px) { .searchbtn { display: none; } }

/* ---------- The app's additions (not in the mockups) ---------- */
.manuscript .editable { outline: none; min-height: 40vh; }
.manuscript .editable:focus-visible { outline: none; }
.manuscript .editable h2 { font: 600 26px/1.25 var(--serif); margin: 30px 0 12px; }
.manuscript .editable ol { margin: 0 0 18px; padding-left: 26px; }
.manuscript .editable.isempty::before { content: "Start writing here. Tesera saves as you type."; color: var(--muted); font-style: italic; pointer-events: none; position: absolute; }
.manuscript sup.fnref { color: var(--indigo); cursor: pointer; font: 600 13px var(--sans); padding: 0 1px; }
.manuscript .fn ol { margin: 0; padding-left: 20px; }
.manuscript .fn li button { font: inherit; color: inherit; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.manuscript .hit { background: #fbe9a6; border-radius: 3px; transition: background 1.5s; }
.dialog textarea { width: 100%; min-height: 90px; padding: 8px 12px; border: 1px solid #c4c3bb; border-radius: 6px; background: #fff; font: 15px/1.5 var(--sans); color: var(--ink); }
.onode { cursor: default; }
.onode.dropbefore { box-shadow: inset 0 3px 0 var(--indigo); }
li[draggable=true] > .onode .grip { cursor: grab; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 720px) {
  .topbar.searching .searchbox { display: flex; order: 6; width: 100%; margin: 6px 0 10px; }
}

/* Screen 5's provenance view (FR-11; item 4, #26), as the approved mockups draw it (docs/mockups/tesera/item-4/).
   Each origin has a wash, an underline style and a name in words, so none is told apart by colour alone. The text
   is marked with ::highlight(), so the editable DOM is never changed. */
:root {
  --o-typed: #1d6a39; --o-typed-wash: #e6f0e8;
  --o-paste: #8a4b00; --o-paste-wash: #fbecc9;
  --o-ver: #274c9f; --o-ver-wash: #e3eaf7;
  --o-unv: #a3221b; --o-unv-wash: #fbe3e1;
  --o-ai: #6a3d9a; --o-ai-wash: #efe6f7;
}
::highlight(o-typed) { background-color: var(--o-typed-wash); text-decoration: underline solid var(--o-typed) 2px; }
::highlight(o-pasted) { background-color: var(--o-paste-wash); text-decoration: underline dashed var(--o-paste) 2px; }
::highlight(o-verified) { background-color: var(--o-ver-wash); text-decoration: underline dotted var(--o-ver) 3px; }
::highlight(o-unverified) { background-color: var(--o-unv-wash); text-decoration: underline wavy var(--o-unv) 1.5px; }
::highlight(o-ai) { background-color: var(--o-ai-wash); text-decoration: underline double var(--o-ai) 3px; }
body.prov-on .editable { text-underline-offset: 5px; text-decoration-skip-ink: none; }
:is(.legend-o, .chips) .o { text-decoration-thickness: 2px; text-underline-offset: 5px; text-decoration-skip-ink: none; border-radius: 2px; }
:is(.legend-o, .chips) .o-typed { background: var(--o-typed-wash); text-decoration-line: underline; text-decoration-style: solid; text-decoration-color: var(--o-typed); }
:is(.legend-o, .chips) .o-pasted { background: var(--o-paste-wash); text-decoration-line: underline; text-decoration-style: dashed; text-decoration-color: var(--o-paste); }
:is(.legend-o, .chips) .o-verified { background: var(--o-ver-wash); text-decoration-line: underline; text-decoration-style: dotted; text-decoration-color: var(--o-ver); text-decoration-thickness: 3px; }
:is(.legend-o, .chips) .o-unverified { background: var(--o-unv-wash); text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: var(--o-unv); text-decoration-thickness: 1.5px; }
:is(.legend-o, .chips) .o-ai { background: var(--o-ai-wash); text-decoration-line: underline; text-decoration-style: double; text-decoration-color: var(--o-ai); text-decoration-thickness: 3px; }

.btn[aria-pressed="true"][data-prov-toggle] { background: var(--tint); border-color: var(--indigo); color: var(--indigo); }
.ws.with-prov { grid-template-columns: 280px minmax(0, 1fr) 352px; }
.prov { border-left: 1px solid var(--line); padding: 20px 24px 32px; font-size: 14px; }
.prov[hidden], .provstrip[hidden] { display: none !important; }
.prov .phead { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.prov .phead h2 { font: 600 20px/1.2 var(--serif); margin: 0; }
.prov .phead .spacer { flex: 1; }
.prov .phone-only { display: none; }
.prov h3 { font: 600 11px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; }
.prov h3 .what { text-transform: none; letter-spacing: 0; font: 500 14px var(--serif); color: var(--ink); margin-left: 4px; }
.legend-o { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.legend-o li { display: grid; grid-template-columns: 58px 1fr; gap: 10px; align-items: baseline; }
.legend-o .sw { font: 400 16px/1.3 var(--serif); text-align: center; padding: 0 4px; }
.legend-o b { font-weight: 600; display: block; }
.legend-o .d { color: var(--muted); font-size: 13px; }
.prov .stack { display: flex; gap: 2px; height: 8px; border-radius: 3px; overflow: hidden; background: var(--paper); }
.prov .stack.wide { height: 12px; margin: 4px 0 10px; }
.prov .stack span { display: block; height: 100%; }
.prov .s-typed { background: var(--o-typed); }
.prov .s-pasted { background: #b8730f; }
.prov .s-verified { background: var(--o-ver); }
.prov .s-unverified { background: repeating-linear-gradient(135deg, var(--o-unv) 0 3px, #d98a85 3px 6px); }
.prov .s-ai { background: var(--o-ai); }
.shares { width: 100%; border-collapse: collapse; font-size: 13px; }
.shares td { padding: 5px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.shares td.n { text-align: right; font-variant-numeric: tabular-nums; padding-left: 10px; white-space: nowrap; }
.shares td.p { text-align: right; font-variant-numeric: tabular-nums; padding-left: 10px; width: 44px; font-weight: 600; }
.shares .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: -1px; }
.shares .note { display: block; color: var(--o-unv); font-size: 12px; font-weight: 500; margin-top: 2px; }
.shares tr.tot td { border-bottom: 0; border-top: 2px solid var(--ink); font-weight: 600; }
.shares tr.zero td { color: var(--muted); }
.bysec { list-style: none; margin: 0; padding: 0; }
.bysec li { display: grid; grid-template-columns: 1fr 96px; gap: 4px 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.bysec li[aria-current] { background: var(--tint); box-shadow: inset 3px 0 0 var(--indigo); padding-left: 8px; }
.bysec .nm { font: 400 15px/1.3 var(--serif); min-width: 0; color: inherit; text-decoration: none; }
.bysec .nm:hover { text-decoration: underline; }
.bysec .nm.sec { padding-left: 14px; font: 400 13px/1.3 var(--sans); }
.bysec .nm small { color: var(--muted); font: 12px var(--sans); margin-left: 4px; font-variant-numeric: tabular-nums; }
.bysec .empty0 { color: var(--muted); font-size: 12px; text-align: right; }
.prov .foot { margin-top: 18px; color: var(--muted); font-size: 12px; }
.prov .one { margin: 4px 0 0; padding: 10px 12px; background: var(--ok-wash); border-radius: 6px; font-size: 13px; }
.prov .nowords { margin: 0; padding: 14px; border: 1px dashed #cfcec6; border-radius: 8px; color: var(--muted); font-size: 13px; }
.prov .sk { margin-bottom: 10px; }
.provstrip, .sheetscrim { display: none; }

/* Phone: the writing view stays as approved; the control is in More, a strip names the origins while they are shown,
   and the summary opens in a sheet. */
@media (max-width: 720px) {
  .ws.with-prov { display: block; }
  .prov { display: none; }
  body.prov-sheet .prov { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 46; max-height: 82vh; overflow-y: auto; background: var(--paper); border: 0; border-radius: 14px 14px 0 0; padding: 16px 16px 28px; box-shadow: 0 -8px 32px rgba(0, 0, 0, .18); }
  body.prov-sheet .sheetscrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(11, 11, 11, .32); }
  .prov .desk-only { display: none; }
  .prov .phone-only { display: inline-flex; }
  .provstrip { display: block; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); background: #fff; }
  .provstrip .top { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
  .provstrip .top b { flex: 1; font-size: 13px; }
  .provstrip .chips { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; }
  .provstrip .chips span.o { padding: 0 3px; }
}

/* ---------- Screens 8 and 9: handwritten pages (item 5, #27), from the approved mockups (PR #44, handwriting.css) ---------- */
.hw .back { display: inline-block; font-size: 14px; margin-bottom: 14px; }
.hw .tag { display: inline-flex; align-items: center; gap: 5px; font: 600 12px/1 var(--sans); padding: 5px 9px; border-radius: 999px; white-space: nowrap; }
.hw .tag.unv { color: var(--late); background: #fbf0df; box-shadow: inset 0 0 0 1px #e8cfa6; }
.hw .tag.ver { color: var(--ok); background: var(--ok-wash); box-shadow: inset 0 0 0 1px #b9d8c2; }
.hw .tag.wait { color: var(--muted); background: var(--wash); box-shadow: inset 0 0 0 1px #d6d5ce; }
.hw .tag.bad { color: var(--err); background: var(--err-wash); box-shadow: inset 0 0 0 1px #e0b4b1; }
.hw .into { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: 22px; }
.hw .into .field { margin: 0; flex: 1; min-width: 220px; }
.hw .into select { width: 100%; height: 40px; padding: 0 10px; border: 1px solid #c4c3bb; border-radius: 6px; background: #fff; font: 15px var(--sans); color: var(--ink); }
.hw .pick { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hw .pickcard { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 22px; border: 1px dashed #bdbcb4; border-radius: 10px; background: #fff; }
.hw .pickcard .big { color: var(--indigo); }
.hw .pickcard h2 { font: 600 20px/1.25 var(--serif); }
.hw .pickcard p { color: var(--muted); font-size: 14px; margin: 0 0 6px; }
.hw .howto { margin: 22px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.hw .howto li::before { content: "·"; margin-right: 8px; color: var(--indigo); font-weight: 700; }
.hw .pages { list-style: none; margin: 0; padding: 0; }
.hw .pages li { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.hw .pages li:first-child { border-top: 1px solid var(--line); }
.hw .pages .thumb { width: 64px; height: 84px; object-fit: cover; border-radius: 3px; box-shadow: 0 2px 8px rgba(0, 0, 0, .14); background: #fffdf6; }
.hw .pages .n { font-weight: 600; }
.hw .pages .m { color: var(--muted); font-size: 13px; }
.hw .pages .acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.hw .prog { width: 100%; max-width: 260px; height: 4px; background: #e3e2dc; border-radius: 2px; overflow: hidden; margin-top: 8px; }
.hw .prog span { display: block; height: 100%; background: var(--indigo); }
.hw .capfoot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 22px; }
.hw .rvhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.hw .rvhead h1 { font: 600 30px/1.15 var(--serif); letter-spacing: -.01em; }
.hw .rvhead .sub { color: var(--muted); font-size: 14px; width: 100%; margin: 0; }
.hw .pagetabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.hw .pagetabs a { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid #c9c8c0; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 500; }
.hw .pagetabs a[aria-current] { border-color: var(--indigo); box-shadow: 0 0 0 1px var(--indigo); background: var(--tint); }
.hw .pagetabs a.addmore { border-style: dashed; color: var(--indigo); }
.hw .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.hw .dot.unv { background: var(--late); }
.hw .dot.ver { background: var(--ok); }
.hw .dot.wait { background: transparent; box-shadow: inset 0 0 0 2px #8f8e87; }
.hw .side { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; align-items: start; }
.hw .pane .panehead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; min-height: 30px; }
.hw .pane .panehead .label { margin: 0; }
/* The photo, as uploaded, with a box over each word Tesera isn't sure of, placed in the image's own pixels. */
.hw .shot { position: relative; line-height: 0; border-radius: 3px; overflow: hidden; box-shadow: 0 6px 22px rgba(0, 0, 0, .16), 0 0 0 1px rgba(0, 0, 0, .05); background: #fffdf6; }
.hw .shot img { display: block; width: 100%; height: auto; }
.hw .wbox { position: absolute; border: 2px dotted var(--late); border-radius: 3px; background: rgba(251, 240, 223, .35); }
.hw .wbox.on { border-style: solid; background: rgba(251, 240, 223, .6); }
.hw .transcript { font: 400 21px/34px var(--serif); padding: 40px 28px 30px; background: #fff; border: 1px solid var(--line); border-radius: 8px; min-height: 280px; overflow-wrap: anywhere; }
.hw .transcript.unverified { border-left: 4px solid var(--late); }
.hw .transcript.verified { border-left: 4px solid var(--ok); }
.hw .transcript p { margin: 0; }
.hw .lc { background: #fbf0df; text-decoration: underline dotted 2px var(--late); text-underline-offset: 5px; border-radius: 2px; }
.hw .lc.on, .hw .lc:focus { outline: 2px solid var(--late); outline-offset: 1px; }
.hw .fixed { background: var(--ok-wash); text-decoration: underline 2px var(--ok); text-underline-offset: 5px; border-radius: 2px; }
.hw textarea.edit { display: block; width: 100%; min-height: 280px; font: 400 21px/34px var(--serif); padding: 38px 26px 28px; border: 2px solid var(--indigo); border-radius: 8px; background: #fff; color: var(--ink); resize: vertical; }
.hw .wordhelp { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px; }
.hw .wordhelp b { font-family: var(--serif); font-size: 17px; }
.hw .legend2 { display: flex; gap: 8px 18px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--muted); }
.hw .rvfoot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.hw .waiting { display: flex; flex-direction: column; justify-content: center; gap: 6px; min-height: 280px; padding: 28px; border: 1px dashed #bdbcb4; border-radius: 8px; color: var(--muted); }
.hw .waiting strong { color: var(--ink); font: 600 19px/1.3 var(--serif); }
.hw .record { margin-top: 12px; font-size: 13px; color: var(--muted); }
.hw .rawread { margin-top: 14px; font-size: 14px; }
.hw .rawread summary { cursor: pointer; color: var(--indigo); }
.hw .rawread .transcript { margin-top: 10px; min-height: 0; padding: 20px 22px; font-size: 18px; line-height: 30px; }
@media (max-width: 720px) {
  .hw .pick { grid-template-columns: 1fr; gap: 10px; }
  .hw .pickcard { padding: 16px; }
  .hw .pages li { grid-template-columns: 52px 1fr; gap: 10px; }
  .hw .pages .thumb { width: 52px; height: 68px; }
  .hw .pages .acts { grid-column: 1 / -1; justify-content: flex-start; }
  .hw .capfoot .btn.primary { flex: 1; justify-content: center; }
  .hw .rvhead h1 { font-size: 25px; }
  .hw .side { grid-template-columns: 1fr; gap: 20px; }
  .hw .transcript, .hw textarea.edit { font-size: 18px; line-height: 30px; padding: 20px 16px; min-height: 0; }
  .hw textarea.edit { min-height: 300px; }
  .hw .waiting { min-height: 0; }
  .hw .rvfoot .btn { flex: 1; justify-content: center; }
}
