/* article.css - annotation widget styles for article pages (Task 3).
   Base tokens (--bg, --fg, --muted, --border, --link, --card-bg, plus the
   semantic/theme tokens) come from style.css and carry both light and dark
   values. This file only maps a couple of local aliases onto them. */

:root {
  --rs-accent: var(--link);        /* text/border accent (lightens in dark) */
  --rs-shadow: var(--shadow-float);
  /* --rs-hl-bg / --rs-hl-fg / --rs-hl-edge are defined per-theme in style.css */
}

/* -------------------------------------------------- buttons */
.rs-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.85rem;
  border-radius: 8px;
  padding: 0.4em 0.9em;
  cursor: pointer;
}
.rs-btn:hover { border-color: var(--rs-accent); }
.rs-btn-primary { background: var(--rs-accent); color: #fff; border-color: var(--rs-accent); }
.rs-btn-primary:hover { filter: brightness(1.05); }
.rs-btn-ghost { background: transparent; }
.rs-btn-sm { font-size: 0.78rem; padding: 0.25em 0.6em; }
.rs-btn:disabled { opacity: 0.5; cursor: default; }

/* The generated header (back-link + #user-chip) is superseded by the sticky
   .rs-review-box below, which is built by article.js and relocates the same
   #user-chip node into itself. Hiding the header here (rather than editing
   build.py's generated HTML) avoids a duplicate back-link / stray chip line
   above the bar. */
header.site-header { display: none; }

/* -------------------------------------------------- reviewed / rewrite toggle bar */
.rs-review-box {
  display: flex;
  align-items: center;
  gap: 0.7em;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 6500;
  max-width: 960px;
  margin: 0 auto 2em;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 0.6em 0;
}
@media (min-width: 900px) {
  .rs-review-box { flex-wrap: nowrap; }
}
.rs-review-btn.on { background: var(--review-on-bg); color: #fff; border-color: var(--review-on-bg); }
.rs-rewrite-btn.on { background: var(--rewrite-on-bg); color: #fff; border-color: var(--rewrite-on-bg); }

/* Article title: the bar's visual anchor between Back and the action
   controls. Shrinks (and ellipsizes) before anything else wraps. */
.rs-article-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 15px;
  color: var(--fg);
}

/* Every other control in the bar (back button, toggle buttons, status
   badges, compact prev/next buttons, user chip) keeps its natural size.
   The article title is the ONLY element allowed to give way, so it is the
   only one that ever ellipsizes; the bar never wraps to a second line at
   >=900px. */
.rs-review-box > * { flex-shrink: 0; }
.rs-review-box > .rs-article-title {
  flex-shrink: 1;
  min-width: 0;
}
.rs-review-box .rs-nav-links.rs-nav-top {
  flex-wrap: nowrap;
}

/* Compact reviewed/rewrite status badges (full detail lives in title=). */
.rs-review-who, .rs-rewrite-who {
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.15em 0.6em;
  white-space: nowrap;
}
.rs-review-who:empty, .rs-rewrite-who:empty { display: none; padding: 0; }
.rs-review-who { color: var(--review-who-fg); background: var(--review-who-bg); }
.rs-rewrite-who { color: var(--rewrite-who-fg); background: var(--rewrite-who-bg); }

/* -------------------------------------------------- presence ("who's here") */
.rs-presence {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  transition: opacity 0.18s ease;
}
.rs-presence:empty { gap: 0; }
.rs-presence-avatar {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--avatar-bg);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.rs-presence-overflow { background: var(--muted); }

/* -------------------------------------------------- prev/next article nav */
.rs-nav-links {
  display: flex;
  align-items: center;
  gap: 0.6em;
  flex-wrap: wrap;
  margin-left: auto;
  font-size: 0.85rem;
}
.rs-nav-link {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.85rem;
  border-radius: 6px;
  padding: 0.4em 0.9em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
}
.rs-nav-link:hover { border-color: var(--rs-accent); }
.rs-nav-link.rs-nav-highlight {
  font-weight: 600;
  text-decoration: none;
  background: var(--rs-accent);
  color: #fff;
  border-color: var(--rs-accent);
}
.rs-nav-link.rs-nav-highlight:hover { filter: brightness(1.08); text-decoration: none; border-color: var(--rs-accent); }
.rs-nav-bottom {
  margin-top: 2em;
  padding-top: 1.2em;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
  font-size: 0.95rem;
}

/* -------------------------------------------------- text highlights */
mark.rs-hl {
  background: var(--rs-hl-bg);
  color: var(--rs-hl-fg);
  border-radius: 2px;
  padding: 0 1px;
  cursor: pointer;
  box-shadow: inset 0 -2px 0 var(--rs-hl-edge);
}

/* -------------------------------------------------- section comment buttons */
.rs-sec-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 0.1em 0.7em;
  margin-left: 0.6em;
  cursor: pointer;
  vertical-align: middle;
  opacity: 0.55;
  transition: opacity 0.15s;
}
:is(h2, h3):hover .rs-sec-btn { opacity: 1; }
.rs-sec-btn:hover { border-color: var(--rs-accent); color: var(--rs-accent); opacity: 1; }

/* -------------------------------------------------- image pins */
figure.shot { position: relative; }
.rs-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--accent-fill);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  z-index: 2;
}
.rs-pin.resolved { background: var(--muted); opacity: 0.7; }

/* -------------------------------------------------- floating select-to-comment button */
.rs-float-comment {
  position: absolute;
  z-index: 8000;
  appearance: none;
  border: none;
  background: var(--fg);
  color: var(--bg);
  font: inherit;
  font-size: 0.82rem;
  border-radius: 8px;
  padding: 0.4em 0.8em;
  cursor: pointer;
  box-shadow: var(--rs-shadow);
}

