/* Rewrite. White page, black ink, one red pencil for corrections. Spacing on the 4/8 ramp. */
:root {
  --bg: #ffffff;
  --surface: #f5f5f5;
  --raise: #ffffff;
  --float: #ffffff;
  --float-edge: rgb(0 0 0 / 0.1);
  --float-shadow: 0.12;
  --ink: #111111;
  --muted: #6b6b6b;
  --faint: #a3a3a3;
  --hair: #ebebeb;
  --soft: #f4f4f4;
  --mark: #d23f1f;
  --accent: #d23f1f; /* read by the edge-glow effect: the light is the red pencil */
  --accent-ink: #ffffff;
  --action: #111111;
  --btn: #111111;
  --btn-ink: #ffffff;
  --btn-hover: #2b2b2b;
  --r-sm: 8px;
  --r-lg: 16px;
  --font: "Geist", system-ui, -apple-system, sans-serif;
  --font-text: var(--font);
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  /* the working indicator: the logo line straightening into its red dot */
  --spin: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='2'%3E%3Ccircle cx='8' cy='8' r='6' opacity='.25'/%3E%3Cpath d='M8 2a6 6 0 0 1 6 6' stroke-linecap='round'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c0e;
    --surface: #14161a;
    --raise: #1d2026;
    --float: #262a31;
    --float-edge: rgb(255 255 255 / 0.14);
    --float-shadow: 0.55;
    --ink: #ededed;
    --muted: #8f939a;
    --faint: #5c6068;
    --hair: rgb(255 255 255 / 0.09);
    --soft: #24272e;
    --mark: #f0745a;
    --accent: #f0745a;
    --accent-ink: #0b0c0e;
    --action: #ededed;
    --btn: #ededed;
    --btn-ink: #0b0c0e;
    --btn-hover: #ffffff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, textarea, select { font: inherit; color: inherit; }
p, ol { margin: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.link:focus-visible { border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.i-sm { width: 12px; height: 12px; }

.app {
  height: 100dvh;
  width: 100%;
  grid-template-columns: minmax(0, 1fr);
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px 32px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

/* Text links: the secondary control style. */
.link {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color 150ms var(--ease), text-decoration-color 150ms var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .link:hover { color: var(--ink); text-decoration-color: currentColor; }
}

.bar { display: flex; align-items: center; justify-content: space-between; height: 64px; font-size: 14px; }
.bar .view-title { font-size: 16px; font-weight: 500; letter-spacing: -0.02em; }
.bar-action {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px; margin-right: -12px; /* text edge lines up with the content edge */
  border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), transform 150ms var(--ease);
}
.bar-action[hidden] { display: none; }
.bar-action:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .bar-action:hover { background: var(--soft); color: var(--ink); } }
.brand { margin: 0; font-size: 14px; font-weight: 500; letter-spacing: -0.01em; }
.brand a { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.mark { width: 24px; height: 24px; border-radius: 6px; }

/* ---------- thread ---------- */
.thread { overflow-y: auto; padding: 32px 0 48px; }
/* text starts on the same 16px line as the draft below it, short measure, sentence in ink, examples quieter */
.empty { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 12px; max-width: calc(44ch + 32px); padding: 0 16px; color: var(--ink); text-wrap: pretty; }
.empty .examples { color: var(--muted); }
.empty[hidden] { display: none; }
.examples .link { color: var(--ink); text-decoration-color: var(--faint); }

.messages { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 32px; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.message.is-new .message-text { animation: unmask 420ms var(--ease) both; }
.message.is-new .message-meta { animation: fade 300ms 180ms var(--ease) both; }
.message-original { margin-top: 8px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
/* actions under each message: readable muted text buttons that light up on hover, the tone as plain metadata */
.message-meta { display: flex; align-items: center; gap: 4px; margin: 8px 0 0 -8px; font-size: 13px; color: var(--muted); }
.message-tone { padding: 0 8px; color: var(--muted); }
.message-tone:empty { display: none; }
.message-meta .link { height: 28px; padding: 0 8px; border-radius: 8px; color: var(--muted); text-decoration: none; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
@media (hover: hover) and (pointer: fine) { .message-meta .link:hover { background: var(--soft); color: var(--ink); } }
@keyframes unmask {
  from { clip-path: inset(0 0 100% 0); transform: translateY(8px); }
  to { clip-path: inset(0 0 -8px 0); transform: none; }
}
@keyframes fade { from { opacity: 0; } }

/* rich text inside messages and the corrected line */
code { font: 0.92em/1 ui-monospace, "SF Mono", Menlo, monospace; padding: 2px 4px; border-radius: 4px; background: var(--soft); }
strong { font-weight: 500; }

/* ---------- composer ----------
   The light lives on the box's own 1px border and washes faintly inside it. It answers the draft:
   each keystroke nudges it forward, a check sends it round, a result settles it with one pulse. */
@property --a { syntax: "<angle>"; inherits: true; initial-value: 0deg; }
@property --lit { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --light { syntax: "<color>"; inherits: true; initial-value: #111111; }
.composer {
  --a: 0deg;
  --lit: 0;
  --light: var(--ink);
  position: relative;
  isolation: isolate;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--hair), 0 8px 24px rgb(0 0 0 / 0.08);
  transition: --a 600ms var(--ease), --lit 700ms var(--ease), --light 500ms var(--ease), box-shadow 200ms var(--ease);
}
.composer:focus-within { box-shadow: 0 0 0 1px color-mix(in oklab, var(--faint) 70%, transparent), 0 8px 24px rgb(0 0 0 / 0.08); }
.glow, .wash {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  /* a long tail that brightens slowly and a soft head that fades out, no hard edge anywhere */
  background: conic-gradient(from var(--a),
    color-mix(in oklab, var(--light) 0%, transparent) 0deg,
    color-mix(in oklab, var(--light) 0%, transparent) 150deg,
    color-mix(in oklab, var(--light) 18%, transparent) 240deg,
    color-mix(in oklab, var(--light) 70%, transparent) 310deg,
    var(--light) 335deg,
    color-mix(in oklab, var(--light) 0%, transparent) 360deg);
}
/* the bright ring: only the 1px border shows */
.glow {
  z-index: 1;
  padding: 1px;
  opacity: var(--lit);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
/* the wash: the same light, blurred and clipped to the inside of the box */
.wash {
  inset: 0;
  z-index: -1;
  filter: blur(40px);
  clip-path: inset(0 round var(--r-lg));
  opacity: calc(var(--lit) * 0.1);
}
.composer[data-glow="typing"] { --lit: 0.55; }
.composer[data-glow="checking"] { --lit: 0.85; animation: orbit 2.4s linear infinite; }
.composer[data-glow="fixes"] { --light: var(--mark); --lit: 0.45; animation: pulse 1200ms var(--ease) 1; }
.composer[data-glow="clean"] { --lit: 0.2; animation: pulse 1200ms var(--ease) 1; }
.composer[data-glow="error"] { --light: var(--mark); --lit: 0.35; }
@keyframes orbit { from { --a: var(--a0, 0deg); } to { --a: calc(var(--a0, 0deg) + 360deg); } }
@keyframes pulse { from { --lit: 0.85; } }

.field { position: relative; }
/* optical padding: the visible text lands 16px from the top edge and 12px above the next block */
.mirror, .field textarea {
  margin: 0;
  padding: 13.5px 16px 1.5px;
  font: inherit;
  letter-spacing: normal;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
}
.mirror { position: absolute; inset: 0; overflow: hidden; color: transparent; pointer-events: none; }
.mirror mark {
  color: transparent;
  background: none;
  text-decoration: underline wavy var(--mark);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  animation: fade 240ms 180ms var(--ease) both; /* arrives with the corrected line, not before it */
}
/* a word autocorrect already fixed: the red pencil line, solid, under the new word */
.mirror mark.auto { text-decoration: underline solid color-mix(in oklab, var(--mark) 70%, transparent); text-decoration-thickness: 2px; }
.field textarea {
  position: relative;
  display: block;
  width: 100%;
  min-height: 0;
  max-height: 40vh;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  caret-color: var(--ink);
}
.field textarea::placeholder { color: var(--faint); }
.field textarea:placeholder-shown { min-height: 72px; }

/* the suggestion is its own panel, so it never reads as a second text field */
.rewrite {
  margin: 8px 8px 0;
  padding: 8px;
  border-radius: 8px;
  background: var(--soft);
  cursor: pointer;
  transition: background-color 150ms var(--ease), transform 120ms var(--ease);
}
.rewrite:active { transform: scale(0.995); }
@media (hover: hover) and (pointer: fine) {
  .rewrite:hover { background: color-mix(in oklab, var(--soft), var(--ink) 5%); }
}
.rewrite-head { display: flex; align-items: center; justify-content: space-between; line-height: 16px; margin-bottom: 4px; }
.rewrite-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--mark); }
.rewrite-head .link { font-size: 13px; }
.rewrite[data-state="empty"], .rewrite[data-state="clean"] { display: none; }
.rewrite-text {
  min-width: 0;
  max-height: 30vh;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  transition: opacity 150ms var(--ease);
}
/* while a new check runs, the old version softens; the new one blurs into focus word by word */
.rewrite-text { transition: opacity 240ms var(--ease), filter 240ms var(--ease); }
.rewrite[data-stale] .rewrite-text { opacity: 0.55; } /* real time: never blurred, only dimmed after an edit mid-text */
.w { display: inline-block; white-space: pre; animation: focus-in 420ms var(--d, 0ms) var(--ease) both; }
@keyframes focus-in { from { opacity: 0; filter: blur(6px); transform: translateY(2px); } }
/* the edit shown as is, like the sign in page: the old word struck in grey, its fix in red beside it */
.rewrite-text del { color: var(--faint); text-decoration: line-through currentColor; text-decoration-thickness: 0.06em; }
.rewrite-text ins { color: var(--mark); text-decoration: none; }
@keyframes draw { from { background-size: 0 2px; } }
.rewrite .link { color: var(--ink); text-decoration-color: var(--faint); }

.reading { margin: 0 16px; padding: 11.5px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); min-height: 0; }
.reading:empty { display: none; }
.reading .error { color: var(--mark); }
.reading-part { cursor: help; text-decoration: underline dotted transparent; text-underline-offset: 3px; transition: text-decoration-color 150ms var(--ease), color 150ms var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .reading-part:hover { color: var(--ink); text-decoration-color: var(--faint); }
  .rewrite-text ins, .rewrite-text del { cursor: help; }
}

/* tooltip and hover cards */
.tip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms var(--ease), visibility 0s 120ms;
}
.tip[data-open] { opacity: 1; visibility: visible; transition: opacity 140ms var(--ease); }
.tip:has(kbd) { flex-direction: row; align-items: center; gap: 8px; }
.tip kbd { background: color-mix(in oklab, var(--bg) 16%, transparent); color: inherit; opacity: 0.8; }
.tip small { font-size: 12px; opacity: 0.65; }
.tip-fix s { opacity: 0.6; text-decoration-color: var(--mark); }
.tip-fix b { font-weight: 500; }

/* ---------- foot: tools, tone, copy, send ---------- */
.foot { display: flex; align-items: center; gap: 8px; padding: 12px 8px 8px; }
.tools { display: flex; align-items: center; gap: 4px; margin-right: auto; min-width: 0; }
.tools-sep { width: 1px; height: 16px; margin: 0 4px; background: var(--hair); }

.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), transform 100ms var(--ease);
}
.tool:active { transform: scale(0.92); }
.tool[aria-expanded="true"] { background: var(--soft); color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
@media (hover: hover) and (pointer: fine) {
  .tool:not([aria-pressed="true"]):not([data-active]):hover { background: var(--soft); color: var(--ink); }
  .tool[aria-pressed="true"]:hover { background: var(--btn-hover); color: var(--bg); }
}

/* menus: one quiet list style for letter styles and tone, opening upward */
.pop { position: relative; }
.menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 20;
  min-width: 224px;
  padding: 6px;
  border-radius: 14px;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--hair), 0 16px 40px rgb(0 0 0 / 0.08);
  transform-origin: bottom left;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px) scale(0.98);
  transition: opacity 140ms var(--ease), transform 140ms var(--ease), visibility 0s 140ms;
}
.menu-right { left: auto; right: 0; transform-origin: bottom right; }
.menu[data-open] { opacity: 1; visibility: visible; transform: none; transition: opacity 160ms var(--ease), transform 160ms var(--ease); }
@media (prefers-color-scheme: dark) {
  .menu { background: var(--surface); box-shadow: 0 0 0 1px var(--hair), 0 16px 40px rgb(0 0 0 / 0.4); }
}
.menu-head {
  display: flex;
  justify-content: space-between;
  padding: 8px 8px 4px;
  font-size: 12px;
  color: var(--faint);
}
.menu-head span { color: var(--faint); }
#tone-items, #style-items { display: grid; gap: 2px; }
.menu-sep { height: 1px; margin: 4px 8px; background: var(--hair); }
.menu-item {
  display: grid;
  grid-template-columns: 1fr 16px;
  align-items: center;
  column-gap: 16px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
  transition: background-color 120ms var(--ease);
}
.menu-item:focus-visible { outline: 2px solid var(--faint); outline-offset: -2px; }
.menu-item small { grid-column: 1; font-size: 12px; line-height: 1.3; color: var(--faint); margin-top: 2px; }
.menu-item .tick { grid-column: 2; grid-row: 1 / span 2; width: 16px; height: 16px; opacity: 0; transform: scale(0.6); color: var(--ink); transition: opacity 150ms var(--ease), transform 150ms var(--ease); }
.menu-item[aria-checked="true"] .tick { opacity: 1; transform: none; }
.menu-item:not([role="menuitemradio"]) { grid-template-columns: 1fr; color: var(--muted); }
@media (hover: hover) and (pointer: fine) {
  .menu-item:hover { background: var(--soft); }
}
.pop-btn[data-active] { background: var(--ink); color: var(--bg); }
.pop-btn .i-sm { transition: transform 200ms var(--ease); }
.pop-btn[aria-expanded="true"] .i-sm { transform: rotate(180deg); }
@media (hover: hover) and (pointer: fine) {
  .pop-btn[data-active]:hover { background: var(--btn-hover); color: var(--bg); }
}

