:root {
  /* Paper theme: warm off-white page, sepia ink, slightly lighter writing fields */
  --bg: #f6f1e7; --panel: #efe8da; --field: #fbf8f2; --ink: #2e2a24; --muted: #7a7164;
  --line: #ddd3c1; --accent: #8a2f4f; --accent-ink: #fbf8f2; --warn: #a3321f;
  --chip: #e9dfd2;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 13px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }

header#top { position: sticky; top: 0; background: var(--bg); z-index: 5;
  border-bottom: 1px solid var(--line); padding: 8px 10px 0; }
.row { display: flex; gap: 6px; align-items: center; }
.row > * { min-width: 0; }
#seriesSelect { flex: 1; font-weight: 600; }
select, input, textarea { background: var(--field); border: 1px solid var(--line);
  border-radius: 4px; padding: 5px 7px; width: 100%; }
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button { background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  padding: 5px 10px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--warn); }
button.danger.armed { background: var(--warn); color: #fff; border-color: var(--warn); }
button.link { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; }
button.small { padding: 2px 7px; font-size: 12px; }

.linkbar { font-size: 12px; color: var(--muted); margin: 6px 0 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.linkbar select { width: auto; flex: 1; padding: 2px 4px; font-size: 12px; }
nav#tabs { display: flex; margin-top: 8px; }
nav#tabs button { flex: 1; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  background: none; padding: 6px 2px; color: var(--muted); }
nav#tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

main { padding: 10px; }
.toolbar { display: flex; gap: 6px; margin-bottom: 8px; }
.toolbar input, .toolbar select { flex: 1; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px;
  cursor: pointer; background: var(--panel); }
.list li:hover { border-color: var(--accent); }
.list .title { font-weight: 600; }
.list .sub { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }

h2 { font-size: 15px; margin: 0 0 8px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  margin: 16px 0 6px; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
label { display: block; margin-bottom: 8px; }
label > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.req { color: var(--warn); margin-left: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 6px; }
.formbar { display: flex; gap: 6px; justify-content: space-between; position: sticky; bottom: 0;
  background: var(--bg); padding: 8px 0; border-top: 1px solid var(--line); margin-top: 12px; }
.back { margin-bottom: 8px; }

/* Quill (#43) - fold its toolbar/editor into the paper theme instead of
   leaving its default white-on-white look. */
#researchEditor { margin-bottom: 8px; }
.ql-toolbar.ql-snow, .ql-container.ql-snow { border-color: var(--line); }
.ql-toolbar.ql-snow { border-radius: 4px 4px 0 0; background: var(--panel); }
.ql-container.ql-snow { border-radius: 0 0 4px 4px; background: var(--field); font: inherit; }
.ql-editor { min-height: 140px; color: var(--ink); }
.ql-snow .ql-stroke { stroke: var(--muted); }
.ql-snow .ql-fill { fill: var(--muted); }
.ql-snow .ql-picker { color: var(--muted); }
.ql-snow.ql-toolbar button:hover .ql-stroke, .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent); }
.ql-snow.ql-toolbar button:hover .ql-fill, .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: var(--chip); border-radius: 12px; padding: 2px 9px; font-size: 12px;
  border: 1px solid transparent; cursor: pointer; user-select: none; }
.chip.on { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.chip.static { cursor: default; }

.rel { display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 5px 0; border-bottom: 1px dashed var(--line); }
/* Not scoped to .rel - a generic muted small-text note, also used in
   #148's sharing rows (an .addrow, not a .rel). */
.note { color: var(--muted); font-size: 12px; }
.addrow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 4px; margin-top: 6px; }

.tl { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 12px; }
.tl li { position: relative; }
.tl li::before { content: ""; position: absolute; left: -19px; top: 12px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.tl li.dim { opacity: .35; }
.tl-pills { display: flex; gap: 6px; align-items: baseline; margin-bottom: 6px; }
.tl-pills .lbl { font-size: 12px; color: var(--muted); min-width: 64px; }
.when { font-size: 12px; font-weight: 600; color: var(--accent); }
.ages { font-size: 12px; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.kv { display: grid; grid-template-columns: auto 1fr auto; gap: 4px; align-items: start; }

#toast { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 6px 12px; border-radius: 4px;
  opacity: 0; transition: opacity .2s; pointer-events: none; font-size: 12px; max-width: 90%; text-align: center; }
#toast.show { opacity: .92; }
#toast.error { background: var(--warn); color: #fff; }

/* #58: a small in-page modal (never window.confirm() - Office Add-ins
   guidance is to avoid browser-native dialogs, since they render outside
   Office's control and behave inconsistently across hosts). Used for both
   the unsaved-changes guard and the save-conflict prompt. */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.modal-overlay[hidden] { display: none; }
.modal { background: var(--bg); border-radius: 6px; padding: 16px; max-width: 320px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.modal p { margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 6px; }
/* Controls that need a document beside the pane (Word, ...); see host.js. */
.doc-only { display: none !important; }
body.has-doc .doc-only { display: flex !important; }
body.has-doc button.doc-only { display: inline-block !important; }
.legal-links { font-size: 12px; margin-top: 16px; }
.legal-links a { color: var(--muted); }
