/* Things that float: dialogs and sheets, the palette, the drafts switcher, settings, the tally,
   the bar over a selection, the "/" menu, colors. All white paper, 13px corners, one shadow. */

/* ---------- Dialogs: grow from their source, fade back the same way ---------- */
dialog {
  padding: 0; border: 0; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px);
  background: var(--paper); color: var(--ink); border-radius: var(--r); box-shadow: var(--shadow-lg);
  font: 400 13px/1.4 var(--font-ui); overscroll-behavior: contain;
  transition: opacity 120ms ease, transform 240ms var(--spring);
}
dialog::backdrop { background: var(--scrim); animation: fade-in 140ms ease; transition: opacity 110ms ease; }
dialog.is-entering { opacity: 0; transform: scale(.97); transition: none; }
dialog.is-leaving { opacity: 0; transform: scale(.985); transition-duration: 100ms; transition-timing-function: ease-in; pointer-events: none; }
dialog.is-leaving::backdrop { opacity: 0; }
dialog.is-anchored { margin: 0; position: fixed; }
dialog.is-anchored::backdrop { background: transparent; }
.grabber { display: none; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 12px 8px 18px; }
.dlg-head h2 { font: 650 17px/1.2 var(--font-ui); letter-spacing: -.022em; outline: none; }

/* In the narrow layout every dialog is a bottom sheet with a grabber. */
dialog.as-sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 640px;
  max-height: calc(100dvh - var(--safe-t) - var(--s7)); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding-bottom: var(--safe-b); transition: none; opacity: 1;
  bottom: var(--kb, 0px);
}
dialog.as-sheet.is-leaving { opacity: 1; }
dialog.as-sheet::backdrop { opacity: var(--sheet-k, 1); animation: fade-in 260ms ease; }
dialog.as-sheet .grabber { display: block; position: absolute; z-index: 3; top: 0; left: 50%; width: 80px; height: 22px; margin-left: -40px; touch-action: none; cursor: grab; }
dialog.as-sheet .grabber::before { content: ""; position: absolute; top: 6px; left: 22px; width: 36px; height: 5px; border-radius: 3px; background: var(--rule-2); }
dialog.as-sheet .sheet-drag { touch-action: none; }
@media (prefers-reduced-transparency: reduce) { dialog::backdrop { background: rgba(24, 28, 36, .35); } }