/* -------------------------------------------------- composer popover */
.rs-composer {
  position: absolute;
  z-index: 8500;
  width: 300px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--rs-shadow);
  padding: 12px;
}
.rs-composer-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rs-composer-input {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.5em 0.6em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
}
.rs-composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* -------------------------------------------------- annotations panel */
.rs-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  max-width: 90vw;
  height: 100vh;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--rs-shadow);
  display: flex;
  flex-direction: column;
  z-index: 7000;
}
.rs-panel.collapsed { display: none; }
.rs-panel-head {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.8em 1em;
  border-bottom: 1px solid var(--border);
}
.rs-panel-title { font-weight: 600; }
.rs-panel-count {
  background: var(--accent-fill);
  color: #fff;
  border-radius: 999px;
  font-size: 0.72rem;
  padding: 0.05em 0.55em;
}
.rs-panel-collapse {
  margin-left: auto;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.rs-panel-body {
  overflow-y: auto;
  padding: 0.8em;
  flex: 1;
}
.rs-panel-tab {
  position: fixed;
  right: 0;
  top: 40%;
  z-index: 7000;
  appearance: none;
  border: 1px solid var(--border);
  border-right: none;
  background: var(--rs-accent);
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.6em 0.7em;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  writing-mode: vertical-rl;
  display: none;
}

/* -------------------------------------------------- annotation cards */
.rs-group { margin-bottom: 1em; }
.rs-group-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.5em;
}
.rs-group-orphan .rs-group-title { color: #b45309; }
.rs-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6em 0.7em;
  margin-bottom: 0.6em;
}
.rs-card.resolved { opacity: 0.6; }
.rs-card.orphan { border-color: #b45309; }
.rs-card.flash { outline: 2px solid var(--rs-accent); }
.rs-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5em;
  font-size: 0.78rem;
  margin-bottom: 0.25em;
}
.rs-card-user { font-weight: 600; }
.rs-card-time { color: var(--muted); }
.rs-card-context {
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 0.3em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rs-card-text { font-size: 0.9rem; white-space: pre-wrap; word-break: break-word; }
/* Thumbnail of the referenced shot on image-anchored comment cards. Fixed box
   (reserved height) so the card never reflows when the image loads; dark-theme
   friendly frame via shared tokens. */
.rs-card-thumb {
  width: 100%;
  height: 96px;
  margin: 2px 0 7px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-sunken);
}
.rs-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; border: 0; border-radius: 0; box-shadow: none; }
.rs-card-actions { margin-top: 0.4em; display: flex; gap: 6px; }
.rs-empty { color: var(--muted); font-size: 0.88rem; padding: 0.4em 0; }

/* -------------------------------------------------- general thread (bottom) */
.rs-thread { margin-top: 2.5em; padding-top: 1.4em; border-top: 1px solid var(--border); }
.rs-thread-title, .rs-uploads-title { font-size: 1.2rem; border: none; margin: 0 0 0.6em; padding: 0; }
.rs-thread-list { display: flex; flex-direction: column; gap: 0.6em; margin-bottom: 1em; }
.rs-thread-composer { display: flex; flex-direction: column; gap: 0.5em; align-items: flex-start; }
.rs-thread-composer .rs-composer-input { min-height: 60px; }

/* -------------------------------------------------- uploads */
.rs-uploads { margin-top: 2em; padding-top: 1.4em; border-top: 1px solid var(--border); }
.rs-drop {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 1.2em;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}
.rs-drop.over { border-color: var(--rs-accent); color: var(--rs-accent); }
.rs-upload-list { margin-top: 0.8em; display: flex; flex-direction: column; gap: 0.35em; }
.rs-upload-row { display: flex; justify-content: space-between; gap: 1em; font-size: 0.88rem; }
.rs-upload-meta { color: var(--muted); font-size: 0.8rem; }

/* -------------------------------------------------- updated indicator */
.rs-updated {
  flex-shrink: 0;
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
}
.rs-updated:empty { display: none; }

/* -------------------------------------------------- what-changed diff */
.rs-what-changed { margin-left: 0.4em; }

.rs-diff-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 20px;
}
.rs-diff-modal {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--rs-shadow);
  width: 760px;
  max-width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.rs-diff-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6em;
  padding: 0.8em 1em;
  border-bottom: 1px solid var(--border);
}
.rs-diff-title { font-weight: 600; font-size: 1.05rem; }
.rs-diff-content { overflow-y: auto; padding: 1em 1.1em; }
.rs-diff-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.8em;
}
.rs-diff-loading { color: var(--muted); font-size: 0.9rem; }
.rs-diff-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
  line-height: 1.6;
}
.rs-diff-ins {
  background: var(--ins-bg);
  border-radius: 2px;
}
.rs-diff-del {
  background: var(--del-bg);
  text-decoration: line-through;
  border-radius: 2px;
}

/* -------------------------------------------------- edit in studio link */
.rs-studio-link {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  font-size: 0.72rem;
  text-decoration: none;
  background: var(--fg);
  color: var(--bg);
  border-radius: 6px;
  padding: 0.25em 0.6em;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.15s;
}
figure.shot:hover .rs-studio-link,
.rs-studio-link:focus { opacity: 1; }
/* Touch devices can't hover: keep the link visible. */
@media (hover: none) {
  .rs-studio-link { opacity: 0.85; }
}

/* -------------------------------------------------- wide vs narrow */
@media (min-width: 1180px) {
  body { padding-right: 360px; }
}
@media (max-width: 1179px) {
  .rs-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 48vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .rs-panel-tab { top: auto; bottom: 12px; border-radius: 8px; writing-mode: horizontal-tb; border-right: 1px solid var(--border); }
}

/* 2026 readability restyle (theme-aware: colors read from style.css tokens) */
.rs-btn, .rs-nav-link {
  min-height: 34px;
  border-color: var(--border-strong);
  border-radius: 8px;
  background: var(--surface-control);
  color: var(--control-fg);
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 7px 11px;
}
.rs-btn:hover, .rs-nav-link:hover { border-color: var(--border-strong); background: var(--surface-control-hover); color: var(--fg); }
.rs-btn-primary { background: var(--accent-fill); color: var(--on-accent-fill); border-color: var(--accent-fill); }
.rs-btn-sm { min-height: 30px; padding: 5px 9px; font-size: .75rem; }
.rs-btn:disabled { opacity: 1; color: var(--muted); background: var(--card-bg); cursor: not-allowed; }

/* Full-bleed sticky topbar: the box is a direct child of <body> (see
   article.js buildReviewToggle), and <body> carries its own horizontal
   padding (24px baseline, narrowing to 16px on small screens, widening to
   380px on the right at >=1100px to reserve room for the comment rail - see
   style.css and the "wide vs narrow" + rail sections below). Negative
   left/right margins matching that padding exactly (set per-breakpoint
   further down) cancel it out so the bar's background/border spans the true
   viewport edge to edge, while its own padding keeps the inner controls at a
   comfortable inset. This avoids the 100vw/scrollbar overflow trap since the
   box never actually exceeds body's border-box width. */
