/* Threadforge — Fable (Lionhead) Albion fantasy look
   Continuous collaborative manuscript (doc mode) */

@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;0,700;1,500;1,600&family=Source+Sans+3:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap");

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  /* Parchment & cream */
  --parchment: #f3e6c8;
  --parchment-deep: #e8d5a8;
  --parchment-soft: #faf3e0;
  --ink: #3a2a1c;
  --ink-soft: #5c4632;
  --ink-mute: #8a7358;
  --ink-faint: #a89070;

  /* Wood & leather */
  --wood: #5c3d28;
  --wood-deep: #3e2918;
  --wood-hi: #7a5538;
  --leather: #6b4428;
  --leather-panel: #4a3220;

  /* Soft gold / bronze trim */
  --gold: #c9a24a;
  --gold-hi: #e2c56a;
  --gold-deep: #8a6a28;
  --bronze: #a07840;
  --brass: #b8924a;

  /* Soft greens & amber (never Xbox neon) */
  --moss: #5a7a48;
  --moss-soft: rgba(90, 122, 72, 0.18);
  --moss-glow: rgba(180, 160, 80, 0.35);
  --amber: #c4883a;
  --amber-soft: rgba(196, 136, 58, 0.2);
  --lantern: #e8c060;

  /* Surfaces */
  --panel: #efe0bc;
  --panel-hi: #f6edd4;
  --edge: #c4a878;
  --edge-soft: rgba(90, 60, 30, 0.18);
  --shadow: rgba(60, 40, 20, 0.28);

  --font-body: "Source Sans 3", "Segoe UI", Georgia, serif;
  --font-display: "Cormorant Garamond", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --rail-w: 210px;
  --topbar-h: 56px;
  --compose-h: 148px;
  --radius: 10px;
  --hover-ms: 170ms;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 30% 20%, rgba(232, 192, 96, 0.12), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(90, 122, 72, 0.08), transparent 45%),
    linear-gradient(165deg, #2a1c12 0%, #3d2918 40%, #2e1e14 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  max-width: 100%;
}

body {
  overflow: hidden;
  overflow-x: hidden;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: 0.85em;
  font-family: var(--font-body);
  background: var(--parchment-deep);
  border: 1px solid var(--bronze);
  border-radius: 4px;
  color: var(--ink-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* ——— App shell ——— */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  box-shadow:
    0 0 0 3px var(--wood-deep),
    0 0 0 5px var(--gold-deep),
    0 12px 60px rgba(0, 0, 0, 0.55);
  background: var(--parchment);
  position: relative;
  overflow-x: hidden;
  min-width: 0;
}

.app::before {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 20; /* below drawers/modals; vignette must never paint over the Tools panel */
  border-radius: 0;
  box-shadow: inset 0 0 80px rgba(60, 40, 20, 0.12);
}

/* ——— Top bar — carved wood beam ——— */
.topbar {
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background:
    linear-gradient(180deg, rgba(255, 220, 160, 0.12) 0%, transparent 40%),
    linear-gradient(180deg, #6e4a30 0%, #523420 48%, #3e2818 100%);
  border-bottom: 2px solid var(--gold-deep);
  box-shadow:
    inset 0 1px 0 rgba(232, 197, 106, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 4px 16px var(--shadow);
  z-index: 20;
  position: relative;
}

.topbar::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -2px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-hi), transparent);
  opacity: 0.55;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, var(--lantern), var(--gold) 45%, var(--gold-deep) 100%);
  border: 2px solid var(--gold-hi);
  box-shadow:
    0 0 12px rgba(232, 192, 96, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1px solid rgba(255, 240, 200, 0.35);
}

.brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--parchment-soft);
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.55),
    0 0 18px rgba(232, 197, 106, 0.25);
}

.topbar-session {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.session-label {
  display: none;
}

.session-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  font-style: italic;
  color: var(--parchment);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.topbar-presence {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  position: relative;
}

.presence-compact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 8px;
  background: rgba(30, 18, 10, 0.45);
  border: 1px solid rgba(201, 162, 74, 0.55);
  border-radius: 14px;
  color: var(--parchment-soft);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.12);
}
.presence-compact:hover,
.presence-compact[aria-expanded="true"] {
  border-color: var(--gold);
  background: rgba(30, 18, 10, 0.6);
}
.presence-compact-dots {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.presence-compact-dots .presence-dot {
  width: 7px;
  height: 7px;
}
.presence-compact-label {
  white-space: nowrap;
}

.players-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 260px;
  max-width: min(340px, 90vw);
  padding: 8px;
  background: #f3e6c8;
  background-image: linear-gradient(180deg, #faf3e0 0%, #f3e6c8 55%, #e8d5a8 100%);
  border: 2px solid var(--gold-deep);
  border-radius: 10px;
  box-shadow:
    0 12px 32px rgba(40, 25, 12, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  color: var(--ink);
}
.players-dropdown[hidden] { display: none; }
.players-dropdown-head {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-deep);
  padding: 4px 8px 8px;
  border-bottom: 1px solid rgba(160, 120, 64, 0.35);
  margin-bottom: 6px;
}
.players-dropdown-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  border-radius: 7px;
  background: #faf6ea;
  border: 1px solid rgba(160, 120, 64, 0.28);
  margin-bottom: 5px;
}
.players-dropdown-row:last-child { margin-bottom: 0; }
.players-dropdown-row .presence-dot {
  margin-top: 4px;
  flex-shrink: 0;
}
.players-dropdown-meta {
  flex: 1;
  min-width: 0;
}
.players-dropdown-name {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.players-dropdown-role {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-deep);
  border: 1px solid rgba(201, 162, 74, 0.55);
  border-radius: 999px;
  background: #f3e2b8;
  vertical-align: middle;
}
.players-dropdown-status {
  margin-top: 2px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-style: italic;
  color: var(--ink-mute);
}
.players-dropdown-status.is-busy {
  color: var(--amber);
  font-style: normal;
  font-weight: 600;
}

.presence-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 6px;
  background: rgba(30, 18, 10, 0.35);
  border: 1px solid rgba(201, 162, 74, 0.45);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.12);
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff4c0, var(--lantern) 50%, var(--amber) 100%);
  box-shadow: 0 0 8px rgba(232, 192, 96, 0.75);
}

.presence-dot.away {
  background: radial-gradient(circle at 40% 35%, #d8c8a0, #9a8860);
  box-shadow: 0 0 4px rgba(160, 140, 80, 0.4);
}

.presence-tag {
  font-size: 0.75rem;
  color: var(--parchment-deep);
  letter-spacing: 0.02em;
}

.presence-chip.you .presence-tag {
  color: var(--parchment-soft);
  font-weight: 600;
}

/* ——— Shell + rail (leather / wood panel) ——— */
.shell {
  flex: 1;
  display: flex;
  min-height: 0;
  padding-bottom: var(--compose-h);
  background: var(--parchment);
}

.rail {
  position: relative;
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0%, transparent 12%),
    linear-gradient(180deg, #5a3c26 0%, #4a3220 50%, #3e2918 100%);
  border-right: 2px solid var(--gold-deep);
  box-shadow:
    inset -2px 0 0 rgba(201, 162, 74, 0.2),
    inset 0 1px 0 rgba(255, 220, 160, 0.08);
  padding: 14px 12px 20px;
  overflow-x: hidden;
  overflow-y: auto;
  transition: flex-basis 220ms ease, width 220ms ease, padding 220ms ease;
}

.rail-toggle {
  position: absolute;
  top: 10px;
  right: -1px;
  z-index: 3;
  width: 18px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--bronze);
  border-right: none;
  border-radius: 6px 0 0 6px;
  background: linear-gradient(180deg, #6a4a30, #4a3220);
  color: var(--gold);
  cursor: pointer;
  opacity: 0.9;
}
.rail-toggle:hover { opacity: 1; filter: brightness(1.08); }

.rail-chevron {
  font-size: 0.9rem;
  line-height: 1;
  display: inline-block;
  transition: transform 220ms ease;
}
.app.rail-collapsed .rail-chevron {
  transform: rotate(180deg);
}
.app.rail-collapsed {
  --rail-w: 56px;
}
.app.rail-collapsed .rail {
  padding: 40px 6px 16px;
  overflow: hidden;
}
.app.rail-collapsed .rail-nav {
  display: none;
}
.rail-icons {
  display: none !important;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.app.rail-collapsed .rail-icons,
.app.rail-collapsed .rail-icons[hidden] {
  display: flex !important;
}
.rail-icon-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 74, 0.45);
  background: rgba(30, 18, 10, 0.35);
  color: var(--gold-hi);
  font-size: 1rem;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.1);
}
.rail-icon-btn:hover {
  background: rgba(201, 162, 74, 0.22);
  border-color: var(--gold);
}

.rail-section {
  margin-bottom: 14px;
  padding: 10px;
  background:
    linear-gradient(160deg, rgba(255, 220, 160, 0.06), transparent 50%),
    rgba(30, 18, 10, 0.35);
  border: 1px solid rgba(201, 162, 74, 0.35);
  border-radius: 8px;
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 160, 0.1),
    0 2px 6px rgba(0, 0, 0, 0.25);
}

.rail-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-hi);
  margin-bottom: 8px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.rail-icon {
  color: var(--lantern);
  opacity: 0.95;
  font-size: 0.95rem;
  filter: drop-shadow(0 0 4px rgba(232, 192, 96, 0.4));
}

.coming-soon {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-style: italic;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  background: rgba(243, 230, 200, 0.12);
  border: 1px dashed rgba(201, 162, 74, 0.4);
  border-radius: 8px;
  padding: 3px 9px;
}

.coming-soon.subtle {
  margin-top: 8px;
  opacity: 0.75;
}

.thread-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.8rem;
}