/* ---------- The command palette ---------- */
.palette { width: min(580px, calc(100vw - 32px)); margin-top: 13vh; max-height: min(560px, 72vh); overflow: hidden; }
.palette[open] { display: flex; flex-direction: column; }
.pal-search { position: relative; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--rule); }
.pal-search .icon { color: var(--ink-3); }
.pal-search input { height: 52px; padding: 0; border: 0; border-radius: 0; background: transparent; font: 400 17px/1 var(--font-ui); letter-spacing: -.022em; box-shadow: none !important; }
.pal-back { margin-left: -8px; }
.pal-crumb { flex: none; color: var(--ink-2); font: 600 13px/1 var(--font-ui); }
.pal-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; scroll-padding: 6px; }
.pal-group { padding: 10px 10px 4px; color: var(--ink-2); font: 600 12px/1.2 var(--font-ui); }
.pal-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 36px; padding: 6px 10px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); text-align: left; font: 400 13.5px/1.25 var(--font-ui); letter-spacing: -.01em;
}
.pal-row .icon { color: var(--ink-2); }
.pal-row.is-on { background: var(--canvas); box-shadow: inset 0 0 0 1px var(--rule); }
.pal-row.is-on .icon { color: var(--ink); }
.pal-row:active { background: var(--press); }
.pal-row[aria-disabled="true"] { color: var(--ink-3); }
.pal-label { flex: 1; min-width: 0; }
.pal-note { color: var(--ink-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.pal-state { color: var(--ink-2); font-size: 12px; }
.pal-state.is-on { color: var(--blue); font-weight: 600; }
.pal-check { color: var(--blue); }
.pal-desc { display: block; color: var(--ink-2); font-size: 12px; margin-top: 2px; letter-spacing: 0; }
.pal-empty { padding: 21px 12px; color: var(--ink-2); text-align: center; }
.pal-foot { flex: none; display: flex; align-items: center; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--rule); color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.pal-foot .pal-count { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-foot .pal-keys { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.palette.as-sheet { margin-top: 0; max-height: 82dvh; height: 82dvh; }
.palette.as-sheet .pal-search { padding-top: 14px; border-bottom: 0; }
.palette.as-sheet .pal-search input { height: 44px; padding: 0 12px; border-radius: var(--r-sm); background: var(--canvas); font-size: 16px; }
.palette.as-sheet .pal-search > .icon { display: none; }
.palette.as-sheet .pal-row { min-height: 46px; font-size: 15px; }
.palette.as-sheet .pal-row .keys, .palette.as-sheet .pal-foot .pal-keys { display: none; }

/* ---------- Drafts: the sidebar ----------
   Out of sight until the pointer rests on the left edge (it comes over the page as a card and
   leaves with the pointer), or kept open from the title: docked beside the page when there is
   room, over it when there isn't. A sheet on a phone. */
:root { --dw: 292px; }
.drafts-edge { position: fixed; z-index: 39; top: calc(var(--spine-h) + var(--safe-t)); bottom: 0; left: 0; width: 22px; }
html[data-drafts]:not([data-drafts=""]) .drafts-edge { display: none; }
@media (max-width: 1079px), (hover: none) { .drafts-edge { display: none; } }
.drafts {
  position: fixed; z-index: 40; left: 8px; top: calc(var(--spine-h) + var(--safe-t) + 4px); bottom: 8px; width: var(--dw);
  display: flex; flex-direction: column; background: var(--paper); color: var(--ink);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  font: 400 13px/1.4 var(--font-ui);
  /* --dx is driven by the spring in drafts.js: it follows the pointer's intent and can turn round mid-flight. */
  transform: translate3d(var(--dx, calc(-100% - 24px)), 0, 0); visibility: hidden; will-change: transform; contain: layout paint;
}
html[data-drafts="peek"] .drafts, html[data-drafts="held"] .drafts, html[data-drafts="pinned"] .drafts, .drafts.is-moving { visibility: visible; }
/* Docked: flush with the edge, part of the desk and not a card over it. */
html[data-drafts="pinned"] .drafts { left: 0; top: 0; bottom: 0; background: var(--canvas); border-radius: 0; box-shadow: none; }
@media (max-width: 1079px) { .drafts { display: none; } }

@media (prefers-contrast: more) { .drafts { box-shadow: inset -1px 0 0 var(--ink-3); } }

.dr { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dr-head { flex: none; display: flex; align-items: center; gap: 2px; height: calc(var(--spine-h) + 2px); padding: 0 8px 0 16px; }
.dr-name { flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 13px/1.2 var(--font-ui); letter-spacing: -.006em; color: var(--ink); }
.dr-tool {
  position: relative; display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--r-xs);
  background: transparent; color: var(--ink-3); transition: background-color 120ms ease, color 120ms ease, transform var(--press-t) ease-out;
}
.dr-tool:hover { background: var(--hover); color: var(--ink); }
.dr-tool:active { transform: scale(.92); }
.dr-tool .icon { width: 15px; height: 15px; }
.dr-pin[aria-pressed="true"] { color: var(--ink); }
/* The sync button: tiny, and it says what it knows when you rest on it. */
.dr-sync .icon { width: 13px; height: 13px; }
.dr-sync[data-state="syncing"] .icon, .dr-sync[data-state="other-tab"] .icon { animation: turn 900ms linear infinite; color: var(--blue); }
.dr-sync[data-state="error"] { color: var(--red); }
.dr-sync[data-state="offline"] { color: var(--warn); }
@keyframes turn { to { transform: rotate(360deg); } }

.dr-find { flex: none; position: relative; margin: 0 10px 8px; }
.dr-find .icon { position: absolute; left: 9px; top: 8px; width: 14px; height: 14px; color: var(--ink-3); pointer-events: none; }
.dr-find-input.dr-find-input { width: 100%; height: 30px; padding: 0 8px 0 30px; border: 0; border-radius: var(--r-sm); background: var(--hover); font-size: 13px; }

/* The view: group, sort, filter. Quiet words until you want them. */
.dr-bar { flex: none; display: flex; align-items: center; gap: 1px; padding: 0 8px 4px 10px; }
.dr-view {
  position: relative; display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 7px; border: 0; border-radius: var(--r-xs);
  background: transparent; color: var(--ink-2); font: 500 12px/1 var(--font-ui); white-space: nowrap; max-width: 104px;
  transition: background-color 120ms ease, color 120ms ease;
}
.dr-view > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.dr-view:hover { background: var(--hover); color: var(--ink); }
.dr-view-icon { margin-left: auto; width: 26px; padding: 0; justify-content: center; color: var(--ink-3); }
.dr-view-icon .icon { width: 14px; height: 14px; }
.dr-dir { display: inline-grid; transition: transform 260ms var(--spring); }
.dr-dir.is-asc { transform: rotate(180deg); }
.dr-dir .icon { width: 11px; height: 11px; stroke-width: 1.8; }
.dr-n { display: inline-grid; place-items: center; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; background: var(--blue); color: var(--paper); font: 650 10px/1 var(--font-ui); font-variant-numeric: tabular-nums; }
.dr-filters { flex: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 16px 8px; }

.dr-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; list-style: none; margin: 0; padding: 0 6px 16px; scrollbar-width: thin; }
.dr-group-row { margin-top: 13px; }
.dr-group-row:first-child { margin-top: 4px; }
.dr-group {
  display: flex; align-items: center; gap: 6px; width: 100%; height: 26px; padding: 0 10px; border: 0; border-radius: var(--r-xs);
  background: transparent; color: var(--ink-2); font: 600 12px/1 var(--font-ui); text-align: left;
}
.dr-group .icon { width: 12px; height: 12px; color: var(--ink-3); opacity: 0; transition: opacity 120ms ease, transform 260ms var(--spring); }
.dr-group:hover .icon, .dr-group:focus-visible .icon, .dr-group.is-folded .icon { opacity: 1; }
.dr-group.is-folded .icon { transform: rotate(-90deg); }
.dr-group:hover { color: var(--ink); }

.dr-row { position: relative; padding: 5px 4px 6px 10px; border-radius: var(--r-sm); cursor: pointer; transition: background-color 100ms ease; }
.dr-row:hover, .dr-row:focus-within { background: var(--hover); }
.dr-row:active { background: var(--press); }
.dr-row.is-current { background: color-mix(in srgb, var(--blue-mark) 9%, transparent); }
.dr-line { display: flex; align-items: center; min-height: 24px; }
.dr-open { flex: 0 1 auto; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.dr-open:focus-visible { outline-offset: 2px; border-radius: 3px; }
.dr-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 400 15px/1.5 var(--font-serif); }
.dr-row.is-current .dr-title { font-weight: 600; }
/* ↗ rides in the title's line: there on the open draft, on hover for the rest. */
.dr-ext, .dr-del {
  position: relative; flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: 2px; padding: 0; border: 0; border-radius: var(--r-xs);
  background: transparent; color: var(--ink-3); opacity: 0; transition: opacity 120ms ease, background-color 120ms ease, color 120ms ease;
}
.dr-ext .icon { width: 12px; height: 12px; stroke-width: 1.7; }
.dr-del .icon { width: 13px; height: 13px; }
.dr-del { margin-left: auto; }
.dr-row:hover :is(.dr-ext, .dr-del), .dr-row:focus-within :is(.dr-ext, .dr-del), .dr-row.is-current .dr-ext { opacity: 1; }
.dr-ext:hover { background: var(--hover); color: var(--blue); }
.dr-del:hover { background: var(--red-wash); color: var(--red); }
@media (hover: none) { .dr-ext, .dr-del { opacity: 1; } }
.dr-props { display: flex; flex-wrap: wrap; gap: 4px; margin: 1px 0 1px -1px; }
.dr-empty, .dr-foot { margin: 0; padding: 21px 14px; color: var(--ink-2); list-style: none; }
.dr-foot { flex: none; padding: 10px 16px calc(12px + var(--safe-b)); font-size: 12px; }

/* A property is a chip: a soft tint of its Notion color, and a button. */
.chip {
  --c: var(--ink-3);
  position: relative; display: inline-flex; align-items: center; gap: 5px; max-width: 100%; height: 20px; padding: 0 7px; border: 0; border-radius: 4px;
  background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink-2); font: 500 11.5px/1 var(--font-ui); letter-spacing: .005em; white-space: nowrap; cursor: pointer;
  transition: background-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease, transform var(--press-t) ease-out;
}
.chip-text { overflow: hidden; text-overflow: ellipsis; }
.chip.is-tint { background: color-mix(in srgb, var(--c) 15%, var(--paper)); color: color-mix(in srgb, var(--c) 62%, var(--ink)); }
.chip.t-status { border-radius: 10px; padding: 0 8px 0 7px; }
.chip-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.chip:hover { box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent); }
.chip:active { transform: scale(.95); }
.chip .icon { width: 10px; height: 10px; stroke-width: 2; }
/* An empty property is only an offer, and only when you're on the row. */
.chip.is-empty { background: transparent; color: var(--ink-3); font-weight: 400; opacity: 0; padding: 0 5px; }
.chip.is-empty::before { content: "+"; }
.dr-row:hover .chip.is-empty, .dr-row:focus-within .chip.is-empty, .dr-row.is-current .chip.is-empty { opacity: 1; }
.chip.is-empty:hover { background: var(--hover); color: var(--ink); box-shadow: none; }
@media (hover: none) { .chip.is-empty { opacity: 1; } }
.chip.is-filter { height: 22px; }

.drafts-sheet.as-sheet { max-height: 88dvh; height: 88dvh; width: 100%; }
.drafts-sheet[open] { display: flex; flex-direction: column; }
.drafts-sheet .dr-head { padding-top: 14px; height: 58px; }
.drafts-sheet .dr-name { font-size: 16px; }
.drafts-sheet .dr-pin { display: none; }
.drafts-sheet .dr-tool { width: 40px; height: 40px; }
.drafts-sheet .dr-find-input.dr-find-input { height: 40px; font-size: 16px; }
.drafts-sheet .dr-find .icon { top: 13px; }
.drafts-sheet .dr-view { height: 34px; font-size: 13px; }
.drafts-sheet .dr-row { padding: 9px 6px 10px 12px; }
.drafts-sheet .dr-title { font-size: 16px; }
.drafts-sheet .chip { height: 26px; font-size: 12.5px; }
.drafts-sheet .dr-ext, .drafts-sheet .dr-del { width: 36px; height: 36px; }

/* ---------- The tally (click the spend) ---------- */
.tally { width: 330px; padding: 16px 16px 14px; }
.tally-amt { display: grid; gap: 3px; }
.tally-spent { color: var(--red); font: 650 30px/1 var(--font-ui); letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.tally-of { color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tally-amt.is-over .tally-of { color: var(--red); }
.tally-meter { height: 3px; margin-top: 12px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.tally-meter span { display: block; height: 100%; border-radius: inherit; background: var(--red-mark); transition: width 400ms var(--spring); }
.tally-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 14px 0 0; }
.tally-stat dt { color: var(--ink-2); font-size: 11.5px; }
.tally-stat dd { margin: 2px 0 0; font: 600 15px/1.2 var(--font-ui); letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
.tally-budget { margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--rule); display: grid; gap: 8px; }
.tally-label { font-weight: 600; font-size: 12.5px; }
.presets { display: flex; flex-wrap: wrap; gap: 5px; }
.preset {
  height: 30px; padding: 0 10px; border: 1px solid var(--rule-2); border-radius: var(--r-sm); background: var(--paper); color: var(--ink);
  font: 600 12.5px/1 var(--font-ui); font-variant-numeric: tabular-nums; transition: background-color 120ms ease, transform var(--press-t) ease-out;
}
.preset:hover { background: var(--canvas); }
.preset:active { transform: scale(.96); }
.preset.is-on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.tally-custom { display: flex; gap: 6px; }
.tally-custom .money-input { width: 130px; height: 30px; }
.tally-review {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 40px; margin-top: 14px; padding: 0 12px;
  border: 0; border-radius: var(--r-sm); background: var(--blue-wash); color: var(--blue); font: 600 13px/1 var(--font-ui);
  transition: transform var(--press-t) ease-out;
}
.tally-review span:not(.keys) { flex: 1; text-align: left; }
.tally-review:active { transform: scale(.98); }
.tally.as-sheet { padding: 26px 21px calc(21px + var(--safe-b)); }
.tally.as-sheet .preset { height: 40px; padding: 0 13px; }
.tally.as-sheet .tally-review { height: 48px; }

/* ---------- Settings: sections on the left, the section on the right ---------- */
.settings { width: min(780px, calc(100vw - 32px)); height: min(620px, calc(100dvh - 64px)); overflow: hidden; }
.settings[open] { display: grid; grid-template-columns: 196px 1fr; }
.set-nav { display: flex; flex-direction: column; gap: 1px; padding: 14px 8px; background: var(--canvas); border-right: 1px solid var(--rule); overflow-y: auto; }
.set-nav h2 { padding: 2px 10px 12px; font: 650 17px/1.2 var(--font-ui); letter-spacing: -.022em; }
.set-nav-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink); text-align: left; font: 400 13px/1 var(--font-ui);
}
.set-nav-item .icon { color: var(--ink-2); }
.set-nav-item:hover { background: var(--hover); }
.set-nav-item[aria-current="true"] { background: var(--paper); box-shadow: var(--shadow-sm); font-weight: 600; }
.set-nav-item .chev-r { display: none; margin-left: auto; color: var(--ink-3); }
.set-version { margin-top: auto; padding: 10px; color: var(--ink-3); font-size: 11.5px; }
.set-main { position: relative; overflow-y: auto; padding: 18px 34px 34px; }
.set-close { position: absolute; top: 10px; right: 10px; }
.set-main-head { display: flex; align-items: center; gap: 4px; margin: 0 0 18px; }
.set-main-head h3 { font: 650 22px/1.2 var(--font-ui); letter-spacing: -.022em; }
.set-back { display: none; margin-left: -10px; }
.set-group { display: grid; margin-bottom: 21px; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--rule); }
.set-group-title { margin: 0 0 6px 2px; color: var(--ink-2); font: 600 12px/1.3 var(--font-ui); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; padding: 10px 14px; }
.set-row + .set-row { border-top: 1px solid var(--rule); }
.set-row.is-stack { display: grid; justify-content: stretch; gap: 8px; }
.set-label { display: grid; gap: 2px; min-width: 0; cursor: default; }
.set-label > span:first-child { color: var(--ink); font-size: 13px; }
.set-label .hint { font-size: 12px; }
.set-note { margin: -12px 2px 21px; color: var(--ink-2); font-size: 12px; line-height: 1.5; }
.set-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.set-field { display: grid; gap: 6px; }
.set-field > label, .set-sub { font-weight: 600; font-size: 12.5px; }
.set-status { color: var(--ink-2); font-size: 12.5px; }
.set-status:empty { display: none; }
.set-status.is-error { color: var(--red); }
.fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.font-card { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--paper); cursor: pointer; text-align: left; color: var(--ink); }
.font-card:has(input:checked) { border-color: var(--blue-mark); box-shadow: inset 0 0 0 1px var(--blue-mark); background: var(--blue-wash); }
.font-card:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
.font-sample { font-size: 22px; line-height: 1.1; }
.font-name { font-size: 12.5px; font-weight: 600; }
.font-desc { font-size: 11.5px; color: var(--ink-2); }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input { flex: 1; min-width: 0; }
.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; min-width: 0; }
.steps { display: grid; gap: 4px; margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 12.5px; }
.acct-form { display: grid; gap: 12px; }
.acct-sub { padding: 14px; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--rule); }
.dict { display: flex; flex-wrap: wrap; gap: 5px; }
.dict-chip { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 2px 0 10px; border-radius: 14px; background: var(--canvas); box-shadow: inset 0 0 0 1px var(--rule); font: 500 12.5px/1 var(--font-ui); }
.dict-x { display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); }
.dict-x:hover { background: var(--hover); }
.dict-x .icon { width: 12px; height: 12px; }
.settings.as-sheet { height: 92dvh; max-height: 92dvh; width: 100%; }
.settings.as-sheet[open] { display: block; }
.settings.as-sheet .set-nav { border: 0; background: var(--paper); padding: 26px 13px 21px; height: 100%; }
.settings.as-sheet .set-nav-item { height: 48px; font-size: 15px; padding: 0 12px; border-radius: 0; border-bottom: 1px solid var(--rule); }
.settings.as-sheet .set-nav-item[aria-current="true"] { background: transparent; box-shadow: none; font-weight: 400; }
.settings.as-sheet .set-nav-item .chev-r { display: block; }
.settings.as-sheet .set-main { position: absolute; inset: 0; padding: 26px 21px calc(34px + var(--safe-b)); background: var(--paper); transform: translateX(100%); transition: transform var(--spring-t) var(--spring); visibility: hidden; }
.settings.as-sheet.is-pushed .set-main { transform: none; visibility: visible; }
.settings.as-sheet .set-back { display: inline-grid; }
.settings.as-sheet .set-close { top: 16px; }
.settings.as-sheet .set-row { min-height: 52px; }
.settings.as-sheet .set-nav h2 { font-size: 22px; padding-bottom: 16px; }