.rs-review-box {
  gap: 8px;
  max-width: none;
  margin: -8px 0 34px;
  margin-left: -24px;
  margin-right: -24px;
  padding: 9px 20px;
  background: var(--surface-toolbar);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 20px -18px rgba(23,32,51,.8);
  backdrop-filter: blur(10px);
}
.rs-review-btn.on { background: var(--review-on-bg); border-color: var(--review-on-bg); color: #fff; }
.rs-rewrite-btn.on { background: var(--rewrite-on-bg); border-color: var(--rewrite-on-bg); color: #fff; }
.rs-article-title { font-size: .875rem; font-weight: 700; padding-inline: 3px; }
.rs-review-who, .rs-rewrite-who { font-size: .6875rem; font-weight: 750; line-height: 1.45; border: 1px solid currentColor; padding: .16em .55em; }
.rs-review-who { color: var(--review-who-fg); background: var(--review-who-bg); }
.rs-rewrite-who { color: var(--rewrite-who-fg); background: var(--rewrite-who-bg); }
.rs-nav-links { gap: 7px; margin-left: 0; }
.rs-nav-link { text-decoration: none; }
.rs-nav-link.rs-nav-highlight { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent-fill); }
.rs-review-box #user-chip { margin-left: 6px; }
.rs-updated { color: var(--muted-soft); font-size: .71875rem; font-variant-numeric: tabular-nums; }
.rs-presence-avatar { border-color: var(--bg); box-shadow: 0 0 0 1px var(--avatar-ring); }
/* Theme toggle sits in the sticky bar as an icon-only control; base styling is
   injected by common.js. It keeps its natural size (flex-shrink:0 via the bar
   rule) so only .rs-article-title ever ellipsizes and the bar stays one line
   at >=900px. */
.rs-review-box .rs-theme-toggle { padding: 6px 9px; }

main[data-article] article { font-size: 1.0625rem; line-height: 1.68; color: var(--fg); }
main[data-article] article > h1:first-child { margin: 0 0 .5em; font-size: clamp(2rem,4vw,2.55rem); line-height: 1.14; font-weight: 760; letter-spacing: -.03em; }
main[data-article] article h2 { margin: 2.15em 0 .65em; padding: 0; border: 0; font-size: 1.45rem; line-height: 1.3; font-weight: 720; letter-spacing: -.02em; }
main[data-article] article h3 { margin: 1.85em 0 .55em; font-size: 1.16rem; font-weight: 720; }
main[data-article] article h4 { margin: 1.65em 0 .5em; font-weight: 700; }
main[data-article] article p { margin: .85em 0; }
main[data-article] article ul, main[data-article] article ol { margin: .85em 0 1.1em; padding-left: 1.4em; }
main[data-article] article li { margin: .32em 0; padding-left: .08em; }
main[data-article] article strong { font-weight: 720; color: var(--heading-fg); }
/* Screenshots arrive pre-framed by the image pipeline (baked rounded border),
   so the review site must NOT add its own card/border/radius or the frame
   doubles up. figure.shot keeps only vertical rhythm + position:relative for
   pins and the Edit-in-Studio link; the image gets at most a whisper of
   elevation, which the baked frame tolerates. Same treatment in both themes. */
figure.shot { position: relative; margin: 1.75em 0 2em; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; overflow: visible; }
figure.shot img { width: 100%; border: 0; border-radius: 0; box-shadow: 0 1px 4px rgba(23,32,51,.10); }

.rs-sec-btn { min-height: 26px; padding: 3px 9px; margin-left: 8px; border-color: var(--border); background: var(--surface-inset); color: var(--muted); font-size: .6875rem; font-weight: 650; opacity: .72; }
:is(h2,h3):hover .rs-sec-btn, .rs-sec-btn:focus-visible { opacity: 1; }
.rs-pin { min-width: 26px; height: 26px; line-height: 22px; border-width: 2px; box-shadow: 0 2px 8px rgba(23,32,51,.35); }
.rs-float-comment { min-height: 34px; padding: 7px 11px; background: var(--accent-navy); color: var(--on-accent); font-weight: 650; }

.rs-composer { width: 320px; padding: 14px; border-color: var(--border-strong); border-radius: 12px; }
.rs-composer-label { color: var(--muted); font-size: .75rem; font-weight: 600; }
.rs-composer-input { min-height: 82px; padding: 9px 10px; border-color: var(--border-strong); line-height: 1.5; }

.rs-panel { width: 360px; max-width: 92vw; background: var(--surface-sunken); border-color: var(--border); box-shadow: -14px 0 36px rgba(23,32,51,.13); }
.rs-panel-head { min-height: 58px; gap: 9px; padding: 10px 14px; background: var(--surface-raised); border-color: var(--border); }
.rs-panel-title { font-size: 1rem; font-weight: 750; letter-spacing: -.01em; }
.rs-panel-count { min-width: 22px; padding: 2px 7px; text-align: center; font-size: .6875rem; font-weight: 750; }
.rs-panel-collapse { width: 32px; height: 32px; border-color: var(--border-strong); border-radius: 8px; background: var(--surface-control); color: var(--control-fg); }
.rs-panel-body { padding: 14px; scrollbar-color: var(--border-strong) transparent; }
.rs-panel-tab { background: var(--accent-navy); color: var(--on-accent); font-weight: 700; box-shadow: -4px 4px 14px rgba(23,32,51,.16); }
.rs-group { margin-bottom: 18px; }
.rs-group-title { margin: 0 0 8px; color: var(--muted); font-size: .6875rem; font-weight: 750; letter-spacing: .07em; }
.rs-group-orphan { padding: 10px; background: var(--orphan-bg); border: 1px solid var(--orphan-border); border-radius: 10px; }
.rs-group-orphan .rs-group-title { color: var(--orphan-fg); }
.rs-card { padding: 11px; margin-bottom: 9px; background: var(--surface-raised); border-color: var(--border); border-radius: 10px; box-shadow: 0 1px 2px rgba(23,32,51,.035); }
.rs-card.orphan { border-color: var(--orphan-edge); }
.rs-card-meta { align-items: baseline; margin-bottom: 6px; font-size: .75rem; }
.rs-card-user { color: var(--fg); font-weight: 750; }
.rs-card-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.rs-card-context { margin-bottom: 7px; color: var(--muted); font-size: .75rem; line-height: 1.4; }
.rs-card-text { color: var(--fg); font-size: .875rem; line-height: 1.55; }
.rs-card-actions { margin-top: 9px; }
.rs-empty { color: var(--muted); }

.rs-diff-backdrop { background: var(--overlay); padding: 24px; backdrop-filter: blur(2px); }
.rs-diff-modal { width: min(820px,100%); max-height: 88vh; border-color: var(--border-strong); border-radius: 14px; box-shadow: 0 24px 70px rgba(11,18,32,.3); }
.rs-diff-head { flex: 0 0 auto; min-height: 58px; padding: 10px 16px; background: var(--surface-raised); border-radius: 14px 14px 0 0; }
.rs-diff-title { font-size: 1.0625rem; font-weight: 750; letter-spacing: -.01em; }
.rs-diff-content { padding: 20px 24px 26px; }
.rs-diff-meta { color: var(--muted); font-size: .75rem; }
.rs-diff-body { max-width: 72ch; color: var(--fg); font-size: .9375rem; line-height: 1.68; }
.rs-diff-ins {
  background: var(--ins-bg);
  text-decoration: underline;
  text-decoration-color: var(--ins-edge);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  padding: 0 .12em;
}
.rs-diff-del {
  background: var(--del-bg);
  text-decoration: line-through;
  text-decoration-color: var(--del-line);
  text-decoration-thickness: 2px;
  padding: 0 .12em;
}
/* A replaced word renders as an adjacent <del><ins> pair with no whitespace
   token between them (the shared spaces around the edit are `eq`), so the two
   words visually collide - "stops" + "testing" reads as "stopstesting". Nudge
   touching del/ins pairs apart without inserting a real space character. */
.rs-diff-del + .rs-diff-ins,
.rs-diff-ins + .rs-diff-del { margin-left: 0.3em; }

.rs-studio-link { top: 10px; right: 10px; min-height: 32px; padding: 6px 10px; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; background: var(--accent-navy); color: var(--on-accent); font-size: .75rem; font-weight: 700; line-height: 1.4; }
.rs-studio-link:hover { background: var(--accent-navy-hover); color: var(--on-accent); }

@media (min-width: 1180px) { body { padding-right: 384px; } }
@media (min-width: 900px) {
  .rs-review-box { flex-wrap: nowrap; }
  .rs-review-box > * { flex-shrink: 0; }
  .rs-review-box > .rs-article-title { flex-shrink: 1; }
}
@media (max-width: 899px) {
  .rs-review-box { margin-top: -10px; }
}
/* Small screens: body's horizontal padding narrows to 16px (style.css), so
   the full-bleed cancel narrows to match. */
@media (max-width: 640px) {
  .rs-review-box { margin-left: -16px; margin-right: -16px; padding-left: 14px; padding-right: 14px; }
}

/* ============================================================================
   2026 add-on: margin comment rail (Feature 1) + suggest mode (Feature 2).
   All colors read the shared style.css tokens, so both light and dark themes
   flow automatically. The old right slide-in panel is retired.
   ========================================================================== */

/* Reserve room to the right of the reading column for the rail (article pages
   only; overrides the retired panel's padding via higher source order). */
@media (min-width: 1100px) {
  body { padding-right: 380px; }
}
/* The topbar spans the full viewport width even though body reserves 380px
   on the right for the rail above: cancel that extra padding on the bar
   specifically (its left-side cancel stays -24px, set in the base rule)
   rather than shrinking the rail's gutter. */
@media (min-width: 1100px) {
  .rs-review-box { margin-right: -380px; }
}

/* ---- the rail ---- */
.rs-rail { display: none; }
@media (min-width: 1100px) {
  .rs-rail {
    display: block;
    position: absolute;
    top: 0;
    width: 320px;
    z-index: 10;
    font-size: 0.8125rem;
  }
}
/* Clear the sticky review bar (which spans wider than the reading column and
   floats over the top strip of the rail). */
.rs-rail-top { position: relative; display: flex; flex-direction: column; gap: 12px; padding-top: 76px; }
.rs-rail-filter {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-bottom: 9px; border-bottom: 1px solid var(--border);
}
.rs-rail-filter-label { font-weight: 750; font-size: 0.8125rem; color: var(--fg); letter-spacing: -0.01em; }
.rs-rail-seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.rs-rail-seg-btn {
  appearance: none; border: 0; background: var(--surface-control); color: var(--control-fg);
  font: inherit; font-size: 0.75rem; font-weight: 650; padding: 4px 11px; cursor: pointer; line-height: 1.5;
}
.rs-rail-seg-btn + .rs-rail-seg-btn { border-left: 1px solid var(--border-strong); }
.rs-rail-seg-btn:hover { background: var(--surface-control-hover); }
.rs-rail-seg-btn.on { background: var(--accent-navy); color: var(--on-accent); }

.rs-rail-cluster-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.rs-rail-cluster-title {
  font-size: 0.6875rem; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 6px;
}
.rs-rail-add { min-height: 26px; padding: 2px 9px; font-size: 0.9rem; line-height: 1; }
.rs-rail-general { display: flex; flex-direction: column; gap: 8px; }
.rs-rail-general .rs-card, .rs-rail-orphan .rs-card { margin-bottom: 0; }
.rs-rail-orphan {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px; background: var(--orphan-bg); border: 1px solid var(--orphan-border); border-radius: 10px;
}
.rs-rail-orphan:empty { display: none; padding: 0; border: 0; }
.rs-rail-orphan-title { color: var(--orphan-fg); }

/* Open/resolved counts on the filter label + cluster heads ("2 open · 1 resolved"). */
.rs-rail-count { font-size: 0.6875rem; font-weight: 600; color: var(--muted); letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rs-rail-count-res { color: var(--muted-soft); }
.rs-rail-filter-label { display: inline-flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.rs-rail-filter-label-text { font-weight: 750; font-size: 0.8125rem; color: var(--fg); letter-spacing: -0.01em; }

/* Resolved comment collapsed to one muted line (always inline at its anchor).
   Deliberately quiet so it never competes visually with an open card. */
.rs-card.rs-card-collapsed {
  padding: 5px 9px; margin-bottom: 0; cursor: pointer;
  background: transparent; border-style: dashed; border-color: var(--border);
  opacity: 0.7; transition: opacity 0.12s ease, background 0.12s ease;
}
.rs-card.rs-card-collapsed:hover,
.rs-card.rs-card-collapsed:focus-visible { opacity: 1; background: var(--surface-control-hover); }
.rs-card-collapsed-line { display: flex; align-items: baseline; gap: 6px; font-size: 0.8125rem; line-height: 1.35; min-width: 0; }
.rs-card-collapsed-check { color: var(--success); font-weight: 800; flex-shrink: 0; }
.rs-card-collapsed-user { color: var(--muted); font-weight: 650; flex-shrink: 0; }
.rs-card-collapsed-text { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* anchored cards are absolutely positioned by JS */
.rs-rail > .rs-card[data-anchored] { position: absolute; left: 0; right: 0; }

/* card <-> anchor hover linking */
.rs-card.flash, .rs-card.rs-card-hot { outline: 2px solid var(--accent-fill); outline-offset: 1px; }
.rs-anchor-active {
  background: var(--rs-hl-bg); color: var(--rs-hl-fg);
  box-shadow: inset 0 -2px 0 var(--rs-hl-edge); border-radius: 3px;
}
h2.rs-anchor-active, h3.rs-anchor-active { box-shadow: -4px 0 0 var(--rs-hl-edge); background: none; color: inherit; }
.rs-pin.rs-anchor-active { outline: 3px solid var(--rs-hl-edge); }

/* rail composer variant (opens in the rail column at the anchor's height) */
.rs-composer.rs-composer-rail { width: 320px; }

/* ---- suggestion cards in the rail ---- */
.rs-sug-card .rs-card-sugdiff {
  font-size: 0.8125rem; line-height: 1.5; margin: 2px 0 0;
  white-space: pre-wrap; word-break: break-word;
}
.rs-sug-line-del { text-decoration: line-through; text-decoration-color: var(--del-line); color: var(--muted); }
.rs-sug-note { color: var(--muted); font-size: 0.72rem; margin-top: 5px; }
.rs-sug-card.applied { opacity: 0.72; }
.rs-sug-card.applied .rs-card-context { color: var(--success); }

/* ---- inline suggestion rendering on prose blocks ---- */
.rs-sug-del { text-decoration: line-through; text-decoration-color: var(--del-line); color: var(--muted); }
.rs-sug-inline-chip {
  display: inline-flex; align-items: center; gap: 3px; margin-left: 8px;
  padding: 1px 9px; border-radius: 999px;
  background: var(--badge-new-bg); color: var(--badge-new-fg); border: 1px solid var(--badge-new-bd);
  font-size: 0.6875rem; font-weight: 650; vertical-align: middle; white-space: nowrap;
}
.rs-sug-inline-sep { color: var(--badge-new-fg); opacity: 0.6; }
.rs-sug-inline-dismiss {
  appearance: none; border: 0; background: none; color: var(--link);
  font: inherit; font-size: 0.6875rem; font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline;
}
.rs-sug-inline-dismiss:hover { color: var(--link-hover); }

/* ---- suggest mode affordances ---- */
.rs-suggest-btn { font-size: 1rem; line-height: 1; }
.rs-suggest-btn.on { background: var(--accent-navy); color: var(--on-accent); border-color: var(--accent-navy); }
body.rs-suggesting main[data-article] article :is(p, li, h2, h3) { position: relative; }
body.rs-suggesting main[data-article] article :is(p, li, h2, h3):hover {
  outline: 1px dashed var(--accent-fill); outline-offset: 3px; border-radius: 3px; cursor: text;
}
main[data-article] article .rs-editing {
  outline: 2px solid var(--accent-fill); outline-offset: 3px;
  background: var(--surface-inset); border-radius: 4px; cursor: text;
}
.rs-block-del {
  position: absolute; top: 2px; right: 2px; z-index: 4;
  appearance: none; width: 26px; height: 26px; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 7px;
  background: var(--surface-control); color: var(--danger);
  font-size: 0.8rem; line-height: 1; cursor: pointer; opacity: 0; transition: opacity 0.12s;
}
body.rs-suggesting :is(p, li, h2, h3):hover > .rs-block-del,
.rs-block-del:focus-visible { opacity: 1; }
.rs-block-del:hover { background: var(--surface-control-hover); }

/* The sticky bar's fit is now managed by JS (layoutBar in article.js): it sheds
   the What-changed diff and Prev/Next into the ⋯ menu, then collapses the
   verdict labels to icons, so the old viewport-based hiding rules are gone.
   The profile chip's verbose "You are <name>" label still collapses on narrow
   viewports (the avatar + switch action stay reachable via the menu). */
@media (max-width: 1099px) {
  .rs-review-box #user-chip .rs-chip > span { display: none; }
}

/* ---- count chips: styled as pills; they live in the ⋯ menu ---- */
.rs-count-chip {
  appearance: none; border: 1px solid var(--border-strong); background: var(--surface-control);
  color: var(--control-fg); border-radius: 999px; font: inherit; font-size: 0.72rem; font-weight: 700;
  padding: 3px 10px; cursor: pointer; white-space: nowrap; line-height: 1.4; flex-shrink: 0;
}
.rs-count-chip:hover { background: var(--surface-control-hover); }
.rs-count-chip.rs-count-empty { display: none; }
.rs-count-chip-sug { color: var(--badge-new-fg); }

/* ==================================================================
   Responsive article topbar (Part 2). Three zones on one no-wrap line:
   LEFT (back icon + always-visible title + updated date) yields first;
   RIGHT (verdict actions + overflow) holds its size. When the bar can't
   fit, layoutBar() sheds the secondary controls into the ⋯ menu, then
   collapses the verdict labels to icons. Theme-aware via style.css tokens.
   ================================================================== */
.rs-review-box { flex-wrap: nowrap; overflow: hidden; }
.rs-bar-left {
  display: flex; align-items: center; gap: 8px;
  flex: 1 1 auto;
  /* Hard floor: the left zone (back + title) never shrinks below this, so when
     the right zone runs out of room the BAR overflows - which is what triggers
     layoutBar() to shed controls into the ⋯ menu - instead of the title
     silently collapsing to zero width and disappearing. */
  min-width: 132px;
}
.rs-bar-right {
  display: flex; align-items: center; gap: 8px;
  flex: 0 0 auto;
}
.rs-bar-verdicts { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.rs-bar-secondary { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* Back = compact icon-only square. */
.rs-bar-back { flex: 0 0 auto; padding: 7px 11px; font-size: 1rem; line-height: 1; }

/* Title: ALWAYS visible, ellipsized, with a floor width so the bar genuinely
   overflows (triggering the ⋯ collapse) rather than the title vanishing. */
.rs-review-box .rs-article-title {
  /* Shrinks/ellipsizes but does NOT grow: leftover width stays as slack the
     verdict labels can use, instead of the title greedily eating it and forcing
     a premature icon collapse. */
  flex: 0 1 auto; min-width: 68px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rs-updated {
  flex: 0 0 auto; white-space: nowrap; font-size: 0.72rem;
  font-weight: 600; color: var(--muted);
}

/* Verdict buttons: icon glyph + label; label hidden under .rs-bar-icons. */
.rs-verdict-btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.rs-vb-icon { line-height: 1; font-size: 0.95em; }
.rs-review-box.rs-bar-icons .rs-vb-label { display: none; }
.rs-review-box.rs-bar-icons .rs-verdict-btn { padding: 7px 10px; }

/* ⋯ overflow button: hidden until layoutBar marks the bar as needing it. */
.rs-bar-more { position: relative; flex: 0 0 auto; }
.rs-bar-more-btn { display: none; padding: 7px 11px; font-weight: 700; line-height: 1; }
.rs-review-box.rs-bar-more-active .rs-bar-more-btn { display: inline-flex; }

/* Body-mounted menu (escapes the bar's overflow:hidden). */
.rs-bar-more-menu {
  position: absolute; z-index: 9100; display: none;
  min-width: 200px; max-width: 280px; padding: 6px;
  background: var(--surface-raised); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--rs-shadow, 0 18px 46px rgba(11, 18, 32, 0.28));
}
.rs-bar-more-menu.open { display: flex; flex-direction: column; gap: 5px; align-items: stretch; }
.rs-bar-more-menu > * { width: 100%; justify-content: flex-start; }
.rs-bar-more-menu .rs-nav-links {
  flex-direction: column; align-items: stretch; gap: 5px; margin: 0; width: 100%;
}
.rs-bar-more-menu .rs-nav-link { width: 100%; justify-content: flex-start; }
.rs-bar-more-menu .rs-count-chip { display: flex; border-radius: 8px; }
.rs-bar-more-menu .rs-count-chip.rs-count-empty { display: none; }

/* ---- popover (narrow: per-anchor thread + overview) ---- */
.rs-popover {
  position: absolute; z-index: 8600; background: var(--surface-raised);
  border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--rs-shadow);
  max-height: 70vh; display: flex; flex-direction: column; overflow: hidden;
}
.rs-popover-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-raised);
}
.rs-popover-title { font-weight: 750; font-size: 0.9rem; }
.rs-popover-body { overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }

/* ---- narrow-screen numbered gutter dots ---- */
.rs-gutter { display: block; }
@media (min-width: 1100px) { .rs-gutter { display: none; } }
.rs-gutter-dot {
  position: absolute; z-index: 20; width: 20px; height: 20px; padding: 0;
  border-radius: 50%; border: 2px solid var(--bg); background: var(--accent-fill); color: #fff;
  font-size: 0.62rem; font-weight: 800; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(23, 32, 51, 0.35);
}
.rs-gutter-dot:hover { filter: brightness(1.08); }

/* -------------------------------------------------- live shot status badges */
/* One badge per figure, top-left (the Edit-in-Studio link owns the top
   right). Approved reuses the green reviewed-badge tokens; Updated reuses the
   amber orphan tokens. Both token sets carry light and dark values in
   style.css, so the badges follow the theme automatically. */
.rs-shot-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  padding: 3px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: .6875rem;
  font-weight: 750;
  line-height: 1.45;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(23, 32, 51, .18);
}
.rs-shot-badge-approved { color: var(--review-who-fg); background: var(--review-who-bg); }
/* "Updated" is an interactive compare toggle (baked <-> live), so it opts back
   into pointer events. Blue treatment (reuses the theme-aware badge-new tokens)
   distinguishes it from the green Approved and the red Needs-reshoot chips. */
.rs-shot-badge-updated { color: var(--badge-new-fg); background: var(--badge-new-bg); border-color: var(--badge-new-bd); }
.rs-shot-badge-live { pointer-events: auto; cursor: pointer; }
.rs-shot-badge-live:hover { filter: brightness(1.04); }
.rs-shot-badge-live.showing-baked { color: var(--orphan-fg); background: var(--orphan-bg); border-color: var(--orphan-edge); }

/* ============================================================ batch-3 additions */
/* New theme tokens: violet for Claude change-highlights, red for reshoot marks.
   Light values live in :root; dark values are mirrored in BOTH the manual
   data-theme="dark" selector and the auto (prefers-color-scheme) block, exactly
   like style.css does for its own tokens. */
:root {
  --rs-claude-hl-bg: #f2ebff;
  --rs-claude-hl-edge: #7c3aed;
  --rs-claude-hl-fg: #5b21b6;
  --rs-claude-chip-bg: #ede4ff;
  --rs-claude-chip-fg: #5b21b6;
  --rs-claude-chip-bd: #cbb6f7;
  --rs-reshoot-bg: #fdeceb;
  --rs-reshoot-fg: #b42318;
  --rs-reshoot-edge: #e7aaa3;
}
:root[data-theme="dark"] {
  --rs-claude-hl-bg: rgba(139, 92, 246, 0.22);
  --rs-claude-hl-edge: #a78bfa;
  --rs-claude-hl-fg: #d3c4fb;
  --rs-claude-chip-bg: rgba(139, 92, 246, 0.18);
  --rs-claude-chip-fg: #cbb8fb;
  --rs-claude-chip-bd: #6a4bb0;
  --rs-reshoot-bg: #3a1f1d;
  --rs-reshoot-fg: #f0958c;
  --rs-reshoot-edge: #7c3a34;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --rs-claude-hl-bg: rgba(139, 92, 246, 0.22);
    --rs-claude-hl-edge: #a78bfa;
    --rs-claude-hl-fg: #d3c4fb;
    --rs-claude-chip-bg: rgba(139, 92, 246, 0.18);
    --rs-claude-chip-fg: #cbb8fb;
    --rs-claude-chip-bd: #6a4bb0;
    --rs-reshoot-bg: #3a1f1d;
    --rs-reshoot-fg: #f0958c;
    --rs-reshoot-edge: #7c3a34;
  }
}

/* ---- selection quick-actions (Comment + Need image) ---- */
.rs-float-actions {
  position: absolute;
  z-index: 8000;
  display: inline-flex;
  gap: 6px;
}
.rs-float-actions .rs-float-comment,
.rs-float-actions .rs-float-needimg {
  position: static;
  appearance: none;
  border: none;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  border-radius: 8px;
  padding: 0.42em 0.8em;
  cursor: pointer;
  box-shadow: var(--rs-shadow);
  white-space: nowrap;
}
.rs-float-actions .rs-float-comment { background: var(--accent-navy); color: var(--on-accent); }
.rs-float-actions .rs-float-needimg { background: var(--rs-reshoot-fg); color: #fff; }
.rs-float-actions .rs-float-needimg:hover { filter: brightness(1.05); }

/* ---- reshoot / need-images pickers (reuses the kbd-picker visual language) ---- */
.rs-reshoot-picker,
.rs-reshoot-note {
  position: absolute;
  z-index: 8700;
  min-width: 240px;
  max-width: min(92vw, 340px);
  padding: 10px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-raised);
  color: var(--fg);
  box-shadow: var(--rs-shadow);
}
.rs-reshoot-picker-title {
  padding: 2px 4px 6px;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.rs-reshoot-picker-hint {
  margin: 0 4px 8px;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--surface-inset);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}
.rs-reshoot-rows { display: flex; flex-direction: column; gap: 2px; max-height: 46vh; overflow-y: auto; }
.rs-reshoot-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}
.rs-reshoot-row:hover { background: var(--surface-control-hover); }
.rs-reshoot-row.checked { background: var(--surface-control-hover); border-color: var(--accent-fill); }
.rs-reshoot-row-lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-reshoot-thumb {
  width: 54px; height: 34px; flex-shrink: 0; overflow: hidden;
  border: 1px solid var(--border-strong); border-radius: 5px; background: var(--surface-sunken);
}
.rs-reshoot-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rs-reshoot-check { margin-left: auto; color: var(--accent-fill); font-weight: 800; opacity: 0; }
.rs-reshoot-row.checked .rs-reshoot-check { opacity: 1; }
.rs-reshoot-foot { display: flex; justify-content: flex-end; gap: 7px; margin-top: 9px; }
.rs-reshoot-note .rs-composer-input { width: 100%; min-height: 64px; resize: vertical; }
.rs-reshoot-note .rs-composer-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 8px; }