/* Copy is the main action: the icon swaps to a check and the label slides to "Copied". */
.btn-copy {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--btn);
  color: var(--btn-ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms var(--ease), transform 120ms var(--ease), opacity 150ms var(--ease);
}
.btn-copy:active:not(:disabled) { transform: scale(0.97); }
.btn-copy:disabled { background: var(--soft); color: var(--faint); cursor: default; }
.btn-copy[aria-busy="true"] { cursor: progress; }
.btn-copy[aria-busy="true"] .i-copy { animation: breathe 900ms var(--ease-in-out) infinite alternate; }
@keyframes breathe { to { opacity: 0.35; } }
.swap { position: relative; width: 16px; height: 16px; }
.swap .i { position: absolute; inset: 0; transition: opacity 200ms var(--ease), transform 200ms var(--ease); }
.i-check { opacity: 0; transform: scale(0.5); }
.btn-copy[data-done] .i-copy { opacity: 0; transform: scale(0.5); }
.btn-copy[data-done] .i-check { opacity: 1; transform: none; }
/* both words share one cell, so the button is as wide as "Copied" and never jumps */
.copy-label { display: inline-grid; justify-items: center; }
.copy-label::after { content: "Copied"; grid-area: 1 / 1; visibility: hidden; height: 0; }
.copy-label.is-swapping { animation: slide 260ms var(--ease); }
@keyframes slide { from { opacity: 0; transform: translateY(6px); filter: blur(2px); } }
@media (hover: hover) and (pointer: fine) {
  .btn-copy:hover:not(:disabled) { background: var(--btn-hover); }
}

/* ---------- shell: sidebar + one tool at a time ---------- */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); height: 100dvh; }
.view { min-width: 0; height: 100dvh; overflow: hidden; }
.view[hidden] { display: none; }
.view-title { margin: 0; font-size: 14px; font-weight: 500; letter-spacing: -0.01em; }
.sidebar { display: flex; flex-direction: column; gap: 16px; padding: 0 12px 16px; background: var(--surface); }
.sidebar .brand { display: flex; align-items: center; height: 64px; padding: 0 12px; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.nav-item[aria-current="page"] { background: var(--raise); color: var(--ink); box-shadow: 0 0 0 1px var(--hair); }
.nav-item:focus-visible { outline-offset: 2px; }
.nav-item .i { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) {
  .nav-item:not([aria-current]):hover { background: color-mix(in oklab, var(--surface), var(--ink) 5%); color: var(--ink); }
}

/* small buttons shared by compose */
.btn-quiet {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms var(--ease), transform 120ms var(--ease), opacity 150ms var(--ease);
}
.btn-quiet:disabled { background: var(--soft); color: var(--faint); cursor: default; }
.btn-small {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--btn);
  color: var(--btn-ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms var(--ease), transform 120ms var(--ease);
}
.send-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: var(--btn);
  color: var(--btn-ink);
  cursor: pointer;
  transition: background-color 150ms var(--ease), transform 120ms var(--ease), opacity 150ms var(--ease);
}
.send-icon:disabled { background: var(--soft); color: var(--faint); cursor: default; }
.send-icon[aria-busy="true"] { animation: breathe 900ms var(--ease-in-out) infinite alternate; }
.btn-quiet:active:not(:disabled), .btn-small:active, .send-icon:active:not(:disabled) { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  .btn-quiet:hover:not(:disabled) { background: color-mix(in oklab, var(--soft), var(--ink) 6%); }
  .btn-small:hover, .send-icon:hover:not(:disabled) { background: var(--btn-hover); }
}

/* ---------- compose: canvas + assistant ---------- */
.compose { display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.canvas { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.canvas-bar { display: flex; align-items: center; gap: 16px; height: 64px; padding: 0 32px; flex-shrink: 0; }
.doc-title { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: 500 14px/1 var(--font); letter-spacing: -0.01em; }
.doc-title::placeholder { color: var(--faint); }
.canvas-bar .link { font-size: 13px; }
.doc-meta { font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; }

.paper { flex: 1; min-height: 0; overflow-y: auto; padding: 32px 32px 96px; }
.sheet { position: relative; max-width: 680px; margin: 0 auto; }
.doc-field { position: relative; }
.doc-field.is-hidden { display: none; }
.doc-mirror, #doc, .review {
  margin: 0;
  padding: 0;
  font: 400 17px/1.7 var(--font);
  letter-spacing: normal;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
#doc {
  position: relative;
  display: block;
  width: 100%;
  min-height: 50vh;
  border: 0;
  outline: 0;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--ink);
  caret-color: var(--ink);
}
#doc::placeholder { color: var(--faint); }
#doc::selection { background: color-mix(in oklab, var(--mark) 34%, transparent); }
.doc-mirror { position: absolute; inset: 0; overflow: hidden; color: transparent; pointer-events: none; }
.doc-mirror mark { color: transparent; background: transparent; border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.doc-mirror mark.pending { background: color-mix(in oklab, var(--mark) 26%, transparent); animation: pending 1.2s var(--ease-in-out) infinite alternate; }
.doc-mirror mark.flash { background: color-mix(in oklab, var(--mark) 22%, transparent); animation: flash-out 1.4s var(--ease) forwards; }
@keyframes pending { to { background: color-mix(in oklab, var(--mark) 14%, transparent); } }
@keyframes flash-out { to { background: transparent; } }

/* the assistant is writing: an empty page shows soft lines, a full one softens */
.paper[data-state="working"] .doc-field:has(#doc:placeholder-shown)::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 160px;
  background: repeating-linear-gradient(to bottom, var(--soft) 0 12px, transparent 12px 29px);
  -webkit-mask: linear-gradient(90deg, #000 55%, transparent);
  mask: linear-gradient(90deg, #000 55%, transparent);
  animation: breathe 900ms var(--ease-in-out) infinite alternate;
}
.paper[data-state="working"] .doc-field:has(#doc:placeholder-shown) #doc::placeholder { color: transparent; }
.paper[data-state="working"] #doc:not(:placeholder-shown) { opacity: 0.5; filter: blur(1px); transition: opacity 240ms var(--ease), filter 240ms var(--ease); }

.review ins { text-decoration: none; background: color-mix(in oklab, var(--mark) 14%, transparent); animation: tint-in 300ms calc(var(--d, 0ms) + 240ms) var(--ease) both; border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.review del { color: var(--mark); text-decoration-thickness: 1px; opacity: 0.7; }
@keyframes tint-in { from { background-color: transparent; } }
/* focus on the change: in a diff the untouched text steps back, insertions stay full ink */
.review .diff { color: color-mix(in oklab, var(--ink) 45%, transparent); transition: color 300ms var(--ease); }
.review .diff ins { color: var(--ink); background: color-mix(in oklab, var(--mark) 20%, transparent); padding: 0 2px; margin: 0 -2px; }
.review .diff del { opacity: 0.6; }
/* rewriting a selection: the field dims and the mirror (same glyphs underneath) keeps the selected words bright */
.doc-field:has(mark.pending) #doc { color: color-mix(in oklab, var(--ink) 35%, transparent); transition: color 240ms var(--ease); }
.doc-mirror mark.pending { color: var(--ink); }
.review del + ins, .review ins + del { margin-left: 4px; }
.review-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 32px 24px;
  padding: 8px 8px 8px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  animation: rise 220ms var(--ease);
}
.review-bar[hidden] { display: none; }
.review-bar .link { font-size: 14px; }
.review-summary { flex: 1; min-width: 0; font-size: 14px; }
.review-bar .link { color: color-mix(in oklab, var(--bg) 70%, transparent); }
.review-bar .btn-small { background: var(--bg); color: var(--ink); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* assistant panel */
.agent { display: flex; flex-direction: column; min-height: 0; padding: 0 16px 16px; background: var(--surface); }
.agent-bar { display: flex; align-items: center; height: 64px; padding: 0 8px; flex-shrink: 0; }
.agent-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 0 16px; /* text and prompts share the tabs' left edge */
  display: flex;
  flex-direction: column;
  /* the conversation fades out where it meets the shortcuts instead of being cut */
  -webkit-mask: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
  mask: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
}
.agent-body > .turns { margin-top: auto; }
.agent-empty { color: var(--muted); font-size: 14px; line-height: 1.5; }
.agent-empty[hidden] { display: none; }
.prompts { display: grid; gap: 4px; margin-top: 16px; }
/* quiet rows on a tonal step, an arrow that wakes on hover; no outlined boxes */
.prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: color-mix(in oklab, var(--surface), var(--ink) 4%);
  color: var(--ink);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms var(--ease), transform 120ms var(--ease);
}
.prompt::after {
  content: "";
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  background: currentColor;
  opacity: 0.35;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M7 7h10v10'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M7 7h10v10'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: opacity 150ms var(--ease), transform 150ms var(--ease);
}
.prompt:active { transform: scale(0.98); }
@media (hover: hover) and (pointer: fine) {
  .prompt:hover { background: color-mix(in oklab, var(--surface), var(--ink) 8%); }
  .prompt:hover::after { opacity: 1; transform: translate(2px, -2px); }
}
.turns { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.turn { display: grid; gap: 8px; animation: rise 220ms var(--ease); }
.turn-ask { justify-self: end; max-width: 88%; margin: 0; padding: 8px 12px; border-radius: 12px 12px 4px 12px; background: var(--btn); color: var(--btn-ink); font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.turn-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--raise);
  box-shadow: 0 0 0 1px var(--hair), 0 1px 2px rgb(0 0 0 / 0.06), inset 0 1px 0 rgb(255 255 255 / 0.04);
}
.turn-head { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.turn-avatar { width: 20px; height: 20px; border-radius: 6px; }
.turn-name { font-weight: 500; color: var(--ink); }
.turn-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.turn-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.turn-card[data-state="working"] .turn-status { color: var(--ink); }
.turn-card[data-state="working"] .turn-status::before { animation: breathe 700ms var(--ease-in-out) infinite alternate; }
.turn-card[data-state="ready"] .turn-status { color: var(--mark); background: color-mix(in oklab, var(--mark) 14%, transparent); }
.turn-card[data-state="accepted"] .turn-status { color: var(--ink); }
.turn-card[data-state="rejected"] .turn-status, .turn-card[data-state="stale"] .turn-status, .turn-card[data-state="unchanged"] .turn-status { color: var(--faint); }
.turn-card[data-state="error"] .turn-status { color: var(--mark); }
.turn-quote { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--soft); color: var(--muted); font-size: 13px; line-height: 1.45; }
.turn-reply { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink); }
.turn-card[data-state="rejected"] .turn-reply { color: var(--faint); }
.turn-card[data-state="error"] .turn-reply { color: var(--mark); }
.turn-card[data-state="working"] .turn-reply {
  background: linear-gradient(90deg, var(--muted) 0%, var(--ink) 50%, var(--muted) 100%) 0 0 / 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: sheen 1.4s linear infinite;
}
@keyframes sheen { to { background-position: -200% 0; } }

.agent-form { padding: 8px; border-radius: 16px; background: var(--raise); box-shadow: 0 0 0 1px var(--hair), 0 8px 24px rgb(0 0 0 / 0.08); }
.agent-form:focus-within { box-shadow: 0 0 0 1px var(--faint), 0 8px 24px rgb(0 0 0 / 0.08); }
.agent-scope { display: flex; margin: 0; padding: 0 0 4px; }
.scope-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 28px; padding: 0 4px 0 10px; border-radius: 8px; background: color-mix(in oklab, var(--mark) 14%, transparent); color: var(--ink); font-size: 12px; }
.scope-chip .i { color: var(--mark); }
.scope-x { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .scope-x:hover { background: color-mix(in oklab, var(--mark) 20%, transparent); color: var(--ink); } }
.agent-scope[hidden] { display: none; }
.agent-scope #agent-scope-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#agent-input, .agent-form textarea { display: block; width: 100%; min-height: 48px; max-height: 30vh; padding: 8px; border: 0; outline: 0; resize: none; background: transparent; font-size: 15px; line-height: 1.5; field-sizing: content; color: var(--ink); }
#agent-input::placeholder, .agent-form textarea::placeholder { color: var(--faint); }
.agent-foot { display: flex; align-items: center; justify-content: space-between; padding-left: 8px; }
.agent-hint { font-size: 12px; color: var(--faint); }
/* one row; if it overflows it scrolls sideways and fades at the edge */
/* quiet text actions above the input: no outlines, no fade; they wrap if the panel is narrow */
.agent-quick { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 0; }
#agent-quick { margin-left: -8px; } /* button text lines up with the panel edge */
.agent-quick:empty { display: none; }
.agent-quick button {
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), transform 100ms var(--ease);
}
.agent-quick button:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) { .agent-quick button:hover { background: var(--soft); color: var(--ink); } }