.thread-list li {
  padding: 5px 8px;
  margin-bottom: 2px;
  border-radius: 5px;
  color: rgba(243, 230, 200, 0.55);
  border-left: 2px solid transparent;
}

.thread-list li.active {
  color: var(--parchment-soft);
  background: rgba(201, 162, 74, 0.18);
  border-left-color: var(--gold);
  box-shadow: inset 0 0 12px rgba(232, 192, 96, 0.08);
}

.thread-list.muted li:not(.active) {
  opacity: 0.65;
}

/* ——— Main thread — parchment manuscript page ——— */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.55 0 0 0 0 0.42 0 0 0 0 0.25 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, var(--parchment-soft) 0%, var(--parchment) 40%, var(--parchment-deep) 100%);
  overflow: hidden;
  position: relative;
}

/* Ornate corner flourishes */
.main::before,
.main::after {
  content: "";
  position: absolute;
  width: 36px;
  height: 36px;
  z-index: 5;
  pointer-events: none;
  opacity: 0.55;
  border-color: var(--bronze);
}

.main::before {
  top: 8px;
  left: 8px;
  border-top: 2px solid var(--gold);
  border-left: 2px solid var(--gold);
  border-radius: 4px 0 0 0;
  box-shadow: -2px -2px 0 rgba(201, 162, 74, 0.25);
}

.main::after {
  top: 8px;
  right: 8px;
  border-top: 2px solid var(--gold);
  border-right: 2px solid var(--gold);
  border-radius: 0 4px 0 0;
  box-shadow: 2px -2px 0 rgba(201, 162, 74, 0.25);
}

/* Manuscript heading */
.thread-header {
  flex: 0 0 auto;
  padding: 18px 48px 10px;
  background: transparent;
  border-bottom: none;
  text-align: center;
  position: relative;
  z-index: 2;
}

.ms-chapter {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-deep);
}

.thread-header h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.thread-blurb {
  margin: 0 auto;
  max-width: 36em;
  font-family: var(--font-display);
  font-size: 0.98rem;
  color: var(--ink-mute);
  font-style: italic;
  line-height: 1.4;
}

.ms-rule {
  margin: 14px auto 0;
  width: min(280px, 55%);
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--bronze) 20%,
    var(--gold) 50%,
    var(--bronze) 80%,
    transparent
  );
  position: relative;
}

.ms-rule::before,
.ms-rule::after {
  content: "✦";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.55rem;
  color: var(--gold-deep);
  opacity: 0.7;
}

.ms-rule::before { left: -14px; }
.ms-rule::after { right: -14px; }

/* Scrollable parchment body */
.thread {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 0 28px;
  position: relative;
  z-index: 1;
  overflow-anchor: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bronze) rgba(196, 168, 120, 0.25);
}

/* ——— Continuous document ——— */
.doc {
  max-width: 42em;
  margin: 0 auto;
  padding: 8px 48px 32px;
  font-family: var(--font-display);
  font-size: 1.12rem;
  line-height: 1.72;
  color: var(--ink);
  text-align: left;
  overflow-x: clip;
  min-width: 0;
}
.doc-para:empty {
  display: none;
}
.doc-para.is-blank-gap {
  display: none;
}

/* Paragraph groups (block contributions) */
.doc-para {
  margin: 0 0 1.05em;
  text-indent: 0;
  overflow-anchor: auto;
}

.doc-para + .doc-para {
  /* natural paragraph rhythm only */
}

/* Append-target selection — soft gold margin bracket (Fable) */
.doc-para.is-append-target {
  position: relative;
  background: linear-gradient(
    90deg,
    rgba(201, 162, 74, 0.12) 0%,
    rgba(201, 162, 74, 0.04) 28%,
    transparent 55%
  );
  border-radius: 4px;
  box-shadow: inset 3px 0 0 var(--gold);
  padding-left: 6px;
  margin-left: -6px;
}

.doc-para.is-append-target::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 0.15em;
  bottom: 0.15em;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold), var(--brass));
  box-shadow: 0 0 8px rgba(232, 192, 96, 0.35);
  pointer-events: none;
}

.app[data-mode="writer"] .doc-para {
  cursor: pointer;
}

/* A contribution span — invisible chrome until hover */
.contrib {
  position: relative;
  border-radius: 3px;
  transition: background-color var(--hover-ms) ease, box-shadow var(--hover-ms) ease;
  /* soft author tint via CSS var set inline */
  --tint: rgba(196, 136, 58, 0.14);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* Block contribs look like normal paragraphs */
.contrib.block {
  display: block;
  margin: 0 0 1.05em;
  padding: 2px 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.contrib.block:last-child {
  margin-bottom: 0;
}

/* Inline contribs sit mid-paragraph for handoffs */
.contrib.inline {
  display: inline;
  padding: 1px 2px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* All hover chrome lives out of flow so prose stays seamless */
.contrib-chrome {
  display: contents;
}

/* Speck sits in the left margin — always-on when locked, no prose shift */
.contrib .lock-speck {
  position: absolute;
  left: -12px;
  top: 0.55em;
  margin: 0;
  right: auto;
}

.contrib.locked-other {
  color: var(--ink-soft);
}

/* Soft highlight on hover — reveals span boundaries */
.contrib:hover,
.contrib:focus-within {
  background-color: var(--tint);
  box-shadow: 0 0 0 1px rgba(201, 162, 74, 0.18);
}

.contrib.locked-self:hover,
.contrib.locked-self:focus-within {
  background-color: rgba(196, 136, 58, 0.2);
  box-shadow: inset 2px 0 0 var(--brass);
}

/* Tiny always-on brass speck when locked (expands on hover) */
.lock-speck {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #e8c878, var(--brass) 60%, var(--gold-deep) 100%);
  box-shadow: 0 0 4px rgba(184, 146, 74, 0.55);
  opacity: 0.7;
  transition: transform var(--hover-ms) ease, opacity var(--hover-ms) ease, width var(--hover-ms), height var(--hover-ms);
  cursor: default;
}

.contrib:hover .lock-speck,
.contrib:focus-within .lock-speck {
  width: 8px;
  height: 8px;
  opacity: 1;
  transform: scale(1.15);
}

/* ——— Hover attribution chip (author + time + lock) ——— */
.attr-chip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 12;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 6px;
  max-width: min(280px, 70vw);
  font-family: var(--font-body);
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--parchment-soft);
  background:
    linear-gradient(180deg, rgba(90, 60, 35, 0.96), rgba(50, 32, 18, 0.97));
  border: 1px solid rgba(201, 162, 74, 0.55);
  border-radius: 999px;
  box-shadow:
    0 4px 14px rgba(40, 25, 12, 0.4),
    inset 0 1px 0 rgba(255, 220, 160, 0.15);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition:
    opacity var(--hover-ms) ease,
    transform var(--hover-ms) ease;
}

/* First contribs near top: flip chip below text */
.contrib.chip-below .attr-chip {
  bottom: auto;
  top: calc(100% + 6px);
  transform: translateY(-3px);
}

.contrib:hover .attr-chip,
.contrib:focus-within .attr-chip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.contrib.chip-below:hover .attr-chip,
.contrib.chip-below:focus-within .attr-chip {
  transform: translateY(0);
}

.attr-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 240, 200, 0.35);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.25);
}

.attr-author {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--parchment-soft);
}

.attr-author.you {
  color: #c8e0a8;
}

.attr-time {
  color: rgba(243, 230, 200, 0.65);
  font-size: 0.68rem;
}

.attr-lock-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-style: italic;
  color: var(--lantern);
  padding-left: 4px;
  border-left: 1px solid rgba(201, 162, 74, 0.35);
}

.editing-shimmer {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-style: italic;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, var(--gold-deep), var(--lantern), var(--gold-deep));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.8s linear infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Lock control — only visible on hover (and focus) */
.lock-btn {
  position: absolute;
  left: 0;
  top: -28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--bronze);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #d4b070, var(--brass) 55%, var(--gold-deep) 100%);
  color: var(--ink);
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 1px 2px var(--shadow);
  transition:
    border-color 150ms,
    box-shadow 150ms,
    filter 150ms,
    opacity var(--hover-ms) ease,
    transform var(--hover-ms) ease;
  font-size: 0.65rem;
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
  flex-shrink: 0;
}

