/* Docly: shared styles for the side panel and the printable report.
   Plain CSS, Tailwind-scale spacing (4/8/12/16/24/32). System fonts only, so the
   extension makes no outside requests (Roboto is the system font on Chromebooks). */

:root {
  --primary: #1e52a0;
  --primary-dk: #163d78;
  --primary-lt: #eef3fb;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --soft: #f9fafb;

  --typed: #1e52a0;
  --pasted: #d97706;
  --start: #9ca3af;
  --restored: #7c3aed;

  --pause-sentence: #1e52a0;
  --pause-word: #7fa3d9;
  --pause-mid: #c7d7ee;

  --notice-bg: #fffbeb;
  --notice-bd: #fde68a;
  --notice-tx: #92400e;
  --ok-bg: #f0fdf4;
  --ok-bd: #bbf7d0;
  --ok-tx: #166534;
  --info-bg: #eff6ff;
  --info-bd: #bfdbfe;
  --info-tx: #1e40af;
  --err-bg: #fef2f2;
  --err-bd: #fecaca;
  --err-tx: #991b1b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

h1, h2 { margin: 0; }
p { margin: 0 0 8px; }
b { font-weight: 600; }

.fine { color: var(--muted); font-size: 12px; }
.fine:last-child { margin-bottom: 0; }

/* ---------- Side panel shell ---------- */

.hdr {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--primary); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--primary-lt); color: var(--primary); }

.wrap { padding: 12px; }

.ctx {
  margin-bottom: 12px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.ctx-label { display: block; color: var(--muted); font-size: 12px; }
.ctx-title { display: block; font-weight: 600; word-break: break-word; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { width: 100%; padding: 12px 16px; background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); border-color: var(--primary-dk); color: #fff; }
.btn-sm { width: auto; padding: 4px 12px; font-size: 12px; }

.progress { margin: 12px 0; }
.progress-track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--primary); transition: width 0.2s; }
.progress-fill.indeterminate { width: 32%; animation: docly-slide 1.2s ease-in-out infinite; }
@keyframes docly-slide { 0% { margin-left: -32%; } 100% { margin-left: 100%; } }
.progress .fine { margin-top: 4px; }

.alert {
  margin: 12px 0;
  padding: 12px 16px;
  background: var(--err-bg);
  border: 1px solid var(--err-bd);
  border-radius: 8px;
  color: var(--err-tx);
}

#facts { margin-top: 12px; }

.actions { display: flex; gap: 8px; margin: 12px 0; }
.actions .btn { flex: 1; }