/* ---------- Shortcuts ---------- */
.shortcuts { width: min(760px, calc(100vw - 32px)); max-height: min(680px, calc(100dvh - 64px)); overflow-y: auto; }
.keys-grid { columns: 2 300px; column-gap: 34px; padding: 0 22px 22px; }
.keys-group { break-inside: avoid; margin-bottom: 18px; }
.keys-group h3 { margin-bottom: 6px; color: var(--ink-2); font: 600 12px/1.3 var(--font-ui); }
.keys-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 28px; border-bottom: 1px solid var(--rule); font-size: 13px; }
.keys-row:last-child { border-bottom: 0; }
.keys-head-end { display: flex; align-items: center; gap: 4px; }
.key-cell { display: inline-flex; align-items: center; gap: 2px; }
.key-set {
  display: inline-flex; align-items: center; justify-content: flex-end; min-width: 44px; height: 24px; padding: 0 3px; border: 0; border-radius: var(--r-xs);
  background: transparent; color: var(--ink-3); font: 500 11.5px/1 var(--font-ui); transition: background-color 80ms ease;
}
.key-set:hover { background: var(--hover); color: var(--ink); }
.key-set.is-empty { opacity: 0; padding: 0 7px; }
.keys-row:hover .key-set.is-empty, .key-set.is-empty:focus-visible { opacity: 1; }
.key-set.is-recording { padding: 0 8px; background: var(--blue-wash); color: var(--blue); font-weight: 600; box-shadow: inset 0 0 0 1px var(--blue-mark); }
.key-reset { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: var(--r-xs); background: transparent; color: var(--ink-3); opacity: 0; }
.key-reset .icon { width: 12px; height: 12px; }
.keys-row:hover .key-reset, .key-reset:focus-visible { opacity: 1; }
.key-reset:hover { background: var(--hover); color: var(--ink); }

