/* Wordroom: a writing room laid out like a word processor.
   Title bar and ribbon across the top, the page on a desk beneath, a status
   bar along the bottom. The app fills the viewport; only the desk scrolls.

   Presentation is driven by custom properties (--sheet-*). The main page
   reads them from :root; each comparison page and look sample carries its
   own, so every page shares one rendering path. */

/* Seven typefaces, all self-hosted so the page makes no third-party request,
   and all under the SIL Open Font Licence 1.1, with no reserved font names.
   Each licence travels with its file in fonts/, and a test checks that it
   does. A browser downloads a face only when something on the page uses it. */
@font-face {
  font-family: 'Newsreader Variable';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(fonts/newsreader-latin-opsz-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans Variable';
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Libre Baskerville';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/libre-baskerville-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/eb-garamond-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/atkinson-hyperlegible-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Courier Prime';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/courier-prime-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  /* Calibrated Ideas house palette */
  --color-paper: #f5f2ec;
  --color-paper-soft: #ece7dd;
  --color-ink: #1b1d1e;
  --color-ink-soft: #3a3d3f;
  --color-muted: #6b6c66;
  --color-line: #d8d2c4;
  --color-navy: #02265d;
  --color-gold: #cda37d;
  --color-night: #16181a;
  --color-night-soft: #202326;

  --bar: var(--color-navy);           /* title bar */
  --bar-ink: var(--color-paper);
  --ribbon: var(--color-paper);
  --desk: #e3ddd1;                    /* the surface the page sits on */
  --page: #fbf9f5;                    /* the sheet itself */
  --field: #ffffff;                   /* inputs in the ribbon */
  --ink: var(--color-ink);
  --ink-soft: var(--color-ink-soft);
  --ink-faint: var(--color-muted);
  --rule: var(--color-line);
  --accent: var(--color-navy);
  --accent-ink: var(--color-paper);
  --highlight: var(--color-gold);
  --focus: var(--color-navy);
  --shadow: 0 1px 2px rgba(27, 29, 30, 0.08), 0 10px 30px rgba(27, 29, 30, 0.12);

  --radius: 0.5rem;
  --radius-sm: 0.375rem;
  --tracking-tight: -0.015em;
  --tracking-wide: 0.12em;

  /* The sheet, in real units. JavaScript sets these from the chosen paper
     size; these defaults are A5. At 100% zoom a millimetre on screen is a CSS
     millimetre, so the type sits on the page in the proportion it will print. */
  --paper-w: 148mm;
  --paper-h: 210mm;
  --m-top: 20mm;
  --m-right: 18mm;
  --m-bottom: 22mm;
  --m-left: 18mm;
  --break: color-mix(in srgb, var(--color-gold) 70%, transparent);

  /* Presentation defaults; JavaScript overrides these. */
  --sheet-family: var(--family-literary);
  --sheet-line: 1.62;
  --sheet-measure: 32ch;
  --sheet-size: 1.125rem;
  --sheet-para-space: 0.9em;
  --sheet-para-indent: 0;

  --family-literary: "Newsreader Variable", Georgia, "Times New Roman", serif;
  --family-warm: "Libre Baskerville", Baskerville, "Baskerville Old Face", Georgia, serif;
  --family-book: "EB Garamond", Garamond, "Adobe Garamond Pro", Georgia, serif;
  --family-sans: "IBM Plex Sans Variable", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --family-legible: "Atkinson Hyperlegible", Verdana, system-ui, sans-serif;
  --family-mono: "Courier Prime", "Courier New", Courier, monospace;
  --family-code: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --font-display: var(--family-literary);
  --ui: var(--family-sans);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bar: var(--color-night-soft);
    --bar-ink: var(--color-paper);
    --ribbon: #1b1d20;
    --desk: #111315;
    --page: var(--color-night-soft);
    --field: var(--color-night);
    --ink: var(--color-paper);
    --ink-soft: #c8c4ba;
    --ink-faint: #9a9c94;
    --rule: #34373a;
    --accent: var(--color-gold);
    --accent-ink: var(--color-night);
    --focus: var(--color-gold);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

/* An author `display` rule beats the user agent's [hidden] { display: none },
   so anything laid out with flex or grid would stay visible when hidden. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 0.875rem/1.45 var(--ui);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- the frame ---------- */

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
}

/* ---------- title bar ---------- */

.topbar {
  display: grid;
  /* The tabs are never clipped: their column is at least as wide as they
     are. The title sits dead centre when there is room, and gives way when
     there is not. */
  grid-template-columns: minmax(max-content, 1fr) minmax(6rem, 20rem) minmax(max-content, 1fr);
  align-items: stretch;
  gap: 1rem;
  min-height: 2.75rem;
  padding: 0 0.5rem 0 1rem;
  background: var(--bar);
  color: var(--bar-ink);
}
.topbar :focus-visible { outline-color: var(--highlight); }

.topbar-left { display: flex; align-items: stretch; gap: 1rem; min-width: 0; }
.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 0.35rem; }