/* floating: selection bar and suggestion card */
.bubble, .suggest {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  border-radius: 12px;
  background: var(--float);
  box-shadow: 0 0 0 1px var(--float-edge), 0 2px 6px rgb(0 0 0 / 0.06), 0 20px 48px rgb(0 0 0 / var(--float-shadow));
  animation: pop 160ms var(--ease);
}
.bubble[hidden], .suggest[hidden] { display: none; }
@keyframes pop { from { opacity: 0; scale: 0.97; } }
.bubble { width: max-content; max-width: calc(100vw - 16px); padding: 4px; }
.bubble-form { display: flex; align-items: center; gap: 4px; padding: 0 0 4px; border-bottom: 1px solid var(--hair); margin: 0 0 4px; }
#bubble-input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; border: 0; outline: 0; background: transparent; font-size: 14px; color: var(--ink); }
#bubble-input::placeholder { color: var(--muted); }
.bubble-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.bubble-actions button {
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: color-mix(in oklab, var(--float), var(--ink) 10%);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms var(--ease), transform 100ms var(--ease);
}
.bubble-actions button:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  .bubble-actions button:hover { background: color-mix(in oklab, var(--float), var(--ink) 18%); }
}
.suggest { width: min(480px, calc(100vw - 16px)); padding: 12px; }
.suggest-label { margin: 0 0 8px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-text { margin: 0; font-size: 15px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 40vh; overflow-y: auto; }
.suggest-text ins { text-decoration: none; background: linear-gradient(var(--mark), var(--mark)) no-repeat 0 100% / 100% 2px; padding-bottom: 1px; animation: draw 360ms calc(var(--d, 0ms) + 240ms) var(--ease) both; }
.suggest-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 12px; font-size: 14px; }
.suggest[data-state="loading"] .suggest-actions { opacity: 0.4; pointer-events: none; }
.skeleton { display: block; height: 52px; background: repeating-linear-gradient(to bottom, var(--soft) 0 10px, transparent 10px 21px); border-radius: 4px; animation: breathe 900ms var(--ease-in-out) infinite alternate; }


/* =================================================================
   Suite additions: tabs, comments, history, insights, documents, dictionary, dialogs
   ================================================================= */
.nav-foot { margin-top: auto; width: 100%; border: 0; background: transparent; cursor: pointer; font: inherit; font-size: 14px; font-weight: 500; }
/* Voices: a settings tile at the foot of the sidebar that shows which voice is on */
.nav-foot small { display: none; }
@media (min-width: 1200px) {
  .nav-foot { height: 52px; text-align: left; background: color-mix(in oklab, var(--surface), var(--ink) 4%); border-radius: 10px; }
  @media (hover: hover) and (pointer: fine) { .nav-foot:hover { background: color-mix(in oklab, var(--surface), var(--ink) 7%); } }
  .nav-foot-label { display: grid; gap: 2px; min-width: 0; line-height: 1.25; color: var(--ink); }
  .nav-foot small { display: flex; align-items: center; gap: 6px; overflow: hidden; font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
  .nav-foot[data-on] small { color: var(--ink); }
  .nav-foot[data-on] small::before { content: ""; flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--mark); }
  .nav-foot[data-on] .nav-icon { color: var(--mark); }
  .nav-foot .nav-badge { display: none; }
}
.nav-badge { margin-left: auto; padding: 2px 6px; border-radius: 999px; background: color-mix(in oklab, var(--mark) 16%, transparent); color: var(--mark); font-size: 11px; }
.link-danger { color: var(--mark); }
.menu-down { top: calc(100% + 8px); bottom: auto; transform-origin: top right; }
.menu-scroll { max-height: min(360px, 60vh); overflow-y: auto; }

/* side panel tabs */
.agent-bar { height: 64px; padding: 0; align-items: center; }
.tabs { display: flex; gap: 2px; padding: 4px; border-radius: 10px; background: color-mix(in oklab, var(--surface), var(--ink) 5%); width: 100%; }
.tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 6px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.tab[aria-selected="true"] { background: var(--raise); color: var(--ink); box-shadow: 0 0 0 1px var(--hair), 0 1px 2px rgb(0 0 0 / 0.06); }
@media (hover: hover) and (pointer: fine) { .tab[aria-selected="false"]:hover { color: var(--ink); } }
.tab-count { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--mark); color: #fff; font-size: 10px; line-height: 16px; }
.panel-cowriter { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.panel-cowriter[hidden], .panel[hidden] { display: none; }
.panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 12px; padding: 0 8px 16px; }
.panel-foot { padding-top: 8px; }
.panel-foot .btn-small { width: 100%; height: 40px; }
.panel-foot .btn-small:disabled { opacity: 0.35; cursor: default; }
.panel-empty { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0; }
.panel-sub { margin: 8px 0 0; font-size: 12px; color: var(--faint); }