/* ---- per-figure reshoot flag affordance ---- */
.rs-reshoot-flag {
  position: absolute;
  bottom: 8px; right: 8px;
  z-index: 3;
  appearance: none;
  min-width: 28px; height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-control);
  color: var(--rs-reshoot-fg);
  font-size: 0.85rem; line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  box-shadow: 0 1px 4px rgba(23, 32, 51, 0.28);
}
figure.shot:hover .rs-reshoot-flag,
.rs-reshoot-flag:focus-visible { opacity: 1; }
@media (hover: none) { .rs-reshoot-flag { opacity: 0.85; } }
.rs-reshoot-flag:hover { background: var(--surface-control-hover); }

/* ---- per-figure "needs reshoot" chip ---- */
.rs-reshoot-chip {
  position: absolute;
  top: 10px; left: 10px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px 3px 10px;
  border: 1px solid var(--rs-reshoot-edge);
  border-radius: 999px;
  background: var(--rs-reshoot-bg);
  color: var(--rs-reshoot-fg);
  font-size: 0.6875rem;
  font-weight: 750;
  line-height: 1.4;
  box-shadow: 0 1px 4px rgba(23, 32, 51, 0.18);
}
.rs-reshoot-chip-label::before { content: "⚑ "; }
.rs-reshoot-tag {
  padding: 0 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--rs-reshoot-fg) 16%, transparent);
  font-size: 0.625rem;
  font-weight: 700;
}
.rs-reshoot-resolve {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--rs-reshoot-fg);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
.rs-reshoot-resolve:hover { background: color-mix(in srgb, var(--rs-reshoot-fg) 18%, transparent); }

