/* Design tokens. Every color goes through these so dark mode is one override. */
:root {
  color-scheme: light;
  --bg: #f7f6f2;
  --glow: transparent;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --fg: #1a1814;
  --muted: #6b665c;
  --border: #e5e1d8;
  --border-strong: #d3cec2;
  --accent: #c2410c;
  --accent-hover: #a8380a;
  --accent-fg: #ffffff;
  --accent-soft: rgb(194 65 12 / .09);
  --grad: linear-gradient(var(--accent), var(--accent));
  --live: #15803d;
  --warn: #b45309;
  --idle: #a39e94;
  --danger: #b42318;
  --danger-soft: rgb(180 35 24 / .08);
  --shadow-sm: 0 1px 2px rgb(26 24 20 / .06);
  --shadow: 0 1px 2px rgb(26 24 20 / .05), 0 8px 24px -14px rgb(26 24 20 / .18);
  --serif: "Iowan Old Style", Charter, "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --text-size: 16px;
  --radius: 14px;
  --radius-sm: 10px;
}

/* Dark tokens; js/theme.js sets data-theme from the saved choice or the system. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #090c0a;
    --glow: transparent;
    --surface: #101512;
    --surface-2: #161d19;
    --fg: #e4eae6;
    --muted: #8d9a92;
    --border: #1d2822;
    --border-strong: #2a3830;
    --accent: #34c77b;
    --accent-hover: #52dc93;
    --accent-fg: #03140a;
    --accent-soft: rgb(52 199 123 / .13);
    --grad: linear-gradient(var(--accent), var(--accent));
    --live: #a3e635;
    --warn: #fbbf24;
    --idle: #6f6a62;
    --danger: #f87171;
    --danger-soft: rgb(248 113 113 / .1);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 32px -16px rgb(0 0 0 / .7);
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(1100px 520px at 50% -260px, var(--glow), transparent 70%) no-repeat, var(--bg);
  color: var(--fg);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.end { margin-left: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- controls ---------- */

button, input { font: inherit; color: inherit; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .08s;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }

button.primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: 0 1px 2px rgb(0 0 0 / .12), inset 0 1px 0 rgb(255 255 255 / .16);
}
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
button.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--fg); }
button.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
button.big { height: 50px; padding: 0 26px; font-size: 16px; border-radius: 12px; }
button.linkish {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--accent);
  font-size: inherit;
}
button.linkish:hover:not(:disabled) { background: none; text-decoration: underline; }

input:not([type]) {
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
input:not([type]):focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="range"] { width: 88px; margin: 0; accent-color: var(--accent); }

/* Checkbox drawn as a switch. */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input {
  appearance: none;
  position: relative;
  width: 30px;
  height: 18px;
  margin: 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color .2s;
}
.switch input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / .25);
  transition: transform .2s;
}
.switch input:checked { background: var(--accent); }
.switch input:checked::before { transform: translateX(12px); }

.size { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; }
.size .a-sm { font-size: 11px; }
.size .a-lg { font-size: 16px; }

/* ---------- shared pieces ---------- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-right: 4px;
  color: inherit;
  text-decoration: none;
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -.015em;
}
.logo { width: 28px; height: 28px; flex: none; border-radius: 8px; }
:root[data-theme="dark"] .logo { box-shadow: 0 0 0 1px var(--border-strong); }
:root[data-theme="dark"] .logo .caret { stroke: var(--accent); }

.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
}
.pill .icon { width: 14px; height: 14px; color: var(--muted); }
.pill:empty, .pill:has(#viewer-count:empty) { display: none; }

.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.status[data-state="live"] { border-color: color-mix(in srgb, var(--live) 35%, var(--border)); }
.status[data-state="live"]::before { background: var(--live); animation: pulse 2s ease-out infinite; }
.status[data-state="waiting"]::before { background: var(--warn); }
.status[data-state="ended"]::before { background: var(--danger); }

.writer { border-color: transparent; background: var(--accent-soft); box-shadow: none; color: var(--accent); }
.writer::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: breathe 1.6s ease-in-out infinite; }

.notice {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}

#requests li::before, .banner::before {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  box-shadow: 0 12px 32px -8px rgb(0 0 0 / .35);
  font-size: 14px;
  font-weight: 500;
  transform: translateX(-50%);
  animation: toast-in .25s cubic-bezier(.2, .8, .2, 1);
}

.spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ---------- document card (host editor, viewer text) ---------- */

.doc { display: flex; flex-direction: column; min-height: 0; overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.doc:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
}

