/* Tiho styling: the same colors as the icon, the emails and the desktop
   app. The dark theme is not a separate skin but the same color roles,
   reassigned once in one place.

   The main layout rule here: buttons do not stick to each other and do not
   tumble under the text. Document actions live in the bar on top, rare ones
   under "more", and the rest of the screen belongs to the sheet. */

:root {
  --brand: #0F6E66;
  --brand-dark: #0B5751;
  --ink: #1A1815;
  --quiet: #6F6B65;
  --paper: #FFFFFF;
  --surface: #F7F7F5;
  --field: #FFFFFF;
  --line: #E6E4E0;
  /* Delete red. Two, not one: "--danger" is the fill under white
     letters, and it must stay dark in both themes; "--danger-ink"
     is the red letters themselves on the page background, and in the dark
     theme they must lighten, otherwise on "--field" they drop to contrast 3.3. */
  --danger: #C0392B;
  --danger-ink: #C0392B;
  /* A letter ON the brand fill. A role, not a color, for the same reason as
     "--danger-ink": in the light theme the fill is dark and the letter on it
     white, while in the dark theme "--brand" lightens — and a white letter has
     nowhere lighter to go, giving 3.3 where 4.5 is needed. A dark letter on the
     light fill gives 5.37. */
  --on-brand: #FFFFFF;
  /* The lit star. One color for both themes on purpose: the star lives on seven
     different backgrounds — "--surface", "--field", "--paper" (which is white in
     the dark theme too) and on the picked row, tinted with "--brand" at 14% — and
     switching its color per theme would miss on one of them.
     The icon needs 3.0; measured on all seven, the worst is 3.23 (picked row
     in the light theme), the best 4.23. The former #E0A21A gave 2.09. */
  --star: #A3720A;
  --shadow: 0 1px 2px rgba(26, 24, 21, .06), 0 8px 24px rgba(26, 24, 21, .08);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #2E9D93;
    --brand-dark: #38B3A8;
    --ink: #ECE9E4;
    --quiet: #9A958D;
    --paper: #FFFFFF;
    --surface: #201F1D;
    --field: #2A2926;
    --line: #3A3835;
    /* Same fill — white letters on it have nowhere lighter to go; the letters are lighter. */
    --danger: #C0392B;
    --danger-ink: #F0705F;
    /* "--brand" is light here, and the letter on it must darken. Not
       "--ink": that one is light itself in the dark theme. */
    --on-brand: #1A1815;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

/* The mail preview sets the theme itself (?theme=dark): the same dark colour roles. */
:root[data-theme="dark"] {
    --brand: #2E9D93;
    --brand-dark: #38B3A8;
    --ink: #ECE9E4;
    --quiet: #9A958D;
    --paper: #FFFFFF;
    --surface: #201F1D;
    --field: #2A2926;
    --line: #3A3835;
    /* Same fill — white letters on it have nowhere lighter to go; the letters are lighter. */
    --danger: #C0392B;
    --danger-ink: #F0705F;
    /* "--brand" is light here, and the letter on it must darken. Not
       "--ink": that one is light itself in the dark theme. */
    --on-brand: #1A1815;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

/* `hidden` means "hidden", and no `display` from our rules has the
   right to override it. Otherwise the find bar and the menu, declared
   flex, would always be open. */
[hidden] { display: none !important; }

html, body { height: 100%; }

/* Our own font: the same one the apps on the Mac, iPhone and Android
   are set in. Without it the web would look like a stranger app with the same name. */
@font-face {
  font-family: 'Ziewnull Sans';
  src: url('font/ZiewnullSans-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Ziewnull Sans';
  src: url('font/ZiewnullSans-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Ziewnull Sans Display';
  src: url('font/ZiewnullSansDisplay-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 15px/1.5 'Ziewnull Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI',
        Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ——— Common ——— */

.button, label.button, button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 36px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
}

.button:hover { background: var(--brand-dark); }
.button:active { transform: translateY(1px); }
.button.small { min-height: 30px; padding: 5px 12px; font-size: 13px; }

.button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.button.ghost:hover { background: var(--line); }

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.icon:hover { background: var(--line); }
.icon svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}

.quiet { color: var(--quiet); font-size: 13px; }

input[type=search], input[type=text], select {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
input:focus-visible, select:focus-visible, .button:focus-visible,
.icon:focus-visible, [contenteditable]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ——— Welcome screen ——— */

.welcome { padding-bottom: 72px; }

/* The same width and the same margins as tiho.one pages (tiho.css: --wrap). */
.welcome .wrap {
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  padding: 0 24px;
}

/* The site header — as on tiho.one: name on the left, siblings and language on the right. */
.site-top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-top .wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 60px;
  flex-wrap: wrap;
}
.brand {
  font-family: 'Ziewnull Sans Display', 'Ziewnull Sans', -apple-system, sans-serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}
.brand span { color: var(--brand); }
.site-top nav { display: flex; gap: 18px; margin-left: auto; }
.site-top nav a { color: var(--quiet); text-decoration: none; font-size: 15px; }
.site-top nav a:hover { color: var(--ink); }
.site-top nav a[aria-current='page'] { color: var(--ink); font-weight: 600; }
.site-top select {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
}
/* Phone: name, siblings and language — on one line, with 16-pixel margins. */
@media (max-width: 480px) {
  .welcome .wrap { padding-left: 16px; padding-right: 16px; }
  .site-top .wrap { gap: 12px; flex-wrap: nowrap; min-height: 54px; }
  .brand { font-size: 17px; }
  .site-top nav { gap: 12px; }
  .site-top nav a { font-size: 14px; }
  .site-top select { font-size: 13px; padding: 4px 4px; max-width: 96px; }
}
.site-top nav a:focus-visible, .brand:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}

/* The first screen — at the scale of the tiho.one home page: a large heading, a calm
   intro paragraph, and straight to business — the place for a file. */
/* Two-class specificity on purpose: the block also has "wrap", and ".welcome .wrap"
   sets all the padding and would otherwise zero the top offset. */
.welcome .hero { padding-top: clamp(40px, 8vw, 88px); }

.welcome h1 {
  font-family: 'Ziewnull Sans Display', 'Ziewnull Sans', -apple-system, sans-serif;
  margin: 0 0 16px;
  font-size: clamp(34px, 6vw, 54px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 700;
  text-wrap: balance;
  max-width: 16ch;
}

.lead {
  margin: 0 0 36px;
  color: var(--quiet);
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.55;
  max-width: 60ch;
}

.drop {
  display: block;
  padding: clamp(36px, 6vw, 56px) 24px;
  border: 1.5px dashed var(--line);
  border-radius: 18px;
  background: var(--field);
  box-shadow: var(--shadow);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease;
}
.drop:hover, .drop.over { border-color: var(--brand); }
.drop .button { font-size: 16px; padding: 12px 24px; }
@media (prefers-reduced-motion: reduce) { .drop { transition: none; } }
.drop input { display: none; }
.drop .quiet { margin: 12px 0 0; }

.cloud {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0 0;
}

.files { list-style: none; margin: 16px 0 0; padding: 0; }
.files li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  margin-bottom: 8px;
  cursor: pointer;
}
.files li:hover { border-color: var(--brand); }

.say { margin: 20px 0 0; font-size: 14px; color: var(--ink); }

/* ——— Editing screen ——— */

.editor {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--field);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  /* Above zoom and the sidebar (6): the "more" menu lives inside the bar and
     opens over them, not under them. */
  z-index: 8;
}

.bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.name { display: flex; flex-direction: column; min-width: 0; }
.name strong {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Document actions: equal height, equal gaps, wrapping without
   sticking — on a narrow screen the bar folds rather than clumps. */
.bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.more { position: relative; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  padding: 6px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.menu button, .menu label {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.menu button:hover, .menu label:hover { background: var(--surface); }
.menu .sep-line { display: block; height: 1px; margin: 6px 4px; background: var(--line); }

.find {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: var(--field);
  border-bottom: 1px solid var(--line);
}
.find input[type=search] { width: 220px; }
.find input[type=text] { width: 200px; }
.find .count { min-width: 64px; }
.case { display: inline-flex; align-items: center; gap: 6px; }
.find .icon:last-child { margin-left: auto; }

.canvas {
  flex: 1;
  overflow: auto;
  padding: 28px 16px 40px;
}

/* The text toolbar. */
.tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 6px 16px;
  background: var(--field);
  border-bottom: 1px solid var(--line);
}
.tools .sep {
  width: 1px;
  height: 22px;
  margin: 0 6px;
  background: var(--line);
}
.tools .icon { width: 32px; height: 32px; font-size: 15px; }
.tools .icon.on { background: var(--brand); color: #fff; }
.pick.narrow { min-width: 118px; }
.pick.tiny { min-width: 56px; }

/* Color: the browser's ordinary color picker, hidden under a letter. */
.colour { position: relative; overflow: hidden; }
.colour input[type=color] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; padding: 0; cursor: pointer;
}
.colour .letter {
  font-weight: 700; font-size: 15px;
  border-bottom: 3px solid currentColor; line-height: 1.1;
  pointer-events: none;
}
/* All caps, small caps, sub/superscript, highlighter and shading: a toggle button
   and next to it a narrow color swatch for the highlighter and shading. */
.icon .sc { font-variant: small-caps; font-size: 15px; }
.icon sup, .icon sub { font-size: 9px; }
.icon .marker { background: #FFFF00; color: #1A1815; padding: 0 3px; border-radius: 3px; font-size: 13px; }
.icon .fill { background: #E7E6E6; color: #1A1815; padding: 0 3px; border-radius: 3px; font-size: 13px; }
.tools .icon.swatch { width: 18px; }
.swatch .letter { border-bottom: 0; font-size: 11px; }

.pick {
  min-height: 32px;
  min-width: 140px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

/* Zoom: a pill in the corner over the sheet. A full-width bar
   took a centimeter of screen from the document for the sake of two characters. */
.zoom {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--quiet);
  z-index: 6;
}
.zoom .icon { width: 28px; height: 28px; }

/* What is said pops up and goes away: no reason to keep a bar for it. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(560px, 90vw);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 20;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  background: var(--field);
  color: var(--ink);
  box-shadow: var(--shadow);
  max-width: 520px;
}
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h2 { margin: 0 0 12px; font-size: 17px; }
dialog ul { margin: 0 0 16px; padding-left: 20px; font-size: 14px; }

/* The question dialog: one column of fields, label above the field, trouble below
   the fields, buttons on the right, the main one last. On a phone the dialog is full width. */
dialog.ask {
  width: min(420px, calc(100vw - 32px));
  padding: 28px 28px 22px;
  border-radius: 18px;
}
dialog.ask[open] { animation: ask-in .16s ease-out; }
@keyframes ask-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { dialog.ask[open] { animation: none; } }
dialog.ask::backdrop { background: rgba(20, 18, 15, .45); backdrop-filter: blur(2px); }
dialog.ask h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.01em; }
.ask-lead { margin: 0 0 18px; color: var(--quiet); font-size: 14px; line-height: 1.45; }
#askfields { display: grid; gap: 14px; margin-top: 16px; }
.ask-field { display: grid; gap: 6px; }
.ask-field > span { font-size: 13px; font-weight: 600; color: var(--ink); }
.ask-field input[type=email], .ask-field input[type=password],
.ask-field input[type=text], .ask-field input[type=number] {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.ask-field input:hover { border-color: var(--quiet); }
.ask-field input:focus-visible {
  outline: none;
  border-color: var(--brand);
  background: var(--field);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
.ask-field input[readonly] { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
/* Code from the email: six digits — large and spaced out, to check by eye. */
.ask-field input.code {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .4em;
  text-align: center;
  padding-left: calc(12px + .4em);
}
.ask-field .hint { font-size: 12px; font-weight: 400; color: var(--quiet); }
.ask-check { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.ask-check input { width: 18px; height: 18px; accent-color: var(--brand); }
.ask-trouble {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: color-mix(in srgb, #C0392B 10%, var(--field));
  border: 1px solid color-mix(in srgb, #C0392B 35%, var(--line));
  color: var(--ink);
  font-size: 13.5px;
}
.ask-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.ask-actions .button { min-width: 108px; justify-content: center; }
.ask-actions .button[disabled] { opacity: .6; cursor: progress; }
.ask-side {
  margin: 18px -28px -22px;
  padding: 14px 28px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  border-radius: 0 0 18px 18px;
  font-size: 13.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}
.ask-side button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  cursor: pointer;
}
.ask-side button:hover { text-decoration: underline; }
@media (max-width: 480px) {
  .ask-actions { flex-direction: column-reverse; }
  .ask-actions .button { width: 100%; }
}

/* ——— Sheet ——— */

.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  transform-origin: top center;
}

/* Document paper. Paper specifically, not the book's table: they used to share one
   class, and `overflow: hidden`, with which the paper clips its
   lines, made the table its own scrolling box — which is why neither the column
   header nor the frozen rows in a book stuck anywhere. */
div.sheet {
  position: relative;
  background: var(--paper);
  color: #1A1815;
  border-radius: 2px;
  box-shadow: var(--shadow);
  overflow: hidden;
  /* Paper is edited like paper: the caret can be placed anywhere. */
  caret-color: var(--brand);
}
div.sheet:focus { outline: none; }

.tabseg, .rowhead { position: absolute; top: 0; white-space: pre; }
/* Dot leader: the dots must stand at exactly the pitch they were measured at — no
   kerning, no ligatures and no letter spacing. */
.leader { position: absolute; top: 0; white-space: pre;
          font-kerning: none; font-variant-ligatures: none; letter-spacing: 0; }
.row {
  position: absolute;
  white-space: pre;
  /* THE BROWSER'S OWN GRID — AWAY. "white-space: pre" tells it to honor the tab
     character, and the browser honors it on its own grid (eight spaces), not
     by "w:tab@w:pos". With zero the character stays alive in the tree — search,
     the caret and edit assembly still read it — but it carries no
     width, and only we assign the span its place. */
  tab-size: 0;
  font-family: Carlito, Calibri, 'Helvetica Neue', Arial, sans-serif;
  color: #1A1815;
  /* OUR OWN LEADING, NOT INHERITED. Without this ".row" took the 1.5
     multiplier from "body", and half the leading pushed the letter a third of the
     font size below where the layout places it. The line position is computed by
     "rowTop" in "app.js", and it computes it for "normal": with that there is
     no half-leading, and the baseline sits exactly at the browser's ascent
     from the top of the box. */
  line-height: normal;
}

/* Picture placeholder: while the picture itself is not drawn, you can see that it is
   there and how much room it takes — more honest than emptiness and far more honest
   than the "OBJ" box the browser draws in place of the object character. */
img.picture {
  display: inline-block;
  vertical-align: middle;
  border: 0;
  background: none;
  /* Stretched to its box, as Word draws it: the box is the size the file
     gives, and a picture is laid into it whatever its own proportions. With
     "contain" a one-pixel grey picture stretched into a bar across a ticket
     came out a small grey square. */
  object-fit: fill;
}

span.picture {
  display: inline-block;
  vertical-align: middle;
  border: 1px dashed #C9C5BE;
  border-radius: 2px;
  background: repeating-linear-gradient(45deg, #F4F2EF, #F4F2EF 4px,
                                        #EDEAE5 4px, #EDEAE5 8px);
}

/* Header/footer — part of the sheet but not part of the text: it is quieter and is not
   edited along with it. */
.row.side { color: #55514C; }
/* Footnote: the same lines as the text, only at the bottom of the page and under a rule. */
.row.note { color: #3A3733; }
.note-rule {
  position: absolute;
  width: 33%;
  border-top: 0.75pt solid #B7B2AB;
}

/* Found text is highlighted on the sheet itself — right where it lies. */
mark.hit { background: #FFE58A; color: inherit; padding: 0; }
mark.hit.now { background: var(--brand); color: #fff; }

@font-face {
  font-family: Carlito;
  src: url('font/Carlito-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Carlito;
  src: url('font/Carlito-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

@media (max-width: 700px) {
  .bar { flex-wrap: wrap; }
  .find input[type=search], .find input[type=text] { width: 100%; }
  .welcome { padding: 32px 16px 48px; }
}

/* ——— Spreadsheet ———
   A book is a grid, not a sheet of paper: it has its own edges, its own headers and its
   own cell line. Everything here stands on the same color set as
   the rest of the app. */

.sheets { display: flex; flex-direction: column; height: 100%; }

.cellbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--field);
  border-bottom: 1px solid var(--line);
}
.cellbar .where {
  min-width: 72px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--quiet);
}
.cellbar input {
  flex: 1;
  min-width: 0;
  font-family: Carlito, Calibri, 'Helvetica Neue', Arial, sans-serif;
}

.grid {
  flex: 1;
  overflow: auto;
  background: var(--paper);
}

table.sheet {
  border-collapse: collapse;
  table-layout: fixed;
  /* Numbers and words in cells — in the same letters as in Excel: the book
     is shown in its own font, not ours. The row and column headers
     below are ours, and in our font too. */
  font: 13px/1.3 Carlito, Calibri, 'Helvetica Neue', Arial, sans-serif;
  color: #1A1815;
}
table.sheet th, table.sheet td {
  border: 1px solid #D8D5D0;
  padding: 1px 4px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
  vertical-align: bottom;
}
/* Row and column headers stay put while the grid moves under them:
   without this, by the fifth hundred rows you can no longer tell where you are. */
table.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}
table.sheet th {
  font-family: 'Ziewnull Sans', sans-serif;
  background: var(--surface);
  color: var(--quiet);
  font-weight: 500;
  font-size: 12px;
  text-align: center;
}
table.sheet tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 44px;
  min-width: 44px;
}
table.sheet thead th:first-child { left: 0; z-index: 3; }
/* The book's frozen rows and columns: what Excel keeps in place
   while scrolling — table headers. The engine computes their position, and they are held
   here. The background is opaque: content must not slide through them. */
table.sheet td.frozen, table.sheet tr.frozen td, table.sheet tr.frozen th {
  position: sticky;
  background: var(--paper, #FFFFFF);
  z-index: 1;
}
/* A frozen row's number stays put both sideways and downward: otherwise
   the left column under the header shows the numbers of rows that scrolled away. */
table.sheet tr.frozen th { background: var(--surface); z-index: 3; }
table.sheet tr.frozen td.frozen { z-index: 2; }
table.sheet td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.sheet td.on {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
table.sheet td.bad { color: #B3261E; }
/* The selection handle: it is dragged to fill down, up, sideways. Inside
   the cell, not on its edge: the cell has "overflow: hidden". */
table.sheet td.corner:not(.frozen) { position: relative; }
table.sheet td .fill-corner {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 7px;
  height: 7px;
  background: var(--brand);
  cursor: crosshair;
  touch-action: none;
  z-index: 3;
}
table.sheet td.dragging { outline: 1px dashed var(--brand); outline-offset: -2px; }

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--field);
  border-top: 1px solid var(--line);
  overflow-x: auto;
}
.tabs button {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.tabs button:hover { background: var(--surface); }
.tabs button.on { background: var(--brand); color: #fff; }

/* Password box: a locked file asks for the word instead of refusing. */
.pw-dialog {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
  z-index: 50;
}

.pw-sheet {
  background: #fff;
  color: #111;
  border-radius: 12px;
  padding: 20px 22px;
  min-width: 280px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: grid;
  gap: 10px;
}

.pw-word { font-weight: 600; margin: 0; }
.pw-name { margin: 0; opacity: 0.7; font-size: 0.9em; word-break: break-all; }

.pw-field {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 8px;
}

.pw-buttons { display: flex; gap: 8px; justify-content: flex-end; }
.pw-buttons button { font: inherit; padding: 7px 14px; border-radius: 8px; }
.pw-yes { background: #2b6cb0; color: #fff; border: none; }
.pw-wrong { background: transparent; border: 1px solid rgba(0, 0, 0, 0.25); }

/* A cell filled by another's spill: it is not its own, and it cannot be edited. */
#grid td.spill { color: #6b6b6b; font-style: italic; }

/* Sheet rules: the boxes of bordered paragraphs. A thin strip laid
   under the lines — it cannot be drawn as a border, its thickness is its own for each
   side and comes from the file. */
.sheet .rule {
  position: absolute;
  pointer-events: none;
}

/* Paragraph shading: a rectangle under the lines. It lies below the rules and below the
   letters — the same way Word lays it. */
.sheet .fill {
  position: absolute;
  pointer-events: none;
}

/* ——— Cloud screen ———
   The document manager: sections on the left, the file list on the right. Colors,
   padding and rounding are the same as in the rest of the app; nothing of its own is
   introduced here except the delete red, and that is taken from the question dialog.

   Names with "fl-" are the ones files.js uses to address nodes. */

.fl-screen {
  display: flex;
  height: 100%;
  background: var(--surface);
  color: var(--ink);
}

/* Sections. On a wide screen — a column on the left, on a narrow one — a bar
   on top: giving a quarter of a phone to five words is not acceptable. */
.fl-sections {
  width: 232px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px;
  border-right: 1px solid var(--line);
  overflow: auto;
}
.fl-sections h2 {
  margin: 4px 8px 12px;
  font-family: 'Ziewnull Sans Display', 'Ziewnull Sans', -apple-system, sans-serif;
  font-size: 15px;
}
.fl-section {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.fl-section:hover { background: var(--line); }
/* The fill is the same brand one as the buttons': two different greens side by side
   would be worse than low contrast. The letter changes, and it changes by role. */
.fl-section.on-mark { background: var(--brand); color: var(--on-brand); }
.fl-section svg, .fl-icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fl-icon { width: 20px; height: 20px; stroke: var(--brand); stroke-width: 1.5; }

/* "min-height: 0" is not decoration. On a narrow screen the sections and the right
   half are stacked, and the right half by default ("auto")
   may grow TALLER than the screen: then the whole page scrolls, and
   the file list inside does not scroll at all — its "overflow: auto" is not at fault,
   it was given room to spare. Zero locks it to the screen height, and the excess
   goes into the file list's own scrolling, as intended. */
.fl-right { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.fl-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--field);
  border-bottom: 1px solid var(--line);
}

/* Folder breadcrumb. The last part — where we are — is not a button: there is
   nowhere to go by pressing "here". */
.fl-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
  margin-right: auto;
  font-size: 15px;
}
.fl-breadcrumb button {
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.fl-breadcrumb button:hover { background: var(--line); }
.fl-breadcrumb b {
  padding: 4px 6px;
  font-family: 'Ziewnull Sans Display', 'Ziewnull Sans', -apple-system, sans-serif;
}
.fl-breadcrumb .fl-slash { color: var(--quiet); }

.fl-find { width: 220px; }
.fl-header select { min-width: 0; }

/* Action bar. It keeps its height even when empty: otherwise the file list jumps up on
   every deselection. */
.fl-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 50px;
  padding: 8px 16px;
  background: var(--field);
  border-bottom: 1px solid var(--line);
}
.fl-actions .button[disabled] { opacity: .45; cursor: default; }
.fl-actions .fl-count { margin-left: auto; color: var(--quiet); font-size: 13px; }

.fl-error {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: color-mix(in srgb, #C0392B 10%, var(--field));
  border: 1px solid color-mix(in srgb, #C0392B 35%, var(--line));
  color: var(--ink);
  font-size: 13.5px;
}

.fl-body { flex: 1; overflow: auto; padding: 8px 16px 24px; }

/* ——— File list as a table ——— */

.fl-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.fl-table th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--quiet);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.fl-table th.fl-pressing { cursor: pointer; }
.fl-table th.fl-pressing:hover { color: var(--ink); }
.fl-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
/* The name column takes everything left and shortens the name with an ellipsis.
   Without this a long name widens the table, and the file list slides sideways together
   with the whole page — and the page must not slide sideways anywhere. */
.fl-table td:first-child, .fl-table th:first-child { width: 100%; max-width: 1px; }
.fl-table tbody tr:hover { background: var(--field); }
.fl-table tbody tr.fl-taken { background: color-mix(in srgb, var(--brand) 14%, transparent); }
.fl-table tbody tr:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.fl-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fl-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-quiet { color: var(--quiet); font-size: 13px; white-space: nowrap; }

.fl-star {
  padding: 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--quiet);
  line-height: 1;
  cursor: pointer;
}
.fl-star svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round;
}
.fl-star.lit { color: var(--star); }
.fl-star.lit svg { fill: currentColor; }
.fl-star:hover { color: var(--star); }
.fl-star:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ——— File list as tiles ——— */

.fl-tiles {
  display: grid;
  gap: 14px;
  padding-top: 12px;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
}
.fl-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  /* Field, not paper: "--paper" stays white in the dark theme too — it is the
     color of the document sheet, and a tile on it would glow as a white blot with
     light letters as well. */
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: default;
}
.fl-tile:hover { border-color: var(--quiet); }
.fl-tile .fl-name { font-weight: 600; }
.fl-tile.fl-taken {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, var(--field));
}
.fl-tile:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Empty state: always with a word on what to do next. */
.fl-empty { max-width: 420px; margin: 64px auto; text-align: center; color: var(--quiet); }
.fl-empty .button + .button { margin-left: 8px; }
/* For a guest — only an invitation to sign in: sections, header and actions are hidden
   (by the hidden attribute, and the class is needed so that display: flex does not override it). */
.fl-guest .fl-sections, .fl-guest .fl-header, .fl-guest .fl-actions { display: none; }
.fl-guest .fl-empty { margin-top: 20vh; }
.fl-empty h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-family: 'Ziewnull Sans Display', 'Ziewnull Sans', -apple-system, sans-serif;
  font-size: 16px;
}
.fl-empty p { margin: 0 0 16px; font-size: 14px; line-height: 1.5; }

/* ——— Details sidebar ——— */

.fl-details {
  width: 292px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--field);
  border-left: 1px solid var(--line);
  overflow: auto;
}
.fl-details-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fl-details-header h2 {
  margin: 0;
  font-family: 'Ziewnull Sans Display', 'Ziewnull Sans', -apple-system, sans-serif;
  font-size: 15px;
}
.fl-details-body { display: grid; gap: 10px; font-size: 14px; }
/* A details row: the label on top, quiet, the value under it. In two
   columns a long email address breaks the second into noodles. */
.fl-details-body div { display: grid; gap: 2px; }
.fl-details-body dt, .fl-details-body b {
  color: var(--quiet);
  font-size: 12px;
  font-weight: 600;
}
.fl-details-body span { overflow-wrap: anywhere; }
.fl-details-empty { margin: 0; color: var(--quiet); font-size: 13px; line-height: 1.5; }
.fl-space { margin-top: auto; display: grid; gap: 6px; }
/* A bar in two pieces: space used by documents and space used by the trash. "flex" —
   so that the second piece stands AFTER the first, not under it: they measure one and the
   same bar, and they must not lie on top of each other. */
.fl-space-bar {
  display: flex;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.fl-space-bar i { display: block; height: 100%; width: 0; background: var(--brand); }
.fl-space-bar i.full { background: #C0392B; }
/* Trash — in the same color as the quiet lines next to it: this is also
   used space, but used by what the person has already thrown away. A different color
   is needed so you can see how much comes back if it is emptied. */
.fl-space-bar i.fl-space-trash { background: var(--quiet); }

/* ——— Cloud screen dialogs ———
   They all carry the class "ask" and take its styling. Here is only what
   the question dialog did not have: a list, a folder tree and a red button. */

dialog.ask.wide { width: min(560px, calc(100vw - 32px)); }
.ask-field.narrow { width: 108px; }
/* The fields of these dialogs stand directly in the form, not in "askfields", and nobody
   gives them a gap between them: a field's label stuck to the list above it. */
dialog.ask > form > .ask-field,
dialog.ask > form > .ask-check { margin-top: 16px; }

.button.danger { background: #C0392B; border-color: transparent; color: #fff; }
.button.danger:hover { background: #A53124; }

/* Lists in dialogs: who has access, which links were issued, which versions
   there were. One look for all three. */
.fl-to, .fl-versions, #sharelinks {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  max-height: 300px;
  overflow: auto;
  font-size: 14px;
}
.fl-to li, .fl-versions li, #sharelinks li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.fl-to li:last-child, .fl-versions li:last-child,
#sharelinks li:last-child { border-bottom: 0; }
.fl-to span, .fl-versions span, #sharelinks span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The first item in a row stretches, buttons are pushed to the right. */
.fl-to li > :first-child, .fl-versions li > :first-child,
#sharelinks li > :first-child { flex: 1; }

/* Links in the access dialog: the dialog's footer, like "ask-side" at sign-in. */
.fl-links {
  margin: 18px -28px -22px;
  padding: 14px 28px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  border-radius: 0 0 18px 18px;
}
.fl-links h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--quiet); }
.fl-link-new { display: flex; align-items: flex-end; gap: 10px; margin-top: 12px; }

/* ——— Narrow screen ———
   Phone: the sections lie as a bar on top, the details sidebar leaves the
   row and pops up from the bottom over the file list, and of the columns only name and
   date remain — size and "shared by" are not what people read even on a wide screen. */
@media (max-width: 720px) {
  .fl-screen { flex-direction: column; }
  .fl-sections {
    width: auto;
    flex-direction: row;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .fl-sections h2 { display: none; }
  .fl-find { width: 100%; }
  .fl-header { padding: 10px 12px; }
  .fl-actions, .fl-body { padding-left: 12px; padding-right: 12px; }
  .fl-error { margin-left: 12px; margin-right: 12px; }
  /* The size and "shared by" columns are the second and fourth cells: their
     order is set in files.js, and if it changes there, it must
     change here too. */
  .fl-table th:nth-child(2), .fl-table td:nth-child(2),
  .fl-table th:nth-child(4), .fl-table td:nth-child(4) { display: none; }
  .fl-tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  /* The drawer pops up OVER the file list, and the bottom of the list goes under it:
     covered rows cannot be clicked (elementFromPoint returns the drawer) nor
     scrolled to — the file list body ends at the bottom edge of the
     window anyway. We give the list as much bottom padding as the drawer is tall. Its height
     only the browser knows: it depends on the language and on how many
     details fit — so files-access.js measures it and puts it here
     as the number "--drawer-height". Drawer closed or screen wide — the number is zero,
     and the padding stays as before. */
  .fl-body {
    padding-bottom: calc(24px + var(--drawer-height, 0px));
    /* The padding gives the list room to SLIDE OUT from under the drawer; this second
       one tells the browser that the bottom of the file list is occupied — otherwise "scrollIntoView"
       (the arrow keys move through rows with it, and it also shows a row after
       a search) will neatly place the row at the bottom edge of the window, that is,
       right under the drawer. */
    scroll-padding-bottom: var(--drawer-height, 0px);
  }

  .fl-details {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: auto;
    max-height: 62vh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    box-shadow: var(--shadow);
    z-index: 30;
  }
}

/* ——— Actions on documents ———
   The toast at the bottom of the screen, the question dialog, the right-click menu, renaming
   right in the row and the highlight while dragging. All of this is set up by
   files-actions.js; names with "fa-" are its.

   Earlier these rules lived inside it, as its own "<style>" in head, and so they
   always overrode the ones here — whatever stood here. Two traces of that are
   worth remembering so as not to bring them back: the background was "--paper",
   and it is white in the dark theme too (it is the color of the document SHEET, not a surface),
   and "--ink" on it gave contrast 1.21; trouble was written in red letters on a
   red background — 2.36. Here, in both places, the roles "--field" and
   "--ink" are used, and only the background glows red. */

/* The toast at the bottom: shows that a long action is in progress, and offers "undo"
   right after a move or delete. Not a "toast": that one has no buttons. */
.fa-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(560px, 92vw);
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink);
  font-size: 14px;
  box-shadow: var(--shadow);
}
.fa-toast-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* "Undo" in the toast. The color is "--brand-dark", not "--brand", and this is not
   a whim: in the dark theme "--brand" (#2E9D93) on the toast background
   ("--field", #2A2926) gives 4.41 against the 4.5 norm for small text. Back
   then the toast text and menu items were measured, but the only CLICKABLE thing in
   the bar was not, and it was also the only one that fell short. "--brand-dark" in
   the dark theme is lighter than "--brand" (the roles are swapped there: #38B3A8) and gives
   5.67; in the light theme it is #0B5751 on white — 8.41.
   The hover highlight is not "--line": on it the same "--brand-dark" drops
   to 4.55, just barely. Our own mix of brand into the background holds 4.83. */
.fa-toast-action {
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--brand-dark);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.fa-toast-action:hover { background: color-mix(in srgb, var(--brand) 12%, var(--field)); }
.fa-toast-close {
  padding: 2px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--quiet);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.fa-toast-close:hover { background: var(--line); color: var(--ink); }

/* The actions' question dialog: folder name, new name, confirmation, folder tree.
   Its own, not "ask": that dialog is built by app.js and its fields differ. Frame and
   colors are shared with "dialog". */
.fa-dialog {
  max-width: min(460px, 92vw);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--field);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.fa-dialog::backdrop { background: rgba(20, 18, 15, .45); }
.fa-form { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.fa-title {
  margin: 0;
  font-family: 'Ziewnull Sans Display', 'Ziewnull Sans', -apple-system, sans-serif;
  font-size: 16px;
}
.fa-lead {
  margin: 0;
  color: var(--quiet);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fa-inner { display: flex; flex-direction: column; gap: 10px; }
.fa-input {
  width: 100%;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.fa-input:focus-visible {
  outline: none;
  border-color: var(--brand);
  background: var(--field);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
/* Refusal in the dialog — in the same look as "ask-trouble" and "fl-error". */
.fa-error {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 10%, var(--field));
  color: var(--ink);
  font-size: 13px;
}
/* The line under the question: whether the deleted item will come back or not. It reads quietly —
   what is scary here is the action itself, not the color of the letters. */
.fa-severe { margin: 0; color: var(--quiet); font-size: 13px; }
.fa-buttons { display: flex; justify-content: flex-end; gap: 8px; }
/* The red button — the same as "button danger". */
.fa-danger, button.fa-danger {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
}
.fa-danger:hover, button.fa-danger:hover { background: #A53124; }
.fa-cancel { align-self: flex-start; }
.fa-for-all {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--quiet);
  font-size: 13px;
}

/* The folder tree in the "move to" dialog. Its own scrolling: there can be a hundred
   folders, and the dialog must not outgrow the screen. */
.fa-tree {
  display: flex;
  flex-direction: column;
  max-height: 46vh;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: auto;
}
.fa-branch {
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.fa-branch:hover:not(:disabled) { background: var(--line); }
/* The same pair as ".fl-section.on-mark", and the same trouble: white on light
   "--brand" gives 3.3. The row is new too — fixed the same way. */
.fa-branch.on-mark { background: var(--brand); color: var(--on-brand); }
.fa-branch:disabled { color: var(--quiet); cursor: default; }
.fa-branch:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* The right-click menu. The same look as the "menu" at the top of the screen. */
.fa-menu {
  position: fixed;
  z-index: 50;
  min-width: 196px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.fa-item {
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.fa-item:hover, .fa-item:focus { background: var(--surface); outline: none; }
/* Dangerous items in the menu — in red letters, not a red tile: a tile in a
   list reads as "already selected". */
.fa-item.fa-danger {
  background: transparent;
  border: 0;
  color: var(--danger-ink);
}
.fa-item.fa-danger:hover { background: color-mix(in srgb, var(--danger) 14%, var(--field)); }

/* Renaming right in a file-list row. */
.fa-edit {
  width: 100%;
  max-width: 340px;
  min-width: 0;
  padding: 2px 6px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

/* Dragging: the folder under the pointer and the screen ready to accept a file from disk.
   The frame appears only where the drop will really land — see "onFileList". */
.fa-target {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--brand) 16%, transparent) !important;
}
.fa-shower { outline: 2px dashed var(--brand); outline-offset: -6px; }

/* ——— Menu longer than the screen ———
   "More" now has three dozen items: on a laptop the bottom ones went past the edge,
   and there was nothing to reach them with. */
.menu { max-height: calc(100vh - 80px); overflow-y: auto; }

/* ——— Sidebar: headings and the list of revisions ———
   It hangs on the right over the sheet rather than pushing it: the sheet is laid out in points, and
   the canvas width does not matter to it, while a relayout for the sake of the sidebar is superfluous. */
.pane {
  position: fixed;
  top: 112px;
  right: 16px;
  bottom: 64px;
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 6;
}
.pane[hidden] { display: none; }
.pane-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pane-top h2 { margin: 0; font-size: 15px; }
.pane ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: grid; gap: 2px; }
.pane li { display: flex; align-items: flex-start; gap: 6px; }
.pane li > button.go {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.pane li > button.go:hover { background: var(--surface); }
.pane li.level-2 > button.go { padding-left: 20px; }
.pane li.level-3 > button.go { padding-left: 32px; }
.pane .who { display: block; font-size: 12px; color: var(--quiet, #6b6b6b); }
.pane .ins { color: #1a7f37; }
.pane .del { color: #b42318; text-decoration: line-through; }
.pane li .icon { flex: none; }

@media (max-width: 720px) {
  .pane {
    top: auto;
    left: 0; right: 0; bottom: 0;
    width: auto;
    max-height: 55vh;
    border-radius: 16px 16px 0 0;
  }
}

/* Printing: the page prints the PDF in an inset, never itself. */
.seal-frame { position: fixed; width: 0; height: 0; border: 0; visibility: hidden; }

/* Column width handle: a strip at the right edge of the header. */
table.sheet thead th .handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 4;
}
table.sheet thead th .handle:hover { background: var(--brand); opacity: .35; }
/* Row height handle: a strip at the bottom edge of the row number. */
table.sheet tbody th .row-handle {
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 100%;
  height: 7px;
  cursor: row-resize;
  touch-action: none;
  z-index: 4;
}
table.sheet tbody th .row-handle:hover { background: var(--brand); opacity: .35; }

/* Recent on the welcome screen and paper in the dialog. */
.recent { margin-top: 24px; }
.recent h2 { font-size: 16px; margin: 0 0 4px; }
.pageinfo { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 12px 0; }
.pageinfo dt { color: var(--quiet, #6b6b6b); }
.pageinfo dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.recent li .open { all: unset; cursor: pointer; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.recent li .open:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.tabs button.tabadd { min-width: 32px; font-weight: 600; color: var(--muted, var(--ink)); }

/* The selected picture and the corner by which its size is dragged. */
img.picture.chosen { outline: 2px solid var(--brand); outline-offset: 1px; }
.pichandle { position: absolute; width: 10px; height: 10px; background: var(--brand);
  border: 1px solid #fff; border-radius: 2px; cursor: nwse-resize; z-index: 5; touch-action: none; }

/* Special characters — as a grid; keyboard help — the same rows as "Paper". */
.symbolgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 4px; margin: 12px 0; max-width: 420px; }
.symbolgrid button { font: inherit; font-size: 18px; height: 36px; border: 1px solid var(--line, #ddd); border-radius: 6px; background: var(--surface, #fff); color: var(--ink); cursor: pointer; }
.symbolgrid button:hover, .symbolgrid button:focus-visible { border-color: var(--brand); }
.shortcuts dd { text-align: left; }
.shortcuts kbd { font: 12px ui-monospace, monospace; white-space: nowrap; }

/* Format painter picked up: the cursor over the sheet is "copy". */
#page.brush { cursor: copy; }

/* A cell's drop-down list: an arrow at the selected cell and the items under it. */
table.sheet td .arrow {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--brand); font-size: 12px;
  padding: 0 2px; cursor: pointer; z-index: 3;
}
table.sheet td .arrow::before { content: '▾'; }
.choice {
  position: absolute; z-index: 50; display: flex; flex-direction: column;
  max-height: 240px; overflow-y: auto; background: var(--paper, #fff);
  border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.18);
  padding: 4px 0;
}
.choice button {
  text-align: left; border: 0; background: transparent; padding: 6px 12px;
  font: inherit; color: inherit; cursor: pointer;
}
.choice button:hover, .choice button:focus { background: var(--field); outline: none; }

/* Book charts over the grid: an SVG frame on their own cells. */
#grid { position: relative; }
/* Pictures, shapes and text boxes: under the charts, over the cells; clicks
   go through them to the cell. */
.drawings { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 4; pointer-events: none; }
.drawing { position: absolute; }
.drawing svg, .drawing img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.drawing svg { overflow: visible; }
.drawing.blind { background: #F3F4F6; outline: 1px solid #C8CCD2; }
.drawing .words {
  position: absolute; inset: 4.8px 9.6px; display: flex; flex-direction: column; overflow: hidden;
  font-family: Carlito, Calibri, 'Helvetica Neue', Arial, sans-serif; line-height: 1.2;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.drawing .words.sketched { inset: 0; white-space: pre; overflow: hidden; line-height: 1; font-family: Arial, 'Liberation Sans', sans-serif; }
/* A cell with a comment: the red corner, as in Excel. */
table.sheet td.noted { position: relative; }
table.sheet td.noted::after {
  content: ''; position: absolute; top: 0; right: 0;
  border-left: 6px solid transparent; border-top: 6px solid #E03030;
}
.charts { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 5; }
.chart {
  position: absolute; background: #fff; cursor: move; touch-action: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.chart svg { display: block; pointer-events: none; }
.chart.picked, .chart:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.chart .remove-btn {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 11px;
  border: 1px solid var(--line, #ccc); background: var(--paper, #fff); color: var(--ink, #333);
  font-size: 14px; line-height: 1; cursor: pointer; display: none; padding: 0;
}
.chart .remove-btn::before { content: '×'; }
.chart.picked .remove-btn, .chart:hover .remove-btn { display: block; }

/* Comment threads: a reply goes under the start with an indent, a resolved one is dimmed. */
.pane li.reply { margin-left: 18px; }
.pane li.resolved .go { opacity: .6; }

/* Suggesting mode: the sheet in a frame of the revision color — you can see that typing goes
   as suggestions, not as editing. */
body.suggest-on #page .sheet { outline: 2px solid var(--ins, #1a7f37); outline-offset: -2px; }

/* "Together": a bar of people under the header, others' carets as colored marks. */
.togetherbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 16px; border-bottom: 1px solid var(--line); background: var(--paper, #fff); }
.togetherpeople { display: flex; gap: 6px; flex-wrap: wrap; }
.togetherperson { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 13px; background: color-mix(in srgb, var(--person-color) 14%, transparent); color: var(--ink); }
.togetherperson::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--person-color); }
.remote-caret { position: absolute; width: 0; border-left: 2px solid var(--person-color); pointer-events: none; z-index: 30; }
.remote-caret::after { content: attr(data-who-name); position: absolute; left: -2px; top: -16px; font: 11px/14px system-ui, sans-serif; color: #fff; background: var(--person-color); padding: 0 4px; border-radius: 3px 3px 3px 0; white-space: nowrap; }
body.viewing #page .sheet { cursor: default; }

/* "Together" in a book: the cell where someone else stands — in their color with their name. */
#grid td.foreign { position: relative; outline: 2px solid var(--person-color); outline-offset: -2px; }
#grid td.foreign::after { content: attr(data-who-name); position: absolute; right: 0; top: -14px; z-index: 5; font: 10px/13px system-ui, sans-serif; color: #fff; background: var(--person-color); padding: 0 4px; border-radius: 3px 3px 0 3px; white-space: nowrap; pointer-events: none; }

/* The attachment preview in mail (?from=app): the sheet only, without the welcome, the bar,
   the editing strip, search and the side pane — the name and "Download" come from mail. */
html.app-preview .welcome,
html.app-preview .bar,
html.app-preview #tools,
html.app-preview #find,
html.app-preview #pane,
html.app-preview #zoom,
html.app-preview .toast { display: none !important; }

/* Mail takes the document back (?from=app&return=1): a bar at the bottom with
   "Sign" and "Send as a reply". Fixed, so it is at hand on a long document; the
   sheet gets room under it so its last line is not hidden. */
.mailreturn[hidden] { display: none; }
.mailreturn {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.mailreturn-said { margin: 0 0 8px; min-height: 1.2em; font-size: 13px; color: var(--quiet); text-align: center; }
.mailreturn-said:empty { display: none; }
.mailreturn-row { display: flex; gap: 10px; align-items: center; max-width: 560px; margin: 0 auto; }
.mailreturn-row .button { flex: 1; min-height: 44px; }
.mailreturn-undo { width: 44px; height: 44px; flex: none; }
.mailreturn-row [hidden] { display: none; }
html.app-return #canvas { padding-bottom: 96px; }

/* The signature pad: the canvas is white paper in either theme — the signature
   lands on paper. "touch-action: none" keeps the finger drawing, not scrolling. */
.signpad { width: min(560px, calc(100vw - 32px)); }
.signcanvas {
  display: block; width: 100%; height: 200px; margin: 12px 0 4px;
  background: #fff; border: 1px dashed var(--line); border-radius: var(--radius);
  touch-action: none; cursor: crosshair;
}