.contrib:hover .lock-btn,
.contrib:focus-within .lock-btn {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* Locked-by-other: show badge on hover only (speck stays always) */
.lock-badge {
  position: absolute;
  left: 0;
  top: -28px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #5a3e18;
  background:
    radial-gradient(ellipse at 50% 30%, #e8c878, #c4883a 70%, #8a5a28 100%);
  border: 1px solid var(--gold-deep);
  border-radius: 999px;
  padding: 2px 7px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 1px 3px var(--shadow);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity var(--hover-ms) ease, transform var(--hover-ms) ease;
  pointer-events: none;
  white-space: nowrap;
}

.contrib:hover .lock-badge,
.contrib:focus-within .lock-badge {
  opacity: 1;
  transform: scale(1);
}

.lock-btn:hover:not(:disabled) {
  border-color: var(--gold-hi);
  filter: brightness(1.08);
  box-shadow:
    0 0 8px rgba(232, 192, 96, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.lock-btn:focus-visible {
  outline: none;
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  border-color: var(--gold-hi);
  box-shadow:
    0 0 0 2px var(--amber-soft),
    0 0 8px rgba(232, 192, 96, 0.5);
}

.lock-btn:disabled {
  opacity: 0;
  cursor: not-allowed;
  filter: grayscale(0.25);
}

.contrib:hover .lock-btn:disabled,
.contrib:focus-within .lock-btn:disabled {
  opacity: 0.45;
}

.lock-btn.is-locked {
  color: var(--ink);
  border-color: var(--gold-deep);
  background:
    radial-gradient(circle at 35% 30%, #e8c878, #b8863a 55%, #6a4a20 100%);
}

/* Landing animation for new contributions */
@keyframes contribLand {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.contrib.is-new {
  animation: contribLand 280ms ease-out;
}


.contrib.chip-below .lock-btn,
.contrib.chip-below .lock-badge {
  top: auto;
  bottom: -28px;
}

.contrib.chip-below .attr-chip {
  /* lock controls sit just under chip when both below */
}

/* ——— New posts pill (remote activity below viewport) ——— */
.new-posts-pill {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  z-index: 32;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px 8px;
  border: 1px solid var(--gold-deep);
  border-radius: 999px;
  background:
    linear-gradient(180deg, #f3e2b8 0%, #e4c98a 45%, #c9a24a 100%);
  color: #3a2618;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow:
    0 4px 16px rgba(40, 25, 12, 0.35),
    inset 0 1px 0 rgba(255, 245, 210, 0.7);
  animation: fadeSlide 180ms ease-out;
}
.new-posts-pill:hover {
  filter: brightness(1.05);
  box-shadow:
    0 6px 20px rgba(40, 25, 12, 0.4),
    inset 0 1px 0 rgba(255, 245, 210, 0.85);
}
.new-posts-pill:active {
  transform: translateX(-50%) translateY(1px);
}
.new-posts-pill[hidden] {
  display: none;
}
.new-posts-pill-count:empty {
  display: none;
}
.new-posts-pill-count:not(:empty) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35em;
  height: 1.35em;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(58, 38, 24, 0.85);
  color: #f3e2b8;
  font-size: 0.72rem;
  font-weight: 700;
}

/* ——— Compose dock — open journal strip ——— */
.compose-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 1400px;
  margin: 0 auto;
  z-index: 30;
  /* Solid dark wood from the top edge — no pale/parchment band */
  height: var(--compose-h);
  min-height: var(--compose-h);
  background-color: #4a3220;
  background-image: linear-gradient(180deg, #5c3d28 0%, #4a3220 40%, #3a2618 100%);
  border-top: 2px solid var(--gold-deep);
  box-shadow:
    inset 0 1px 0 rgba(232, 197, 106, 0.28),
    0 -10px 36px rgba(40, 25, 12, 0.45);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.compose-writer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  justify-content: flex-end;
}
.compose-writer[hidden] {
  display: none !important;
}
.app[data-mode="info"] .info-banner {
  flex: 1;
  align-self: stretch;
}

.queue-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  height: 32px;
  min-height: 32px;
  max-height: 32px;
  flex-shrink: 0;
  box-sizing: border-box;
  /* Always rendered — dock height must not change with queue occupancy */
}

.q-empty {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-style: italic;
  letter-spacing: 0.02em;
  color: rgba(243, 230, 200, 0.42);
  user-select: none;
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.queue-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
}

.queue-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.78rem;
}

.q-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  background: rgba(30, 18, 10, 0.4);
  border: 1px solid rgba(201, 162, 74, 0.4);
  color: var(--parchment-deep);
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.1);
}

.q-chip.you {
  color: var(--parchment-soft);
  border-color: var(--gold);
  background: rgba(201, 162, 74, 0.28);
  box-shadow:
    0 0 8px rgba(232, 192, 96, 0.3),
    inset 0 1px 0 rgba(255, 220, 160, 0.2);
}

.q-arrow {
  color: var(--gold);
  font-size: 0.7rem;
  margin: 0 2px;
  opacity: 0.8;
}

.compose-bar {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 18px 12px;
  min-height: 0;
}

.compose-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.compose-avatar {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--parchment-soft);
  background: linear-gradient(145deg, #6a8a50, #3a5a30);
  border: 2px solid var(--gold);
  box-shadow:
    0 0 10px rgba(232, 192, 96, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  margin-bottom: 0;
}

.compose-target {
  display: flex;
  align-items: center;
  margin-left: calc(38px + 12px);
  min-height: 0;
}

.compose-target[hidden] {
  display: none;
}

.compose-target-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 6px 3px 10px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-style: italic;
  color: var(--parchment-soft);
  background: rgba(30, 18, 10, 0.4);
  border: 1px solid rgba(201, 162, 74, 0.5);
  border-radius: 999px;
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 160, 0.12),
    0 0 10px rgba(232, 192, 96, 0.15);
}

.compose-target-chip.is-locked {
  border-color: rgba(196, 136, 58, 0.7);
  background: rgba(90, 50, 20, 0.5);
  color: var(--lantern);
  font-style: normal;
}

.compose-target-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compose-target-clear {
  appearance: none;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  background: rgba(201, 162, 74, 0.25);
  color: var(--parchment-soft);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: background 150ms, color 150ms;
}

.compose-target-clear:hover {
  background: rgba(201, 162, 74, 0.55);
  color: #2a1c0c;
}

.compose-input {
  flex: 1;
  min-width: 0;
  width: auto;
  resize: none;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--parchment-soft), var(--parchment));
  border: 1px solid var(--bronze);
  border-radius: 8px;
  box-shadow:
    inset 0 2px 6px rgba(80, 50, 20, 0.12),
    0 1px 0 rgba(255, 255, 255, 0.2);
  outline: none;
  transition: border-color 150ms, box-shadow 150ms;
}

.compose-input::placeholder {
  color: var(--ink-faint);
  font-style: italic;
  font-family: var(--font-display);
}

.compose-input:focus {
  border-color: var(--gold);
  box-shadow:
    0 0 0 2px var(--amber-soft),
    0 0 14px rgba(232, 192, 96, 0.35),
    inset 0 2px 6px rgba(80, 50, 20, 0.1);
}

.compose-hint {
  margin-top: 0;
  margin-left: calc(38px + 12px);
  font-size: 0.7rem;
  color: rgba(243, 230, 200, 0.65);
  line-height: 1.2;
}

.btn-post {
  flex-shrink: 0;
  margin-bottom: 0;
  align-self: center;
  padding: 9px 20px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #2a1c0c;
  border: 1px solid var(--gold-deep);
  border-radius: 8px;
  cursor: pointer;
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 45%, var(--brass) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.35);
  transition: filter 150ms, box-shadow 150ms;
}

.btn-post:hover {
  filter: brightness(1.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 0 14px rgba(232, 192, 96, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.35);
}

.btn-post:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--amber-soft),
    0 0 14px rgba(232, 192, 96, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.btn-post:active {
  filter: brightness(0.96);
  transform: translateY(1px);
}

.btn-post.is-locked-target:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

/* Scrollbar — soft wood/bronze */
.thread::-webkit-scrollbar,
.rail::-webkit-scrollbar {
  width: 10px;
}
.thread::-webkit-scrollbar-track {
  background: rgba(196, 168, 120, 0.25);
}
.rail::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
.thread::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--bronze), var(--wood));
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
}
.rail::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--gold), var(--bronze));
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
}
.thread::-webkit-scrollbar-thumb:hover,
.rail::-webkit-scrollbar-thumb:hover {
  background: var(--gold-hi);
}

/* (legacy ≤900 rail-hide removed — see Thin windows section) */

/* ========== Mode switcher (brass / leather tabs) ========== */
.mode-switch {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  background: rgba(30, 18, 10, 0.4);
  border: 1px solid rgba(201, 162, 74, 0.5);
  border-radius: 8px;
  padding: 2px;
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 160, 0.1),
    0 2px 6px rgba(0, 0, 0, 0.25);
  gap: 0;
}

.mode-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(243, 230, 200, 0.65);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition:
    background 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

.mode-tab-icon {
  font-size: 0.75rem;
  color: var(--gold);
  opacity: 0.7;
}

.mode-tab:hover {
  color: var(--parchment-soft);
  background: rgba(201, 162, 74, 0.12);
}

.mode-tab.is-active {
  color: #2a1c0c;
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 50%, var(--brass) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 1px 3px rgba(0, 0, 0, 0.3);
}

.mode-tab.is-active .mode-tab-icon {
  color: #3a2810;
  opacity: 1;
}

.btn-view-source {
  appearance: none;
  flex-shrink: 0;
  margin-left: 4px;
  padding: 4px 10px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(243, 230, 200, 0.7);
  background: rgba(30, 18, 10, 0.3);
  border: 1px dashed rgba(201, 162, 74, 0.45);
  border-radius: 6px;
  cursor: pointer;
  transition: color 150ms, border-color 150ms, background 150ms;
}

.btn-view-source:hover {
  color: var(--parchment-soft);
  border-color: var(--gold);
  background: rgba(201, 162, 74, 0.15);
}

/* Mode banner flash */
.mode-banner {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  z-index: 8;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}

.mode-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mode-banner-label {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--parchment-soft), var(--parchment-deep));
  border: 1px solid var(--bronze);
  border-radius: 999px;
  padding: 4px 14px;
  box-shadow: 0 4px 14px rgba(60, 40, 20, 0.25);
}

/* Soft page tint / transition per mode */
.app[data-mode="writer"] .main {
  /* clean parchment — default */
}

.app[data-mode="trace"] .main {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.55 0 0 0 0 0.42 0 0 0 0 0.25 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #f6edd8 0%, #efe0bc 40%, #e4d0a4 100%);
}

.app[data-mode="info"] .main {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.55 0 0 0 0 0.42 0 0 0 0 0.25 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #faf6ea 0%, #f3e6c8 45%, #e8d8b0 100%);
}

.app.mode-fade .doc,
.app.mode-fade .trace-legend {
  animation: modeSoftIn 220ms ease-out;
}