/* ---- "needs image" toggle tag on the discussion composer ---- */
.rs-thread-composer-bar { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.rs-thread-composer-bar .rs-btn-primary { margin-left: auto; }
.rs-needimg-tag {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-control);
  color: var(--control-fg);
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}
.rs-needimg-tag:hover { background: var(--surface-control-hover); }
.rs-needimg-tag.on {
  background: var(--rs-reshoot-bg);
  border-color: var(--rs-reshoot-edge);
  color: var(--rs-reshoot-fg);
}
.rs-reshoot-bar-btn { white-space: nowrap; }

/* ---- Claude change-highlights (violet, two-way linked) ---- */
.rs-claude-hl {
  background: var(--rs-claude-hl-bg);
  box-shadow: inset 3px 0 var(--rs-claude-hl-edge);
  border-radius: 3px;
  padding: 0 2px;
  cursor: pointer;
  transition: background 0.15s;
}
.rs-claude-hl:hover,
.rs-claude-hl.rs-claude-flash { background: color-mix(in srgb, var(--rs-claude-hl-edge) 26%, var(--rs-claude-hl-bg)); }
.rs-claude-hl:focus-visible { outline: 2px solid var(--rs-claude-hl-edge); outline-offset: 2px; }
.rs-claude-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 6px 0 2px;
  padding: 2px 10px;
  border: 1px solid var(--rs-claude-chip-bd);
  border-radius: 999px;
  background: var(--rs-claude-chip-bg);
  color: var(--rs-claude-chip-fg);
  font: inherit;
  font-size: 0.6875rem;
  font-weight: 700;
  cursor: pointer;
}
.rs-claude-chip:hover { filter: brightness(1.03); }