/* Offered only when the app is embedded in another page. */
.bar-btn {
  padding: 0.28rem 0.7rem;
  border: 1px solid rgba(245, 242, 236, 0.4);
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.bar-btn:hover { background: rgba(245, 242, 236, 0.12); border-color: var(--highlight); }
/* In a narrow frame, such as a blog column, the name gives way so every tab
   and the Full window button still fit on one row. */
@media (max-width: 50rem) { .framed .brand { display: none; } }

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  white-space: nowrap;
}
/* The one flourish: the short gold rule from the Calibrated Ideas masthead. */
.brand::before {
  content: "";
  width: 1rem;
  height: 2px;
  border-radius: 2px;
  background: var(--highlight);
}

.tabs {
  display: flex;
  gap: 0.1rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  position: relative;
  padding: 0 0.85rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  opacity: 0.75;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { opacity: 1; }
.tab[aria-selected="true"] { opacity: 1; }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0.6rem;
  right: 0.6rem;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--highlight);
}
.tab:focus-visible { outline-offset: -4px; }

.doc-title {
  display: flex;
  align-items: center;
  min-width: 0;
}
.doc-title input {
  width: 100%;
  padding: 0.28rem 0.6rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font-family: var(--font-display);
  font-size: 0.975rem;
  text-align: center;
}
.doc-title input::placeholder { color: inherit; opacity: 0.55; }
.doc-title input:hover { border-color: rgba(245, 242, 236, 0.28); }
.doc-title input:focus { background: rgba(245, 242, 236, 0.1); border-color: rgba(245, 242, 236, 0.4); outline: none; }

.icon-btn {
  align-self: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(245, 242, 236, 0.12); }

/* ---------- ribbon ---------- */

.ribbon {
  background: var(--ribbon);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(27, 29, 30, 0.03);
}

.panel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  row-gap: 0.4rem;
  padding: 0.5rem 0.5rem 0.3rem;
}

.group {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.3rem;
  padding: 0 0.9rem;
  border-right: 1px solid var(--rule);
}
.group:last-child { border-right: 0; }
.group-wide { max-width: 30rem; }

.group-body {
  display: flex;
  flex: 1;
  align-items: flex-end;
  gap: 0.5rem;
  min-height: 2.6rem;
}
.group-text { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0.25rem; }

.group-label {
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.64rem;
  letter-spacing: var(--tracking-wide);
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.field { display: flex; flex-direction: column; gap: 0.15rem; }
.field > span { color: var(--ink-soft); font-size: 0.72rem; font-weight: 500; }
.field select {
  min-width: 7.75rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.8125rem;
}

.rbtn {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 120ms ease, opacity 120ms ease;
}
.rbtn:hover { border-color: var(--accent); }
.rbtn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rbtn.primary:hover { opacity: 0.9; }
.rbtn:disabled { opacity: 0.42; cursor: default; border-color: var(--rule); }

.segmented {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.segmented label { position: relative; }
.segmented input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segmented span {
  display: block;
  padding: 0.4rem 0.8rem;
  border-right: 1px solid var(--rule);
  background: var(--field);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -3px; }

.meta { margin: 0; color: var(--ink-soft); font-size: 0.8125rem; }
.meta strong { color: var(--ink); }
.ribbon-note { margin: 0; color: var(--ink-soft); font-size: 0.76rem; line-height: 1.4; max-width: 44ch; }
.ribbon-note-narrow { max-width: 26ch; }

.check { display: flex; align-items: center; gap: 0.45rem; font-size: 0.8125rem; font-weight: 500; cursor: pointer; }
.check input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent); }

/* ---------- the desk and the page ---------- */

.canvas {
  overflow: auto;
  background: var(--desk);
  overscroll-behavior: contain;
}

.desk {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100%;
  padding: clamp(1rem, 3vw, 2.5rem) clamp(0.5rem, 2vw, 2rem) 4rem;
}