@keyframes modeSoftIn {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

/* ========== Segments (replaces .contrib for new model) ========== */
.seg {
  position: relative;
  border-radius: 3px;
  transition:
    background-color var(--hover-ms) ease,
    box-shadow var(--hover-ms) ease,
    outline-color 180ms ease;
  --tint: rgba(196, 136, 58, 0.14);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding: 1px 2px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Writer: clean — tint only on hover */
.app[data-mode="writer"] .seg:hover,
.app[data-mode="writer"] .seg:focus-within {
  background-color: var(--tint);
  box-shadow: 0 0 0 1px rgba(201, 162, 74, 0.18);
}

.app[data-mode="writer"] .seg.locked-self:hover,
.app[data-mode="writer"] .seg.locked-self:focus-within {
  background-color: rgba(196, 136, 58, 0.2);
  box-shadow: inset 2px 0 0 var(--brass);
}

/* Trace: always-on soft author tint + underline */
.app[data-mode="trace"] .seg.trace-tint {
  background-color: var(--trace-tint, rgba(196, 136, 58, 0.18));
  box-shadow: inset 0 -2px 0 var(--trace-under, rgba(196, 136, 58, 0.45));
}

.app[data-mode="trace"] .seg.has-edits {
  /* dotted underline marker for edits (in addition to tint) */
  box-shadow:
    inset 0 -2px 0 var(--trace-under, rgba(196, 136, 58, 0.45)),
    inset 0 -5px 0 -2px rgba(90, 60, 30, 0.35);
  border-bottom: 1.5px dotted rgba(90, 60, 30, 0.45);
}

.app[data-mode="trace"] .seg.locked-other,
.app[data-mode="trace"] .seg.locked-self {
  outline: 1px dashed var(--brass);
  outline-offset: 1px;
}

.app[data-mode="trace"] .seg:hover,
.app[data-mode="trace"] .seg:focus-within {
  filter: brightness(1.04);
}

/* Info: names highlighted, segments quiet */
.app[data-mode="info"] .seg:hover {
  background-color: transparent;
  box-shadow: none;
}

.seg.locked-other {
  color: var(--ink-soft);
}

.seg .lock-speck {
  position: absolute;
  left: -12px;
  top: 0.55em;
  margin: 0;
}

.app[data-mode="trace"] .seg .lock-speck {
  opacity: 1;
  width: 7px;
  height: 7px;
}

/* Edit quill mark (trace) */
.edit-quill {
  position: absolute;
  right: -14px;
  top: 0.15em;
  font-size: 0.7rem;
  color: var(--gold-deep);
  opacity: 0.85;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Richer attr chip in Trace */
.attr-chip-rich {
  max-width: min(420px, 85vw);
  white-space: normal;
  line-height: 1.35;
  border-radius: 10px;
  padding: 5px 10px 5px 7px;
}

.attr-rich-text {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--parchment-soft);
}

/* Reuse chip show/hide for .seg */
.seg .attr-chip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 12;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 6px;
  max-width: min(280px, 70vw);
  font-family: var(--font-body);
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--parchment-soft);
  background:
    linear-gradient(180deg, rgba(90, 60, 35, 0.96), rgba(50, 32, 18, 0.97));
  border: 1px solid rgba(201, 162, 74, 0.55);
  border-radius: 999px;
  box-shadow:
    0 4px 14px rgba(40, 25, 12, 0.4),
    inset 0 1px 0 rgba(255, 220, 160, 0.15);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition:
    opacity var(--hover-ms) ease,
    transform var(--hover-ms) ease;
}

.seg.chip-below .attr-chip {
  bottom: auto;
  top: calc(100% + 6px);
  transform: translateY(-3px);
}

.seg:hover .attr-chip,
.seg:focus-within .attr-chip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.seg.chip-below:hover .attr-chip,
.seg.chip-below:focus-within .attr-chip {
  transform: translateY(0);
}

/* In Trace, chips show on hover with rich text; in Info, hide segment chips */
.app[data-mode="info"] .seg .attr-chip,
.app[data-mode="info"] .seg .lock-btn,
.app[data-mode="info"] .seg .lock-badge {
  display: none !important;
}

.app[data-mode="trace"] .lock-badge.visible-trace {
  opacity: 0.95;
  transform: scale(1);
  pointer-events: none;
  position: absolute;
  left: auto;
  right: -4px;
  top: -22px;
}

.seg .lock-btn,
.seg .lock-badge {
  position: absolute;
  left: 0;
  top: -28px;
}

.seg:hover .lock-btn,
.seg:focus-within .lock-btn,
.seg:hover .lock-badge,
.seg:focus-within .lock-badge {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.seg.chip-below .lock-btn,
.seg.chip-below .lock-badge {
  top: auto;
  bottom: -28px;
}

/* Inline editing */
.seg.is-editing {
  background-color: rgba(196, 136, 58, 0.18) !important;
  box-shadow:
    inset 2px 0 0 var(--brass),
    0 0 0 1px rgba(201, 162, 74, 0.35) !important;
  outline: none;
  cursor: text;
}

.seg.is-editing .contrib-chrome,
.seg.is-editing .attr-chip,
.seg.is-editing .lock-btn,
.seg.is-editing .lock-badge,
.seg.is-editing .edit-quill {
  pointer-events: none;
}

.locked-tip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-style: italic;
  color: #5a3e18;
  background:
    radial-gradient(ellipse at 50% 30%, #e8c878, #c4883a 70%, #8a5a28 100%);
  border: 1px solid var(--gold-deep);
  border-radius: 8px;
  padding: 4px 10px;
  box-shadow: 0 4px 12px rgba(40, 25, 12, 0.35);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
  white-space: nowrap;
}

.locked-tip.show {
  opacity: 1;
  transform: translateY(0);
}

/* Remote edit shimmer */
@keyframes editShimmer {
  0% { background-color: rgba(232, 192, 96, 0.35); }
  100% { background-color: transparent; }
}

.seg.edit-shimmer {
  animation: editShimmer 1.1s ease-out;
}

.seg.is-new {
  animation: contribLand 280ms ease-out;
}

/* ========== Trace legend ========== */
.trace-legend {
  position: absolute;
  top: 64px;
  right: 18px;
  z-index: 6;
  width: 168px;
  padding: 10px 12px;
  background:
    linear-gradient(180deg, var(--parchment-soft), var(--parchment-deep));
  border: 1px solid var(--bronze);
  border-radius: 10px;
  box-shadow:
    0 6px 20px rgba(60, 40, 20, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  font-family: var(--font-display);
  animation: modeSoftIn 220ms ease-out;
}

.trace-legend[hidden] {
  display: none;
}

.legend-head {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin-bottom: 8px;
}

.legend-authors {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  font-size: 0.8rem;
  color: var(--ink);
}

.legend-authors li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid;
  flex-shrink: 0;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}

.legend-markers {
  border-top: 1px solid rgba(160, 120, 64, 0.35);
  padding-top: 6px;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.legend-mark {
  width: 14px;
  height: 10px;
  flex-shrink: 0;
}

.legend-mark.edited {
  border-bottom: 1.5px dotted rgba(90, 60, 30, 0.7);
  box-shadow: inset 0 -2px 0 rgba(122, 74, 42, 0.35);
}

.legend-mark.locked {
  border: 1px dashed var(--brass);
  border-radius: 2px;
  background: rgba(184, 146, 74, 0.15);
}

/* ========== Info mode name hits + card ========== */
.info-name-hit {
  cursor: help;
  border-bottom: 1px dotted var(--bronze);
  color: var(--ink);
  transition: background-color 150ms, border-color 150ms;
}

.info-name-hit:hover,
.info-name-hit:focus {
  background-color: rgba(201, 162, 74, 0.22);
  border-bottom-color: var(--gold);
  outline: none;
}

.info-card {
  position: fixed;
  z-index: 80;
  width: 260px;
  padding: 0;
  background:
    linear-gradient(180deg, var(--parchment-soft) 0%, var(--parchment) 100%);
  border: 1px solid var(--bronze);
  border-radius: 12px;
  box-shadow:
    0 12px 36px rgba(40, 25, 12, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  overflow: hidden;
  pointer-events: auto;
  animation: modeSoftIn 160ms ease-out;
}

.info-card[hidden] {
  display: none;
}

.info-ribbon {
  position: absolute;
  top: 10px;
  right: -28px;
  width: 110px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #3a2810;
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  border: 1px solid var(--gold-deep);
  transform: rotate(35deg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.info-card-body {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 14px 8px;
}

.info-portrait {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--parchment-soft);
  border: 2px solid var(--gold);
  box-shadow: 0 0 10px rgba(232, 192, 96, 0.35);
}

.info-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.info-role {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-style: italic;
  color: var(--ink-mute);
}

.info-bio {
  margin: 0;
  padding: 0 14px 8px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

.info-stats {
  display: grid;
  gap: 4px;
  padding: 8px 14px 12px;
  border-top: 1px solid rgba(160, 120, 64, 0.3);
  background: rgba(196, 168, 120, 0.15);
}

.info-stat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--ink);
}

.info-stat-label {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-deep);
  font-size: 0.65rem;
}

/* ========== View source modal ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(30, 18, 10, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modeSoftIn 180ms ease-out;
}

.modal-backdrop[hidden] {
  display: none;
}

.parchment-modal {
  width: min(720px, 94vw);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, var(--parchment-soft), var(--parchment-deep));
  border: 2px solid var(--gold-deep);
  border-radius: 12px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  overflow: hidden;
}

.modal-head {
  position: relative;
  padding: 12px 44px 10px 16px;
  border-bottom: 1px solid rgba(160, 120, 64, 0.4);
  background:
    linear-gradient(180deg, rgba(255, 240, 200, 0.35), transparent);
}

.modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink);
}

.modal-sub {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-style: italic;
  color: var(--ink-mute);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--bronze);
  border-radius: 50%;
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  filter: brightness(1.06);
}

.source-pre {
  margin: 0;
  padding: 14px 16px 18px;
  overflow: auto;
  flex: 1;
  font-family: "Source Sans 3", ui-monospace, monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Compose disabled in non-writer */
.compose-input:disabled,
.btn-post:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

@media (max-width: 900px) {
  .trace-legend {
    top: auto;
    bottom: calc(var(--compose-h) + 12px);
    right: 10px;
    width: 148px;
  }
}

.seg-edit {
  display: inline;
  outline: none;
  min-width: 1ch;
}

/* ========== Feature 1: Info-mode banner ========== */
.app[data-mode="info"] {
  --compose-h: 78px;
}
.app[data-mode="info"] .compose-writer {
  display: none;
}
.app[data-mode="info"] .info-banner {
  display: flex;
}
.app[data-mode="info"].is-paused {
  /* pause banner sits above; info banner still slim */
}

.info-banner {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 8px 16px 10px;
  min-height: 58px;
  background:
    linear-gradient(180deg, rgba(255, 240, 200, 0.12) 0%, transparent 40%),
    linear-gradient(180deg, #5a3c26 0%, #3e2918 100%);
}

.info-banner-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex-shrink: 0;
}

.info-link-tab {
  appearance: none;
  padding: 4px 10px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--parchment-soft);
  background: rgba(30, 18, 10, 0.35);
  border: 1px solid rgba(201, 162, 74, 0.55);
  border-radius: 6px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.12);
  transition: background 150ms, border-color 150ms, color 150ms;
  white-space: nowrap;
}
.info-link-tab:hover {
  color: #2a1c0c;
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  border-color: var(--gold-deep);
}

