/* Docs Studio (/document-editor). It wears Video Studio's frame
   (video-studio.css): menus and Export along the top, then the formatting
   bar, then the outline, the pages and the side panel in a row, then the
   status bar. The pages are white sheets on the dark stage, drawn in CSS
   px and scaled for zoom; the text on them is styled like Word's defaults
   (DEFAULT_LOOK in public/js/docs-studio/model.js). On a phone the outline
   and the panels become sheets opened from tabs. */

@font-face { font-family: "Montserrat"; font-weight: 100 900; font-display: swap; src: url(/fonts/montserrat-latin-wght-normal.woff2) format("woff2-variations"); }
@font-face { font-family: "Playfair Display"; font-weight: 400 900; font-display: swap; src: url(/fonts/playfair-display-latin-wght-normal.woff2) format("woff2-variations"); }
@font-face { font-family: "Bitter"; font-weight: 100 900; font-display: swap; src: url(/fonts/bitter-latin-wght-normal.woff2) format("woff2-variations"); }
@font-face { font-family: "Oswald"; font-weight: 200 700; font-display: swap; src: url(/fonts/oswald-latin-wght-normal.woff2) format("woff2-variations"); }
@font-face { font-family: "Bebas Neue"; font-weight: 400; font-display: swap; src: url(/fonts/bebas-neue-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Dancing Script"; font-weight: 400 700; font-display: swap; src: url(/fonts/dancing-script-latin-wght-normal.woff2) format("woff2-variations"); }
@font-face { font-family: "Pacifico"; font-weight: 400; font-display: swap; src: url(/fonts/pacifico-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 300 700; font-display: swap; src: url(/fonts/fredoka-latin-wght-normal.woff2) format("woff2-variations"); }

@property --push { syntax: "<length>"; inherits: false; initial-value: 0px; }

/* ---- Start screen ---- */
.ds-new .st-new-row + .st-new-row { margin-top: 12px; }
.ds-new .st-new-row > .st-field { flex: 0 0 auto; }

/* ---- The frame ---- */
.ds-work { grid-template-rows: auto auto minmax(0, 1fr) auto; }
.ds-work.is-pdf { grid-template-rows: auto minmax(0, 1fr); }
.ds-work.is-pdf :is(.ds-bar, .ds-body, .ds-status) { display: none; }
.ds-work .ds-flow, .ds-work .ds-flow * { -webkit-user-select: text; user-select: text; }
.ds-pdf { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ds-pdf[hidden] { display: none; }
.ds-menu { max-height: 72vh; overflow-y: auto; scrollbar-width: thin; }
.ds-menu-head { margin: 8px 10px 2px; }
.ds-menu-sep { margin: 4px 6px; border: 0; border-top: 1px solid var(--border); }

/* ---- The formatting bar ---- */
.ds-bar { display: flex; align-items: center; gap: 2px; min-width: 0; padding: 4px 8px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); scrollbar-width: none; }
.ds-bar::-webkit-scrollbar { display: none; }
.ds-bar > * { flex: none; }
.ds-bar .st-select { height: 30px; padding: 0 26px 0 8px; font-size: 0.8rem; }
.ds-style { width: 118px; }
.ds-font { width: 150px; }
.ds-size { width: 54px; height: 30px; padding: 0 6px; font-size: 0.8rem; text-align: center; }
.ds-tb-gap { width: 1px; height: 22px; margin: 0 5px; background: var(--border); }
.ds-swatch-btn { position: relative; }
.ds-swatch-bar { position: absolute; left: 7px; right: 7px; bottom: 4px; height: 3px; border: 1px solid var(--edge); }
.ds-caret-btn { width: 16px; margin-left: -2px; }
.ds-pop { min-width: 0; padding: 6px; }
.ds-color-pop { width: 232px; }
.ds-colors { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin: 6px 0; }
.ds-color { aspect-ratio: 1; padding: 0; background: var(--c); border: 1px solid var(--edge); cursor: pointer; transition: transform 120ms ease, box-shadow 120ms ease; }
.ds-color.is-none { background: repeating-linear-gradient(135deg, #fff 0 5px, #f0918d 5px 6px, #fff 6px 11px); }
.ds-shades { grid-template-columns: repeat(7, 34px); }
.ds-color-more { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 10px; color: var(--muted); font-size: 0.8rem; }
.ds-color-custom { width: 36px; height: 24px; padding: 0; border: 1px solid var(--edge); background: none; cursor: pointer; }
.ds-tp { padding: 4px; }
.ds-tp-label { margin: 0 0 6px; color: var(--muted); font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
.ds-tp-grid { display: grid; gap: 2px; }
.ds-tp-cell { width: 18px; height: 18px; padding: 0; background: var(--surface-2); border: 1px solid var(--edge); cursor: pointer; }
.ds-tp-cell.is-on { background: var(--accent); }
.ds-tp-more { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); }
.ds-tp-num { width: 56px; height: 28px; padding: 0 6px; }

/* ---- Body: outline, stage, panels ---- */
.ds-body { position: relative; display: grid; grid-template-columns: 230px minmax(0, 1fr) 320px; min-height: 0; }
.ds-work.no-left .ds-body { grid-template-columns: 0 minmax(0, 1fr) 320px; }
.ds-work.no-right .ds-body { grid-template-columns: 230px minmax(0, 1fr) 0; }
.ds-work.no-left.no-right .ds-body { grid-template-columns: 0 minmax(0, 1fr) 0; }
.ds-work.no-left #ds-left, .ds-work.no-right #ds-right { display: none; }
.ds-side { min-width: 0; min-height: 0; padding: 10px 12px 16px; overflow-y: auto; background: var(--surface); scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
#ds-left { border-right: 1px solid var(--border); }
.ds-right { display: flex; flex-direction: column; padding: 0; border-left: 1px solid var(--border); }
.ds-outline { display: flex; flex-direction: column; gap: 1px; }
.ds-ol-item { display: block; width: 100%; padding: 5px 8px; overflow: hidden; color: var(--text); background: none; border: 0; font-size: 0.8rem; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.ds-ol-item.is-l0, .ds-ol-item.is-l1 { font-weight: 700; }
.ds-ol-item.is-l2 { padding-left: 18px; }
.ds-ol-item.is-l3 { padding-left: 28px; color: var(--muted); }
.ds-ol-item.is-l4, .ds-ol-item.is-l5, .ds-ol-item.is-l6 { padding-left: 38px; color: var(--muted); font-size: 0.74rem; }
.ds-rtabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--border); }
.ds-rtab { padding: 6px 10px; color: var(--muted); background: none; border: 0; font-size: 0.78rem; cursor: pointer; }
.ds-rtab.is-active { color: var(--tint-text); background: var(--tint); }
.ds-rbody { flex: 1; min-height: 0; padding: 10px 12px 16px; overflow-y: auto; scrollbar-width: thin; }
.ds-pane { display: flex; flex-direction: column; gap: 8px; min-height: 100%; }
.ds-pane[hidden] { display: none; }
.ds-pane .vs-lib-head { margin: 2px 0 0; }
.ds-find-row { display: flex; align-items: center; gap: 4px; }
.ds-find-row .input { flex: 1; min-width: 0; height: 32px; padding: 0 8px; font-size: 0.85rem; }
.ds-find-count { min-height: 1.2em; margin: 0; color: var(--muted); font-size: 0.78rem; }
.ds-checks { display: flex; flex-direction: column; gap: 4px; }
.ds-check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.8rem; cursor: pointer; }
.ds-check input { accent-color: var(--accent); }
.ds-issues { display: flex; flex-direction: column; gap: 6px; }
.ds-issue { padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid #3b82f6; }
.ds-issue.is-spelling { border-left-color: #f0918d; }
.ds-issue.is-style { border-left-color: #a37ff8; }
.ds-issue-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; width: 100%; padding: 0; color: var(--text); background: none; border: 0; text-align: left; cursor: pointer; }
.ds-issue-head small { color: var(--faint); font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.06em; text-transform: uppercase; }
.ds-issue-msg { margin: 4px 0 6px; color: var(--muted); font-size: 0.78rem; line-height: 1.4; }
.ds-issue-btns { display: flex; flex-wrap: wrap; gap: 4px; }
.ds-issue-btns .vs-chip { padding: 3px 9px; }
.vs-chip.is-quiet { color: var(--muted); background: none; }
.ds-rules summary { color: var(--muted); font-size: 0.8rem; cursor: pointer; }
.ds-rules[open] { display: flex; flex-direction: column; gap: 4px; }
.ds-md { flex: 1; min-height: 320px; width: 100%; padding: 10px; color: var(--text); background: var(--bg); border: 2px solid var(--edge); font: 0.8rem/1.5 var(--mono); resize: vertical; tab-size: 4; }
.ds-md:focus-visible { outline: none; border-color: var(--accent); }
.ds-stats { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; font-size: 0.82rem; }
.ds-stats dt { color: var(--muted); }
.ds-stats dd { margin: 0; font-family: var(--mono); text-align: right; }

/* ---- Stage and pages ---- */
.ds-stage { position: relative; min-width: 0; min-height: 0; padding: 24px 16px 48px; overflow: auto; background: #2a2540; scrollbar-color: var(--border) transparent; }
.ds-sizer { position: relative; margin: 0 auto; }
.ds-paper { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.ds-sheets { position: absolute; inset: 0; }
.ds-sheet { position: absolute; left: 0; background: #fff; box-shadow: 6px 6px 0 var(--edge); outline: 2px solid var(--edge); }
.ds-hdr, .ds-ftr { position: absolute; color: #000; font: var(--ds-size, 11pt)/var(--ds-lh, 1.15) var(--ds-font, Calibri, Carlito, "Segoe UI", Arial, sans-serif); white-space: pre-wrap; cursor: default; }
.ds-hdr p, .ds-ftr p { margin: 0; }
.ds-sheet:hover .ds-hdr.is-empty, .ds-sheet:hover .ds-ftr.is-empty { min-height: 1.2em; }

/* The text: Word's look. */
.ds-flow {
  position: absolute;
  min-height: 100px;
  color: #000;
  font: var(--ds-size, 11pt)/var(--ds-lh, 1.15) var(--ds-font, Calibri, Carlito, "Segoe UI", Arial, sans-serif);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  tab-size: 36pt;
  outline: none;
  caret-color: #000;
  -webkit-font-smoothing: auto;
}
.ds-flow ::selection { background: #b4d5fe; }
.ds-flow > *, .ds-flow li, .ds-flow blockquote > * { padding-top: var(--push); }
.ds-flow :is(td, th) { padding: calc(var(--push) + 1pt) 5.4pt 1pt; }
.ds-flow p { margin: var(--ds-before, 0) 0 var(--ds-after, 8pt); }
.ds-flow :is(h1, h2, h3, h4, h5, h6) { margin: 12pt 0 4pt; font-family: "Calibri Light", Calibri, Carlito, "Segoe UI", Arial, sans-serif; font-weight: 400; line-height: 1.15; }
.ds-flow h1 { font-size: 16pt; color: #2f5496; }
.ds-flow h2 { font-size: 13pt; color: #2f5496; }
.ds-flow h3 { font-size: 12pt; color: #1f3763; }
.ds-flow :is(h4, h5, h6) { font-size: 11pt; color: #2f5496; font-style: italic; }
.ds-flow > :first-child { margin-top: 0; }
.ds-flow p.title { margin: 0 0 4pt; font: 28pt/1.1 "Calibri Light", Calibri, Carlito, Arial, sans-serif; letter-spacing: -0.01em; }
.ds-flow p.subtitle { margin: 0 0 8pt; color: #5a5a5a; font-size: 15pt; letter-spacing: 0.02em; }
.ds-flow :is(ul, ol) { margin: 0 0 8pt; padding-left: 36pt; }
.ds-flow li :is(ul, ol) { margin: 0; padding-left: 24pt; }
.ds-flow li { margin: 0; }
.ds-flow ul.checklist { list-style: none; padding-left: 26pt; }
.ds-flow ul.checklist > li { position: relative; }
.ds-flow ul.checklist > li::before { content: ""; position: absolute; left: -20pt; top: calc(var(--push) + 0.2em); width: 0.85em; height: 0.85em; border: 1.3px solid #444; cursor: pointer; }
.ds-flow ul.checklist > li[data-checked="true"] { color: #777; text-decoration: line-through; }
.ds-flow ul.checklist > li[data-checked="true"]::before { background: #444 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5'%3E%3Cpath d='M5 12.5 10 17 19 7'/%3E%3C/svg%3E") center / 90% no-repeat; }
.ds-flow blockquote { margin: 10pt 43pt 10pt 43pt; color: #404040; font-style: italic; text-align: center; }
.ds-flow blockquote p:last-child { margin-bottom: 0; }
.ds-flow pre { margin: 0 0 8pt; padding: calc(var(--push) + 6pt) 8pt 6pt; background: #f4f4f4; font: 10pt/1.3 Consolas, "Courier New", monospace; white-space: pre-wrap; }
.ds-flow code { font-family: Consolas, "Courier New", monospace; }
.ds-flow a { color: #0563c1; text-decoration: underline; }
.ds-flow img { max-width: 100%; height: auto; vertical-align: bottom; }
.ds-flow hr { height: 0; margin: 6pt 0 12pt; border: 0; border-top: 1px solid #999; }
.ds-flow hr.page-break { position: relative; height: 10px; margin: 4pt 0; border: 0; background: repeating-linear-gradient(90deg, #9aa0b5 0 6px, transparent 6px 10px) center / 100% 1px no-repeat content-box; }
.ds-flow hr.page-break::after { content: "Page break"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 0 6px; color: #7a7f93; background: #fff; font: 8pt Arial, sans-serif; letter-spacing: 0.04em; }
.ds-flow table { width: auto; margin: 0 0 8pt; border-collapse: collapse; }
.ds-flow :is(td, th) { min-width: 24px; border: 1px solid #000; vertical-align: top; text-align: left; font-weight: inherit; }
.ds-flow th { font-weight: 700; }
.ds-flow :is(td, th) p { margin: 0; }
.ds-flow table[data-borders="none"] :is(td, th) { border-color: transparent; outline: 1px dashed #c8cbd6; outline-offset: -1px; }
.ds-flow ol.footnotes { margin-top: 18pt; padding-top: 6pt; border-top: 1px solid #999; font-size: 9pt; }
.ds-flow sup.fn-ref a { text-decoration: none; }
.ds-flow span[data-field] { background: #eef0f6; }
.ds-field-chip { padding: 0 4px; color: var(--tint-text); background: var(--tint); font-size: 0.85em; }

::highlight(ds-find) { background-color: #ffe066; color: #000; }
::highlight(ds-find-now) { background-color: #ff9f1c; color: #000; }
::highlight(ds-spell) { text-decoration: underline wavy #e5484d; text-decoration-skip-ink: none; text-underline-offset: 2px; }
::highlight(ds-grammar) { text-decoration: underline wavy #2f6fed; text-decoration-skip-ink: none; text-underline-offset: 2px; }
::highlight(ds-hard) { background-color: #fde9a8; }
::highlight(ds-vhard) { background-color: #f7c1c1; }
::highlight(ds-passive) { background-color: #cfe3ff; }
::highlight(ds-adverb) { text-decoration: underline 2px #8b5cf6; text-underline-offset: 2px; }
::highlight(ds-style) { text-decoration: underline dotted #8b5cf6; text-decoration-thickness: 2px; text-underline-offset: 2px; }

/* A picked picture: a box and a corner to drag. */
.ds-img-box { position: absolute; z-index: 3; outline: 2px solid var(--accent); pointer-events: none; }
.ds-img-box[hidden] { display: none; }
.ds-img-edit { position: absolute; top: 6px; right: 6px; pointer-events: auto; }
.ds-img-grip { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; background: var(--accent); border: 2px solid #fff; cursor: nwse-resize; pointer-events: auto; touch-action: none; }

/* ---- Status bar ---- */
.ds-status { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 3px 10px; color: var(--muted); background: var(--surface); border-top: 1px solid var(--border); font-size: 0.75rem; }
.ds-pageno { flex: none; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.04em; }
.ds-words { flex: none; padding: 2px 6px; color: var(--muted); background: none; border: 0; font: inherit; cursor: pointer; }
.ds-msg { flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-msg[data-kind="warn"] { color: var(--gold); }
.ds-msg[data-kind="ok"] { color: #7ee0c3; }
.ds-zoombox { display: flex; align-items: center; gap: 2px; flex: none; }
.ds-zoom { min-width: 52px; padding: 2px 4px; color: var(--text); background: none; border: 0; font: 0.72rem var(--mono); cursor: pointer; }

/* ---- Dialogs ---- */
.ds-form { display: flex; flex-direction: column; gap: 12px; }
.ds-form-row { display: flex; flex-wrap: wrap; gap: 10px; }
.ds-form-row > .st-field { flex: 1 1 110px; }
.ds-field { display: flex; flex-direction: column; gap: 4px; }
.ds-field .input, .ds-field .st-select { width: 100%; }
.ds-hf-box { min-height: 40px; padding: 8px 10px; color: #000; background: #fff; border: 2px solid var(--edge); font: 11pt/1.3 Calibri, Carlito, Arial, sans-serif; outline: none; }
.ds-hf-box:focus { border-color: var(--accent); }
.ds-symbols { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
.ds-symbol { aspect-ratio: 1; padding: 0; color: var(--text); background: var(--surface-2); border: 1px solid var(--edge); font-size: 1.2rem; cursor: pointer; }
.ds-export-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.ds-ext { font: 600 0.72rem var(--mono); }

/* ---- Gold under the pointer ---- */
@media (hover: hover) {
  :is(.ds-ol-item, .ds-rtab, .ds-rtab.is-active, .ds-words, .ds-zoom, .ds-tp-cell, .ds-symbol, .ds-issue-head):hover { color: var(--bg); background: var(--gold); }
  .ds-issue-head:hover small { color: var(--bg); }
  .ds-color:hover { box-shadow: 0 0 0 2px var(--gold); transform: scale(1.12); }
  .ds-tb.is-open, .ds-caret-btn.is-open { color: var(--bg); background: var(--gold); }
}
:is(.ds-ol-item, .ds-rtab, .ds-tp-cell, .ds-symbol):active { color: var(--bg); background: var(--gold); }

/* ---- Printing: only the pages, closed up ---- */
.ds-print { display: none; }
@media print {
  body.ds-printing > :not(.ds-print) { display: none !important; }
  body.ds-printing .ds-print { display: block; }
  .ds-print-page { position: relative; overflow: hidden; break-after: page; }
  .ds-print-page:last-child { break-after: auto; }
  body.ds-printing .ds-sheet { box-shadow: none; outline: 0; }
  body.ds-printing .ds-flow hr.page-break, body.ds-printing .ds-img-box, body.ds-printing span[data-field] { background: none; }
  body.ds-printing .ds-flow hr.page-break::after { content: none; }
}
html:has(body.ds-printing) { zoom: 1 !important; }
body.ds-exporting .ds-flow span[data-field] { background: none; }

/* ---- Phones ---- */
@media (max-width: 760px) {
  .ds-work { grid-template-rows: auto auto minmax(0, 1fr) auto auto; }
  .ds-work.is-pdf { grid-template-rows: auto minmax(0, 1fr); }
  .ds-work.is-pdf .vs-tabs { display: none; }
  .ds-body, .ds-work.no-left .ds-body, .ds-work.no-right .ds-body, .ds-work.no-left.no-right .ds-body { position: static; display: block; }
  .ds-stage { height: 100%; padding: 12px 8px 32px; }
  .ds-work #ds-left, .ds-work #ds-right { display: none; }
  .ds-work[data-sheet="lib"] #ds-left, .ds-work[data-sheet="insp"] #ds-right { position: absolute; left: 0; right: 0; top: 80px; bottom: 56px; z-index: 20; display: flex; flex-direction: column; border: 0; border-top: 1px solid var(--border); box-shadow: 0 -16px 36px rgba(0, 0, 0, 0.55); }
  .ds-work[data-sheet="lib"] #ds-left { display: block; padding-right: 48px; }
  .ds-work[data-sheet] .vs-sheet-close { top: 88px; }
  .ds-status .ds-msg { display: none; }
  .ds-zoombox #ds-zoom-in, .ds-zoombox #ds-zoom-out { display: none; }
  .ds-style { width: 104px; }
  .ds-font { width: 120px; }
}

/* The Words and Text panels' parts. */
.ds-sub { margin: 16px 0 8px; font-family: var(--mono); font-size: 0.7rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.ds-wrap { flex-wrap: wrap; }
.ds-limits dd.is-over { color: #ff8a8a; }
.ds-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.ds-key { padding: 1px 6px; color: #000; font-size: 0.72rem; }
.ds-key.is-hard { background: #fde9a8; }
.ds-key.is-vhard { background: #f7c1c1; }
.ds-key.is-passive { background: #cfe3ff; }
.ds-key.is-adverb { color: var(--text); text-decoration: underline 2px #8b5cf6; }
.ds-fancy { display: grid; gap: 4px; margin-top: 8px; }
.ds-fancy-btn { display: grid; gap: 2px; padding: 6px 8px; text-align: left; color: var(--text); background: var(--surface-2); border: 2px solid var(--edge); cursor: pointer; overflow: hidden; }
.ds-fancy-btn small { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.ds-fancy-btn span { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) { .ds-fancy-btn:hover { border-color: var(--gold); } }
.ds-lorem-n { width: 70px; }
.ds-lorem-unit { flex: 1; }
/* A table linked to a Sheets tab (docs-studio/tables.js): its edge says so. */
.ds-flow :is(table, img)[data-wtb-link] { outline: 2px dashed var(--gold, #e8b44f); outline-offset: 3px; }