.diag { margin: 12px 0; font-size: 12px; color: var(--muted); }
.diag summary { cursor: pointer; }
.diag pre {
  margin: 8px 0;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

.foot { margin-top: 16px; text-align: center; }

/* ---------- Settings ---------- */

.settings .field { display: grid; grid-template-columns: 1fr 72px; align-items: center; gap: 4px 8px; margin-bottom: 12px; }
.settings .field span { font-weight: 600; }
.settings .field small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.settings input {
  width: 72px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  text-align: right;
}
.settings .row { display: flex; gap: 8px; }

/* ---------- Cards ---------- */

.card {
  margin-bottom: 12px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.count {
  padding: 0 8px;
  background: var(--primary-lt);
  border-radius: 8px;
  color: var(--primary);
  letter-spacing: 0;
}

/* Composition */
.headline { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.big { font-size: 32px; font-weight: 700; line-height: 1; color: var(--primary); }
.big-label { color: var(--muted); }
.compbar { display: flex; height: 16px; margin-bottom: 8px; background: var(--line); border-radius: 8px; overflow: hidden; }
.seg { height: 100%; }
.seg-typed, .sw-typed { background: var(--typed); }
.seg-pasted, .sw-pasted { background: var(--pasted); }
.seg-start, .sw-start { background: var(--start); }
.seg-restored, .sw-restored { background: var(--restored); }
.seg-empty { background: var(--line); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 8px; padding: 0; list-style: none; font-size: 12px; }
.legend li { display: inline-flex; align-items: center; gap: 4px; }
.legend-sm { margin-top: 8px; color: var(--muted); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; flex: none; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-paste { background: var(--pasted); }
.dot-start { background: var(--start); border-radius: 0; }
.dot-restore { background: var(--restored); transform: rotate(45deg); border-radius: 0; }
.ln { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--primary); }
.ln-break { border-top: 2px dashed #9ca3af; }

/* Flags */
.flags { margin: 0; padding: 0; list-style: none; }
.flag { margin-bottom: 8px; padding: 8px 12px; border: 1px solid; border-radius: 8px; }
.flag:last-child { margin-bottom: 0; }
.flag-notice { background: var(--notice-bg); border-color: var(--notice-bd); color: var(--notice-tx); }
.flag-info { background: var(--info-bg); border-color: var(--info-bd); color: var(--info-tx); }
.flag-ok { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-tx); }
.flag-warn { background: var(--err-bg); border-color: var(--err-bd); color: var(--err-tx); }

/* Key facts */
.facts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fact { padding: 8px 12px; background: var(--soft); border-radius: 8px; }
.fact .lab { color: var(--muted); font-size: 12px; }
.fact .val { font-size: 16px; font-weight: 700; }
.fact .sub { color: var(--muted); font-size: 12px; }

/* Chart */
.chart { display: block; width: 100%; height: auto; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-area { fill: var(--primary-lt); }
.ch-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; }
.ch-break { stroke: #9ca3af; stroke-width: 1; stroke-dasharray: 4 4; }
.ch-lab { fill: var(--muted); font-size: 10px; }
.mk-paste { fill: var(--pasted); stroke: #fff; stroke-width: 2; }
.mk-start { fill: var(--start); stroke: #fff; stroke-width: 2; }
.mk-restore { fill: var(--restored); stroke: #fff; stroke-width: 2; }

/* Pastes */
.pastes { margin: 0 0 8px; padding: 0; list-style: none; }
.paste { padding: 12px 0; border-top: 1px solid var(--line); }
.paste:first-child { padding-top: 0; border-top: 0; }
.paste-hd { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.paste-hd .size { margin-left: auto; font-weight: 600; }
.paste-hd .when { color: var(--muted); font-size: 12px; }
.paste-meta { margin-top: 4px; color: var(--muted); font-size: 12px; }
.tag { padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.tag-paste { background: var(--notice-bg); color: var(--notice-tx); }
.tag-start { background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.tag-restore { background: #f5f3ff; color: #5b21b6; }
.paste blockquote {
  margin: 8px 0 0;
  padding: 8px 12px;
  background: var(--soft);
  border-left: 4px solid var(--pasted);
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  word-break: break-word;
}
.paste-start blockquote { border-left-color: var(--start); }
.paste-restore blockquote { border-left-color: var(--restored); }

/* Sessions table */
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { padding: 0 4px 4px; color: var(--muted); font-weight: 600; text-align: left; }
.tbl td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: top; font-size: 14px; }
.tbl td:first-child { color: var(--muted); }

/* Definition list */
.dl { margin: 0; }
.dl-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px solid var(--line); }
.dl-row:first-child { border-top: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 600; text-align: right; }

/* Contributors */
.people { margin: 0; padding: 0; list-style: none; }
.people li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 4px 0; }
.people .sw { border-radius: 50%; }
.people .fine { flex-basis: 100%; padding-left: 20px; }

/* Notes */
.notes { margin: 0; padding-left: 16px; color: var(--muted); font-size: 12px; }
.notes li { margin-bottom: 4px; }

/* In plain words */
.story { margin: 0; line-height: 1.6; }

/* Writing rhythm */
.sub-h { margin: 16px 0 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.pause-sentence { background: var(--pause-sentence); }
.pause-word { background: var(--pause-word); }
.pause-mid { background: var(--pause-mid); }
.card .dl + .fine, .card .legend + .fine { margin-top: 8px; }

/* Final draft by source */
.draft { max-height: 480px; overflow-y: auto; margin: 0 -8px; padding: 0 8px; border-top: 1px solid var(--line); }
.para { border-bottom: 1px solid var(--line); }
.para summary {
  display: block;
  padding: 8px;
  border-radius: 4px;
  line-height: 1.6;
  cursor: pointer;
  list-style: none;
  word-break: break-word;
}
.para summary::-webkit-details-marker { display: none; }
.para summary:hover { background: var(--soft); }
.para[open] summary { background: var(--primary-lt); }
.para-meta { padding: 0 8px 8px; color: var(--muted); font-size: 12px; }
.src-pasted { background: #fef3c7; border-bottom: 2px solid var(--pasted); }
.src-start { color: var(--muted); }
.src-restored { background: #f5f3ff; border-bottom: 2px solid var(--restored); }
.legend .src { padding: 0 4px; border-radius: 2px; }

/* ---------- Help bubbles ("?") ----------
   Native popovers opened by popovertarget (no JavaScript). Each animation loops; its
   resting style is the final frame, which is what reduced-motion users see. */

.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  font: 700 10px/1 system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  text-transform: none;
  letter-spacing: 0;
  vertical-align: 2px;
  cursor: pointer;
}
.help-btn:hover, .help-btn:focus-visible { border-color: var(--primary); background: var(--primary); color: #fff; }

.help-pop {
  width: min(320px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 16px 48px rgba(17, 24, 39, 0.25);
}
.help-pop::backdrop { background: rgba(17, 24, 39, 0.24); }
.help-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.help-hd h3 { margin: 0; font-size: 16px; }
.help-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.help-close:hover { background: var(--soft); color: var(--ink); }
.help-text { margin: 12px 0 0; font-size: 14px; }

/* A help animation shown on its own (documentation site) */
.hx-fig { max-width: 320px; margin: 16px 0; }
.hx-fig .anim { margin-top: 0; }
.hx-fig figcaption { margin-top: 8px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.hx-fig figcaption b { color: var(--ink); }

/* The animation stage: 12px monospace on 20px lines, so text positions can use ch units. */
.anim {
  position: relative;
  height: 104px;
  margin-top: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  color: var(--ink);
  font: 12px/20px ui-monospace, "Cascadia Mono", Consolas, "Roboto Mono", "Noto Sans Mono", monospace;
}
.anim .hx-ln { position: absolute; left: 12px; white-space: pre; }
.anim .hx-l1 { top: 12px; }
.anim .hx-l2 { top: 32px; }
.anim .hx-l3 { top: 52px; }
.anim .hx-ty { display: inline-block; vertical-align: top; overflow: hidden; white-space: pre; }
.anim .hx-caret {
  display: inline-block;
  width: 2px;
  height: 16px;
  margin-top: 2px;
  vertical-align: top;
  background: var(--primary);
  animation: hx-blink 1s steps(1) infinite;
}
.hx-cap { position: absolute; left: 12px; right: 12px; bottom: 8px; color: var(--muted); font: 11px/16px system-ui, "Segoe UI", Roboto, Arial, sans-serif; }
.hx-badge {
  position: absolute;
  padding: 0 8px;
  border: 1px solid var(--notice-bd);
  border-radius: 8px;
  background: var(--notice-bg);
  color: var(--notice-tx);
  font: 600 10px/16px system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  white-space: nowrap;
}
.hx-note { position: absolute; top: 52px; color: var(--muted); font: 600 10px/16px system-ui, "Segoe UI", Roboto, Arial, sans-serif; }
@keyframes hx-blink { 50% { opacity: 0; } }

/* Typing bursts */
.hx-bu-ty { width: 34ch; animation: hx-bu-ty 8s infinite; }
@keyframes hx-bu-ty {
  0% { width: 0; animation-timing-function: steps(10, end); }
  10% { width: 10ch; }
  32% { width: 10ch; animation-timing-function: steps(14, end); }
  46% { width: 24ch; }
  66% { width: 24ch; animation-timing-function: steps(10, end); }
  76%, 100% { width: 34ch; }
}
.hx-bar { position: absolute; top: 38px; height: 8px; border-radius: 4px; background: var(--primary); }
.hx-b1 { left: 12px; width: 9ch; animation: hx-b1 8s infinite; }
.hx-b2 { left: calc(12px + 10ch); width: 13ch; animation: hx-b2 8s infinite; }
.hx-b3 { left: calc(12px + 24ch); width: 10ch; animation: hx-b3 8s infinite; }
@keyframes hx-b1 { 0%, 9% { opacity: 0; } 11%, 100% { opacity: 1; } }
@keyframes hx-b2 { 0%, 45% { opacity: 0; } 47%, 100% { opacity: 1; } }
@keyframes hx-b3 { 0%, 75% { opacity: 0; } 77%, 100% { opacity: 1; } }
.hx-p1 { left: calc(12px + 6ch); animation: hx-p1 8s infinite; }
.hx-p2 { left: calc(12px + 20ch); animation: hx-p2 8s infinite; }
@keyframes hx-p1 { 0%, 14% { opacity: 0; } 16%, 100% { opacity: 1; } }
@keyframes hx-p2 { 0%, 50% { opacity: 0; } 52%, 100% { opacity: 1; } }

/* Thinking pauses */
.hx-pz-ty { width: 32ch; animation: hx-pz-ty 8s infinite; }
@keyframes hx-pz-ty {
  0% { width: 0; animation-timing-function: steps(20, end); }
  18% { width: 20ch; }
  62% { width: 20ch; animation-timing-function: steps(12, end); }
  74%, 100% { width: 32ch; }
}
.hx-pz-think, .hx-pz-done { top: 38px; left: calc(12px + 16ch); }
.hx-pz-think { opacity: 0; animation: hx-pz-think 8s infinite; }
.hx-pz-done { animation: hx-pz-done 8s infinite; }
@keyframes hx-pz-think { 0%, 20% { opacity: 0; } 22%, 60% { opacity: 1; } 62%, 100% { opacity: 0; } }
@keyframes hx-pz-done { 0%, 62% { opacity: 0; } 64%, 100% { opacity: 1; } }
.hx-timer { position: absolute; top: 60px; left: calc(12px + 16ch); width: 0; height: 4px; border-radius: 2px; background: var(--pasted); animation: hx-timer 8s infinite; }
@keyframes hx-timer { 0%, 20% { width: 0; } 60% { width: 12ch; } 62%, 100% { width: 0; } }

/* Where typing resumed */
.hx-rows .hx-ln { right: 12px; padding: 0 4px; border-radius: 4px; }
.hx-rl { float: right; color: var(--muted); font: 600 10px/20px system-ui, "Segoe UI", Roboto, Arial, sans-serif; }
.hx-r1 { animation: hx-r1 6s infinite; }
.hx-r2 { animation: hx-r2 6s infinite; }
.hx-r3 { animation: hx-r3 6s infinite; }
@keyframes hx-r1 { 0%, 30% { background: var(--primary-lt); } 33%, 100% { background: transparent; } }
@keyframes hx-r2 { 0%, 31% { background: transparent; } 34%, 63% { background: var(--primary-lt); } 66%, 100% { background: transparent; } }
@keyframes hx-r3 { 0%, 64% { background: transparent; } 67%, 97% { background: var(--primary-lt); } 100% { background: transparent; } }

/* Most minutes (speed range) */
.hx-col { position: absolute; bottom: 32px; width: 16px; border-radius: 2px 2px 0 0; background: var(--pause-word); transform-origin: bottom; animation: hx-grow 7s infinite backwards; }
@keyframes hx-grow { 0% { transform: scaleY(0); } 12%, 90% { transform: scaleY(1); } 100% { transform: scaleY(0); } }
.anim .hx-axis { position: absolute; left: 12px; right: 12px; bottom: 31px; height: 1px; background: #d1d5db; }
.hx-band { position: absolute; left: 8px; right: 8px; bottom: 58px; height: 14px; border-top: 2px dashed var(--primary); border-bottom: 2px dashed var(--primary); background: rgba(30, 82, 160, 0.1); animation: hx-band 7s infinite; }
.hx-band b { position: absolute; right: 4px; top: -18px; color: var(--primary); font: 600 10px/16px system-ui, "Segoe UI", Roboto, Arial, sans-serif; }
@keyframes hx-band { 0%, 30% { opacity: 0; } 38%, 88% { opacity: 1; } 96%, 100% { opacity: 0; } }

/* Final words per active minute */
.hx-eq { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 0 16px; font-size: 13px; }
.hx-e { animation: 7s infinite; }
.hx-e1 { animation-name: hx-e1; }
.hx-e2 { animation-name: hx-e2; }
.hx-e3 { animation-name: hx-e3; color: var(--primary); font-weight: 700; }
@keyframes hx-e1 { 0% { opacity: 0; } 8%, 92% { opacity: 1; } 100% { opacity: 0; } }
@keyframes hx-e2 { 0%, 25% { opacity: 0; } 33%, 92% { opacity: 1; } 100% { opacity: 0; } }
@keyframes hx-e3 { 0%, 50% { opacity: 0; } 58%, 92% { opacity: 1; } 100% { opacity: 0; } }

/* Went back to change earlier parts */
.hx-wb-ins { width: 5ch; background: var(--ok-bg); color: var(--ok-tx); animation: hx-wb-ins 8s infinite; }
@keyframes hx-wb-ins { 0%, 30% { width: 0; animation-timing-function: steps(5, end); } 44%, 100% { width: 5ch; } }
.anim .hx-wb-caret { position: absolute; left: calc(12px + 12ch); top: 34px; margin: 0; animation: hx-wb-caret 8s infinite, hx-blink 1s steps(1) infinite; }
@keyframes hx-wb-caret {
  0%, 18% { left: calc(12px + 12ch); top: 34px; }
  24%, 30% { left: calc(12px + 14ch); top: 14px; animation-timing-function: steps(5, end); }
  44%, 54% { left: calc(12px + 19ch); top: 14px; }
  60%, 100% { left: calc(12px + 12ch); top: 34px; }
}
.hx-wb-count { left: 12px; top: 58px; animation: hx-wb-count 8s infinite; }
@keyframes hx-wb-count { 0%, 58% { opacity: 0; } 62%, 100% { opacity: 1; } }

/* Rewrote text from earlier sessions */
.hx-day { position: absolute; left: 12px; top: 12px; color: var(--muted); font: 700 10px/20px system-ui, "Segoe UI", Roboto, Arial, sans-serif; text-transform: uppercase; }
.hx-d1 { opacity: 0; animation: hx-d1 8s infinite; }
.hx-d2 { animation: hx-d2 8s infinite; }
@keyframes hx-d1 { 0%, 38% { opacity: 1; } 40%, 100% { opacity: 0; } }
@keyframes hx-d2 { 0%, 38% { opacity: 0; } 40%, 100% { opacity: 1; } }
.hx-rw-a { width: 14ch; animation: hx-rw-a 8s infinite; }
@keyframes hx-rw-a { 0% { width: 0; animation-timing-function: steps(14, end); } 16%, 100% { width: 14ch; } }
.hx-rw-b { width: 0; animation: hx-rw-b 8s infinite; }
@keyframes hx-rw-b {
  0%, 16% { width: 0; background: transparent; animation-timing-function: steps(4, end); }
  22%, 40% { width: 4ch; background: transparent; }
  42%, 46% { width: 4ch; background: var(--err-bg); color: var(--err-tx); animation-timing-function: steps(4, end); }
  54%, 100% { width: 0; background: var(--err-bg); }
}
.hx-rw-c { width: 14ch; background: var(--ok-bg); color: var(--ok-tx); animation: hx-rw-c 8s infinite; }
@keyframes hx-rw-c { 0%, 58% { width: 0; animation-timing-function: steps(14, end); } 74%, 100% { width: 14ch; } }
.hx-rw-count { left: 12px; top: 60px; animation: hx-rw-count 8s infinite; }
@keyframes hx-rw-count { 0%, 76% { opacity: 0; } 80%, 100% { opacity: 1; } }

/* Typed text kept / Deleted per 100 added */
.hx-kp-a { width: 14ch; animation: hx-kp-a 8s infinite; }
@keyframes hx-kp-a { 0% { width: 0; animation-timing-function: steps(14, end); } 16%, 100% { width: 14ch; } }
.hx-kp-b { width: 0; animation: hx-kp-b 8s infinite; }
@keyframes hx-kp-b {
  0%, 16% { width: 0; background: transparent; animation-timing-function: steps(10, end); }
  28%, 34% { width: 10ch; background: transparent; }
  36% { width: 10ch; background: var(--err-bg); color: var(--err-tx); animation-timing-function: steps(10, end); }
  48%, 100% { width: 0; background: var(--err-bg); }
}
.hx-kp-c { width: 5ch; animation: hx-kp-c 8s infinite; }
@keyframes hx-kp-c { 0%, 52% { width: 0; animation-timing-function: steps(5, end); } 60%, 100% { width: 5ch; } }
.hx-kp-tally { left: 12px; top: 40px; animation: hx-kp-tally 8s infinite; }
@keyframes hx-kp-tally { 0%, 64% { opacity: 0; } 68%, 100% { opacity: 1; } }

/* Writing sessions / Active and idle time */
.hx-ticks { position: absolute; inset: 0; animation: hx-reveal 7s linear infinite; }
.hx-tick { position: absolute; top: 24px; width: 2px; height: 20px; border-radius: 1px; background: var(--primary); }
@keyframes hx-reveal { 0% { clip-path: inset(0 100% 0 0); } 50%, 100% { clip-path: inset(0 0 0 0); } }
.hx-tl .hx-axis { bottom: auto; top: 44px; }
.hx-span {
  position: absolute;
  top: 56px;
  height: 20px;
  border-radius: 4px;
  font: 600 10px/20px system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  text-align: center;
  animation: hx-span 7s infinite;
}
.hx-sess { border-top: 2px solid var(--primary); color: var(--primary); }
.hx-act { background: var(--primary-lt); color: var(--primary); }
.hx-idle { background: #e5e7eb; color: var(--muted); }
@keyframes hx-span { 0%, 50% { opacity: 0; } 56%, 100% { opacity: 1; } }
.hx-gap { position: absolute; top: 26px; color: var(--muted); font: 600 10px/16px system-ui, "Segoe UI", Roboto, Arial, sans-serif; animation: hx-span 7s infinite; }

/* Paste */
.hx-ps-a { width: 10ch; animation: hx-ps-a 8s infinite; }
@keyframes hx-ps-a { 0% { width: 0; animation-timing-function: steps(10, end); } 16%, 100% { width: 10ch; } }
.hx-ps-block {
  position: absolute;
  top: 34px;
  left: 12px;
  right: 12px;
  background: #fef3c7;
  border-bottom: 2px solid var(--pasted);
  animation: hx-ps-block 8s infinite;
}
@keyframes hx-ps-block { 0%, 33% { opacity: 0; } 34%, 100% { opacity: 1; } }
.hx-ps-badge { right: 12px; top: 12px; animation: hx-ps-badge 8s infinite; }
@keyframes hx-ps-badge { 0%, 40% { opacity: 0; } 44%, 100% { opacity: 1; } }

/* Moved within the document */
.hx-sent { position: absolute; left: 12px; padding: 0 4px; border-radius: 4px; white-space: pre; }
.hx-mv-a { top: 32px; animation: hx-mv-a 8s infinite; }
.hx-mv-b { top: 12px; animation: hx-mv-b 8s infinite; }
@keyframes hx-mv-a { 0%, 30% { top: 12px; } 50%, 100% { top: 32px; } }
@keyframes hx-mv-b {
  0%, 26% { top: 32px; background: transparent; }
  30% { top: 32px; background: var(--primary-lt); }
  50%, 70% { top: 12px; background: var(--primary-lt); }
  80%, 100% { top: 12px; background: transparent; }
}
.hx-mv-badge { left: 12px; top: 60px; animation: hx-mv-badge 8s infinite; }
@keyframes hx-mv-badge { 0%, 50% { opacity: 0; } 54%, 100% { opacity: 1; } }

/* Starting text */
.hx-st-t { color: var(--muted); animation: hx-st-t 8s infinite; }
@keyframes hx-st-t { 0%, 8% { opacity: 0; } 9%, 100% { opacity: 1; } }
.hx-st-ty { width: 26ch; animation: hx-st-ty 8s infinite; }
@keyframes hx-st-ty { 0%, 30% { width: 0; animation-timing-function: steps(26, end); } 62%, 100% { width: 26ch; } }
.hx-side { position: absolute; right: 12px; color: var(--muted); font: 600 10px/20px system-ui, "Segoe UI", Roboto, Arial, sans-serif; }
.hx-st-l1 { top: 22px; animation: hx-st-t 8s infinite; }
.hx-st-l2 { top: 52px; color: var(--primary); animation: hx-st-l2 8s infinite; }
@keyframes hx-st-l2 { 0%, 30% { opacity: 0; } 34%, 100% { opacity: 1; } }

/* Timeline */
.hx-svg { display: flex; align-items: center; justify-content: center; }
.hx-svg svg { display: block; overflow: visible; }
.hx-ax { stroke: #d1d5db; stroke-width: 1; }
.hx-ses { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; animation: hx-ses 8s infinite; }
.hx-line { fill: none; stroke: var(--typed); stroke-width: 2; stroke-linejoin: round; stroke-dasharray: 100; stroke-dashoffset: 0; animation: hx-draw 8s linear infinite; }
.hx-dot { fill: var(--pasted); animation: hx-dot 8s infinite; }
.hx-svg text { fill: var(--muted); font: 600 10px system-ui, "Segoe UI", Roboto, Arial, sans-serif; }
.hx-t1 { animation: hx-t1 8s infinite; }
.hx-t2 { animation: hx-dot 8s infinite; }
.hx-t3 { animation: hx-ses 8s infinite; }
@keyframes hx-draw { 0% { stroke-dashoffset: 100; } 60%, 100% { stroke-dashoffset: 0; } }
@keyframes hx-t1 { 0%, 12% { opacity: 0; } 16%, 100% { opacity: 1; } }
@keyframes hx-dot { 0%, 31% { opacity: 0; } 33%, 100% { opacity: 1; } }
@keyframes hx-ses { 0%, 38% { opacity: 0; } 41%, 100% { opacity: 1; } }

/* Computers set to reduce motion see the final frame, plus a switch to play it anyway. */
.hx-play { display: none; }
@media (prefers-reduced-motion: reduce) {
  .hx-play {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
  }
  .hx-play input { margin: 0; accent-color: var(--primary); }
  .hx-demo:not(:has(.hx-play input:checked)) .anim *,
  .hx-demo:not(:has(.hx-play input:checked)) .anim *::before,
  .hx-demo:not(:has(.hx-play input:checked)) .anim *::after { animation: none !important; }
}

/* ---------- Printable report ---------- */

.report-wrap { max-width: 800px; margin: 0 auto; padding: 32px 16px; }
.report-bar { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.report-bar .btn-primary { width: auto; }
.report-hd { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.report-hd h1 { font-size: 24px; }
.report-hd .doc-title { font-size: 16px; font-weight: 600; }
.report .facts-grid { grid-template-columns: repeat(4, 1fr); }
.report .chart { max-width: 520px; margin: 0 auto; }
.report .draft { max-height: none; overflow: visible; }

@media (max-width: 640px) {
  .report .facts-grid { grid-template-columns: 1fr 1fr; }
}

@media print {
  body { background: #fff; font-size: 12px; }
  .no-print { display: none !important; }
  .report-wrap { max-width: none; padding: 0; }
  .card { break-inside: avoid; border-color: #d1d5db; }
  .card.draft-card { break-inside: auto; }
  .draft { max-height: none; overflow: visible; }
  .para { break-inside: avoid; }
  .seg, .sw, .dot, .flag, .tag, .fact, .paste blockquote, .src {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