.info-banner-widgets {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  justify-content: flex-end;
}

.info-banner-tag {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-style: italic;
  letter-spacing: 0.04em;
  color: rgba(243, 230, 200, 0.5);
  white-space: nowrap;
}

/* Widget types */
.w-bar, .w-stat, .w-currency, .w-resource, .w-list, .w-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: rgba(30, 18, 10, 0.4);
  border: 1px solid rgba(201, 162, 74, 0.4);
  border-radius: 6px;
  font-size: 0.72rem;
  color: var(--parchment-deep);
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.08);
}
.w-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}
.w-bar-track {
  width: 56px;
  height: 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  border: 1px solid rgba(201, 162, 74, 0.3);
}
.w-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--moss), var(--lantern));
  box-shadow: 0 0 6px rgba(232, 192, 96, 0.35);
}
.w-bar-fill.mana {
  background: linear-gradient(90deg, #3a5a8a, #7ab0e0);
}
.w-bar-val, .w-stat-val, .w-currency-val, .w-resource-val {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--parchment-soft);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
.w-list-items {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.w-list-item {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(201, 162, 74, 0.18);
  color: var(--parchment);
  font-size: 0.68rem;
}
.w-currency .w-currency-val::before {
  content: "⚜ ";
  color: var(--gold-hi);
  font-size: 0.7em;
}
.w-resource .w-resource-icon {
  color: var(--lantern);
  font-size: 0.75rem;
}

.thread-list li {
  cursor: pointer;
}
.thread-list li:hover:not(.active) {
  color: rgba(243, 230, 200, 0.85);
  background: rgba(201, 162, 74, 0.08);
}

.info-link-modal {
  width: min(420px, 92vw);
  max-height: min(60vh, 480px);
}
.info-link-body {
  padding: 14px 18px 18px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink-soft);
}
.info-link-body h4 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: var(--ink);
}
.info-link-body ul {
  margin: 6px 0 0;
  padding-left: 1.2em;
}
.info-link-body .sample-ribbon-inline {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #3a2810;
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  border: 1px solid var(--gold-deep);
  border-radius: 4px;
  padding: 2px 8px;
}

/* ========== Feature 2: Tools panel ========== */
.btn-view-source.is-active-tools {
  color: #2a1c0c;
  border-style: solid;
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
}

.tools-scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(30, 18, 10, 0.25);
}
.tools-scrim[hidden] { display: none; }

.tools-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  width: min(440px, 92vw);
  max-width: 92vw;
  height: 100%;
  min-height: 100%;
  transition: width 180ms ease;
  display: flex;
  flex-direction: column;
  /* Fully opaque solid parchment — never let the manuscript show through */
  background-color: #f3e6c8;
  background-image: linear-gradient(180deg, #faf3e0 0%, #f3e6c8 42%, #e8d5a8 100%);
  border-left: 2px solid var(--gold-deep);
  box-shadow:
    -12px 0 40px rgba(40, 25, 12, 0.4),
    inset 1px 0 0 rgba(255, 255, 255, 0.35);
  /* Slide with transform only — never animate opacity */
  animation: toolsSlideIn 200ms ease-out;
  isolation: isolate;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  opacity: 1;
  mix-blend-mode: normal;
  overflow: hidden;
}
.tools-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-color: #f3e6c8;
  pointer-events: none;
}
.tools-panel[hidden] { display: none; }

@keyframes toolsSlideIn {
  from { transform: translateX(24px); }
  to { transform: translateX(0); }
}

.tools-panel-head {
  position: relative;
  flex: 0 0 auto;
  padding: 14px 72px 10px 16px;
  border-bottom: 1px solid rgba(160, 120, 64, 0.4);
  background-color: #f6edd4;
  background-image: linear-gradient(180deg, #faf6ea 0%, #f3e6c8 100%);
  opacity: 1;
}
.tools-panel-head-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.tools-expand-btn {
  appearance: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--bronze);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}
.tools-expand-btn:hover { filter: brightness(1.05); }
.tools-expand-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--brass), var(--gold-deep));
  color: var(--parchment-soft);
}
.tools-panel.is-expanded {
  width: max(640px, 60vw);
  max-width: 92vw;
}
.tools-panel.is-expanded .move-item-text,
.tools-panel.is-expanded .delete-item-text {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tools-panel-head .modal-close {
  position: static;
}
.tools-panel-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--ink);
}
.tools-panel-sub {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-style: italic;
  color: var(--ink-mute);
}

.tools-panel-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
  padding: 8px 10px 0;
  border-bottom: 1px solid rgba(160, 120, 64, 0.3);
  background-color: #efe0bc;
  background-image: none;
  opacity: 1;
}
.tools-tab {
  appearance: none;
  flex: 1;
  padding: 7px 6px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink-mute);
  background-color: #efe0bc;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  opacity: 1;
}
.tools-tab:hover { color: var(--ink); background-color: #f0e4c0; }
.tools-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--gold-deep);
  background-color: #faf3e0;
}

.tools-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 20px;
  background-color: #f3e6c8;
  background-image: none;
  opacity: 1;
}
.tools-pane {
  min-height: 100%;
  background-color: #f3e6c8;
  opacity: 1;
}
.tools-pane[hidden] { display: none; }

.tools-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-deep);
}
.tools-input {
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--ink);
  background: linear-gradient(180deg, var(--parchment-soft), var(--parchment));
  border: 1px solid var(--bronze);
  border-radius: 6px;
  outline: none;
}
.tools-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--amber-soft);
}
.tools-toggles {
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
}
.tools-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--ink-soft);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.tools-actions {
  margin-bottom: 12px;
}
.btn-tools-primary {
  appearance: none;
  padding: 7px 14px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #2a1c0c;
  border: 1px solid var(--gold-deep);
  border-radius: 7px;
  cursor: pointer;
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2px 4px var(--shadow);
}
.btn-tools-primary:hover { filter: brightness(1.05); }
.btn-tools-primary:disabled {
  opacity: 1;
  cursor: not-allowed;
  filter: none;
  background: linear-gradient(180deg, #e8d5a8, #d4c090);
  color: #8a7358;
  border-color: #c4a878;
}
.btn-tools-small {
  appearance: none;
  padding: 2px 8px;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink);
  background-color: #e8d5a8;
  border: 1px solid var(--bronze);
  border-radius: 4px;
  cursor: pointer;
  opacity: 1;
}
.btn-tools-small:hover { background-color: #dcc488; }
.btn-tools-small:disabled {
  opacity: 1;
  cursor: not-allowed;
  background-color: #efe0bc;
  color: #a89070;
}

.find-preview-head {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin-bottom: 6px;
}
.find-preview {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  background-color: #f3e6c8;
  opacity: 1;
}
.find-match {
  padding: 8px 8px;
  margin-bottom: 4px;
  background: #faf6ea;
  border: 1px solid rgba(160, 120, 64, 0.3);
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--ink);
}
.find-match.is-skipped {
  opacity: 1;
  border-style: dashed;
  background: #efe0bc;
  color: var(--ink-soft);
}
.find-match-snippet {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 4px;
}
.find-match-snippet mark {
  background-color: #e8c878;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.find-match-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.68rem;
  color: var(--ink-mute);
}
.find-match-status.ok { color: var(--moss); font-weight: 600; }
.find-match-status.skipped { color: var(--amber); font-weight: 600; }

/* Gold find highlights in document (soft mark) */
.seg .find-hit {
  background: rgba(232, 192, 96, 0.42);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(201, 162, 74, 0.25);
  padding: 0 1px;
}

.tools-note {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-style: italic;
  color: var(--ink-mute);
  line-height: 1.4;
}
.tools-note code {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
  font-style: normal;
  background-color: #e8d5a8;
  padding: 0 4px;
  border-radius: 3px;
}