/* ---------------------------------------------------------------- cross-refs
   Article cross-references are written in the corpus as italic *[Title]* and
   rendered by build.py's link_xrefs() into a real link to that article's page
   on this review site. The italic styling is the corpus convention and stays;
   the added affordance is a dotted underline that goes solid on hover, so a hub
   article reads as clickable at a glance without shouting over body text. */
article .xref {
  color: var(--link);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
article .xref:hover,
article .xref:focus-visible {
  color: var(--link-hover, var(--link));
  text-decoration-style: solid;
}

/* ------------------------------------------------ finalize gate (Max only)
   Top rung above the import ladder. The button is rendered only when the active
   reviewer is max (article.js canFinalize); the read-only "Finalized by Max"
   chip is shown to everyone. Uses the link accent so it never reads as the
   green "reviewed" verdict. */
.rs-final-btn.on { background: var(--link); border-color: var(--link); color: #fff; }
.rs-final-who {
  font-size: .6875rem; font-weight: 750; line-height: 1.45;
  border: 1px solid var(--link); border-radius: 6px; padding: .16em .55em;
  color: #fff; background: var(--link); white-space: nowrap;
}
.rs-final-who:empty { display: none; border: none; padding: 0; background: none; }

/* Retired rewrite flags in the topbar: history of who asked for the rewrite
   before the article was rewritten. Muted, struck through, never alarming. */
.rs-rewrite-history {
  font-size: .6875rem; font-weight: 650; line-height: 1.45; color: var(--muted);
  text-decoration: line-through; text-decoration-thickness: 1px; white-space: nowrap;
}
.rs-rewrite-history:empty { display: none; }

/* ==================================================== inline editor (max only)
   Visually distinct from suggest mode on purpose: suggest proposes, edit
   writes to git. Suggest mode is the neutral dotted outline; edit mode is
   amber, and the banner is always visible while it is on. */

.rs-edit-btn { filter: saturate(1.2); }
.rs-edit-btn.on {
  background: var(--edit-accent, #b45309);
  border-color: var(--edit-accent, #b45309);
  color: #fff;
}
.rs-edit-btn-off { opacity: .4; cursor: not-allowed; }

.rs-edit-banner {
  display: flex; align-items: center; gap: .6em;
  margin: 0 0 14px; padding: .55em .9em;
  border: 1px solid var(--edit-accent, #b45309);
  border-left-width: 4px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--edit-accent, #b45309) 10%, transparent);
  font-size: .9rem;
}
.rs-edit-banner-dot { color: var(--edit-accent, #b45309); }
.rs-edit-banner-stale {
  border-color: var(--danger, #c0392b);
  background: color-mix(in srgb, var(--danger, #c0392b) 12%, transparent);
}
.rs-edit-banner-stale .rs-btn { margin-left: auto; }

/* Blocks become obviously editable, and only in edit mode. */
body.rs-editing-live article :is(p, li, h2, h3) {
  position: relative;
  border-radius: 4px;
  transition: background-color .12s ease, box-shadow .12s ease;
}
body.rs-editing-live article :is(p, li, h2, h3):hover {
  background: color-mix(in srgb, var(--edit-accent, #b45309) 8%, transparent);
  cursor: text;
}
body.rs-editing-live .rs-editing-live-block {
  outline: 2px solid var(--edit-accent, #b45309);
  outline-offset: 3px;
  background: var(--bg, #fff);
}
.rs-block-saving { opacity: .55; }
.rs-block-saved {
  background: color-mix(in srgb, var(--ok, #15803d) 16%, transparent) !important;
  transition: background-color 1.4s ease;
}

.rs-live-del {
  position: absolute; top: 0; right: -1.9em;
  appearance: none; border: none; background: transparent;
  font-size: .85rem; line-height: 1; cursor: pointer; opacity: 0;
  padding: .2em;
}
body.rs-editing-live :is(p, li, h2, h3):hover > .rs-live-del,
.rs-live-del:focus { opacity: .75; }
.rs-live-del:hover { opacity: 1; }

.rs-edit-confirm {
  display: flex; align-items: center; gap: .5em; flex-wrap: wrap;
  margin: .5em 0; padding: .45em .7em;
  border: 1px solid var(--danger, #c0392b); border-radius: 6px;
  background: var(--bg, #fff); font-size: .85rem;
}

/* Gaps between blocks: insert target and image drop target, same strip. */
.rs-edit-gap { display: none; }
body.rs-editing-live .rs-edit-gap {
  display: block; position: relative; height: 14px; margin: -4px 0;
}
body.rs-editing-live .rs-edit-gap::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  height: 2px; background: transparent; border-radius: 2px;
}
body.rs-editing-live .rs-edit-gap:hover::before,
body.rs-editing-live .rs-edit-gap-over::before {
  background: var(--edit-accent, #b45309);
}
.rs-edit-gap-plus {
  position: absolute; left: -1.6em; top: 50%; transform: translateY(-50%);
  appearance: none; border: 1px solid var(--border, #ccc);
  background: var(--bg, #fff); color: var(--muted, #666);
  width: 1.3em; height: 1.3em; line-height: 1; border-radius: 50%;
  font-size: .8rem; cursor: pointer; opacity: 0; padding: 0;
}
body.rs-editing-live .rs-edit-gap:hover .rs-edit-gap-plus { opacity: 1; }
/* While dragging, every gap becomes a visible-but-quiet target and only the
   one under the cursor reads as the drop point. */
body.rs-dragging-img .rs-edit-gap { height: 22px; }
body.rs-dragging-img .rs-edit-gap::before {
  height: 0; border-top: 1px dashed var(--edit-accent, #b45309); opacity: .35;
}
body.rs-dragging-img .rs-edit-gap-over::before {
  height: 3px; border-top: none; opacity: 1;
  background: var(--edit-accent, #b45309);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--edit-accent, #b45309) 22%, transparent);
}
body.rs-dragging-img .rs-edit-gap-plus { display: none; }
.rs-edit-newblock {
  margin: .4em 0; padding: .4em .6em;
  border: 1px dashed var(--edit-accent, #b45309); border-radius: 6px;
  min-height: 1.4em; background: var(--bg, #fff);
}

/* Image controls: the handle is draggable, not the figure, so text selection
   inside the article is unaffected. */
.rs-live-imgbar { display: none; }
body.rs-editing-live figure.shot { position: relative; }
body.rs-editing-live .rs-live-imgbar {
  display: flex; gap: .3em; align-items: center;
  position: absolute; top: 6px; left: 6px; z-index: 3;
  background: var(--bg, #fff); border: 1px solid var(--border, #ccc);
  border-radius: 6px; padding: .15em .35em;
}
.rs-live-drag { cursor: grab; font-size: .9rem; line-height: 1; user-select: none; }
.rs-live-drag:active { cursor: grabbing; }
.rs-live-imgdel {
  appearance: none; border: none; background: transparent;
  color: var(--danger, #c0392b); font-size: 1rem; line-height: 1;
  cursor: pointer; padding: 0 .15em;
}

/* Edit history lives above the discussion thread. */
.rs-edit-history { margin: 22px 0 0; }
.rs-edit-history-sum {
  cursor: pointer; font-size: .9rem; color: var(--muted, #666);
  padding: .3em 0;
}
.rs-edit-history-list { display: flex; flex-direction: column; gap: .3em; margin-top: .5em; }
.rs-edit-history-row {
  display: flex; align-items: center; gap: .6em; flex-wrap: wrap;
  font-size: .84rem; padding: .3em .5em;
  border: 1px solid var(--border, #e2e2e2); border-radius: 6px;
}
.rs-edit-history-row.reverted { opacity: .55; text-decoration: line-through; }
.rs-edit-history-ts { color: var(--muted, #777); white-space: nowrap; }
.rs-edit-history-sumtext { flex: 1; min-width: 12ch; }
.rs-edit-history-sha { font-size: .78rem; color: var(--muted, #777); }
.rs-edit-history-note, .rs-edit-history-synced {
  font-size: .78rem; color: var(--muted, #777);
}

@media (prefers-color-scheme: dark) {
  :root { --edit-accent: #f59e0b; }
}
:root[data-theme="dark"] { --edit-accent: #f59e0b; }