/* ---------- The margin's content in a sheet (narrow layout) ---------- */
.margin-sheet { width: 100%; }
.margin-sheet[open] { display: flex; flex-direction: column; }
.margin-sheet.is-tall { height: 80dvh; }
.ms-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 22px 12px 8px 21px; }
.ms-title { flex: 1; font: 650 17px/1.2 var(--font-ui); letter-spacing: -.022em; }
.ms-close { width: 44px; height: 44px; }
.ms-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 21px calc(21px + var(--safe-b)); }
.margin-sheet .ov-text { min-height: 40vh; height: 100%; }
.margin-sheet .alts { position: static; transform: none; width: auto; margin: 0; padding: 0; box-shadow: none; }
.margin-sheet .alts-head .alts-title, .margin-sheet .alts-close { display: none; }
.margin-sheet .alts-head .seg { margin-left: 0; }
.margin-sheet .alts-input { font-size: 17px; padding: 8px; }
.margin-sheet .nn { position: static; transform: none; width: auto; }

/* ---------- The bar over a selection ---------- */
.bubble {
  position: fixed; z-index: 58; display: flex; align-items: center; gap: 1px; height: 38px; padding: 0 4px;
  background: var(--paper); color: var(--ink); border-radius: 11px; box-shadow: var(--shadow-lg);
  font: 500 13px/1 var(--font-ui); white-space: nowrap; transform-origin: 50% 100%;
}
.bubble.is-in { animation: grow-in var(--pop-t) var(--spring); }
.bub-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; min-width: 30px; padding: 0 8px;
  border: 0; border-radius: 7px; background: transparent; color: var(--ink); font: inherit; transition: background-color 100ms ease;
}
.bub-btn:hover { background: var(--hover); }
.bub-btn:active { background: var(--press); }
.bub-btn.is-on { color: var(--blue); background: var(--blue-wash); }
.bub-btn { width: 32px; padding: 0; color: var(--ink-2); }
.bub-btn:hover { color: var(--ink); }
.bub-ai, .bub-ai:hover { color: var(--blue); }
/* The bar is over the words, so its tips go up and away from them; under the words, down. */
.bubble [data-tip]::after { top: auto; bottom: calc(100% + 10px); white-space: nowrap; max-width: none; }
.bubble.is-below [data-tip]::after { bottom: auto; top: calc(100% + 10px); }
.bub-sep { width: 1px; height: 18px; margin: 0 3px; background: var(--rule); }
@media (max-width: 1079px) { .bubble { height: 44px; } .bub-btn { height: 38px; min-width: 38px; } }