.move-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background-color: #f3e6c8;
  opacity: 1;
}
.move-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-bottom: 5px;
  background: #faf6ea;
  border: 1px solid rgba(160, 120, 64, 0.35);
  border-radius: 7px;
  cursor: grab;
  color: var(--ink);
}
.move-item.is-disabled {
  opacity: 1;
  cursor: not-allowed;
  border-style: dashed;
  background-color: #efe0bc;
  color: #8a7358;
}
.move-item.is-dragging {
  opacity: 1;
  border-color: var(--gold);
  background-color: #fff6d8;
}
.move-item-handle {
  color: var(--bronze);
  font-size: 0.9rem;
  user-select: none;
}
.move-item-body {
  flex: 1;
  min-width: 0;
}
.move-item-text {
  font-family: var(--font-display);
  font-size: 0.82rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.move-item-authors {
  display: flex;
  gap: 4px;
  margin-top: 3px;
}
.move-author-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 240, 200, 0.4);
}
.move-item-reason {
  font-size: 0.65rem;
  color: var(--amber);
  font-style: italic;
}
.move-item-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.move-btn {
  appearance: none;
  width: 22px;
  height: 18px;
  padding: 0;
  font-size: 0.65rem;
  line-height: 1;
  border: 1px solid var(--bronze);
  border-radius: 3px;
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  color: var(--ink);
  cursor: pointer;
}
.move-btn:disabled {
  opacity: 1;
  cursor: not-allowed;
  background: #efe0bc;
  color: #a89070;
  border-color: #c4a878;
}

/* GM pause / locks / delete */
.gm-block {
  padding: 12px;
  background: #faf6ea;
  border: 1px solid rgba(160, 120, 64, 0.4);
  border-radius: 8px;
  color: var(--ink);
}
.gm-delete-block {
  margin-top: 12px;
}
.gm-pause-note {
  margin: 8px 0 12px;
  padding-left: 46px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-style: italic;
  color: var(--ink-mute);
  line-height: 1.35;
}
.gm-release-btn {
  width: 100%;
  margin-top: 2px;
}
.gm-block-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin-bottom: 10px;
}
.gm-soon {
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--ink-faint);
}
.gm-pause-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.gm-pause-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.gm-pause-knob {
  flex-shrink: 0;
  width: 36px;
  height: 20px;
  margin-top: 2px;
  border-radius: 999px;
  background-color: #d4c090;
  border: 1px solid var(--bronze);
  position: relative;
  transition: background 180ms;
}
.gm-pause-knob::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--parchment-soft), var(--parchment-deep));
  border: 1px solid var(--bronze);
  transition: transform 180ms;
}
.gm-pause-toggle input:checked + .gm-pause-knob {
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
}
.gm-pause-toggle input:checked + .gm-pause-knob::after {
  transform: translateX(16px);
}
.gm-pause-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.85rem;
  color: var(--ink);
}
.gm-pause-text strong {
  font-family: var(--font-display);
  font-size: 0.95rem;
}
.gm-pause-text em {
  font-size: 0.75rem;
  color: var(--ink-mute);
  font-style: italic;
  line-height: 1.35;
}