/* comments */
.doc-mirror mark.comment { background: color-mix(in oklab, #e8a317 22%, transparent); }
.note-card { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--raise); box-shadow: 0 0 0 1px var(--hair); animation: rise 200ms var(--ease); }
.note-card.is-resolved { opacity: 0.55; }
.note-quote { justify-self: start; max-width: 100%; padding: 6px 8px; border: 0; border-radius: 6px; background: color-mix(in oklab, #e8a317 18%, transparent); color: var(--ink); font-size: 13px; line-height: 1.4; text-align: left; cursor: pointer; }
.note-quote:disabled { cursor: default; background: var(--soft); color: var(--muted); }
.note-text { width: 100%; padding: 8px; border: 0; border-radius: 8px; background: var(--soft); color: var(--ink); font-size: 14px; line-height: 1.45; resize: vertical; outline: 0; }
.note-text:focus { box-shadow: 0 0 0 1px var(--faint); }
.note-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 13px; }
.note-lost { color: var(--faint); margin-right: auto; }
/* word tools (Define, Comment) look up or annotate instead of rewriting: their own group and style */
.bubble-sep { width: 1px; align-self: stretch; margin: 4px 4px; background: var(--hair); }
.bubble-actions .bubble-tool { display: inline-flex; align-items: center; gap: 6px; background: transparent; box-shadow: inset 0 0 0 1px var(--hair); color: var(--muted); }
.bubble-actions .bubble-tool .i { color: var(--mark); }
@media (hover: hover) and (pointer: fine) { .bubble-actions .bubble-tool:hover { background: var(--soft); color: var(--ink); } }
.bubble-actions [hidden] { display: none; }

/* history */
.version { display: grid; gap: 4px; padding: 12px; border-radius: 12px; background: var(--raise); box-shadow: 0 0 0 1px var(--hair); }
.version-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.version-head b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.version-head span { color: var(--faint); flex-shrink: 0; }
.version-meta { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.version .link { justify-self: start; font-size: 13px; }

/* insights */
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { display: grid; gap: 2px; padding: 12px; border-radius: 12px; background: var(--raise); box-shadow: 0 0 0 1px var(--hair); }
.metric-label { font-size: 12px; color: var(--muted); }
.metric-value { font-size: 24px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.metric-hint { font-size: 12px; color: var(--faint); }
.finding { display: grid; gap: 6px; padding: 12px; border-radius: 12px; background: var(--raise); box-shadow: 0 0 0 1px var(--hair); }
.finding b { font-size: 14px; font-weight: 500; }
.finding p { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.finding .btn-quiet { justify-self: start; }

/* ---------- documents ---------- */
.documents { display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.library { display: flex; flex-direction: column; min-height: 0; padding: 0 16px 16px; box-shadow: 1px 0 0 var(--hair); }
.library-bar { display: flex; align-items: center; justify-content: space-between; height: 64px; flex-shrink: 0; }
.library-tools { display: flex; gap: 8px; align-items: center; min-width: 0; }
.library-tools .pop-btn { white-space: nowrap; flex-shrink: 0; width: 36px; height: 36px; padding: 0; justify-content: center; background: var(--soft); }
#sort-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.library-tools .pop { flex-shrink: 0; }
.search { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: 8px; background: var(--soft); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.search:focus-within { box-shadow: 0 0 0 1px var(--faint); }
.template-cta { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; padding: 12px; border: 0; border-radius: 12px; background: var(--raise); box-shadow: 0 0 0 1px var(--hair); color: var(--ink); text-align: left; cursor: pointer; transition: box-shadow 150ms var(--ease), transform 120ms var(--ease); }
.template-cta .i { color: var(--mark); }
.template-cta span { display: grid; gap: 2px; }
.template-cta b { font-size: 14px; font-weight: 500; }
.template-cta small { font-size: 12px; color: var(--muted); }
.template-cta:active { transform: scale(0.99); }
@media (hover: hover) and (pointer: fine) { .template-cta:hover { box-shadow: 0 0 0 1px var(--faint); } }
.doc-list { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 2px; }
.doc-empty { padding: 16px 4px; color: var(--muted); font-size: 14px; }
.doc-row { display: grid; gap: 4px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; transition: background-color 120ms var(--ease); }
.doc-row[aria-current="true"] { background: var(--raise); box-shadow: 0 0 0 1px var(--hair); }
@media (hover: hover) and (pointer: fine) { .doc-row:not([aria-current]):hover { background: color-mix(in oklab, var(--bg), var(--ink) 4%); } }
.doc-row-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.doc-row-top b { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-tag { flex-shrink: 0; margin-left: auto; padding: 1px 6px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 11px; }
.doc-snippet { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-row-meta { font-size: 12px; color: var(--faint); }

.studio { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.studio-empty { margin: auto; color: var(--muted); font-size: 14px; }
.studio-empty[hidden], .studio-main[hidden] { display: none; }
.studio-main { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.studio-bar { display: flex; align-items: center; gap: 16px; height: 64px; padding: 0 24px; flex-shrink: 0; min-width: 0; }
.studio-bar .doc-title { min-width: 120px; }
.studio-bar > button { white-space: nowrap; flex-shrink: 0; }
.studio-bar .doc-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 1399px) {
  .studio-bar .doc-meta { display: none; }
  .documents { grid-template-columns: 240px minmax(0, 1fr); }
  .studio-body { grid-template-columns: minmax(0, 1fr) 272px; }
  .stage { padding: 24px; }
}
.studio-bar .link { font-size: 13px; }
.studio-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 288px; }
.stage { min-height: 0; overflow-y: auto; padding: 24px 32px 64px; background: color-mix(in oklab, var(--surface), var(--ink) 3%); }
.stage-note { display: flex; align-items: center; justify-content: center; gap: 12px; max-width: 794px; margin: 0 auto 16px; padding: 8px 12px; border-radius: 10px; background: color-mix(in oklab, #e8a317 16%, transparent); font-size: 13px; }
.stage-note[hidden] { display: none; }
.page-frame { position: relative; width: 100%; max-width: 794px; margin: 0 auto; overflow: hidden; border-radius: 4px; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.06), 0 12px 40px rgb(0 0 0 / 0.14); background: #fff; }
#preview { position: absolute; top: 0; left: 0; display: block; width: 794px; border: 0; transform-origin: top left; background: #fff; }

.inspector { min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 24px; padding: 16px 16px 32px; background: var(--surface); }
.inspector-label { margin: 0 0 8px; font-size: 12px; font-weight: 500; color: var(--muted); }
.design-ask { position: relative; isolation: isolate; padding: 12px; border-radius: 12px; background: var(--raise); box-shadow: 0 0 0 1px var(--hair), 0 8px 24px rgb(0 0 0 / 0.06); }
.design-ask[data-glow="checking"] { animation: pending-card 1.2s var(--ease-in-out) infinite alternate; }
@keyframes pending-card { to { box-shadow: 0 0 0 1px color-mix(in oklab, var(--mark) 60%, transparent), 0 8px 24px rgb(0 0 0 / 0.06); } }
.design-ask textarea { display: block; width: 100%; padding: 0; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink); font-size: 14px; line-height: 1.5; }
.design-ask textarea::placeholder { color: var(--faint); }
.design-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.design-foot .btn-small { white-space: nowrap; flex-shrink: 0; }
.design-foot .agent-hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layout-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.layout-card { display: grid; gap: 4px; padding: 8px; border: 0; border-radius: 10px; background: var(--raise); box-shadow: 0 0 0 1px var(--hair); color: var(--ink); text-align: left; cursor: pointer; transition: box-shadow 150ms var(--ease), transform 120ms var(--ease); }
.layout-card[aria-checked="true"] { box-shadow: 0 0 0 2px var(--ink); }
.layout-card:active { transform: scale(0.98); }
.layout-card b { font-size: 12px; font-weight: 500; }
.layout-card small { font-size: 11px; color: var(--faint); line-height: 1.3; }
/* live previews: the open document rendered in each layout (layout-thumbs.js scales an A4 frame down) */
.layout-thumb { position: relative; display: block; aspect-ratio: 210 / 150; overflow: hidden; border-radius: 6px; background: #ffffff; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06); }
.layout-thumb iframe { position: absolute; top: 0; left: 0; width: 793.7px; height: 1123px; border: 0; transform-origin: 0 0; pointer-events: none; background: #ffffff; }
#layout-menu { width: 456px; max-height: min(560px, 70vh); overflow-y: auto; overscroll-behavior: contain; }
.chip-row, .segmented { display: flex; flex-wrap: wrap; gap: 4px; }
.seg { height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--raise); box-shadow: 0 0 0 1px var(--hair); color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer; transition: box-shadow 120ms var(--ease), color 120ms var(--ease); }
.seg[aria-checked="true"] { background: var(--ink); color: var(--bg); box-shadow: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12); transition: transform 120ms var(--ease); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.swatch:active { transform: scale(0.92); }
.swatch-custom { background: conic-gradient(#d23f1f, #e8a317, #1f5c49, #0f766e, #1e4fd6, #111, #d23f1f); overflow: hidden; }
.swatch-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.inspector-split { display: grid; gap: 24px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.toggle input { width: 16px; height: 16px; accent-color: var(--ink); }

/* ---------- dialogs ---------- */
.dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 16px; background: var(--float); color: var(--ink); box-shadow: 0 0 0 1px var(--float-edge), 0 24px 64px rgb(0 0 0 / var(--float-shadow)); }
.dialog-wide { width: min(760px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(0 0 0 / 0.4); backdrop-filter: blur(2px); }
.dialog[open] { animation: pop 180ms var(--ease); }
.dialog-inner { display: grid; gap: 16px; padding: 24px; margin: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 18px; font-weight: 500; letter-spacing: -0.01em; }
.dialog-lede { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 16px; }
.dialog-foot .link { font-size: 13px; }
.dialog-foot > :first-child { margin-right: auto; }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--soft); color: var(--ink); } }
.voice-list { display: grid; gap: 4px; max-height: 220px; overflow-y: auto; }
.voice-row { display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; transition: background-color 120ms var(--ease); }
.voice-row:has(input:checked) { background: var(--soft); }
.voice-row input { accent-color: var(--mark); margin: 0; }
.voice-row span { display: grid; gap: 2px; min-width: 0; }
.voice-row b { font-size: 14px; font-weight: 500; }
.voice-row small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-row .link { font-size: 13px; }
.voice-editor, .form-field { display: grid; gap: 8px; }
.voice-editor label, .form-field span { font-size: 12px; font-weight: 500; color: var(--muted); }
.voice-editor input, .voice-editor textarea, .form-field input, .form-field textarea { width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: var(--soft); color: var(--ink); font-size: 14px; line-height: 1.5; outline: 0; resize: vertical; }
.voice-editor input:focus, .voice-editor textarea:focus, .form-field input:focus, .form-field textarea:focus { box-shadow: 0 0 0 1px var(--faint); }
.voice-status { margin: 0; min-height: 18px; font-size: 12px; color: var(--muted); }
/* voices: head and lede sit close, list rows breathe, the editor is its own titled section */
#voices-dialog .dialog-lede { margin-top: -8px; }
#voices-dialog .dialog-head { margin-right: -8px; }
.voice-list { margin: 0 -12px; }
.voice-row { padding: 12px; border-radius: 8px; }
@media (hover: hover) and (pointer: fine) { .voice-row:not(:has(input:checked)):hover { background: color-mix(in oklab, var(--float), var(--ink) 4%); } }
.voice-row input {
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--faint);
  transition: box-shadow 150ms var(--ease);
  cursor: pointer;
}
.voice-row input:checked { box-shadow: inset 0 0 0 5px var(--ink); }
.voice-row input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.voice-editor { padding-top: 16px; box-shadow: 0 -1px 0 var(--hair); }
.voice-editor-title { margin: 0 0 4px; font-size: 14px; font-weight: 500; color: var(--ink); }
.voice-editor label { margin-top: 4px; }
.voice-editor input, .voice-editor textarea { padding: 12px; border-radius: 8px; }
/* contrast: --soft sits almost on --float, so the dialog gets its own visible steps */
#voices-dialog { --field: color-mix(in oklab, var(--float), var(--ink) 7%); --hint: color-mix(in oklab, var(--muted) 85%, var(--float)); }
#voices-dialog .voice-editor input, #voices-dialog .voice-editor textarea { background: var(--field); box-shadow: inset 0 0 0 1px var(--hair); }
#voices-dialog .voice-editor input:focus, #voices-dialog .voice-editor textarea:focus { box-shadow: inset 0 0 0 1px var(--muted); }
#voices-dialog ::placeholder { color: var(--hint); opacity: 1; }
#voices-dialog .voice-editor label, #voices-dialog .voice-row small, #voices-dialog .dialog-lede { color: var(--muted); }
#voices-dialog .voice-row:has(input:checked) { background: var(--field); }
#voices-dialog .voice-row input { box-shadow: inset 0 0 0 1.5px var(--muted); }
#voices-dialog .voice-row input:checked { box-shadow: inset 0 0 0 5px var(--ink); }
#voices-dialog .dialog-foot .link { color: var(--ink); text-decoration-color: var(--muted); }
.template-body { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.template-list { display: grid; align-content: start; gap: 4px; }
.template-option { display: grid; gap: 2px; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.template-option[aria-checked="true"] { background: var(--soft); box-shadow: inset 0 0 0 1px var(--hair); }
.template-option b { font-size: 14px; font-weight: 500; }
.template-option small { font-size: 12px; color: var(--muted); }
.template-fields { display: grid; align-content: start; gap: 12px; }

/* ---------- dictionary ---------- */
.dictionary { overflow-y: auto; }
.dict { max-width: 880px; margin: 0 auto; padding: 0 32px 96px; }
.dict-search { display: flex; align-items: center; gap: 12px; height: 56px; margin-top: 16px; padding: 0 16px; border-radius: 14px; background: var(--raise); box-shadow: 0 0 0 1px var(--hair), 0 8px 24px rgb(0 0 0 / 0.06); color: var(--muted); }
.dict-search:focus-within { box-shadow: 0 0 0 1px var(--faint), 0 8px 24px rgb(0 0 0 / 0.06); }
.dict-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 18px; }
.dict-search input::-webkit-search-cancel-button { display: none; }
.dict-recent { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.dict-recent[hidden] { display: none; }
.word-chip { height: 28px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--soft); color: var(--ink); font-size: 13px; cursor: pointer; transition: background-color 120ms var(--ease), transform 100ms var(--ease); }
.word-chip:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) { .word-chip:hover { background: color-mix(in oklab, var(--soft), var(--ink) 8%); } }
.dict-body { margin-top: 48px; }
.dict-error, .dict-missing p { color: var(--muted); font-size: 15px; }
.dict-missing { display: grid; justify-items: start; gap: 12px; }
.entry { display: grid; grid-template-columns: minmax(0, 1fr) 260px; column-gap: 64px; row-gap: 32px; }
.entry-head { grid-column: 1 / -1; display: grid; gap: 12px; }
.entry-word { margin: 0; font-size: clamp(48px, 7vw, 88px); font-weight: 500; line-height: 1.05; letter-spacing: -0.035em; }
.entry-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin: 0; color: var(--muted); font-size: 15px; }
.entry-tag { padding: 2px 10px; border-radius: 999px; background: color-mix(in oklab, var(--mark) 14%, transparent); color: var(--mark); font-size: 12px; font-weight: 500; }
.listen { height: 28px; font-size: 12px; }
.senses { list-style: none; margin: 0; padding: 0; display: grid; gap: 32px; counter-reset: sense; }
.sense { display: grid; gap: 8px; counter-increment: sense; }
.pos { justify-self: start; font-size: 12px; font-weight: 500; color: var(--mark); }
.pos::before { content: counter(sense) ". "; color: var(--faint); }
.definition { margin: 0; font-size: 20px; line-height: 1.45; letter-spacing: -0.01em; }
.example { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--soft); color: var(--muted); font-size: 15px; line-height: 1.5; }
.example::before { content: "\201C"; }
.example::after { content: "\201D"; }
.entry-side { display: grid; align-content: start; gap: 24px; }
.dict-group { display: grid; gap: 8px; }
.dict-group > div, .dict-group { align-content: start; }
.dict-group p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.dict-group:has(.word-chip) { display: flex; flex-wrap: wrap; gap: 6px; }
.dict-group:has(.word-chip) .dict-label { flex-basis: 100%; }
.dict-label { margin: 0; font-size: 12px; font-weight: 500; color: var(--faint); }
.entry-actions { display: flex; align-items: center; gap: 16px; margin-top: 24px; font-size: 14px; }
.entry-daily { grid-template-columns: 1fr; padding: 32px; border-radius: 20px; background: var(--raise); box-shadow: 0 0 0 1px var(--hair), 0 16px 48px rgb(0 0 0 / 0.08); }
.entry-daily .entry-word { font-size: clamp(56px, 9vw, 112px); }
.entry-loading { display: grid; gap: 16px; }
.dict-history { margin-top: 48px; }
.dict-history[hidden] { display: none; }
.dict-history-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.dict-history-head h3 { margin: 0 auto 0 0; font-size: 14px; font-weight: 500; }
.dict-history-head .link { font-size: 13px; }
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.history-row { display: grid; gap: 4px; width: 100%; padding: 12px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; transition: background-color 120ms var(--ease); }
@media (hover: hover) and (pointer: fine) { .history-row:hover { background: var(--soft); } }
.history-row:active { transform: scale(0.995); }
.history-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.history-top b { font-size: 16px; font-weight: 500; letter-spacing: -0.01em; }
.history-time { margin-left: auto; font-size: 12px; color: var(--faint); white-space: nowrap; }
.history-def { font-size: 13px; line-height: 1.45; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.history-empty { padding: 12px; font-size: 13px; color: var(--muted); }
@media (max-width: 599px) { .dict-history-head { flex-wrap: wrap; } .dict-history-head .segmented { order: 3; flex-basis: 100%; } }
.skeleton-title { height: 72px; width: 40%; border-radius: 8px; background: var(--soft); }

/* ---------- studio toolbar: file and design controls live above the page ---------- */
.studio-body { grid-template-columns: minmax(0, 1fr) !important; }
/* two rows, like a document app: title and the main action, then a menu bar */
.studio-bar { position: relative; flex-wrap: wrap; height: auto; padding: 12px 24px 8px; row-gap: 4px; column-gap: 12px; box-shadow: 0 1px 0 var(--hair); }
.studio-bar .doc-title { flex: 1; font-size: 16px; }
.studio-tools { order: 3; flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-left: -8px; min-width: 0; }
.studio-tools::-webkit-scrollbar { display: none; }
.studio-tools .pop { position: static; }
.studio-bar .menu { top: auto; margin-top: 4px; }
.studio-tools .pop-btn { white-space: nowrap; }
.studio-bar #studio-dl { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; white-space: nowrap; flex-shrink: 0; }
.accent-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--mark); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.15); }
.ai-btn { color: var(--ink); background: color-mix(in oklab, var(--mark) 12%, transparent); }
.ai-btn .i { color: var(--mark); }
@media (hover: hover) and (pointer: fine) { .ai-btn:hover { background: color-mix(in oklab, var(--mark) 18%, transparent) !important; } }
.panel-menu { width: 360px; padding: 12px; display: grid; gap: 8px; align-content: start; }
.panel-menu .inspector-label { margin: 4px 0 0; }
.panel-menu .layout-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel-menu .layout-card small { display: none; }
.font-list { display: grid; gap: 2px; }
.font-list .seg { height: 36px; padding: 0 10px; text-align: left; background: transparent; box-shadow: none; color: var(--ink); font-size: 14px; }
.font-list .seg[aria-checked="true"] { background: var(--soft); color: var(--ink); }
@media (hover: hover) and (pointer: fine) { .font-list .seg:not([aria-checked="true"]):hover { background: var(--soft); } }
.panel-menu .swatches { padding: 4px; }
.ai-panel .design-ask { box-shadow: none; background: transparent; }
.ai-panel { width: 452px; padding: 12px; }
.studio-bar .ai-panel { right: 16px; }
.directions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.direction { display: grid; grid-template-rows: auto auto 1fr; align-content: start; gap: 2px; padding: 4px 4px 8px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; transition: background-color 150ms var(--ease), transform 120ms var(--ease); }
.direction img { display: block; width: 100%; height: 96px; object-fit: cover; border-radius: 6px; margin-bottom: 6px; background: var(--soft); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06); transition: transform 300ms var(--ease); }
.direction b { padding: 0 4px; font-size: 13px; font-weight: 500; }
.direction small { padding: 0 4px; font-size: 11px; line-height: 1.3; color: var(--faint); }
.direction:active { transform: scale(0.98); }
.direction[data-busy] img { animation: breathe 800ms var(--ease-in-out) infinite alternate; }
@media (hover: hover) and (pointer: fine) {
  .direction:hover { background: var(--soft); }
  .direction:hover img { transform: scale(1.02); }
}
.working { position: absolute; inset: 0; z-index: 2; display: grid; place-items: start center; padding-top: 48px; pointer-events: none; opacity: 0; transition: opacity 240ms var(--ease); overflow: hidden; }
.working::before { content: ""; position: absolute; inset: 0; backdrop-filter: blur(2px) saturate(0.8); -webkit-backdrop-filter: blur(2px) saturate(0.8); background: rgb(255 255 255 / 0.45); }
/* one soft diagonal sheen crossing the page; it starts and ends off the page so the loop has no seam */
.working::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / 0.55) 50%, transparent 65%); transform: translateX(-100%); animation: sweep 2.2s cubic-bezier(0.45, 0, 0.55, 1) infinite; }
@keyframes sweep { to { transform: translateX(100%); } }
.working-chip { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px; border-radius: 999px; background: #111; color: #fff; font-size: 13px; font-weight: 500; box-shadow: 0 8px 24px rgb(0 0 0 / 0.2); }
.working-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #d23f1f; animation: breathe 700ms var(--ease-in-out) infinite alternate; }
.page-frame[data-working] .working { opacity: 1; }
.working-chip { transform: translateY(-8px); opacity: 0; transition: transform 320ms var(--ease), opacity 240ms var(--ease); }
.page-frame[data-working] .working-chip { transform: none; opacity: 1; }
/* keep the step chip in view on a tall page: clip-path instead of overflow so sticky still works */
.working { overflow: visible; clip-path: inset(0); padding-top: 24px; }
.working-chip { position: sticky; top: 24px; }
@media (prefers-reduced-motion: reduce) { .working::after { animation: none; opacity: 0; } }
.page-frame[data-reveal] #preview { animation: page-in 700ms var(--ease) both; }
@keyframes page-in { from { opacity: 0; filter: blur(8px); } }
.stage-hint[data-state="saving"] { color: var(--muted); }
.stage-hint[data-state="saved"] { color: var(--mark); }
.stage-hint { max-width: 794px; margin: 0 auto 12px; font-size: 12px; color: var(--faint); }
.menu-item.link-danger span { color: var(--mark); }

/* ---------- sidebar: one icon set, the active tool carries the red pencil ---------- */
.nav-icon { width: 20px; height: 20px; stroke-width: 1.75; transition: color 150ms var(--ease); }
.nav-item[aria-current="page"] {
  background: var(--raise);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05), 0 1px 2px rgb(0 0 0 / 0.08), 0 4px 12px rgb(0 0 0 / 0.06);
}
/* shortcut hint: real Cmd/Ctrl+1..4, shown on hover so the list stays quiet */
@media (min-width: 1200px) {
  .nav-item[data-key]::after {
    content: attr(data-key);
    margin-left: auto;
    font-size: 12px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    color: var(--faint);
    opacity: 0;
    transition: opacity 150ms var(--ease);
  }
  .nav-item:focus-visible::after { opacity: 1; }
}
@media (min-width: 1200px) and (hover: hover) and (pointer: fine) { .nav-item:hover::after { opacity: 1; } }
.nav-item[aria-current="page"] .nav-icon { color: var(--mark); }
@media (hover: hover) and (pointer: fine) { .nav-item:not([aria-current]):hover .nav-icon { color: var(--ink); } }

/* ---------- one spec for every menu, toolbar and panel ---------- */
.menu { padding: 4px; border-radius: 12px; }
.menu-item { min-height: 36px; padding: 8px 12px; border-radius: 8px; font-size: 14px; column-gap: 16px; }
.menu-item:has(small) { min-height: 48px; }
.menu-item small { margin-top: 2px; }
.menu-sep { margin: 4px 8px; }
.menu-head { padding: 8px 12px 4px; }
.menu-scroll { padding: 4px; }
.panel-menu { padding: 12px; gap: 8px; }
.panel-menu .inspector-label { margin: 8px 0 0; }
.panel-menu .inspector-label:first-child { margin-top: 0; }
.panel-menu .toggle { margin-top: 8px; }
.font-list .seg { border-radius: 8px; }
.tool { height: 32px; padding: 0 10px; gap: 6px; border-radius: 8px; font-size: 13px; }
.tool.pop-btn .i-sm { opacity: 0.7; }
.tools-sep { height: 16px; margin: 0 6px; }
.canvas-bar { gap: 4px; }
/* title and word count read as one label on the left; actions sit together on the right */
.canvas-bar .doc-title { flex: 0 1 auto; field-sizing: content; min-width: 64px; max-width: 60%; margin-right: 12px; font-size: 16px; letter-spacing: -0.02em; }
.canvas-bar .doc-meta { margin-right: auto; white-space: nowrap; }
.canvas-bar .btn-quiet { margin-left: 4px; }
/* the stage fills the studio so the grey never stops halfway */
.studio-body { display: flex; flex-direction: column; overflow-y: auto; }
.stage { flex: 1 0 auto; overflow: visible; }

/* ---------- segmented control: one track, the choice raised inside it ---------- */
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--soft); }
.segmented .seg { height: 28px; padding: 0 12px; border-radius: 7px; background: transparent; box-shadow: none; color: var(--muted); font-size: 13px; font-weight: 500; }
.segmented .seg[aria-checked="true"] { background: var(--raise); color: var(--ink); box-shadow: 0 0 0 1px var(--hair), 0 1px 2px rgb(0 0 0 / 0.08); }
@media (hover: hover) and (pointer: fine) { .segmented .seg[aria-checked="false"]:hover { color: var(--ink); } }
@media (prefers-color-scheme: dark) { .segmented { background: color-mix(in oklab, var(--float), #000 22%); } .segmented .seg[aria-checked="true"] { background: color-mix(in oklab, var(--float), #fff 9%); } }

/* ---------- settings rows: label left, control right, equal heights ---------- */
.settings-menu { width: max-content; min-width: 300px; gap: 4px; }
.setting-row { display: grid; grid-template-columns: 88px auto; align-items: center; column-gap: 16px; min-height: 40px; padding: 0 4px; cursor: default; }
label.setting-row { cursor: pointer; }
.setting-label { font-size: 13px; color: var(--muted); }
.setting-row > :last-child { justify-self: start; }
.switch { position: relative; display: inline-flex; width: 36px; height: 20px; }
.switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.switch-track { width: 36px; height: 20px; border-radius: 999px; background: var(--soft); box-shadow: inset 0 0 0 1px var(--hair); transition: background-color 150ms var(--ease); }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform 180ms var(--ease), background-color 150ms var(--ease); }
.switch input:checked + .switch-track { background: var(--ink); }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: var(--bg); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- art menu ---------- */
.art-chip { width: 14px; height: 14px; border-radius: 4px; background: var(--soft); overflow: hidden; display: inline-grid; }
.art-chip svg { width: 100%; height: 100%; }
.art-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.art-option { display: grid; gap: 6px; padding: 4px 4px 8px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; transition: background-color 120ms var(--ease); }
.art-option .art-thumb { display: block; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: #fff; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06); }
.art-option .art-thumb svg { display: block; width: 100%; height: 100%; }
.art-option b { padding: 0 4px; font-size: 12px; font-weight: 500; }
.art-option[aria-checked="true"] .art-thumb { box-shadow: 0 0 0 2px var(--ink); }
@media (hover: hover) and (pointer: fine) { .art-option:hover { background: var(--soft); } }
.art-remix { justify-self: start; margin-top: 4px; }

/* ---------- documents: the designer bar floats at the bottom of the canvas ---------- */
.studio-main { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
.studio-main > .studio-body { min-height: 0; }
.stage { padding-bottom: 176px; }
.designer-dock { position: sticky; bottom: 16px; z-index: 6; display: grid; gap: 8px; width: min(680px, calc(100% - 48px)); margin: -152px auto 16px; }
.dd-thread { display: none; grid-template-rows: auto minmax(0, 1fr); max-height: min(52vh, 520px); border-radius: 16px; background: var(--float); box-shadow: 0 0 0 1px var(--float-edge), 0 24px 56px rgb(0 0 0 / var(--float-shadow)); overflow: hidden; }
.designer-dock[data-expanded="true"] .dd-thread { display: grid; animation: rise 220ms var(--ease); }
.dd-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 4px 16px; }
.dd-title { margin-right: auto; font-size: 13px; font-weight: 500; }
.dd-body { min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 16px; padding: 4px 16px 16px; }
.dd-directions p { margin: 0 0 12px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.dd-directions[hidden] { display: none; }
.dd-body .turns { gap: 12px; }
.designer-dock .agent-quick { padding: 0; }
.chip-directions { background: color-mix(in oklab, var(--mark) 14%, var(--float)) !important; box-shadow: 0 0 0 1px color-mix(in oklab, var(--mark) 28%, transparent) !important; }
.dd-form { background: var(--float); box-shadow: 0 0 0 1px var(--float-edge), 0 16px 40px rgb(0 0 0 / var(--float-shadow)); }
.dd-form:focus-within { box-shadow: 0 0 0 1px var(--faint), 0 16px 40px rgb(0 0 0 / var(--float-shadow)); }
.dd-form textarea { min-height: 40px; }
.dd-form .agent-foot { gap: 12px; padding-left: 8px; }
.dd-form .agent-hint { margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dd-toggle { font-size: 13px; white-space: nowrap; }
.menu-up { top: auto; bottom: calc(100% + 8px); transform-origin: bottom right; }
.dversions-menu { width: 300px; max-height: min(420px, 60vh); overflow-y: auto; }
.dversions-empty { padding: 12px; font-size: 13px; }
.turn-actions { display: flex; justify-content: flex-end; gap: 12px; font-size: 13px; }
.turn-card[data-state="undone"] .turn-status, .turn-card[data-state="restored"] .turn-status { color: var(--muted); }
.turn-card[data-state="applied"] .turn-status { color: var(--ink); }
.ai-btn[aria-pressed="true"] { background: color-mix(in oklab, var(--mark) 18%, transparent); }
@media (max-width: 599px) {
  .designer-dock { width: calc(100% - 24px); }
  .dd-form .agent-hint { display: none; }
  .dd-form .agent-foot { justify-content: space-between; }
}

/* ---------- working indicator: one small ring that takes the colour of the text around it ---------- */
@keyframes spin { to { rotate: 360deg; } }
.loader { display: inline-block; width: 12px; height: 12px; flex-shrink: 0; -webkit-mask: var(--spin) center / contain no-repeat; mask: var(--spin) center / contain no-repeat; background: currentColor; animation: spin 700ms linear infinite; }
.turn-card[data-state="working"] .turn-status::before { width: 12px; height: 12px; border-radius: 0; -webkit-mask: var(--spin) center / contain no-repeat; mask: var(--spin) center / contain no-repeat; background: currentColor; animation: spin 700ms linear infinite; }
/* status reads as quiet metadata, not a pill: plain text, a tick when done, a dot only when it needs you */
.turn-status { height: auto; padding: 0; border-radius: 0; background: none !important; font-size: 12px; font-weight: 400; color: var(--faint); }
.turn-status::before { display: none; }
.turn-card[data-state="working"] .turn-status::before,
.turn-card[data-state="ready"] .turn-status::before,
.turn-card[data-state="accepted"] .turn-status::before,
.turn-card[data-state="applied"] .turn-status::before { display: block; }
.turn-card[data-state="ready"] .turn-status::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.turn-card[data-state="accepted"] .turn-status::before,
.turn-card[data-state="applied"] .turn-status::before {
  width: 12px; height: 12px; border-radius: 0; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.turn-card[data-state="accepted"] .turn-status, .turn-card[data-state="applied"] .turn-status { color: var(--muted); }
.working-chip::before { width: 12px; height: 12px; border-radius: 0; -webkit-mask: var(--spin) center / contain no-repeat; mask: var(--spin) center / contain no-repeat; background: currentColor; animation: spin 700ms linear infinite; }
.send-icon[aria-busy="true"], .btn-copy[aria-busy="true"] { position: relative; animation: none; opacity: 1; }
.send-icon[aria-busy="true"] > .i { opacity: 0; }
.send-icon[aria-busy="true"]::after { content: ""; position: absolute; inset: 9px; -webkit-mask: var(--spin) center / contain no-repeat; mask: var(--spin) center / contain no-repeat; background: currentColor; animation: spin 700ms linear infinite; }
.btn-copy[aria-busy="true"] .i-copy { opacity: 0; }
.btn-copy[aria-busy="true"] .swap::after { content: ""; position: absolute; inset: 1px; -webkit-mask: var(--spin) center / contain no-repeat; mask: var(--spin) center / contain no-repeat; background: currentColor; animation: spin 700ms linear infinite; }
.reading[data-busy]::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; -webkit-mask: var(--spin) center / contain no-repeat; mask: var(--spin) center / contain no-repeat; background: currentColor; animation: spin 700ms linear infinite; }
.direction[data-busy] { position: relative; }
.direction[data-busy] img { animation: none; opacity: 0.5; }
.direction[data-busy]::after { content: ""; position: absolute; left: 50%; top: 52px; width: 20px; height: 20px; margin: -10px 0 0 -10px; color: #ffffff; -webkit-mask: var(--spin) center / contain no-repeat; mask: var(--spin) center / contain no-repeat; background: currentColor; animation: spin 700ms linear infinite; filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.5)); }

/* =================================================================
   Responsive system
   1200+      full sidebar
   900-1199   icon rail; each tool gets the room
   under 900  bottom tab bar in thumb reach; panels stack
   under 600  compact controls; labels hidden visually, kept for screen readers
   ================================================================= */
@media (max-width: 1199px) {
  .shell { grid-template-columns: 64px minmax(0, 1fr); }
  .sidebar { align-items: center; padding: 0 8px 16px; }
  .sidebar .brand { padding: 0; justify-content: center; }
  .sidebar .brand a { font-size: 0; gap: 0; }
  .nav { width: 100%; justify-items: center; }
  .nav-item, .nav-foot { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .nav-item span, .nav-foot span:not(.nav-badge) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav-item { position: relative; }
  .nav-badge { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; padding: 0; font-size: 0; background: var(--mark); }
  .compose { grid-template-columns: minmax(0, 1fr) 320px; }
  .documents { grid-template-columns: 240px minmax(0, 1fr); }
  .studio-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; align-content: start; overflow-y: auto; }
  .studio-body > * { min-height: auto; } /* rows grow to the page and controls instead of squeezing them */
  .stage { overflow: visible; }
  .entry { grid-template-columns: 1fr; }
}
@media (max-width: 899px) {
  :root { --tabbar: calc(64px + env(safe-area-inset-bottom)); }
  .shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
  .view { height: calc(100dvh - var(--tabbar)); min-height: 0; }
  /* bottom tab bar */
  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 40;
    flex-direction: row;
    gap: 0;
    height: var(--tabbar);
    padding: 0 8px env(safe-area-inset-bottom);
    background: color-mix(in oklab, var(--surface) 92%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 -1px 0 var(--hair);
  }
  .sidebar .brand { display: none; }
  .nav { display: contents; }
  .nav li { display: contents; }
  .nav-item, .nav-foot {
    flex: 1;
    width: auto;
    height: 56px;
    margin: 4px 0;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    border-radius: 12px;
    font-size: 12px;
  }
  .nav-item span, .nav-foot span:not(.nav-badge) { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  /* active tab: a pill behind the icon only, not a slab across the whole cell */
  .nav-item .nav-icon, .nav-foot .nav-icon { box-sizing: content-box; padding: 4px 16px; border-radius: 999px; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
  .nav-item[aria-current="page"] { background: none; box-shadow: none; color: var(--ink); }
  .nav-item[aria-current="page"] .nav-icon { background: var(--raise); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05); }
  @media (hover: hover) and (pointer: fine) { .nav-item:not([aria-current]):hover, .nav-foot:hover { background: none; } }
  .nav-badge { top: 6px; right: calc(50% - 16px); }
  .app { height: calc(100dvh - var(--tabbar)); max-width: none; margin: 0; padding: 0 16px 16px; }
  #view-correct .bar { height: 56px; }
  .compose { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .agent { max-height: 46dvh; padding: 0 12px 12px; box-shadow: 0 -1px 0 var(--hair); }
  .agent-bar { height: 56px; }
  .canvas-bar, .paper { padding-left: 16px; padding-right: 16px; }
  .canvas-bar { gap: 8px; }
  .doc-meta { display: none; }
  .paper { padding-top: 16px; padding-bottom: 48px; }
  .review-bar { margin: 0 16px 16px; }
  .documents { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .library { max-height: 38dvh; padding: 0 16px 12px; box-shadow: 0 1px 0 var(--hair); }
  .library-bar { height: 56px; }
  .template-cta { margin: 12px 0 8px; }
  .studio { overflow-y: auto; }
  .studio-main { flex: none; }
  .studio-bar { padding: 8px 16px; }
  .studio-body { overflow: visible; }
  .stage { padding: 16px; }
  .studio-bar .menu { left: 16px; right: 16px; width: auto; }
  .template-body { grid-template-columns: 1fr; }
  .template-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dict { padding: 0 16px 48px; }
  .dict-body { margin-top: 32px; }
  .entry-daily { padding: 24px; }
  .dialog-inner { padding: 20px; }
}
@media (max-width: 599px) {
  .nav-item, .nav-foot { font-size: 11px; letter-spacing: 0; }
  .nav-item .nav-icon, .nav-foot .nav-icon { padding: 4px 12px; }
  /* Correct: format tools left, tone and copy right on one row */
  .tools { gap: 0; }
  .pop { position: static; }
  .menu, .menu-right { left: 8px; right: 8px; min-width: 0; }
  #style-label, #lang-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .foot { flex-wrap: nowrap; gap: 4px; }
  .foot .tool, .foot .btn-copy { flex-shrink: 0; }
  .foot .tools-sep { display: none; }
  .reading { order: 0; }
  /* Compose: icon-only toolbar */
  #translate-btn span, #export-btn span, #doc-copy-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tabs .tab { font-size: 11px; padding: 0 4px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .entry-word { font-size: 48px; }
  .entry-daily .entry-word { font-size: 56px; }
  .definition { font-size: 18px; }
  .bubble { width: calc(100vw - 16px); }
  .bubble-actions { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .bubble-actions .bubble-comment { margin-left: 0; }
  .template-list { grid-template-columns: 1fr; }
}
@media (max-width: 359px) {
  .copy-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .btn-copy { width: 32px; padding: 0; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0ms !important; }
  .composer { --a: 300deg !important; }
}

/* ---------- deleting: Undo toast, the confirm step, Recently deleted, select mode ---------- */
[hidden] { display: none !important; }
:root { --toast-action: #f0745a; --toast-shadow: 0 16px 40px rgb(0 0 0 / 0.12); }
@media (prefers-color-scheme: dark) { :root { --toast-action: #b8341a; --toast-shadow: none; } }

.toast {
  position: fixed;
  left: 16px; /* placed by toast.js above the open tool's composer or bar */
  top: 16px;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(440px, calc(100vw - 32px));
  min-height: 48px;
  padding: 8px 8px 8px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  line-height: 1.4;
  box-shadow: var(--toast-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 150ms var(--ease), transform 150ms var(--ease), visibility 0s linear 150ms;
}
.toast[data-open] { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition: opacity 220ms var(--ease), transform 220ms var(--ease), visibility 0s; }
.toast:not(:has(.toast-undo)) { padding-right: 16px; }
.toast-text { min-width: 0; overflow-wrap: anywhere; }
.toast-undo { flex-shrink: 0; height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--toast-action); font-size: 14px; font-weight: 500; cursor: pointer; transition: background-color 150ms var(--ease), transform 120ms var(--ease); }
.toast-undo:active { transform: scale(0.96); }
.toast-undo:focus-visible { outline-color: var(--bg); }
@media (hover: hover) and (pointer: fine) { .toast-undo:hover { background: color-mix(in oklab, currentColor 14%, transparent); } }
@media (prefers-reduced-motion: reduce) { .toast, .toast[data-open] { transform: none; } }

/* destructive buttons: solid red only where the action is final */
.btn-danger { height: 32px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--mark); color: var(--accent-ink); font-size: 13px; font-weight: 500; cursor: pointer; transition: background-color 150ms var(--ease), transform 120ms var(--ease); }
.btn-danger:active:not(:disabled) { transform: scale(0.96); }
.btn-danger:disabled { background: var(--soft); color: var(--faint); cursor: default; }
.btn-quiet-danger { color: var(--mark); }
@media (hover: hover) and (pointer: fine) {
  .btn-danger:hover:not(:disabled) { background: color-mix(in oklab, var(--mark), var(--ink) 16%); }
  .btn-quiet-danger:hover:not(:disabled) { background: color-mix(in oklab, var(--mark) 12%, var(--soft)); }
}
.dialog-confirm { width: min(400px, calc(100vw - 32px)); }
.dialog-confirm .dialog-inner { gap: 8px; }
.confirm-title { margin: 0; font-size: 18px; font-weight: 500; line-height: 1.3; letter-spacing: -0.01em; }
.dialog-confirm .dialog-foot { gap: 8px; margin-top: 16px; }
.dialog-confirm .dialog-foot > :first-child { margin-right: 0; }

/* library header: Documents, Select and New; Recently deleted gets a way back and Empty */
.library-bar { justify-content: flex-start; gap: 8px; }
.library-bar .view-title { margin-right: auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-back { margin-left: -8px; }
.lib-note { margin: 16px 4px 8px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.library[data-mode="trash"] .doc-list { gap: 4px; }

/* a row's delete button shows on hover or keyboard focus; touch screens use Select instead */
.doc-item { position: relative; }
.doc-del { position: absolute; right: 8px; bottom: 6px; display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; opacity: 0; transition: opacity 120ms var(--ease), background-color 120ms var(--ease), color 120ms var(--ease), transform 100ms var(--ease); }
.doc-del .i { width: 14px; height: 14px; }
.doc-item:hover .doc-del, .doc-item:has(.doc-row:focus-visible) .doc-del, .doc-del:focus-visible { opacity: 1; }
.doc-del:active { transform: scale(0.92); }
@media (hover: hover) and (pointer: fine) { .doc-del:hover { background: color-mix(in oklab, var(--mark) 12%, transparent); color: var(--mark); } }
@media (hover: none) { .doc-del { display: none; } }

/* select mode: a tick before each title */
.doc-check { display: grid; place-items: center; flex-shrink: 0; width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--faint); color: transparent; transition: background-color 120ms var(--ease), box-shadow 120ms var(--ease), color 120ms var(--ease); }
.doc-check .i { width: 10px; height: 10px; stroke-width: 3; }
.doc-row[aria-pressed="true"] { background: var(--raise); box-shadow: 0 0 0 1px var(--hair); }
.doc-row[aria-pressed="true"] .doc-check { background: var(--ink); box-shadow: none; color: var(--bg); }

/* library foot: the way into Recently deleted, or the selection actions */
.lib-foot { flex-shrink: 0; margin: 8px -4px 0; padding-top: 8px; box-shadow: 0 -1px 0 var(--hair); }
.lib-foot:not(:has(> :not([hidden]))) { display: none; }
.lib-trash { display: flex; align-items: center; gap: 8px; width: 100%; height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; text-align: left; cursor: pointer; transition: background-color 120ms var(--ease), color 120ms var(--ease); }
.lib-count { margin-left: auto; color: var(--faint); font-variant-numeric: tabular-nums; }
@media (hover: hover) and (pointer: fine) { .lib-trash:hover { background: var(--soft); color: var(--ink); } }
.lib-selbar { display: flex; align-items: center; gap: 16px; min-height: 40px; padding: 0 4px; }
.lib-selcount { margin-right: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lib-selbar .link { font-size: 13px; white-space: nowrap; }

/* Recently deleted rows: what it was, when it went, and the two ways out */
.trash-item { display: grid; gap: 4px; padding: 12px; border-radius: 10px; background: color-mix(in oklab, var(--bg), var(--ink) 3%); }
.trash-item b { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trash-actions { display: flex; align-items: center; gap: 16px; margin-top: 8px; }
.trash-actions .link { font-size: 13px; }

/* Dictionary history: remove one word; on hover the time makes room for the button */
.history-item { position: relative; }
.history-del { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; opacity: 0; transition: opacity 120ms var(--ease), background-color 120ms var(--ease), color 120ms var(--ease), transform 100ms var(--ease); }
.history-del:active { transform: scale(0.92); }
.history-item:hover .history-del, .history-item:has(.history-row:focus-visible) .history-del, .history-del:focus-visible { opacity: 1; }
.history-item:hover .history-time, .history-item:has(:focus-visible) .history-time { opacity: 0; }
.history-time { transition: opacity 120ms var(--ease); }
@media (hover: hover) and (pointer: fine) { .history-del:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); color: var(--ink); } }
@media (hover: none) { .history-del { opacity: 1; } .history-top { padding-right: 32px; } }

/* Correct: deleting one copy turns red on hover */
@media (hover: hover) and (pointer: fine) { .message-meta .link-remove:hover { color: var(--mark); } }

/* Compose: the More menu, and Clear conversation where the send hint was */
.more-btn { width: 32px; padding: 0; }
/* co-writer input: no hint line (Send's tooltip shows the key); Clear is a quiet text button */
#agent-hint { display: none; }
#agent-form .agent-foot { justify-content: flex-end; gap: 8px; }
.agent-clear { margin-right: auto; height: 28px; padding: 0 8px; margin-left: -8px; border-radius: 8px; font-size: 12px; color: var(--muted); text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .agent-clear:hover { background: var(--soft); color: var(--ink); } }
.lib-trash.lib-empty { color: var(--mark); }
@media (hover: hover) and (pointer: fine) { .lib-trash.lib-empty:hover { background: color-mix(in oklab, var(--mark) 10%, transparent); color: var(--mark); } }
.trash-actions .btn-quiet { background: var(--bg); }
@media (hover: hover) and (pointer: fine) { .trash-actions .btn-quiet:hover { background: color-mix(in oklab, var(--bg), var(--ink) 6%); } }

/* the designer bar floats over the page: a progressive blur behind its chips keeps page text from peeking between them */
.designer-dock .agent-quick { position: relative; }
.designer-dock .agent-quick::before {
  content: "";
  position: absolute;
  inset: -32px -16px -24px;
  z-index: -1;
  pointer-events: none;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 40px), linear-gradient(to right, transparent, #000 16px, #000 calc(100% - 16px), transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to bottom, transparent, #000 40px), linear-gradient(to right, transparent, #000 16px, #000 calc(100% - 16px), transparent);
  mask-composite: intersect;
}

@media (prefers-reduced-motion: reduce) { .loader, .turn-card[data-state="working"] .turn-status::before, .working-chip::before, .send-icon[aria-busy="true"]::after, .btn-copy[aria-busy="true"] .swap::after, .reading[data-busy]::before, .direction[data-busy]::after { animation-duration: 2s; } }

/* designer chips float over the white page, so they keep a solid dark surface (the quiet text style is for panels) */
.designer-dock .agent-quick button {
  height: 28px;
  padding: 0 12px;
  background: var(--float);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--float-edge), 0 4px 12px rgb(0 0 0 / 0.16);
}
@media (hover: hover) and (pointer: fine) {
  .designer-dock .agent-quick button:hover { background: color-mix(in oklab, var(--float), var(--ink) 10%); color: var(--ink); }
}

/* ---------- typeface menu: search and filters over the full Google Fonts list (font-menu.js) ---------- */
.font-menu { width: 368px; padding: 8px; }
.font-picker { display: grid; gap: 8px; }
.font-search { width: 100%; height: 36px; padding: 0 12px; border: 0; border-radius: 8px; background: color-mix(in oklab, var(--float), var(--ink) 7%); box-shadow: inset 0 0 0 1px var(--hair); color: var(--ink); font: inherit; font-size: 14px; outline: 0; }
.font-search:focus { box-shadow: inset 0 0 0 1px var(--muted); }
.font-search::placeholder { color: color-mix(in oklab, var(--muted) 85%, var(--float)); }
.font-filters { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.font-filter { flex-shrink: 0; height: 28px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.font-filter[aria-checked="true"] { background: color-mix(in oklab, var(--float), var(--ink) 10%); color: var(--ink); }
@media (hover: hover) and (pointer: fine) { .font-filter:not([aria-checked="true"]):hover { color: var(--ink); } }
.font-picker .font-list { max-height: min(360px, 50vh); overflow-y: auto; overscroll-behavior: contain; }
.font-picker .font-row { width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 15px; }
.font-picker .font-row[aria-checked="true"] { background: color-mix(in oklab, var(--float), var(--ink) 10%); }
.font-group { margin: 8px 0 4px; padding: 0 10px; font-size: 12px; color: var(--muted); }
.font-group:first-child { margin-top: 0; }

/* side panel tabs: labels never wrap; tabs share space by content, so a count badge can't squeeze Co-writer */
.tabs .tab { flex: 1 1 auto; min-width: 0; white-space: nowrap; padding: 0 8px; }

/* library, cleaned: one filled action (New), quiet Select, the template entry as a plain row, no outlines on rows */
#lib-select.btn-quiet { height: 32px; padding: 0 8px; background: transparent; color: var(--muted); }
@media (hover: hover) and (pointer: fine) { #lib-select.btn-quiet:hover:not(:disabled) { background: var(--soft); color: var(--ink); } }
.template-cta { height: 40px; margin: 12px 0 4px; padding: 0 12px; gap: 12px; border-radius: 10px; background: transparent; box-shadow: none; color: var(--ink); }
.template-cta small { display: none; }
.template-cta b { font-size: 14px; font-weight: 500; }
.template-cta .i { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) { .template-cta:hover { background: color-mix(in oklab, var(--bg), var(--ink) 4%); box-shadow: none; } }
.doc-row { padding: 12px; }
.doc-row[aria-current="true"], .doc-row[aria-pressed="true"] { box-shadow: none; }
#lib-select.btn-small { padding: 0 12px; background: var(--btn); color: var(--btn-ink); } /* select mode: Done stays the one solid action */
@media (hover: hover) and (pointer: fine) { #lib-select.btn-small:hover { background: var(--btn-hover); color: var(--btn-ink); } }

/* paging (pager.js) */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.pager-at { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pager-btn, .pager-more { height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: background-color 150ms var(--ease); }
.pager-btn:disabled { color: var(--faint); cursor: default; }
.pager-more { width: 100%; margin-top: 4px; color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .pager-btn:not(:disabled):hover, .pager-more:hover { background: var(--soft); color: var(--ink); } }
.thread-earlier, .doc-more { list-style: none; }
.thread-earlier .pager-more { width: auto; margin: 0 0 0 -12px; }

/* tablet and phone: the sidebar becomes the bottom tab bar, so the logo and name move to a slim top bar.
   aria-hidden + tabindex -1: the sidebar's own brand link (still in the DOM) stays the one screen readers meet. */
.app-bar { display: none; }
@media (max-width: 899px) {
  :root { --appbar: calc(48px + env(safe-area-inset-top)); }
  .app-bar {
    position: fixed; inset: 0 0 auto 0; z-index: 40;
    display: flex; align-items: center; height: var(--appbar); padding: env(safe-area-inset-top) 16px 0;
    background: color-mix(in oklab, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    box-shadow: 0 1px 0 var(--hair);
  }
  .app-bar a { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; font-weight: 500; letter-spacing: -0.01em; text-decoration: none; }
  .shell { padding-top: var(--appbar); }
  .view, .app { height: calc(100dvh - var(--tabbar) - var(--appbar)); }
}

/* the designer dock floats over the page: the stage keeps exactly the dock's measured height (+ air) free at
   the bottom, on every screen size, so the end of the document can always scroll clear of it */
.stage { padding-bottom: calc(var(--dock-h, 136px) + 40px); }
.designer-dock { margin-top: calc(-1 * var(--dock-h, 136px) - 16px); }

/* phone and tablet: the message box sits right on the tab bar instead of floating over a bare strip */
@media (max-width: 899px) { .app { padding-bottom: 8px; } }

/* app bar: part of the canvas, not a tinted slab. No hard rule; a short fade lets content dissolve under it. */
@media (max-width: 899px) {
  .app-bar {
    background: color-mix(in oklab, var(--bg) 78%, transparent);
    -webkit-backdrop-filter: blur(20px) saturate(140%); backdrop-filter: blur(20px) saturate(140%);
    box-shadow: none;
  }
  .app-bar::after {
    content: ""; position: absolute; inset: 100% 0 auto 0; height: 16px; pointer-events: none;
    background: linear-gradient(var(--bg), transparent); opacity: 0.8;
  }
  .app-bar a { font-size: 14px; letter-spacing: -0.01em; }
  .app-bar .mark { width: 20px; height: 20px; border-radius: 6px; outline: 1px solid rgb(255 255 255 / 0.08); outline-offset: -1px; }
}

/* phone and tablet: the designer box sits close to the tab bar instead of floating over a band of empty page */
@media (max-width: 899px) {
  .designer-dock { bottom: 8px; margin-bottom: 0; }
  .stage { padding-bottom: calc(var(--dock-h, 136px) + 24px); }
  .designer-dock { margin-top: calc(-1 * var(--dock-h, 136px) - 8px); }
}
.doc-snippet:empty { display: none; }

/* ---------- documents: cleanup pass ----------
   one solid button on the page (New); Download steps back to a tonal button, the toolbar loses its divider,
   the bar loses its rule (the stage's own tone already separates them), and the designer dock drops its
   tinted Directions chip and the always-on footer note */
.studio-bar #studio-dl { background: var(--raise); color: var(--ink); box-shadow: none; }
@media (hover: hover) and (pointer: fine) { .studio-bar #studio-dl:hover { background: color-mix(in oklab, var(--raise), var(--ink) 8%); } }
.studio-bar #studio-dl[aria-expanded="true"] { background: color-mix(in oklab, var(--raise), var(--ink) 8%); }
.studio-tools .tools-sep { display: none; }
.studio-bar { box-shadow: none; }
.chip-directions { background: var(--float) !important; box-shadow: 0 0 0 1px var(--float-edge) !important; }
.dd-form .agent-hint { display: none; }
.dd-form .agent-foot { justify-content: space-between; }

/* Upload: a quiet text button beside New, and the library lights up while a file is dragged over it */
.upload-cta { margin-top: 0; }
#lib-upload[aria-busy="true"] svg { animation: upload-pulse 900ms ease-in-out infinite alternate; }
@keyframes upload-pulse { from { opacity: 1; } to { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { #lib-upload[aria-busy="true"] svg { animation: none; opacity: 0.5; } }
.library { transition: background-color 160ms ease-out; }
.library[data-drop="true"] { background: color-mix(in oklab, var(--accent) 6%, transparent); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 40%, transparent); }
.template-cta[hidden] { display: none; }

/* Correct: Try again after a failed check */
.reading-retry { font-size: inherit; margin-left: 4px; }

/* designer chips, cleaned: one quiet row, no outlines or per-chip shadows, scrolls sideways instead of wrapping */
.designer-dock .agent-quick { flex-wrap: nowrap; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.designer-dock .agent-quick::-webkit-scrollbar { display: none; }
.designer-dock .agent-quick button,
.designer-dock .agent-quick .chip-directions {
  flex-shrink: 0;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--float), transparent 15%) !important;
  box-shadow: none !important;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.designer-dock .agent-quick .chip-directions { color: var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .designer-dock .agent-quick button:hover { background: color-mix(in oklab, var(--float), var(--ink) 10%) !important; color: var(--ink); }
}
html[data-booting] body { visibility: hidden; }

/* account: an avatar row under Voices, the same avatar in the phone header, and the Account dialog */
.avatar { display: inline-grid; place-items: center; flex-shrink: 0; width: 24px; height: 24px; border-radius: 999px; background: color-mix(in oklab, var(--mark) 18%, var(--surface)); color: var(--mark); font-size: 12px; font-weight: 500; line-height: 1; }
.avatar-lg { width: 40px; height: 40px; font-size: 16px; }
.account-btn { display: flex; align-items: center; gap: 12px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; border-radius: 10px; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.account-btn-side { width: 100%; height: 44px; margin-top: 8px; padding: 0 16px; text-align: left; }
.account-email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn-bar { display: none; width: 44px; height: 44px; justify-content: center; margin-left: auto; }
@media (hover: hover) and (pointer: fine) { .account-btn:hover { background: color-mix(in oklab, var(--surface), var(--ink) 6%); color: var(--ink); } }
.account-btn:focus-visible { outline: 2px solid var(--mark); outline-offset: 2px; }
.account-who { display: flex; align-items: center; gap: 12px; }
.account-who span:last-child { display: grid; gap: 2px; min-width: 0; }
.account-who b { color: var(--ink); font-weight: 500; }
.account-who small { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.account-section { display: grid; gap: 8px; margin-top: 24px; }
.account-section h3 { margin: 0 0 4px; font-size: 14px; font-weight: 500; }
.account-section p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.account-section label { font-size: 12px; font-weight: 500; color: var(--muted); }
.account-section input { width: 100%; height: 40px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--soft); color: var(--ink); font: inherit; font-size: 14px; outline: 0; }
.account-section input:focus { box-shadow: 0 0 0 1px var(--faint); }
.account-section .btn-small, .account-section .btn-danger { justify-self: start; margin-top: 4px; }
.account-status:empty { display: none; }
.account-row { display: flex; flex-wrap: wrap; gap: 8px; }
.account-danger h3 { color: var(--mark); }
#account-dialog .dialog-inner { max-height: min(88dvh, 720px); overflow-y: auto; }
@media (max-width: 899px) {
  .account-btn-side { display: none; }
  .account-btn-bar { display: flex; margin-right: -12px; }
}
.account-btn[hidden] { display: none !important; }