/* ---------- The "/" menu and colors ---------- */
.slash-menu {
  position: fixed; z-index: 60; width: 290px; max-height: min(380px, 50vh); overflow-y: auto; padding: 5px;
  background: var(--paper); color: var(--ink); border-radius: var(--r); box-shadow: var(--shadow-lg);
  font: 400 13px/1.25 var(--font-ui); animation: grow-in var(--pop-t) var(--spring); transform-origin: 0 0;
}
.slash-group { padding: 8px 9px 4px; color: var(--ink-2); font-size: 12px; font-weight: 600; }
.slash-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 5px 8px; border: 0; border-radius: var(--r-sm); background: transparent; color: inherit; text-align: left; font: inherit; }
.slash-item.is-on { background: var(--canvas); box-shadow: inset 0 0 0 1px var(--rule); }
.slash-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--paper); box-shadow: inset 0 0 0 1px var(--rule); color: var(--ink-2); font: 500 13px/1 var(--font-serif); }
.slash-text { display: grid; gap: 1px; min-width: 0; }
.slash-hint { color: var(--ink-2); font-size: 12px; }
.slash-empty { padding: 8px 10px; color: var(--ink-2); }
.color-pop {
  position: fixed; z-index: 62; width: 236px; padding: 6px 9px 9px; background: var(--paper); color: var(--ink);
  border-radius: var(--r); box-shadow: var(--shadow-lg); font: 400 13px/1.2 var(--font-ui); animation: grow-in var(--pop-t) var(--spring);
}
.color-head { padding: 7px 1px 5px; color: var(--ink-2); font-size: 12px; font-weight: 600; }
.color-row { display: flex; flex-wrap: wrap; gap: 4px; }
.swatch { width: 24px; height: 24px; padding: 0; border: 0; border-radius: var(--r-xs); box-shadow: inset 0 0 0 1px var(--rule-2); background: var(--paper); color: var(--ink); font: 600 13px/24px var(--font-serif); text-align: center; }
.swatch:hover, .swatch:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.swatch.is-on { box-shadow: inset 0 0 0 2px var(--blue); }
.sw-default { color: var(--ink); }
.link-card {
  position: fixed; z-index: 59; display: flex; align-items: center; gap: 1px; max-width: min(420px, calc(100vw - 16px)); height: 34px; padding: 0 3px;
  background: var(--paper); color: var(--ink); border-radius: 10px; box-shadow: var(--shadow-lg); font: 400 13px/1 var(--font-ui);
  animation: grow-in var(--pop-t) var(--spring); transform-origin: 20px 0;
}
.link-url { display: inline-flex; align-items: center; gap: 6px; min-width: 0; height: 28px; padding: 0 9px 0 7px; border-radius: 7px; color: var(--blue); text-decoration: none; }
.link-url span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-url .icon { width: 13px; height: 13px; }
a.link-url:hover { background: var(--blue-wash); }
.link-url.is-plain { color: var(--ink-2); }
.link-act { flex: none; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); }
.link-act:hover { background: var(--hover); color: var(--ink); }
.link-act .icon { width: 14px; height: 14px; }
.ctx-anchor { position: fixed; width: 1px; height: 1px; pointer-events: none; }
dialog:focus-visible { outline: none; }
.rn-sheet .rn-card:only-child .rn-card-kind { display: none; }