/* Pause banner across manuscript top */
.pause-banner {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 16px;
  background:
    linear-gradient(180deg, #c4883a 0%, #8a5a28 100%);
  border-bottom: 2px solid var(--gold-deep);
  color: #2a1c0c;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: inset 0 1px 0 rgba(255, 240, 200, 0.35);
  z-index: 18;
  animation: fadeSlide 180ms ease-out;
}
.pause-banner[hidden] { display: none; }
.pause-banner-seal {
  font-size: 1rem;
}
.app.is-paused .shell {
  /* slight dim via parchment overlay feel — optional */
}
.app.is-paused .doc-para {
  cursor: not-allowed;
}
.app.is-paused[data-mode="writer"] .compose-input {
  border-color: var(--amber);
  box-shadow: inset 0 0 0 1px rgba(196, 136, 58, 0.25);
}
.app.is-paused[data-mode="writer"] .btn-post {
  /* Still clickable — queues the post */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 0 10px rgba(196, 136, 58, 0.35);
}

/* Toast */
.tf-toast {
  position: fixed;
  bottom: calc(var(--compose-h) + 18px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 110;
  max-width: min(460px, 90vw);
  padding: 10px 18px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  color: #2a1c0c;
  background: linear-gradient(180deg, #f3e2b8, #e4c98a);
  border: 1px solid var(--gold-deep);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(40, 25, 12, 0.4);
  animation: fadeSlide 180ms ease-out;
  text-align: center;
}
.tf-toast[hidden] { display: none; }
.tf-toast-action {
  appearance: none;
  margin-left: 2px;
  padding: 0;
  border: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: inherit;
  font-weight: 700;
  color: #5a3a14;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.tf-toast-action:hover {
  color: #2a1c0c;
}

/* GM delete list */
.delete-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  background-color: #f3e6c8;
  opacity: 1;
}
.delete-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-bottom: 5px;
  background: #faf6ea;
  border: 1px solid rgba(160, 120, 64, 0.35);
  border-radius: 7px;
  color: var(--ink);
}
.delete-item.is-confirming {
  border-color: #8a4040;
  background: #f3e4d4;
}
.delete-item-body {
  flex: 1;
  min-width: 0;
}
.delete-item-text {
  font-family: var(--font-display);
  font-size: 0.82rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.delete-item-authors {
  display: flex;
  gap: 4px;
  margin-top: 3px;
}
.delete-item-confirm {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.delete-confirm-prompt {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-style: italic;
  color: var(--ink-soft);
}
.delete-confirm-actions {
  display: flex;
  gap: 6px;
}
.btn-delete {
  appearance: none;
  flex-shrink: 0;
  padding: 4px 10px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f3e6c8;
  background: linear-gradient(180deg, #8a5050 0%, #6a3434 55%, #4a2424 100%);
  border: 1px solid #5a2828;
  border-radius: 5px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 200, 180, 0.18),
    0 1px 3px rgba(40, 20, 15, 0.25);
}
.btn-delete:hover {
  filter: brightness(1.08);
}
.btn-delete-confirm {
  appearance: none;
  padding: 3px 10px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: #f3e6c8;
  background: linear-gradient(180deg, #8a5050 0%, #6a3434 100%);
  border: 1px solid #5a2828;
  border-radius: 5px;
  cursor: pointer;
}
.btn-delete-cancel {
  appearance: none;
  padding: 3px 10px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  border: 1px solid var(--gold-deep);
  border-radius: 5px;
  cursor: pointer;
}

/* Tools lock seal flicker */
.tools-lock-seal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 120;
  padding: 10px 22px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #3a2810;
  background:
    radial-gradient(ellipse at 50% 30%, #e8c878, #c4883a 70%, #8a5a28 100%);
  border: 2px solid var(--gold-deep);
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(40, 25, 12, 0.45);
  animation: sealFlicker 700ms ease-out forwards;
  pointer-events: none;
}
.tools-lock-seal[hidden] { display: none; }
@keyframes sealFlicker {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1); }
}

@media (max-width: 900px) {
  .info-banner-tag { display: none; }
  .info-banner-widgets { justify-content: flex-start; }
}


/* —— Tools live lists: lock badges, fresh flash, para count —— */
.move-pane-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.move-para-count {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-style: italic;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
}
.tools-lock-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  font-size: 0.65rem;
  font-style: italic;
  color: var(--amber, #a86a2a);
  line-height: 1.2;
}
.tools-lock-row.tools-lock-self-edit {
  color: var(--forest, #4a6a3a);
}
.tools-lock-row.tools-lock-tools {
  color: var(--bronze, #8a6a3a);
}
.tools-wax-seal {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e8b4a0, #8b2e2e 55%, #5a1818);
  border: 1px solid #6a2020;
  box-shadow: 0 0 0 1px rgba(201, 162, 74, 0.35);
  flex-shrink: 0;
}
.move-item.is-fresh,
.delete-item.is-fresh {
  animation: toolsFreshFlash 1.2s ease;
}
@keyframes toolsFreshFlash {
  0% {
    box-shadow: 0 0 0 2px rgba(201, 162, 74, 0.9);
    background: #fff6d8;
  }
  100% {
    box-shadow: none;
    background: #faf6ea;
  }
}
.delete-gone-note {
  margin: 0 0 8px;
  padding: 6px 8px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-style: italic;
  color: #8a4040;
  background: #f3e4d4;
  border: 1px dashed #8a4040;
  border-radius: 6px;
}
.delete-gone-note[hidden] { display: none; }


/* ——— Post ID tag (Info mode) ——— */
.post-id-tag {
  position: fixed;
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 10px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.72rem;
  color: var(--ink);
  background: linear-gradient(180deg, #faf6ea, #f3e6c8);
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
  box-shadow:
    0 2px 10px rgba(40, 25, 12, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  pointer-events: auto;
}
.post-id-tag[hidden] { display: none; }
.post-id-tag-text { color: var(--gold-deep); font-weight: 600; letter-spacing: 0.02em; }
.post-id-copy {
  appearance: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--bronze);
  border-radius: 4px;
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  color: var(--ink);
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1;
}
.post-id-copy:hover { filter: brightness(1.06); }
.doc-para.is-post-id-hover {
  outline: 1px solid rgba(201, 162, 74, 0.45);
  outline-offset: 2px;
  background: rgba(232, 192, 96, 0.08);
  border-radius: 4px;
}

.tools-post-id {
  display: inline-block;
  margin-left: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.68rem;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
}
.attr-chip .chip-post-id,
.attr-chip-rich .chip-post-id {
  margin-left: 6px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.68em;
  color: var(--ink-mute);
  opacity: 0.9;
}

/* ——— Delete preview popover ——— */
.delete-preview {
  position: fixed;
  z-index: 110;
  width: min(360px, 42vw);
  max-height: min(420px, 70vh);
  overflow-y: auto;
  padding: 12px 14px;
  background-color: #f3e6c8;
  background-image: linear-gradient(180deg, #faf3e0 0%, #f3e6c8 55%, #e8d5a8 100%);
  border: 2px solid var(--gold-deep);
  border-radius: 10px;
  box-shadow:
    -8px 8px 28px rgba(40, 25, 12, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  color: var(--ink);
  pointer-events: none;
  opacity: 1;
  isolation: isolate;
  backdrop-filter: none;
}
.delete-preview[hidden] { display: none; }
.delete-preview-id {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.72rem;
  color: var(--gold-deep);
  margin-bottom: 6px;
}
.delete-preview-authors {
  font-family: var(--font-display);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.delete-preview-lock {
  font-size: 0.72rem;
  font-style: italic;
  color: var(--amber);
  margin-bottom: 8px;
}
.delete-preview-text {
  font-family: var(--font-display);
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  color: var(--ink);
}
.doc-para.is-delete-preview {
  box-shadow: inset 3px 0 0 var(--gold), 0 0 0 1px rgba(201, 162, 74, 0.35);
  background: rgba(232, 192, 96, 0.1);
  border-radius: 3px;
}

/* ——— Sidebar thread links ——— */
.rail-all-threads,
.rail-manage-link {
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 5px 8px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  text-align: left;
  color: var(--gold-hi);
  background: rgba(30, 18, 10, 0.25);
  border: 1px dashed rgba(201, 162, 74, 0.4);
  border-radius: 6px;
  cursor: pointer;
}
.rail-manage-link {
  margin-top: 4px;
  border-style: solid;
  background: transparent;
  color: rgba(243, 230, 200, 0.7);
  font-style: italic;
}
.rail-all-threads:hover,
.rail-manage-link:hover {
  background: rgba(201, 162, 74, 0.18);
  color: var(--parchment-soft);
}
.rail-threads-head {
  cursor: pointer;
}
.rail-threads-head:hover { color: var(--lantern); }
.thread-list li {
  cursor: pointer;
}
.topbar-threads-btn {
  margin-left: 4px;
}

/* ——— Threads page ——— */
.scene-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.scene-view[hidden] { display: none !important; }
.threads-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 28px 40px;
}
.threads-page[hidden] { display: none !important; }
.threads-page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}
.threads-page-titles { flex: 1; min-width: 0; }
.threads-page-titles h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.85rem;
  color: var(--ink);
}
.threads-page-sub {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-mute);
}
.btn-back-scene,
.btn-new-thread {
  appearance: none;
  padding: 7px 12px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid var(--bronze);
}
.btn-back-scene {
  background: linear-gradient(180deg, #faf6ea, #e8d5a8);
  color: var(--ink);
}
.btn-new-thread {
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  color: #2a1c0c;
  border-color: var(--gold-deep);
  font-weight: 700;
}
.threads-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.threads-search {
  flex: 1;
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  background: linear-gradient(180deg, var(--parchment-soft), var(--parchment));
  border: 1px solid var(--bronze);
  border-radius: 8px;
  outline: none;
}
.threads-search:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--amber-soft);
}
.threads-sort-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  color: var(--ink-mute);
}
.threads-sort {
  padding: 6px 8px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  border: 1px solid var(--bronze);
  border-radius: 6px;
  background: var(--parchment-soft);
  color: var(--ink);
}
.threads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.thread-card {
  position: relative;
  padding: 14px 14px 12px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.35), transparent 45%),
    linear-gradient(180deg, #faf3e0, #f3e6c8 60%, #e8d5a8);
  border: 1px solid rgba(160, 120, 64, 0.45);
  border-radius: 10px;
  box-shadow:
    0 2px 8px rgba(60, 40, 20, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: border-color 150ms, box-shadow 150ms;
}
.thread-card:hover {
  border-color: var(--gold);
  box-shadow:
    0 4px 14px rgba(60, 40, 20, 0.18),
    0 0 0 1px rgba(201, 162, 74, 0.25);
}
.thread-card.is-active {
  border-color: var(--gold-deep);
  box-shadow: inset 3px 0 0 var(--gold), 0 2px 10px rgba(60, 40, 20, 0.15);
}
.thread-card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.thread-card-star {
  appearance: none;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-size: 1.15rem;
  cursor: pointer;
  line-height: 1;
}
.thread-card-star.is-on { color: var(--gold); text-shadow: 0 0 8px rgba(232, 192, 96, 0.55); }
.thread-card-star:hover { color: var(--gold-hi); }
.thread-card-title {
  flex: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.thread-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 4px 0 8px;
  font-size: 0.72rem;
  color: var(--ink-mute);
}
.thread-card-meta .pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(160, 120, 64, 0.35);
  background: rgba(255, 248, 230, 0.6);
}
.thread-card-meta .pill.role-gm { border-color: var(--gold); color: var(--gold-deep); }
.thread-card-meta .pill.status-paused { color: var(--amber); }
.thread-card-blurb {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-style: italic;
  color: var(--ink-soft);
  line-height: 1.35;
}
.thread-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--ink-mute);
}
.thread-card-unread {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  color: #2a1c0c;
  font-weight: 700;
  font-size: 0.68rem;
}
.thread-card-unread:empty,
.thread-card-unread[data-n="0"] { display: none; }
.thread-card-actions {
  display: flex;
  gap: 4px;
  margin-top: 10px;
}
.thread-card-actions button {
  appearance: none;
  padding: 3px 8px;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid var(--bronze);
  border-radius: 5px;
  background: rgba(255, 248, 230, 0.7);
  color: var(--ink-soft);
  cursor: pointer;
}
.thread-card-actions button:hover { background: rgba(201, 162, 74, 0.25); color: var(--ink); }
.thread-card-actions .btn-card-delete {
  color: #6a3434;
  border-color: #8a5050;
}
.thread-fav-order {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.thread-fav-order button {
  appearance: none;
  width: 20px;
  height: 16px;
  padding: 0;
  font-size: 0.6rem;
  line-height: 1;
  border: 1px solid var(--bronze);
  border-radius: 3px;
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  cursor: pointer;
}
.thread-fav-order button:disabled { opacity: 0.35; cursor: not-allowed; }

/* Quick switcher */
.quick-switcher {
  width: min(480px, 92vw);
}
.quick-switcher-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 14px 10px;
}
.quick-switcher-input {
  display: block;
  width: 100%;
  margin: 0;
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  background: linear-gradient(180deg, var(--parchment-soft), var(--parchment));
  border: 1px solid var(--bronze);
  border-radius: 8px;
  outline: none;
}
.quick-switcher-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--amber-soft);
}
.quick-switcher-manage {
  appearance: none;
  align-self: stretch;
  padding: 7px 12px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #2a1c0c;
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  border: 1px solid var(--gold-deep);
  border-radius: 8px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 1px 3px rgba(40, 25, 12, 0.2);
}
.quick-switcher-manage:hover { filter: brightness(1.05); }
.quick-switcher-manage:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--amber-soft), 0 0 10px rgba(232, 192, 96, 0.45);
}
.quick-switcher-item.is-manage-row {
  border: 1px solid var(--gold-deep);
  background: linear-gradient(180deg, #f6edd4, #e8d5a8);
  font-weight: 700;
}
.quick-switcher-item.is-manage-row .qs-title {
  color: var(--gold-deep);
}
.quick-switcher-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0 10px 8px;
  max-height: 360px;
  overflow-y: auto;
}
.quick-switcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--ink);
  border: 1px solid transparent;
}
.quick-switcher-item:hover,
.quick-switcher-item.is-active {
  background: rgba(201, 162, 74, 0.18);
  border-color: rgba(201, 162, 74, 0.4);
}
.quick-switcher-item .qs-star {
  color: var(--gold);
  width: 1.1em;
  text-align: center;
}
.quick-switcher-item .qs-star.is-off { color: transparent; }
.quick-switcher-item .qs-title {
  flex: 1;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
}
.quick-switcher-item .qs-meta {
  font-size: 0.72rem;
  color: var(--ink-mute);
}
.coming-soon-modal { width: min(360px, 92vw); }
.coming-soon-body {
  margin: 0 16px 18px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-soft);
}
.edit-thread-form {
  padding: 4px 16px 16px;
}
.app.view-threads .compose-dock {
  display: none !important;
}
.app.view-threads .shell {
  padding-bottom: 0;
}
.app.view-threads .threads-page {
  flex: 1;
  min-height: 0;
  height: 100%;
}
.app.view-threads .mode-banner { display: none; }

.topbar-session {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.topbar-session .session-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-threads-btn {
  display: none !important;
}


/* Topbar comfort at ~1024–1280 */
@media (max-width: 1280px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-title { font-size: 1.15rem; letter-spacing: 0.04em; }
  .mode-tab { padding: 5px 9px; font-size: 0.78rem; }
  .btn-view-source { padding: 4px 8px; font-size: 0.7rem; margin-left: 0; }
  .topbar-presence { gap: 4px; }
}

/* ========== Thin windows (desktop side-snap ~420–1000px) ========== */

.topbar {
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: visible;
  min-width: 0;
}
.topbar > * {
  flex-shrink: 0;
}
.topbar-session {
  flex-shrink: 1;
  min-width: 0;
}
.topbar-hamburger {
  appearance: none;
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  margin-right: 2px;
  border: 1px solid rgba(201, 162, 74, 0.55);
  border-radius: 7px;
  background: rgba(30, 18, 10, 0.4);
  color: var(--gold-hi);
  font-size: 1rem;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.12);
}
.topbar-hamburger:hover {
  border-color: var(--gold);
  background: rgba(201, 162, 74, 0.18);
}
.topbar-hamburger[hidden] { display: none !important; }

.mode-tab-label { display: inline; }
.btn-source-label { display: inline; }
.btn-source-icon { margin-right: 2px; }