/* The sheet: the chosen paper size and its margins, scaled by zoom. Type,
   margins and paper all scale together, so the text wraps in exactly the same
   places at any zoom. On a narrow window the zoom is reduced to fit rather
   than squeezing the sheet, which would change where the lines break. */
.canvas { --zoom: 1; }

.page {
  flex: none;
  width: calc(var(--paper-w) * var(--zoom));
  min-height: calc(var(--paper-h) * var(--zoom));
  padding: calc(var(--m-top) * var(--zoom)) calc(var(--m-right) * var(--zoom))
           calc(var(--m-bottom) * var(--zoom)) calc(var(--m-left) * var(--zoom));
  border-radius: 2px;
  background: var(--page);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-family: var(--sheet-family);
  font-size: calc(var(--sheet-size) * var(--zoom));
  line-height: var(--sheet-line);
  text-align: left;              /* never justified */
  hyphens: none;
  font-variant-numeric: tabular-nums lining-nums;
}

.page-title {
  margin: 0 0 1.2em;
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Writing happens on the page itself. The textarea wears the page's type,
   so what you see while typing is the presentation you have chosen. */
.composer {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  /* A faint gold rule where each sheet would end. The pitch is a whole number
     of lines, worked out in JavaScript from the paper, margins, size and line
     spacing, so the rule falls between the last line of one page and the
     first of the next. */
  background-image: repeating-linear-gradient(to bottom,
    transparent 0, transparent calc(var(--break-pitch, 100000px) - 1px),
    var(--break) calc(var(--break-pitch, 100000px) - 1px), var(--break) var(--break-pitch, 100000px));
  background-attachment: local;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  tab-size: 4;
  caret-color: var(--accent);
}
.composer::placeholder { color: var(--ink-faint); font-style: italic; }
.page:has(.composer:focus-visible) { outline: 2px solid color-mix(in srgb, var(--focus) 30%, transparent); outline-offset: 4px; }

/* Rendered text: Read view, comparison pages, look samples, print. */
/* Read view: the writing flowed onto separate sheets of the chosen size. */
.read-pages { display: flex; flex-direction: column; align-items: center; gap: calc(1.75rem * var(--zoom)); }
/* In Edit view the sheets are laid out out of sight, only to count them. */
.read-pages.measuring { position: absolute; left: -100000px; top: 0; visibility: hidden; pointer-events: none; }
.sheet-slot { display: flex; flex-direction: column; align-items: center; gap: 0.45rem; }
.page-sheet { height: calc(var(--paper-h) * var(--zoom)); min-height: 0; }
.sheet-fill { height: calc((var(--paper-h) - var(--m-top) - var(--m-bottom)) * var(--zoom)); overflow: hidden; }
.sheet-cap { margin: 0; color: var(--ink-faint); font-size: 0.72rem; letter-spacing: 0.04em; }
.sheet-body p.cont { text-indent: 0; }

.sheet-body .verbatim {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  tab-size: 4;
}
.sheet-body p {
  margin: 0 0 var(--sheet-para-space);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  text-indent: var(--sheet-para-indent);
}
.sheet-body p:first-child { text-indent: 0; }
.sheet-body p:last-child { margin-bottom: 0; }
.sheet-empty { color: var(--ink-faint); font-style: italic; }

.desk-note {
  max-width: 34rem;
  margin: 3rem auto;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  text-align: center;
}
.desk-note p { margin: 0 0 0.9rem; }
.desk-foot { margin: 2rem 0 0; color: var(--ink-faint); font-size: 0.78rem; }

/* ---------- compare: two pages on the desk ---------- */

/* Each page keeps its own width. If two do not fit side by side they wrap,
   so neither is ever squeezed just to keep them level. */
.pair {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(1rem, 2.5vw, 2.5rem);
  width: 100%;
}
.version { display: flex; flex-direction: column; align-items: center; max-width: 100%; margin: 0; }
.version figcaption { margin: 0 0 0.7rem; color: var(--ink-soft); font-size: 0.8125rem; text-align: center; }
.version figcaption strong { color: var(--ink); }
.tag {
  color: var(--ink-faint);
  font-size: 0.64rem;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}
.sub { color: var(--ink-faint); }
.sub::before { content: "\00b7\00a0"; }
.pair { --zoom: 1; }

/* ---------- looks: eight pages on the desk ---------- */

.looks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 1.75rem 1.5rem;
  width: 100%;
  max-width: 110rem;
}
.look-card { display: flex; flex-direction: column; gap: 0.6rem; max-width: 100%; }
.look-head { display: flex; flex-direction: column; gap: 0.1rem; font-family: var(--ui); }
.look-name { margin: 0; font-family: var(--font-display); font-size: 1rem; font-weight: 600; letter-spacing: var(--tracking-tight); }
.look-note { margin: 0; color: var(--ink-faint); font-size: 0.76rem; max-width: 40ch; }
.looks { --zoom: 0.62; }
.look-page { min-height: 0; }
.look-card.is-current .look-page { outline: 2px solid var(--highlight); outline-offset: 4px; }
/* Clipped by height only; the text itself is never cut. */
.look-sample {
  max-height: 12rem;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 78%, transparent 100%);
}
.look-card .rbtn { align-self: flex-start; }