/* ---------- The bench: what you reach for, under the page ---------- */
.bench {
  position: fixed; z-index: 24; left: calc(var(--col-l, 89px) - 9px); bottom: calc(13px + var(--safe-b));
  display: flex; align-items: center; gap: 1px; height: 34px; padding: 0 3px;
  border-radius: 11px; background: var(--material); color: var(--ink-3);
  -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 7%, transparent);
  font: 500 12.5px/1 var(--font-ui); transition: opacity 400ms ease;
}
html.is-typing .bench:not(:hover):not(:focus-within) { opacity: .28; }
html.drafts-moving .bench { transition: left 300ms var(--spring), opacity 400ms ease; }
.bench-btn, .bench-format {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 3px; height: 28px; min-width: 30px; padding: 0 7px;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font: inherit;
  transition: background-color 80ms ease, color 80ms ease, transform var(--press-t) ease-out;
}
.bench-btn { width: 30px; padding: 0; }
.bench-btn:hover, .bench-format:hover, .bench [aria-haspopup]:focus-visible { background: var(--hover); color: var(--ink); }
.bench-btn:active, .bench-format:active { transform: scale(.94); background: var(--press); }
.bench-btn.is-on { color: var(--blue); background: var(--blue-wash); }
.bench-format { padding: 0 5px 0 9px; color: var(--ink); font-weight: 600; }
.bench-format .icon { width: 12px; height: 12px; color: var(--ink-3); }
.bench-sep { width: 1px; height: 16px; margin: 0 3px; background: var(--rule-2); }
.bench-x { width: 0; min-width: 0; opacity: 0; overflow: hidden; transition: width 160ms var(--spring), opacity 120ms ease, background-color 80ms ease; }
.bench-x .icon { width: 12px; height: 12px; }
.bench:hover .bench-x, .bench-x:focus-visible { width: 26px; opacity: 1; overflow: visible; }
@media (max-width: 1079px) {
  .bench { left: 50%; transform: translateX(-50%); bottom: calc(10px + max(var(--safe-b), var(--kb, 0px))); height: 44px; padding: 0 5px; }
  .bench-btn, .bench-format { height: 38px; min-width: 40px; }
  .bench-btn { width: 40px; }
  .bench-x { display: none; }
  html.has-cards .bench, html.is-typing .bench { display: none; }
}
@media (prefers-reduced-transparency: reduce) { .bench { background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; } }