.doc-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  min-height: 50px;
  padding: 9px 12px 9px 18px;
  border-bottom: 1px solid var(--border);
}
.doc-title { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.doc-title .icon { color: var(--accent); }

.text {
  flex: 1;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 20px 24px;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: var(--text-size)/1.7 var(--sans);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
  resize: none;
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.text[contenteditable="false"] { color: var(--muted); cursor: default; }
/* Highlights are light colours: keep highlighted text dark in both themes. A picked font colour is inline and still wins. */
.text [style*="background-color"]:not([style*="transparent"]) { color: #1a1814; }
.text[data-placeholder]:empty::before { content: attr(data-placeholder); color: var(--muted); opacity: .7; }
.text.live:empty::before { content: "Nothing yet. Text appears here as it's typed."; color: var(--muted); font: 15px var(--sans); }

/* A blinking caret after the live text while the session is connected. */
.text.live::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.15em;
  margin-left: 1px;
  border-radius: 1px;
  background: var(--accent);
  vertical-align: -.2em;
  visibility: hidden;
}
body:has(#status[data-state="live"]) .text.live::after { visibility: visible; animation: blink 1.1s step-end infinite; }

/* ---------- formatting toolbar ---------- */

.toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.tool-group { display: inline-flex; flex-wrap: nowrap; align-items: center; gap: 2px; }
.tool-group + .tool-group { padding-left: 12px; border-left: 1px solid var(--border); }
.tool {
  gap: 0;
  height: 32px;
  min-width: 32px;
  padding: 0 7px;
  border-color: transparent;
  border-radius: 7px;
  background: transparent;
  box-shadow: none;
  font-size: 14px;
  font-weight: 500;
}
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.tool sup, .tool sub { font-size: .62em; line-height: 0; }
.tool sub { vertical-align: -.3em; }
.tool sup { vertical-align: .55em; }
.tool:hover:not(:disabled):not([aria-pressed="true"]) { background: var(--surface); }
/* Dropdowns: one look everywhere. The arrow is drawn with gradients (the CSP
   blocks data: images). Browsers with customizable <select> also get a styled
   list; others keep their native list. select.tool beats the .tool reset. */
select, select.tool {
  appearance: none;
  height: 34px;
  padding: 0 28px 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 15px) 50% / 5px 5px no-repeat,
    linear-gradient(-45deg, transparent 50%, var(--muted) 50%) calc(100% - 10px) 50% / 5px 5px no-repeat,
    var(--surface);
  color: var(--fg);
  font: 500 13px var(--sans);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
select:hover:not(:disabled), select.tool:hover:not(:disabled) { border-color: var(--muted); }
select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.tool { max-width: 132px; height: 32px; }
.toolbar select.tool { padding-left: 9px; padding-right: 26px; }
@supports (appearance: base-select) {
  select, ::picker(select) { appearance: base-select; }
  select { display: inline-flex; align-items: center; }
  select::picker-icon { display: none; }
  ::picker(select) {
    margin-top: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
    max-height: min(360px, 70dvh);
  }
  option { padding: 7px 10px; border-radius: 6px; font-size: 13px; color: var(--fg); }
  option:hover, option:focus-visible { background: var(--surface-2); outline: none; }
  option:checked { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  option::checkmark { display: none; }
}
.mark-fg, .mark-hl { padding: 0 2px; border-bottom: 3px solid var(--swatch); line-height: 1.1; }
.tool-caret { position: relative; width: 18px; min-width: 18px; margin-left: -2px; padding: 0; font-size: 15px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.tool-caret:hover { color: var(--fg); }
.tool-color { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.tool-caret:has(:disabled) { opacity: .45; cursor: default; }
.toolbar :disabled { opacity: .45; cursor: default; }


/* Dark mode toggle: show the moon in light mode, the sun in dark mode. */
.theme-toggle { width: 34px; padding: 0; }
.writer:empty + .theme-toggle { margin-left: auto; }
.theme-toggle .sun, [data-theme="dark"] .theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }

/* Download menu */
.download { position: relative; }
.toolbar > .download { margin-left: auto; align-self: center; }
.download > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); font-size: 13px; font-weight: 550; }
.download > summary::-webkit-details-marker { display: none; }
.download .menu { position: absolute; right: 0; top: 36px; z-index: 5; display: grid; gap: 2px; padding: 4px; min-width: 150px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.download .menu button { justify-content: flex-start; border: 0; box-shadow: none; background: none; }

/* Download as PDF prints only the document. */
@media print {
  body > *:not(main), .doc-head, .toolbar, .share, .requests, .watching, #writer-banner { display: none !important; }
  main, .doc, .text:not([hidden]) { display: block !important; overflow: visible !important; height: auto !important; border: 0 !important; box-shadow: none !important; }
  .text { color: #000 !important; background: #fff !important; }
  .text.live::after { display: none; }
}

/* ---------- app pages ---------- */

body.app {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100dvh;
  padding: 14px 20px 20px;
}

/* Host: document on the left, share link and requests on the right. */
.host-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "doc share" "doc requests" "doc watching";
  gap: 14px;
}
.host-main > .doc { grid-area: doc; }

.share { grid-area: share; display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.share label { font-size: 14px; font-weight: 600; }
.share-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.info { position: relative; }
.info > summary {
  list-style: none; cursor: pointer; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong);
  color: var(--muted); font: italic 600 12px/1 var(--serif);
}
.info > summary::-webkit-details-marker { display: none; }
.info > summary:hover, .info[open] > summary { color: var(--fg); border-color: var(--muted); }
.info > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.info-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 240px;
  padding: 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); box-shadow: 0 10px 30px rgb(0 0 0 / .25);
  font-size: 13px; color: var(--muted); display: grid; gap: 8px; justify-items: start;
}
.info-pop p { margin: 0; line-height: 1.45; }
/* One box: the link with the copy button inside it. */
.copy-row { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.copy-row:focus-within { border-color: var(--border-strong); }
.copy-row input { flex: 1; min-width: 0; border: 0; background: transparent; box-shadow: none; outline: none; color: var(--muted); font: 13px var(--mono); }
.copy-row .icon-btn {
  width: 34px; height: 34px; min-height: 0; padding: 0; justify-content: center; flex: none; border-radius: 7px;
  background: transparent; border: 0; box-shadow: none; color: var(--accent);
}
.copy-row .icon-btn:hover { background: var(--border); color: var(--accent); transform: none; }
.hint { display: flex; gap: 8px; margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.hint .icon { width: 14px; height: 14px; margin-top: 2px; }

.requests {
  grid-area: requests;
  align-self: start;
  display: flex;
  flex-direction: column;
  max-height: 46dvh;
  min-height: 0;
  padding: 16px;
}
.requests h2, .watching h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.count:empty { display: none; }
.count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 12px;
}
.requests ul {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
  scrollbar-width: thin;
}
#requests li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  animation: rise .25s ease-out;
}
#requests li::before { content: attr(data-initial); }

/* Host: who is watching, with raised hands and the pen. */
.watching { grid-area: watching; display: flex; flex-direction: column; min-height: 0; padding: 16px; }
.muted-count { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
#watchers { display: flex; flex-direction: column; gap: 2px; min-height: 0; margin: 0; padding: 0; list-style: none; overflow: auto; scrollbar-width: thin; }
#watchers li { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 8px; font-size: 14px; animation: rise .25s ease-out; }
#watchers li::before { content: attr(data-initial); display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
#watchers li > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { flex: none; padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font-size: 12px; }
.tag-pen { border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#requests li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.empty {
  margin: 0;
  padding: 4px 0;
  color: var(--muted);
  font-size: 13px;
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-soft);
  font-size: 14px;
  animation: rise .25s ease-out;
}
.banner::before { content: attr(data-initial); }
.banner > span { flex: 1; min-width: 0; }

/* Viewer: the request controls sit centered under the document. */
main.doc { flex: 1; }
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.controls form { flex: 1; max-width: 480px; }
.controls form input { flex: 1; min-width: 140px; }
.denied { margin: 0; color: var(--danger); font-size: 13px; font-weight: 500; }

/* ---------- reactions and questions ---------- */

.requests { overflow: auto; scrollbar-width: thin; }
.requests h2.sub { margin-top: 20px; }
.hands { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 13px; font-weight: 550; }
.hands .linkish { margin-left: auto; }

.questions { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.questions li {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13.5px;
  animation: rise .25s ease-out;
}
.questions li.answered { border-color: var(--accent-soft); }
.q-name { color: var(--muted); font-size: 12px; font-weight: 600; }
.q-text { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.q-answer, .q-wait { margin: 6px 0 0; padding-left: 10px; border-left: 2px solid var(--accent); overflow-wrap: anywhere; }
.q-wait { border-color: var(--border-strong); color: var(--muted); font-size: 12.5px; }
.q-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.q-actions input { flex: 1; min-width: 0; }
.q-actions .dismiss { width: 30px; padding: 0; font-size: 16px; color: var(--muted); }

.interact { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 12px 14px; min-width: 0; }
.audience-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.reactions {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}
.emoji {
  width: 36px; height: 36px; padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 19px; line-height: 1;
  transition: transform .12s, background .12s;
}
.emoji:hover:not(:disabled) { transform: scale(1.18); background: var(--surface); }
.emoji:active:not(:disabled) { transform: scale(.95); }
.hand-btn, .audience-row #request-btn { height: 44px; border-radius: 999px; }
.view-main .audience-row #request-btn { height: 40px; }
.name-field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.name-field input { font-weight: 400; }
.name-field small { font-weight: 400; color: var(--muted); margin-left: 4px; }
.panel-title { margin: 4px 0 0; font-size: 14px; font-weight: 600; }
/* Viewer doc header: icon buttons, like the host toolbar. */
.doc-head .icon-only, .doc-head .download > summary { width: 34px; height: 34px; padding: 0; justify-content: center; }
.doc-head .icon-only .label { display: none; }
.hand-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.audience-row .controls { flex: 1; justify-content: flex-end; }
.ask-form { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.ask-form #ask-text { flex: 1; min-width: 180px; }
.interact .questions { max-height: 22vh; overflow: auto; scrollbar-width: thin; }
.interact .questions:empty { display: none; }

.float-emoji {
  position: fixed;
  right: calc(24px + var(--x, 0px));
  bottom: 24px;
  z-index: 50;
  font-size: 30px;
  pointer-events: none;
  animation: float-up 2.4s ease-out forwards;
}
@keyframes float-up {
  0% { opacity: 0; transform: translateY(0) scale(.6); }
  15% { opacity: 1; transform: translateY(-30px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-260px) scale(1); }
}

@media print { .interact, .float-emoji { display: none !important; } }

/* Viewer: document on the left, audience panel (react, write, ask) on the right. */
.view-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
}
.view-main > .doc { min-height: 0; }
.view-main > .interact { align-self: stretch; min-height: 0; overflow: auto; scrollbar-width: thin; }
.view-main .audience-row .controls { flex: 1 1 100%; justify-content: stretch; }
.view-main .audience-row #request-btn, .view-main .audience-row #stop-writing { flex: 1; }
.view-main .hand-btn { flex: 1; height: 40px; }
.view-main .reactions { flex: 1 1 100%; justify-content: space-between; }
.view-main .ask-form #ask-text { flex: 1 1 100%; width: auto; }
.view-main .ask-form button { flex: 1; }
.view-main .interact .questions { max-height: none; }
@media (max-width: 900px) {
  .view-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(320px, 1fr) auto; overflow: auto; }
  .view-main > .interact { overflow: visible; }
}

/* ---------- replay ---------- */

.tool-actions { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.tool-actions #replay-btn, .tool-actions .download > summary { width: 32px; height: 32px; padding: 0; justify-content: center; }
.tool-actions #replay-btn .label { display: none; }
.tool-actions .download .menu { right: 0; left: auto; }
.replay {
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 16px;
  background: var(--surface);
  color: var(--fg);
}
.replay[open] { display: flex; flex-direction: column; gap: 12px; }
.replay::backdrop { background: rgb(0 0 0 / .6); }
.replay-head { display: flex; align-items: center; gap: 10px; }
.replay-head h2 { margin: 0; font-size: 16px; }
.replay-close { margin-left: auto; }
.replay-text {
  min-height: 200px;
  max-height: 55dvh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.replay-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.replay-controls button { min-width: 38px; }
.replay-seek { flex: 1; min-width: 160px; accent-color: var(--accent); }
.replay-time { min-width: 84px; color: var(--muted); font: 12.5px var(--mono); text-align: center; }
.replay-note { margin: 0; color: var(--muted); font-size: 12px; }
@media print { .replay { display: none !important; } }

/* ---------- landing ---------- */

.home { display: flex; flex-direction: column; }
.top { width: 100%; max-width: 1080px; margin: 0 auto; padding: 18px 24px; }
.hero { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 56px 24px 40px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 56px; align-items: center; }
.kicker { margin: 0 0 18px; color: var(--accent); font: 600 13px var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.hero h1 { margin: 0; font: 600 clamp(2.4rem, 6vw, 3.9rem)/1.04 var(--serif); letter-spacing: -.02em; text-wrap: balance; }
.hero h1 em { color: var(--accent); font-style: italic; }
.lead { max-width: 30em; margin: 22px 0 30px; color: var(--muted); font-size: 1.12rem; line-height: 1.6; text-wrap: pretty; }
.cta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.cta p { margin: 0; }
.cta #error { flex-basis: 100%; }
#start .icon { transition: transform .2s; }
#start:hover:not(:disabled) .icon { transform: translateX(3px); }

/* product preview: a session window with code typing, a reaction and a question */
.demo { position: relative; overflow: visible; }
.demo .doc-head { padding-left: 16px; }
.dots { display: inline-flex; gap: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.demo-text { margin: 0; padding: 22px 24px 30px; font: 14.5px/1.85 var(--mono); }
.demo-text span { display: block; box-sizing: content-box; width: 0; overflow: hidden; white-space: pre; border-right: 2px solid transparent; }
.demo-text b { color: var(--tok-k, var(--accent)); font-weight: 600; }
.demo-text i { color: var(--tok-s, var(--live)); font-style: normal; }
.demo-text .l1 { --w: 22ch; animation: type 1.1s steps(22) .5s forwards, caret 1.1s .5s; }
.demo-text .l2 { --w: 26ch; animation: type 1.2s steps(26) 1.8s forwards, caret 1.2s 1.8s; }
.demo-text .l3 { --w: 1ch; animation: type .1s steps(1) 3.2s forwards, caret-blink 1.1s step-end 3.3s infinite; }
.demo-ask, .demo-react { position: absolute; animation: appear .4s ease-out backwards; }
.demo-ask { right: -18px; bottom: -26px; max-width: 250px; padding: 12px 14px; font-size: 13.5px; animation-delay: 3.8s; }
.demo-ask small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 12px; }
.demo-react { right: 26px; top: 56px; font-size: 22px; animation-delay: 2.6s; }

.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin: 96px 0 0; padding: 28px 0 0; border-top: 1px solid var(--border); list-style: none; counter-reset: step; }
.steps li { counter-increment: step; }
.steps li::before { content: "0" counter(step); display: block; margin-bottom: 10px; color: var(--accent); font: 600 13px var(--mono); }
.steps strong { display: block; margin-bottom: 4px; font: 600 1.15rem var(--serif); }
.steps span { color: var(--muted); font-size: 14.5px; }
.uses { margin: 40px 0 0; color: var(--muted); font-size: 14.5px; }
.uses strong { color: var(--fg); font-weight: 600; }

.foot { width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 24px; color: var(--muted); font-size: 13px; }

/* ---------- motion ---------- */

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 6px transparent; }
}
@keyframes breathe { 50% { opacity: .35; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes appear { from { opacity: 0; transform: translateY(8px); } }
@keyframes type { to { width: var(--w); } }
@keyframes caret { from, to { border-color: var(--accent); } }
@keyframes caret-blink { 0% { border-color: var(--accent); } 50% { border-color: transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .demo-text span { width: var(--w); }
  .demo-ask, .demo-react { opacity: 1; }
}

/* ---------- small screens ---------- */

/* The toolbar is one row while it fits; narrower editors wrap it. */
@media (max-width: 1330px) and (min-width: 641px) { .toolbar, .tool-group { flex-wrap: wrap; } }
/* Phones: one row that scrolls sideways instead of four wrapped rows. */
@media (max-width: 640px) { .toolbar { overflow-x: auto; scrollbar-width: none; } .toolbar > * { flex: none; } .toolbar > .tool-group:nth-child(2) { order: 1; } .toolbar > .tool-group:nth-child(2) ~ :not(.tool-group) { order: 2; } .toolbar .download .menu { position: fixed; top: auto; right: 16px; margin-top: 36px; } }


@media (max-width: 720px) {
  .hero { padding-top: 28px; }
  .hero-grid, .steps { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .steps { margin-top: 64px; gap: 24px; }
  .demo-text { padding: 16px 18px 24px; font-size: 12.5px; }
  .demo-ask { right: 8px; bottom: -30px; }
}

@media (max-width: 640px) {
  body.app { gap: 12px; padding: 12px 14px 14px; }
  body.host { height: auto; }
  .host-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas: "share" "doc" "requests" "watching";
  }
  .host-main > .doc { min-height: 55dvh; }
  .requests { max-height: none; }
  .doc-head { gap: 12px; padding-left: 14px; }
  .doc-hint, .size .a-sm, .size .a-lg { display: none; }
  input[type="range"] { width: 72px; }
  .text { padding: 16px 18px; }
}

/* ---------- developer mode: code documents ---------- */
:root { --tok-k: #7c3aed; --tok-s: #15803d; --tok-n: #b45309; --tok-c: #6b7280; --tok-f: #2563eb; --tok-t: #0e7490; }
:root[data-theme="dark"] { --tok-k: #c4b5fd; --tok-s: #86efac; --tok-n: #fcd34d; --tok-c: #8b8b9b; --tok-f: #93c5fd; --tok-t: #67e8f9; }
.tok-k { color: var(--tok-k); font-weight: 600; }
.tok-s { color: var(--tok-s); }
.tok-n { color: var(--tok-n); }
.tok-c { color: var(--tok-c); font-style: italic; }
.tok-f { color: var(--tok-f); }
.tok-t { color: var(--tok-t); }
select.tool.mode { font-weight: 600; }
.text.has-code { display: flex; flex-direction: column; padding: 16px; }
/* The code box fills the editor, so there is no second, smaller box inside it. */
.text.has-code > .code { flex: 1 0 auto; display: flex; flex-direction: column; }
.text.has-code .code-body { flex: 1 0 auto; }
.code { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--fg); overflow: hidden; white-space: normal; font: calc(var(--text-size) * .9)/1.6 var(--mono); }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 4px 12px; border-bottom: 1px solid var(--border); font: 600 12px var(--sans); color: var(--muted); }
.code-body { display: flex; overflow-x: auto; scrollbar-width: thin; }
.code-gutter, .code-hl, .code-input { margin: 0; padding: 12px 14px; border: 0; font: inherit; letter-spacing: 0; white-space: pre; tab-size: 4; overflow-wrap: normal; }
.code-gutter { position: sticky; left: 0; z-index: 1; padding-right: 10px; text-align: right; color: var(--muted); background: var(--surface-2); border-right: 1px solid var(--border); user-select: none; }
.code-stack { position: relative; flex: 1 0 auto; }
.code-hl { min-height: 100%; }
.code-input { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; overflow: hidden; background: transparent; color: transparent; caret-color: var(--fg); outline: none; }
.code-input::selection { background: rgb(99 102 241 / .3); color: transparent; }
@media print { .code-head { display: none; } .code { border: 0; background: #fff; } .code-gutter { background: #fff; } }
.text.live:has(.code)::after { display: none; } /* the live cursor would sit below the code box */
.replay-controls select { flex: none; height: 34px; }
.replay-controls :disabled { opacity: .35; }
.replay-writer[hidden] { display: none; }
@media (max-width: 640px) { .toast { top: 16px; bottom: auto; } }
button.end-session { color: var(--danger); margin-right: 6px; }
button.end-session:hover { background: var(--danger-soft); }
.prose { width: 100%; max-width: 680px; margin: 0 auto; padding: 40px 24px 24px; line-height: 1.65; }
.prose h1 { margin: 0 0 12px; }
.prose h2 { margin: 32px 0 8px; font-size: 18px; }
.prose ul { padding-left: 20px; }
.prose li { margin: 6px 0; }
.foot a { color: inherit; }
.foot a:hover { color: var(--accent); }
.why { margin: 72px 0 0; }
.why h2 { margin: 0 0 20px; font: 600 1.6rem var(--serif); }
.why-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.why-grid div { padding: 20px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface, transparent); }
.why-grid strong { display: block; margin-bottom: 6px; font-size: 15px; }
.why-grid span { color: var(--muted); font-size: 14px; line-height: 1.55; }
@media (max-width: 860px) { .why-grid { grid-template-columns: minmax(0, 1fr); } }
.expiry button { margin-left: 8px; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.expiry button:hover { text-decoration: underline; }
.expiry button:disabled { color: var(--muted); cursor: default; text-decoration: none; }
/* Diff checker (/diff) */
.nav-link { margin-right: 10px; color: var(--muted); font-size: 14px; font-weight: 550; text-decoration: none; }
.nav-link:hover { color: var(--fg); }
.diff-main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 24px 8px; }
.diff-intro h1 { margin: 0 0 6px; font-family: var(--serif); font-size: clamp(28px, 4vw, 40px); font-weight: 600; }
.diff-intro p { margin: 0 0 20px; max-width: 70ch; }
.diff-inputs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.diff-side-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; min-height: 32px; }
.diff-side-head label { font-weight: 600; }
.diff-side-head .d-file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diff-side-head button { margin-left: auto; gap: 6px; }
.diff-side-head .icon { width: 15px; height: 15px; }
.diff-input { display: block; width: 100%; height: 260px; min-height: 120px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); font: 13px/1.55 var(--mono); tab-size: 4; resize: vertical; }
.diff-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.diff-input.drop { outline: 2px dashed var(--accent); outline-offset: -4px; background: var(--accent-soft); }
.diff-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 16px 0 12px; padding: 10px 0; background: var(--bg); }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.seg button { height: 30px; border: 0; box-shadow: none; background: none; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--fg); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.diff-stats { display: inline-flex; gap: 10px; font: 600 14px var(--mono); }
.diff-stats .muted { font: 500 13px var(--sans); }
.s-del { color: var(--danger); }
.s-add { color: var(--live); }
.diff-actions { display: inline-flex; gap: 6px; margin-left: auto; }
.diff-out { overflow-x: auto; font: 13px/1.55 var(--mono); }
.d-note { margin: 0; padding: 40px 20px; color: var(--muted); font-family: var(--sans); text-align: center; }
.d-row { display: grid; min-width: 0; }
.diff-out.split .d-row { grid-template-columns: 3.4em minmax(0, 1fr) 3.4em minmax(0, 1fr); }
.diff-out.unified .d-row { grid-template-columns: 3.4em 3.4em 1.6em minmax(0, 1fr); }
.diff-out.split .d-row > :nth-child(3) { border-left: 1px solid var(--border); }
.d-num { padding: 0 8px; color: var(--muted); text-align: right; user-select: none; opacity: .75; }
.d-sign { color: var(--muted); text-align: center; user-select: none; }
.d-text { padding: 0 12px 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.d-text.del, .tdel .d-sign, .tdel .d-num { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.d-text.ins, .tins .d-sign, .tins .d-num { background: color-mix(in srgb, var(--live) 12%, transparent); }
.diff-out.unified .tdel .d-sign { color: var(--danger); }
.diff-out.unified .tins .d-sign { color: var(--live); }
.d-text.del mark { background: color-mix(in srgb, var(--danger) 28%, transparent); color: inherit; border-radius: 3px; }
.d-text.ins mark { background: color-mix(in srgb, var(--live) 32%, transparent); color: inherit; border-radius: 3px; }
.d-blank { background: repeating-linear-gradient(-45deg, transparent 0 6px, var(--surface-2) 6px 12px); }
.d-fold { display: block; width: 100%; height: auto; padding: 6px 12px; border: 0; border-block: 1px solid var(--border); border-radius: 0; box-shadow: none; background: var(--surface-2); color: var(--muted); font: 500 12.5px var(--sans); text-align: left; }
.d-fold:hover:not(:disabled) { color: var(--fg); }
.d-fold:first-child { border-top: 0; }
.d-fold:last-child { border-bottom: 0; }
.d-row.flash { animation: d-flash 1.2s ease-out; }
@keyframes d-flash { from { box-shadow: inset 3px 0 0 var(--accent), 0 0 0 2px var(--accent-soft); } to { box-shadow: none; } }
.diff-about { padding-top: 24px; max-width: 760px; margin: 0; }
.tok-add { color: var(--live); }
.tok-del { color: var(--danger); }
@media (max-width: 760px) {
  .diff-main { padding: 16px 16px 8px; }
  .diff-inputs { grid-template-columns: minmax(0, 1fr); }
  .diff-input { height: 180px; }
  .diff-actions { margin-left: 0; width: 100%; }
  .diff-actions #discuss { margin-left: auto; }
  .diff-out.split .d-row { grid-template-columns: 2.6em minmax(0, 1fr) 2.6em minmax(0, 1fr); }
  .diff-out.unified .d-row { grid-template-columns: 2.8em 2.8em 1.2em minmax(0, 1fr); }
  .nav-link { display: none; }
}

/* Line numbers beside the diff inputs */
.diff-ed { position: relative; overflow: hidden; border-radius: var(--radius-sm); }
.diff-ed .diff-input { padding-left: 58px; }
.diff-gut { position: absolute; top: 1px; left: 1px; margin: 0; padding: 12px 10px 12px 0; width: 44px; text-align: right; font: 13px/1.55 var(--mono); color: var(--muted); z-index: 2; pointer-events: none; user-select: none; }
.diff-ed::before { content: ''; position: absolute; top: 1px; bottom: 1px; left: 1px; width: 46px; border-right: 1px solid var(--border); background: var(--surface); z-index: 1; pointer-events: none; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }

/* Diff checker: options row, merge arrows, no-wrap, print */
.diff-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: -4px 0 12px; font-size: 14px; }
.opt { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.opt select, .opt input { height: 30px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); font: inherit; }
.opt-ignore input { width: 220px; font-family: var(--mono); font-size: 12.5px; }
.d-row { position: relative; }
.d-merge { position: absolute; top: 0; z-index: 1; display: none; gap: 2px; }
.diff-out.split .d-merge { left: 50%; transform: translateX(-50%); }
.diff-out.unified .d-merge { right: 6px; }
.d-row:hover .d-merge, .d-merge:focus-within { display: inline-flex; }
.d-merge button { height: 20px; min-width: 24px; padding: 0 5px; font-size: 12px; line-height: 1; }
@media (hover: none) { .d-merge { display: inline-flex; } }
.diff-out.nowrap .d-text { white-space: pre; overflow-wrap: normal; }
.diff-out.nowrap.split .d-row { grid-template-columns: 3.4em minmax(var(--wl), 1fr) 3.4em minmax(var(--wr), 1fr); }
.diff-out.nowrap.unified .d-row { grid-template-columns: 3.4em 3.4em 1.6em minmax(var(--wu), 1fr); }
.diff-out.nowrap .d-row, .diff-out.nowrap .d-fold { width: max-content; min-width: 100%; }
@media print {
  header.top, .diff-intro, .diff-inputs, .diff-bar, .diff-opts, .diff-about, .foot, .toast, .d-merge { display: none !important; }
  .diff-main { padding: 0; max-width: none; }
  .diff-out { overflow: visible; box-shadow: none; border: 0; }
  .diff-out * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .d-row { break-inside: avoid; }
}
@media (max-width: 760px) { .opt-ignore, .opt-ignore input { width: 100%; } .opt-ignore input { flex: 1; } }

/* Merge conflicts: marker lines, sides, and the resolve bar */
.tok-cm { color: var(--accent); font-weight: 700; background: var(--accent-soft); }
.cf-ours { background: color-mix(in srgb, var(--live) 12%, transparent); }
.cf-theirs { background: color-mix(in srgb, #2563eb 12%, transparent); }
.cf-base { opacity: .6; }
.cf-msg { font-weight: 600; }
.cf-nav, .cf-acts { display: inline-flex; gap: 6px; }
.cf-acts { margin-left: auto; flex-wrap: wrap; }
@media (max-width: 760px) { .cf-acts { margin-left: 0; width: 100%; } .cf-acts button { flex: 1; } }

.d-open { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; margin-left: auto; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--fg); cursor: pointer; }
.d-open:hover { border-color: var(--muted); color: var(--accent); }
.d-open .icon { width: 16px; height: 16px; margin: 0; }
.diff-title { display: flex; align-items: center; gap: 12px; }
.diff-help > summary { width: 26px; height: 26px; font-size: 14px; }
.diff-help .info-pop { left: 0; right: auto; width: min(460px, calc(100vw - 32px)); padding: 14px 16px; font-size: 14px; color: var(--fg); }
.diff-help .info-pop ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; line-height: 1.5; color: var(--muted); }
.diff-help .info-pop b { color: var(--fg); }
.diff-title { position: relative; } .diff-title .diff-help { position: static; }
.d-open { position: relative; }
.d-open::after { content: attr(data-tip); position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 10; padding: 6px 10px; border-radius: 8px; background: var(--fg); color: var(--bg); font-size: 12px; font-weight: 550; white-space: nowrap; pointer-events: none; opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; }
.d-open:hover::after, .d-open:focus-visible::after { opacity: 1; transform: none; }

/* ---- Tools (4.4.0) ---- */
.tl, .tl-index { width: 100%; max-width: 1180px; margin: 0 auto; padding: 8px 24px 40px; }
.tl { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start; }
.tl-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; padding-top: 12px; }
.tl-group { margin: 14px 0 4px; padding: 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tl-group:first-child { margin-top: 0; }
.tl-side a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--fg); text-decoration: none; font-size: 14px; }
.tl-side a:hover { background: var(--surface-2); }
.tl-side a.on { background: var(--surface-2); color: var(--accent); font-weight: 600; }
.tl-side svg { width: 16px; height: 16px; flex: none; }
.tl-ico { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: none; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--accent); }
.tl-ico svg { width: 18px; height: 18px; }
.tl-main { min-width: 0; padding-top: 12px; }
.tl-crumb { font-size: 13px; color: var(--muted); }
.tl-crumb a { color: var(--muted); }
.tl-title { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.tl-title h1 { margin: 0; }
.tl-blurb { margin: 6px 0 0; }
.tl-bar { margin: 12px 0; }
.tl-grow { flex: 1; }
.tl-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tl-box { margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; min-width: 0; }
.tl-box-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding: 4px 8px 4px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tl-box-title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tl-box-right { display: inline-flex; align-items: center; gap: 8px; }
.tl-input { display: block; width: 100%; min-height: 120px; padding: 12px 14px; border: 0; resize: vertical; background: var(--surface); color: var(--fg); font: 13px/1.55 var(--mono); outline: none; }
.tl-input.expired { color: var(--muted); }
.tl-out { min-height: 120px; max-height: 70vh; overflow: auto; }
.tl-out pre, .tl-pre { margin: 0; padding: 12px 14px; font: 13px/1.55 var(--mono); white-space: pre-wrap; word-break: break-all; }
.tl-empty, .tl-err { margin: 0; padding: 12px 14px; font-size: 14px; }
.tl-err { color: #c0392b; }
.tl-stat.ok { color: var(--live); }
.tl-stat.bad { color: #c0392b; }
.tl-note { margin: -6px 0 16px; font-size: 13px; color: var(--muted); }
.tl-rows { display: flex; flex-direction: column; }
.tl-row { display: grid; grid-template-columns: 160px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; border-top: 1px solid var(--border); }
.tl-row:first-child { border-top: 0; }
.tl-row-label { font-size: 13px; color: var(--muted); }
.tl-row-val code { font: 13px/1.5 var(--mono); word-break: break-all; }
.tl-now { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0 4px; }
.tl-now-item { display: inline-flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.tl-now-val { font: 600 15px var(--mono); }
.tl-field-wrap { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.tl-field { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); font: 14px var(--mono); }
.tl-cards-group { margin-top: 28px; }
.tl-cards-group h2 { margin: 0 0 12px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tl-card { display: flex; flex-direction: column; gap: 6px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s; }
.tl-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.tl-card .tl-ico { margin-bottom: 6px; }
.tl-card span { font-size: 14px; }
.tl-foot { display: block; }
.tl-foot-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 24px; width: 100%; max-width: 1080px; margin: 0 auto; }
.tl-foot-cols b { display: block; margin-bottom: 8px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tl-foot-cols a { display: block; padding: 3px 0; color: var(--fg); text-decoration: none; font-size: 14px; }
.tl-foot-cols a:hover { color: var(--accent); }
@media (max-width: 820px) {
  .tl { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 4px 16px 32px; }
  .tl-index { padding: 4px 16px 32px; }
  .tl-side { position: static; flex-direction: row; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
  .tl-group { display: none; }
  .tl-side a { flex: none; border: 1px solid var(--border); background: var(--surface); }
  .tl-two { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .tl-row { grid-template-columns: minmax(0, 1fr) auto; }
  .tl-row-label { grid-column: 1 / -1; }
}
.tl-out .code { margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.tl-out .code-head { display: none; }
.home-tools { margin-top: 56px; padding-top: 40px; border-top: 1px solid var(--border); }
.home-tools-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.home-tools-head h2 { margin: 0; font-family: var(--serif); font-weight: 500; }
.home-tools > p { margin: 8px 0 20px; }
.home-tools-head a { color: var(--accent); text-decoration: none; font-weight: 600; }