.topbar-overflow {
  position: relative;
  flex-shrink: 0;
  display: none;
}
.topbar-overflow.is-active { display: block; }
.topbar-overflow-btn {
  appearance: none;
  width: 32px;
  height: 28px;
  padding: 0;
  border: 1px dashed rgba(201, 162, 74, 0.45);
  border-radius: 6px;
  background: rgba(30, 18, 10, 0.3);
  color: rgba(243, 230, 200, 0.85);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.topbar-overflow-btn:hover,
.topbar-overflow-btn[aria-expanded="true"] {
  color: var(--parchment-soft);
  border-color: var(--gold);
  background: rgba(201, 162, 74, 0.15);
}
.topbar-overflow-btn[hidden] { display: none !important; }

.parchment-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  min-width: 160px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  background: #f3e6c8;
  background-image: linear-gradient(180deg, #faf3e0 0%, #f3e6c8 55%, #e8d5a8 100%);
  border: 2px solid var(--gold-deep);
  border-radius: 10px;
  box-shadow:
    0 12px 32px rgba(40, 25, 12, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  color: var(--ink);
}
.parchment-dropdown[hidden] { display: none !important; }
.topbar-overflow-item,
.info-sheets-item {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  margin: 0 0 2px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.topbar-overflow-item:hover,
.info-sheets-item:hover {
  background: rgba(201, 162, 74, 0.22);
  border-color: rgba(160, 120, 64, 0.35);
}

/* Rail overlay / scrim */
.rail-scrim {
  position: fixed;
  inset: 0;
  z-index: 88;
  background: rgba(30, 18, 10, 0.45);
}
.rail-scrim[hidden] { display: none !important; }

.rail-icon-btn[data-rail-icon="expand"] {
  color: var(--parchment-soft);
  border-style: dashed;
}

/* Compose post icon (hidden by default) */
.btn-post-icon { display: none; }
.compose-hint-short { display: none; }

/* Info sheets menu (hidden until narrow) */
.info-sheets-menu {
  display: none;
  position: relative;
}
.info-sheets-btn {
  appearance: none;
  padding: 4px 10px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--parchment-soft);
  background: rgba(30, 18, 10, 0.35);
  border: 1px solid rgba(201, 162, 74, 0.55);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.info-sheets-btn:hover,
.info-sheets-btn[aria-expanded="true"] {
  color: #2a1c0c;
  background: linear-gradient(180deg, var(--gold-hi), var(--brass));
  border-color: var(--gold-deep);
}
.info-sheets-dropdown {
  left: 0;
  right: auto;
  min-width: 180px;
}

/* —— Breakpoint: ≤1100 — auto icon rail, players compact already via JS —— */
@media (max-width: 1100px) {
  .presence-chip .presence-tag { max-width: 4.5em; overflow: hidden; text-overflow: ellipsis; }

  /* Auto-collapse to icon rail (manual expand opens overlay) */
  .app:not(.rail-overlay-open) {
    --rail-w: 56px;
  }
  .app:not(.rail-overlay-open) .rail {
    padding: 40px 6px 16px;
    overflow: hidden;
  }
  .app:not(.rail-overlay-open) .rail-nav {
    display: none;
  }
  .app:not(.rail-overlay-open) .rail-icons,
  .app:not(.rail-overlay-open) .rail-icons[hidden] {
    display: flex !important;
  }
  .app:not(.rail-overlay-open) .rail-toggle {
    display: none;
  }
  /* User-expanded preference above 1100 still uses .rail-collapsed */
}

/* Rail overlay (full sidebar as solid panel) */
.app.rail-overlay-open .rail {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 92;
  width: min(280px, calc(100vw - 48px)) !important;
  flex-basis: auto !important;
  padding: 14px 12px 20px;
  overflow-x: hidden;
  overflow-y: auto;
  box-shadow:
    8px 0 32px rgba(20, 12, 6, 0.55),
    inset -2px 0 0 rgba(201, 162, 74, 0.2);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0%, transparent 12%),
    linear-gradient(180deg, #5a3c26 0%, #4a3220 50%, #3e2918 100%);
}
.app.rail-overlay-open .rail-nav { display: block !important; }
.app.rail-overlay-open .rail-icons { display: none !important; }
.app.rail-overlay-open .rail-toggle { display: none; }
.app.rail-overlay-open .shell {
  /* keep layout as if rail were icon/hidden so manuscript doesn't jump under overlay */
}
.app.rail-overlay-open.mq-rail-hidden {
  --rail-w: 0px;
}
.app.rail-overlay-open.mq-rail-hidden .rail {
  /* overlay still shows; in-flow space is none */
}

/* —— ≤960: mode icon-only, denser topbar —— */
@media (max-width: 960px) {
  .mode-tab {
    padding: 5px 8px;
    font-size: 0.78rem;
    gap: 0;
  }
  .mode-tab-label { display: none; }
  .mode-tab-icon {
    display: inline !important;
    font-size: 0.95rem;
    opacity: 0.9;
  }
  .mode-tab.is-active .mode-tab-icon { opacity: 1; }
  .brand-title { font-size: 1.05rem; }
  .main::before,
  .main::after { display: none; }
  .doc { padding: 8px 22px 28px; }
  .thread-header { padding: 12px 22px 8px; }
  .thread-header h2 { font-size: 1.55rem; }
  .thread-blurb { font-size: 0.9rem; }
}

/* —— ≤820: Tools/Source → overflow menu; players dots+count —— */
@media (max-width: 820px) {
  .topbar-tools-btn,
  .topbar-source-btn { display: none !important; }
  .topbar-overflow { display: block; }
  .topbar-overflow-btn { display: inline-flex !important; align-items: center; justify-content: center; }
  .presence-compact-label { display: none; }
  .presence-compact {
    padding: 4px 8px;
    gap: 4px;
  }
  .presence-compact::after {
    content: attr(data-count);
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--parchment-soft);
  }
  .compose-hint-full { display: none; }
  .compose-hint-short { display: inline; }
  .compose-hint { font-size: 0.72rem; }
  .info-banner-links .info-link-tab { display: none; }
  .info-sheets-menu { display: inline-block; }
  .info-banner {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 10px;
    min-height: 0;
    overflow: hidden;
  }
  .info-banner-widgets {
    flex: 1 1 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    padding-bottom: 2px;
    mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent);
    scrollbar-width: thin;
  }
  .app[data-mode="info"] { --compose-h: 108px; }
}

/* —— ≤800: shorter compose hint already; tweak dock —— */
@media (max-width: 800px) {
  .compose-bar { padding: 6px 12px 10px; }
  .queue-strip { padding: 0 12px; }
  .compose-target { margin-left: 0; }
}

/* —— ≤700: threads 2-col; tighter manuscript —— */
@media (max-width: 700px) {
  .doc { padding: 6px 16px 24px; font-size: 1.05rem; }
  .thread-header { padding: 10px 16px 6px; }
  .thread-header h2 { font-size: 1.4rem; }
  .threads-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .threads-page { padding: 14px 14px 32px; }
  .threads-toolbar { flex-wrap: wrap; }
  .threads-page-head { flex-wrap: wrap; }
}

/* —— ≤640: hide rail; hamburger; tools full width —— */
@media (max-width: 640px) {
  .app:not(.rail-overlay-open) {
    --rail-w: 0px;
  }
  .app:not(.rail-overlay-open) .rail {
    display: none;
  }
  .topbar-hamburger {
    display: inline-flex !important;
  }
  .topbar-hamburger[hidden] { display: inline-flex !important; }

  .tools-panel {
    width: 100vw !important;
    max-width: 100vw !important;
    left: 0;
    right: 0;
  }
  .tools-panel.is-expanded {
    width: 100vw !important;
    max-width: 100vw !important;
  }
  .tools-expand-btn { display: none !important; }
  .tools-panel-head { padding-right: 48px; }

  .players-dropdown,
  .quick-switcher,
  .parchment-modal,
  .coming-soon-modal {
    max-width: calc(100vw - 24px) !important;
    width: min(720px, calc(100vw - 24px));
  }
  .players-dropdown {
    min-width: 0;
    right: -8px;
  }
}

/* —— ≤520: hide avatar; post icon-only; threads 1-col —— */
@media (max-width: 520px) {
  .compose-avatar { display: none; }
  .compose-target { margin-left: 0; }
  .compose-hint { margin-left: 0; }
  .btn-post {
    min-width: 40px;
    width: 40px;
    padding: 0;
    border-radius: 50%;
  }
  .btn-post-label { display: none; }
  .btn-post-icon { display: inline; font-size: 1.05rem; }
  .threads-grid { grid-template-columns: 1fr; }
  .brand-title { display: none; }
  .doc { padding: 6px 12px 20px; }
  .thread-header { padding: 8px 12px 4px; }
  :root { --compose-h: 132px; }
  .app[data-mode="info"] { --compose-h: 110px; }
}

/* —— ≤420 comfort —— */
@media (max-width: 420px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .mode-tab { padding: 5px 7px; }
  .session-name { font-size: 0.92rem; }
}

/* Tools default width clamp */
.tools-panel {
  width: min(440px, 100vw);
  max-width: 100vw;
}
.tools-panel.is-expanded {
  width: min(max(640px, 60vw), 100vw);
  max-width: 100vw;
}

/* Delete preview: when JS adds .is-inline, show under the row as a card */
.delete-preview.is-inline {
  position: fixed;
  z-index: 100;
  max-width: min(360px, calc(100vw - 24px));
  box-shadow:
    0 12px 32px rgba(40, 25, 12, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* New posts pill / toast stay in manuscript column */
.new-posts-pill {
  max-width: calc(100% - 24px);
  white-space: nowrap;
}
.tf-toast {
  max-width: min(460px, calc(100vw - 24px));
  left: 50%;
}

/* Shell / main never spill horizontally */
.shell, .main, .scene-view {
  min-width: 0;
  max-width: 100%;
}