/* ---------- export ---------- */

.page-code {
  --zoom: 1;
  width: min(100%, 50rem);
  min-height: 0;
  padding: 2.5rem 3rem;
  font-family: var(--family-code);
  font-size: 0.8125rem;
  line-height: 1.6;
}
.export-out { margin: 0; overflow-x: auto; font: inherit; white-space: pre; tab-size: 2; }

/* ---------- status bar ---------- */

.statusbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 1.9rem;
  padding: 0.2rem 0.5rem 0.2rem 1rem;
  border-top: 1px solid var(--rule);
  background: var(--ribbon);
  color: var(--ink-soft);
  font-size: 0.75rem;
  white-space: nowrap;
}
.sb-hint { color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; }
.sb-status { flex: 1; min-width: 0; overflow: hidden; color: var(--accent); text-overflow: ellipsis; }
.sb-views { display: inline-flex; gap: 0.15rem; }
.sb-btn {
  padding: 0.15rem 0.5rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.sb-btn:hover { background: var(--desk); }
.sb-btn[aria-pressed="true"] { background: var(--desk); color: var(--ink); font-weight: 600; }
.statusbar > * { flex-shrink: 0; }
.statusbar > .sb-status, .statusbar > .sb-hint { flex-shrink: 1; }
.sb-zoom { display: inline-flex; align-items: center; gap: 0.1rem; }
.sb-zoom .sb-btn { min-width: 1.6rem; }
#zoomReset { min-width: 3.2rem; font-variant-numeric: tabular-nums; }

/* ---------- dialogs ---------- */

dialog {
  max-width: min(34rem, calc(100vw - 2rem));
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--page);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}
dialog::backdrop { background: rgba(22, 24, 26, 0.4); }
dialog h2 { margin: 0 0 0.6rem; font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; letter-spacing: var(--tracking-tight); }
dialog p, dialog li { color: var(--ink-soft); font-size: 0.875rem; }
dialog ul { margin: 0; padding-left: 1.1rem; }
dialog li { margin-bottom: 0.4rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.1rem; }

/* ---------- smaller screens ---------- */

@media (max-width: 52rem) {
  .sb-hint { display: none; }
  /* The longest face name would push the ribbon onto a third row in a blog
     column. The closed control may clip; the open list shows names in full. */
  #ctlStyle { max-width: 12.5rem; }
}

@media (max-width: 42rem) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; row-gap: 0; padding-right: 0.25rem; }
  .topbar-left { grid-column: 1 / -1; order: 2; }
  .topbar-left .brand { display: none; }
  .doc-title { justify-content: flex-start; }
  .doc-title input { text-align: left; padding-left: 0.2rem; }
  .tabs { min-height: 2.4rem; margin-left: -0.6rem; }
  .sb-zoom { display: none; }
}

@media (max-width: 36rem) {
  .panel-row { flex-wrap: nowrap; overflow-x: auto; }
  .group { flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- print: the writing only ---------- */

@media print {
  :root { --page: #fff; --ink: #000; --ink-soft: #333; }
  .canvas { --zoom: 1 !important; }
  html, body { height: auto; overflow: visible; background: #fff; }
  .app { display: block; height: auto; }
  .topbar, .ribbon, .statusbar, #deskCompare, #deskLooks, #deskExport, #readPages, dialog, .composer { display: none !important; }
  .canvas { overflow: visible; background: none; }
  .desk { display: block; min-height: 0; padding: 0; }
  #deskWrite, #page, #printBody { display: block !important; }
  /* The paper size and margins come from an @page rule JavaScript keeps in
     step with the Page size control, so the printer lays the text out on the
     same sheet the screen simulates. */
  .page {
    width: auto;
    min-height: 0;
    padding: 0;
    background: none;
    box-shadow: none;
  }
  .page-title { color: #333; }
}