/* ---------- Effects (fx.js) ---------- */
.fx-layer { position: fixed; inset: 0; z-index: 70; pointer-events: none; overflow: hidden; contain: strict; }
.fx-glyph { position: absolute; white-space: pre; will-change: transform, opacity; }
.fx-money { position: absolute; left: 0; top: 0; color: var(--red); font: 700 14px/1 var(--font-ui); font-variant-numeric: tabular-nums; white-space: nowrap; will-change: transform, opacity; }
.fx-chad { position: absolute; border-radius: 50%; background: var(--canvas); box-shadow: inset 0 0 0 1px var(--rule-2), 0 1px 2px rgba(20, 30, 50, .18); will-change: transform, opacity; }
.fx-chad.is-red { background: var(--red-mark); box-shadow: none; }
.fx-chad.is-blue { background: var(--blue-mark); box-shadow: none; }
/* Trim reads: a blue pencil line travels down the text with a faint wash behind it. */
.fx-scan { position: absolute; overflow: hidden; animation: fade-in 160ms ease; }
.fx-scan i {
  position: absolute; left: 0; right: 0; top: -70px; height: 70px;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--blue-mark) 13%, transparent));
  border-bottom: 1.5px solid var(--blue-mark); border-radius: 0 0 2px 2px;
  animation: fx-scan var(--t, 1400ms) cubic-bezier(.45, .05, .55, .95) infinite alternate;
}
@keyframes fx-scan { to { transform: translateY(calc(var(--run) + 70px)); } }
/* The challenge reel: names run past a window; a red pencil rings the one that stops. */
.fx-reel { position: absolute; height: 46px; display: grid; place-items: center; animation: reel-in 180ms var(--spring); transform-origin: 50% 100%; }
.fx-reel-window { width: 100%; height: 34px; border-radius: var(--r-sm); background: var(--paper); box-shadow: var(--shadow-lg); }
.fx-reel-mask {
  height: 100%; overflow: hidden; border-radius: inherit;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent); mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
}
.fx-reel.is-landed .fx-reel-mask { -webkit-mask-image: none; mask-image: none; }
.fx-reel.is-landed .fx-reel-window { animation: reel-land 320ms var(--spring); }
.fx-reel-list { will-change: transform; }
.fx-reel-row { height: 34px; padding: 0 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; color: var(--ink); font: 600 14px/34px var(--font-ui); letter-spacing: -.01em; }
.fx-ring { position: absolute; inset: -4px -8px; opacity: 0; }
.fx-ring svg { width: 100%; height: 100%; overflow: visible; }
.fx-ring path { fill: none; stroke: var(--red-mark); stroke-width: 2; stroke-linecap: round; vector-effect: non-scaling-stroke; stroke-dasharray: 1; stroke-dashoffset: 1; }
.fx-reel.is-landed .fx-ring { opacity: 1; }
.fx-reel.is-landed .fx-ring path { animation: ring-draw 380ms 60ms cubic-bezier(.4, 0, .2, 1) forwards; }
.fx-reel.is-leaving { opacity: 0; transform: translateY(8px) scale(.97); transition: opacity 200ms ease-in, transform 220ms ease-in; }
@keyframes reel-in { from { opacity: 0; transform: scale(.94); } }
@keyframes reel-land { 0% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes ring-draw { to { stroke-dashoffset: 0; } }
