/* Семейный архив: книжная сцена разговорника.
   Runtime-логика живет в app.js; здесь только материал, сетка и состояния. */

:root {
  color-scheme: dark;

  --stage-w: 1448px;
  --stage-h: 1086px;
  --topbar-h: 69px;

  --leather: #171614;
  --leather-2: #22201c;
  --wood: #3f2f21;
  --wood-deep: #22170f;
  --paper: #f0e2c4;
  --paper-hi: #f8ecd1;
  --paper-low: #dfc999;
  --paper-line: rgba(88, 59, 30, 0.18);
  --ink: #35271b;
  --ink-soft: #755f45;
  --ink-faint: #9a8263;
  --gold: #d9b46f;
  --gold-soft: #b79a67;
  --red: #b24b32;
  --red-deep: #923b28;
  --green: #425b4c;
  --green-deep: #263f35;
  --green-soft: #eef4eb;
  --shadow-ink: rgba(25, 14, 6, 0.45);

  --font-title: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: "PT Serif", Georgia, "Times New Roman", serif;
  --font-hand: "Marck Script", "Segoe Script", cursive;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body.room {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  overflow: auto;
  background:
    radial-gradient(1200px 680px at 50% 18%, rgba(246, 212, 145, 0.18), transparent 62%),
    linear-gradient(180deg, #2a2119 0%, #120d09 100%);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
}

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

button {
  cursor: pointer;
}

button:disabled,
textarea:disabled {
  cursor: default;
}

h1,
h2,
p {
  margin: 0;
}

/* Desktop/laptop fit shell. JS sets the exact scaled dimensions so the
   reference artboard can shrink to old/small screens without horizontal scroll. */
.archive-shell {
  position: relative;
  width: var(--stage-w);
  height: var(--stage-h);
  margin: 0 auto;
}

/* ---------- stage ---------- */
.archive-stage {
  position: relative;
  width: var(--stage-w);
  min-height: var(--stage-h);
  margin: 0;
  overflow: hidden;
  transform-origin: top left;
  background:
    linear-gradient(180deg, rgba(156, 103, 55, 0.42), rgba(58, 32, 18, 0.10)),
    url("./assets/archive/desk-tabletop.jpg") center / cover no-repeat,
    linear-gradient(180deg, #594231 0, #3f2d1f 38%, #2a1b11 100%);
  background-blend-mode: screen, normal, normal;
  box-shadow: 0 0 0 1px rgba(255, 240, 202, 0.08) inset;
}

body.room--compact {
  overflow: hidden;
}

body.room--compact .archive-shell,
body.room--compact .archive-stage {
  height: 100vh;
}

body.room--compact .archive-stage {
  min-height: 100vh;
}

body.room--compact .topbar {
  grid-template-columns: 390px minmax(0, 1fr) 140px;
  gap: 14px;
  padding: 0 24px;
}

body.room--compact .brand {
  gap: 11px;
}

body.room--compact .brand__copy {
  padding-left: 11px;
}

body.room--compact .brand__copy::before {
  top: 5px;
  bottom: 4px;
}

body.room--compact .brand__title {
  font-size: 25px;
  letter-spacing: 0.024em;
  white-space: nowrap;
}

body.room--compact .brand__mark {
  display: block;
  font-size: 38px;
}

body.room--compact .brand__tagline {
  display: block;
  font-size: 11px;
}

body.room--compact .source-nav__label {
  display: none;
}

body.room--compact .source-nav {
  min-height: 38px;
  padding: 5px 8px;
  border-radius: 11px;
}

body.room--compact .authors {
  gap: 5px;
}

body.room--compact .author-chip {
  min-width: 80px;
  min-height: 29px;
  padding: 0 9px;
}

body.room--compact .author-chip__name {
  font-size: 12px;
}

body.room--compact .archive-links {
  gap: 12px;
  margin-right: 0;
}

body.room--compact .archive-links a {
  gap: 6px;
  font-size: 12px;
}

body.room--compact .archive-links a span:first-child {
  font-size: 17px;
}

@media (min-width: 861px) and (max-width: 1080px) {
  body.room--compact .topbar {
    grid-template-columns: 340px minmax(0, 1fr);
  }

  body.room--compact .brand {
    gap: 10px;
  }

  body.room--compact .brand__mark {
    font-size: 34px;
  }

  body.room--compact .brand__title {
    font-size: 28px;
  }

  body.room--compact .brand__tagline {
    display: none;
  }
}

.archive-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.74;
  mix-blend-mode: overlay;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 205, 125, 0.10) 0 2px,
      transparent 2px 72px,
      rgba(25, 12, 6, 0.34) 72px 78px,
      transparent 78px 166px
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0 198px,
      rgba(255, 222, 150, 0.08) 198px 200px,
      rgba(22, 10, 5, 0.28) 200px 203px,
      transparent 203px 408px
    ),
    radial-gradient(760px 520px at 20% 42%, rgba(190, 115, 56, 0.24), transparent 64%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: auto, auto, auto, 220px 220px;
}

html[data-archive-debug="target"] .archive-stage::after,
html[data-archive-debug="diff"] .archive-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: url("/assets/archive/archive-ui-target.png") 0 0 / 1448px 1086px no-repeat;
  opacity: 0.42;
}

html[data-archive-debug="diff"] .archive-stage::after {
  mix-blend-mode: difference;
  opacity: 0.55;
}

/* ---------- leather topbar ---------- */
.topbar {
  position: relative;
  z-index: 5;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr) 260px;
  align-items: center;
  gap: 20px;
  padding: 0 34px;
  overflow: hidden;
  background:
    radial-gradient(780px 116px at 52% -44%, rgba(223, 185, 104, 0.070), transparent 65%),
    linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.012) 42%, rgba(0,0,0,0.32) 100%),
    linear-gradient(180deg, rgba(31, 29, 25, 0.58), rgba(18, 16, 14, 0.70)),
    url("./assets/archive/topbar-leather.jpg") center / cover no-repeat,
    linear-gradient(180deg, #201f1b, #171511 58%, #0d0c0a);
  border: 1px solid rgba(226, 196, 135, 0.13);
  border-top-left-radius: 9px;
  border-top-right-radius: 9px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.10) inset,
    0 -1px 0 rgba(0,0,0,0.84) inset,
    0 0 0 1px rgba(0,0,0,0.42),
    0 16px 28px -22px #000,
    0 3px 0 rgba(0,0,0,0.55);
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 24.5%, rgba(226, 196, 135, 0.060) 24.58%, rgba(0,0,0,0.30) 24.68%, transparent 24.82% 74.85%, rgba(226, 196, 135, 0.045) 74.93%, rgba(0,0,0,0.28) 75.03%, transparent 75.18%),
    linear-gradient(180deg, rgba(255,255,255,0.018), transparent 36%, transparent 72%, rgba(208, 174, 110, 0.040) 73%, rgba(0,0,0,0.40) 100%);
  opacity: 0.26;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.32' numOctaves='4'/%3E%3C/filter%3E%3Crect width='150' height='150' filter='url(%23n)'/%3E%3C/svg%3E");
}

.brand,
.source-nav,
.archive-links {
  position: relative;
  z-index: 2;
}

.brand {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand__mark {
  flex: 0 0 auto;
  display: block;
  font-family: var(--font-title);
  font-size: 42px;
  line-height: 0.9;
  font-weight: 700;
  letter-spacing: -0.065em;
  color: #ddb66d;
  transform: translateY(-1px);
  text-shadow:
    0 1px 0 #000,
    0 0 14px rgba(226, 186, 104, 0.26);
}

.brand__copy {
  position: relative;
  min-width: 0;
  padding-left: 13px;
}

.brand__copy::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 5px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(224, 189, 118, 0.55), transparent);
}

.brand__title {
  font-family: var(--font-title);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: 0.026em;
  text-transform: none;
  color: #e5c37d;
  line-height: 0.96;
  text-shadow:
    0 1px 0 #000,
    0 -1px 0 rgba(255, 239, 184, 0.16),
    0 0 12px rgba(226, 186, 104, 0.24);
}

.brand__tagline {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 600;
  color: #d4c29a;
  letter-spacing: 0.018em;
}

.source-nav {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-height: 43px;
  padding: 5px 10px;
  border: 1px solid rgba(214, 189, 139, 0.085);
  border-radius: 13px;
  background:
    radial-gradient(120px 28px at 50% 0, rgba(62, 89, 64, 0.26), transparent 70%),
    linear-gradient(180deg, rgba(255,255,255,0.020), rgba(0,0,0,0.24)),
    rgba(10, 9, 8, 0.22);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.040) inset,
    0 0 0 1px rgba(0,0,0,0.24),
    0 12px 22px -22px rgba(0,0,0,0.84);
}

.source-nav::before {
  display: none;
}

.source-nav__label {
  display: none;
}

.authors {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.author-chip {
  min-width: 94px;
  min-height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 14px;
  border: 1px solid rgba(215, 195, 151, 0.25);
  border-radius: 999px;
  background:
    radial-gradient(110% 120% at 50% 0%, rgba(255,255,255,0.09), transparent 44%),
    linear-gradient(180deg, rgba(255,255,255,0.045), rgba(0,0,0,0.28)),
    linear-gradient(180deg, rgba(51, 46, 38, 0.93), rgba(30, 27, 23, 0.90));
  box-shadow:
    0 1px 0 rgba(255,255,255,0.13) inset,
    0 -1px 0 rgba(0,0,0,0.58) inset,
    0 9px 18px -13px rgba(0,0,0,0.95);
  color: #cfc0a5;
  transition: color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.author-chip:hover {
  border-color: rgba(224, 199, 143, 0.6);
  color: #f4e7c9;
}

.author-chip--active {
  border-color: #d35a38;
  color: #fff2d4;
  background:
    radial-gradient(120% 130% at 50% 0%, rgba(255, 209, 139, 0.13), transparent 48%),
    linear-gradient(180deg, rgba(255,255,255,0.075), rgba(121, 38, 24, 0.22)),
    linear-gradient(180deg, #2b251f, #161310);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.14) inset,
    0 -1px 0 rgba(0,0,0,0.52) inset,
    0 0 0 1px rgba(213, 88, 55, 0.50),
    0 0 14px rgba(214, 83, 43, 0.66),
    0 0 34px rgba(174, 53, 30, 0.30);
}

.stamp {
  display: none;
}

.author-chip__name {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 0 #000;
}

.archive-links {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 22px;
  margin-right: 0;
}

.archive-links a {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #d6c4a3;
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}

.archive-links a span:first-child {
  font-size: 20px;
  line-height: 1;
  color: var(--gold-soft);
  opacity: 0.9;
}

/* ---------- mobile tabs, hidden on desktop ---------- */
.mobile-tabs {
  display: none;
}

/* ---------- desk columns ---------- */
.columns {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 813px 512px;
  gap: 35px;
  align-items: start;
  padding: 14px 14px 24px 73px;
}

body.room--compact .columns {
  grid-template-columns: minmax(0, 1fr) minmax(480px, 32vw);
  gap: 24px;
  height: calc(100vh - var(--topbar-h));
  padding: 14px 18px 16px 62px;
}

.col {
  min-width: 0;
}

.desk-prop--left {
  position: absolute;
  left: -48px;
  top: 142px;
  width: 224px;
  aspect-ratio: 830 / 1894;
  z-index: 1;
  pointer-events: none;
  background: url("./assets/archive/desk-pen-notes.png") center / contain no-repeat;
  filter: drop-shadow(11px 18px 18px rgba(0, 0, 0, 0.34)) sepia(0.05) saturate(0.94);
  opacity: 0.96;
}

body.room--compact .desk-prop--left {
  left: -62px;
  top: 132px;
  width: 198px;
}

/* ---------- paper panels ---------- */
.panel {
  position: relative;
  z-index: 2;
  min-width: 0;
  color: var(--ink);
  border: 1px solid rgba(70, 46, 24, 0.30);
  background:
    linear-gradient(90deg, rgba(99, 68, 35, 0.10), transparent 14%, transparent 88%, rgba(87, 58, 28, 0.10)),
    radial-gradient(600px 520px at 40% 4%, rgba(255,255,255,0.36), transparent 70%),
    linear-gradient(180deg, var(--paper-hi), var(--paper) 70%, #e6d3a6);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.62) inset,
    0 0 0 1px rgba(255,255,255,0.10) inset,
    0 24px 36px -22px rgba(0,0,0,0.65),
    0 4px 0 rgba(68, 45, 26, 0.28);
  overflow: hidden;
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.20;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='210' height='210'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.48' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='210' height='210' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 210px 210px;
}

.panel > * {
  position: relative;
  z-index: 1;
}

.book-panel {
  height: 906px;
  border-radius: 10px 17px 12px 10px;
  padding: 46px 68px 42px 74px;
  box-shadow:
    9px 0 0 -4px #efddb0,
    13px 0 0 -5px #d6bb7f,
    17px 0 0 -6px rgba(84, 55, 28, 0.68),
    22px 0 0 -8px rgba(35, 22, 12, 0.78),
    0 1px 0 rgba(255,255,255,0.62) inset,
    0 30px 42px -22px rgba(0,0,0,0.72),
    0 0 0 8px rgba(21, 16, 12, 0.36);
}

body.room--compact .book-panel {
  height: calc(100vh - var(--topbar-h) - 30px);
  min-height: 0;
  padding: 34px 62px 28px 64px;
}

.book-panel::before {
  content: "";
  position: absolute;
  top: 10px;
  right: 6px;
  bottom: 10px;
  width: 19px;
  border-radius: 0 14px 14px 0;
  background:
    repeating-linear-gradient(90deg, rgba(96, 62, 30, 0.30) 0 1px, transparent 1px 4px),
    linear-gradient(90deg, rgba(111, 76, 36, 0.30), rgba(255,255,255,0.24), rgba(108, 75, 38, 0.20));
  opacity: 0.82;
}

.library-panel {
  height: 916px;
  border-radius: 10px;
  padding: 36px 32px 34px;
  box-shadow:
    8px 0 0 -4px #eedbb1,
    12px 0 0 -5px #d7bb81,
    17px 0 0 -8px rgba(54, 35, 20, 0.70),
    0 1px 0 rgba(255,255,255,0.62) inset,
    0 28px 38px -24px rgba(0,0,0,0.76),
    0 0 0 7px rgba(21, 16, 12, 0.34);
}

body.room--compact .library-panel {
  height: calc(100vh - var(--topbar-h) - 30px);
  min-height: 0;
  padding: 28px 30px 24px;
}

.library-panel::before {
  content: none;
}

/* ---------- dialog book ---------- */
.panel__head {
  display: none;
}

.panel__title {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink);
  white-space: nowrap;
}

.panel__subtitle {
  margin-top: 8px;
  color: #a94a33;
  font-family: var(--font-hand);
  font-size: 23px;
  line-height: 1.05;
  letter-spacing: 0.05em;
}

body.room--compact .panel__title {
  font-size: 15px;
}

.panel__head::after {
  content: "";
  display: block;
  width: 130px;
  height: 1px;
  margin-top: 16px;
  background: rgba(135, 93, 45, 0.42);
}

.book-lead {
  display: none;
  width: min(760px, 100%);
  margin-top: 20px;
  font-size: 17px;
  line-height: 1.42;
  font-weight: 600;
  color: #2d251b;
  white-space: nowrap;
}

body.room--compact .book-lead {
  width: min(760px, 82%);
  margin-top: 18px;
  font-size: 15px;
  line-height: 1.38;
}

.lamp-sketch {
  position: absolute;
  top: 56px;
  right: 88px;
  width: 126px;
  height: 156px;
  opacity: 0.16;
  transform: rotate(-8deg);
}

.lamp-sketch::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 24px;
  width: 70px;
  height: 46px;
  border: 2px solid #6e5637;
  border-bottom-width: 4px;
  border-radius: 8px 8px 16px 16px;
  transform: rotate(24deg);
}

.lamp-sketch::after {
  content: "";
  position: absolute;
  left: 64px;
  top: 72px;
  width: 38px;
  height: 70px;
  border-left: 3px solid #6e5637;
  border-bottom: 4px solid #6e5637;
  transform: skewX(-18deg);
  box-shadow: -42px 68px 0 -18px #6e5637, -18px 71px 0 -21px #6e5637;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 704px;
  min-height: 0;
  margin-top: 0;
  overflow: auto;
  padding: 0 10px 42px 0;
  border-bottom: 1px solid rgba(135, 93, 45, 0.18);
  scrollbar-color: rgba(96, 68, 38, 0.36) transparent;
}

body.room--compact .thread {
  height: calc(100vh - var(--topbar-h) - 150px);
  min-height: 72px;
  margin-top: 0;
}

.papa-intro {
  display: none;
}

.msg {
  display: flex;
  flex-direction: column;
}

.msg--you {
  align-items: stretch;
}

.msg--you .msg__label {
  display: none;
}

.msg--you .msg__text {
  position: relative;
  min-height: 58px;
  display: grid;
  align-items: center;
  padding: 14px 28px;
  border: 1px solid rgba(97, 68, 35, 0.22);
  border-radius: 8px;
  background: rgba(245, 232, 203, 0.44);
  color: #392b1d;
  font-family: var(--font-title);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.35;
  font-style: italic;
  box-shadow: 0 1px 0 rgba(255,255,255,0.55) inset;
}

.msg--you .msg__text::before {
  display: none;
  content: none;
}

.msg--you .msg__text::after {
  display: none;
  content: none;
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(111, 92, 64, 0.62);
  font-family: var(--font-body);
  font-size: 13px;
  font-style: normal;
}

.msg--papa {
  align-items: stretch;
}

.msg--papa > .msg__text {
  font-family: var(--font-hand);
  font-size: 25px;
  line-height: 1.4;
  color: var(--ink);
}

.papa-answer {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.answer-lead {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 18px;
  font-weight: 700;
  color: #3b2d1f;
}

.answer-lead::before {
  content: "⌕";
  color: var(--red);
  font-size: 30px;
  line-height: 1;
}

/* ---------- quote cards ---------- */
.vypiska {
  position: relative;
  border: 1px solid rgba(88, 59, 30, 0.16);
  border-radius: 8px;
  background:
    radial-gradient(360px 180px at 40% 0%, rgba(255,255,255,0.42), transparent 74%),
    linear-gradient(180deg, #f8ecd2, #efe0bf);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.56) inset,
    0 16px 20px -16px rgba(67, 43, 22, 0.72);
  padding: 24px 64px 26px 68px;
}

.vypiska::before {
  content: "“";
  position: absolute;
  left: 24px;
  top: 20px;
  font-family: var(--font-title);
  font-size: 58px;
  line-height: 1;
  color: rgba(194, 151, 78, 0.58);
}

.vypiska::after {
  content: "⌑";
  position: absolute;
  right: 24px;
  top: 24px;
  color: rgba(106, 82, 52, 0.44);
  font-size: 25px;
}

.vypiska--fresh {
  animation: rise 0.42s ease-out both;
}

.vypiska__text {
  white-space: pre-line;
  color: var(--ink);
  font-family: var(--font-title);
  font-size: 21px;
  line-height: 1.35;
  font-style: italic;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.vypiska__foot {
  display: block;
  margin-top: 17px;
}

.vypiska__sign {
  display: inline-block;
  color: var(--red-deep);
  font-family: var(--font-hand);
  font-size: 20px;
  line-height: 1.2;
}

/* ---------- loading ---------- */
.papa-loading {
  display: flex;
  align-items: center;
  gap: 13px;
  font-weight: 700;
  color: #3b2d1f;
}

.papa-loading::before {
  content: "⌕";
  color: var(--red);
  font-size: 30px;
  line-height: 1;
}

.papa-loading::after {
  display: none;
  content: none;
}

.papa-loading__dots {
  display: inline-flex;
  gap: 11px;
  order: 3;
  margin-left: 6px;
}

.papa-loading__dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c88b67;
  animation: dot-pulse 1.1s ease-in-out infinite;
}

.papa-loading__dots i:nth-child(1) {
  background: var(--red);
}

.papa-loading__dots i:nth-child(2) {
  background: var(--gold);
  animation-delay: 0.18s;
}

.papa-loading__dots i:nth-child(3) {
  background: var(--green);
  animation-delay: 0.36s;
}

.papa-loading__text {
  font-size: 18px;
}

/* ---------- composer ---------- */
.composer {
  position: absolute;
  left: 40px;
  right: 42px;
  bottom: 39px;
  display: grid;
  grid-template-columns: 1fr 188px;
  gap: 18px;
  align-items: stretch;
  min-height: 104px;
  padding: 18px 30px;
  border: 1px solid rgba(130, 88, 40, 0.22);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.45), rgba(235, 210, 166, 0.55)),
    #ead8b3;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.62) inset,
    0 16px 22px -17px rgba(61, 37, 18, 0.78);
}

body.room--compact .composer {
  left: 40px;
  right: 42px;
  bottom: 24px;
  grid-template-columns: 1fr 148px;
  min-height: 76px;
  padding: 12px 22px;
}

body.room--compact .composer::before {
  content: none;
}

body.room--compact .composer__input {
  font-size: 15px;
}

body.room--compact .composer__btn {
  font-size: 17px;
}

.composer::before {
  content: none;
}

.composer::after {
  content: none;
}

.composer--shake {
  animation: shake 0.45s ease-in-out;
}

.composer__input {
  width: 100%;
  min-width: 0;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 8px 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.45;
  outline: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(103, 78, 46, 0.50) transparent;
}

.composer__input::-webkit-scrollbar {
  width: 10px;
}

.composer__input::-webkit-scrollbar-track {
  background: rgba(138, 103, 60, 0.08);
  border-radius: 999px;
}

.composer__input::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(103, 78, 46, 0.48);
  border: 3px solid rgba(244, 230, 199, 0.76);
}

.composer__input::placeholder {
  color: rgba(111, 92, 64, 0.74);
}

.composer__btn {
  border: 1px solid rgba(101, 42, 27, 0.5);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14), transparent 34%),
    var(--red);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.24) inset,
    0 6px 10px -6px rgba(0,0,0,0.72);
  color: #fff0ce;
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: 700;
}

.composer__btn:hover:not(:disabled) {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14), transparent 34%),
    var(--red-deep);
}

.composer__btn:disabled {
  opacity: 0.58;
}

/* ---------- shelf ---------- */
.shelf__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

body.room--compact .shelf__head {
  margin-bottom: 18px;
}

.shelf__title {
  font-family: var(--font-title);
  font-size: 31px;
  line-height: 1.05;
  font-weight: 700;
  color: var(--ink);
}

body.room--compact .shelf__title {
  font-size: 24px;
}

body.room--compact .shelf__count {
  min-width: 32px;
  height: 28px;
  font-size: 12px;
}

.shelf__count {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--green-deep);
  color: #fff1d0;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 12px 18px -12px rgba(0,0,0,0.78);
}

.tagcloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 8px;
  margin-bottom: 18px;
}

body.room--compact .tagcloud {
  gap: 8px 8px;
  margin-bottom: 16px;
}

body.room--compact .tag {
  min-height: 26px;
  padding: 0 9px;
  font-size: 12px;
}

body.room--compact .tag__n {
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  font-size: 11px;
}

body.room--compact .shelf__divider {
  margin: 0 24px 12px;
  font-size: 15px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(97, 68, 35, 0.15);
  border-radius: 999px;
  background: rgba(250, 241, 220, 0.58);
  color: #2f2418;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.tag:hover {
  border-color: rgba(66, 91, 76, 0.44);
}

.tag__n {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.62);
  color: #74624a;
  font-size: 12px;
  box-shadow: 0 1px 3px rgba(103, 78, 46, 0.10);
}

.tag--active {
  background: #385343;
  border-color: #385343;
  color: #fff1d0;
  box-shadow: 0 6px 12px -10px rgba(24, 31, 25, 0.8);
}

.tag--active .tag__n {
  color: var(--green-deep);
}

.shelf__divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 0 18px 24px;
  color: #3a2b1c;
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 700;
}

.shelf__divider::before,
.shelf__divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(135, 93, 45, 0.36);
}

.shelf__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 592px;
  overflow: auto;
  scrollbar-gutter: stable;
  padding: 0 10px 24px 0;
  scrollbar-color: rgba(96, 68, 38, 0.48) transparent;
}

body.room--compact .shelf__list {
  height: calc(100vh - var(--topbar-h) - 206px);
  min-height: 240px;
}

body.room--compact .vypiska--compact {
  padding: 17px 44px 17px 24px;
}

body.room--compact .vypiska--compact::after {
  top: 15px;
  font-size: 17px;
}

body.room--compact .vypiska--compact .vypiska__text {
  font-size: 20px;
  line-height: 1.3;
}

body.room--compact .vypiska--compact .vypiska__sign {
  font-size: 15px;
}

.shelf__list::-webkit-scrollbar {
  width: 10px;
}

.shelf__list::-webkit-scrollbar-track {
  background: rgba(138, 103, 60, 0.09);
  border-radius: 999px;
}

.shelf__list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(103, 78, 46, 0.50);
  border: 3px solid rgba(244, 230, 199, 0.76);
}

.shelf__empty {
  padding: 18px 8px;
  color: var(--ink-faint);
  font-family: var(--font-hand);
  font-size: 22px;
}

.vypiska--compact {
  cursor: default;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.5) inset,
    0 11px 15px -13px rgba(67, 43, 22, 0.66);
  padding: 19px 54px 18px 30px;
  transition: box-shadow 0.16s ease;
}

.vypiska--compact::before {
  content: none;
}

.vypiska--compact::after {
  right: 18px;
  top: 25px;
  font-size: 21px;
}

.vypiska--compact .vypiska__text {
  font-family: var(--font-title);
  font-size: 21px;
  line-height: 1.28;
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0;
}

.vypiska--compact .vypiska__foot {
  margin-top: 12px;
}

.vypiska--compact .vypiska__sign {
  font-family: var(--font-hand);
  font-size: 17px;
}

/* ---------- update modal ---------- */
.update-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 12, 7, 0.68);
}

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

.update-card {
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid rgba(88, 59, 30, 0.22);
  border-radius: 9px;
  background: linear-gradient(180deg, var(--paper-hi), var(--paper));
  box-shadow: 0 24px 40px -24px #000;
  color: var(--ink);
}

.update-card h2 {
  font-family: var(--font-title);
  font-size: 30px;
}

.update-card p {
  margin-top: 10px;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink-soft);
}

.update-button {
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  border: 1px solid rgba(101, 42, 27, 0.5);
  border-radius: 7px;
  background: var(--red);
  color: #fff0ce;
  font-weight: 700;
}

/* ---------- utilities ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes rise {
  from {
    transform: translateY(10px);
    opacity: 0.2;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes dot-pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes loading-sweep {
  0% {
    transform: translateX(0);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  82% {
    opacity: 1;
  }
  100% {
    transform: translateX(330%);
    opacity: 0;
  }
}

@keyframes shake {
  10%,
  90% {
    transform: translateX(-2px);
  }
  20%,
  80% {
    transform: translateX(4px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-7px);
  }
  40%,
  60% {
    transform: translateX(7px);
  }
}



/* ---------- reference repair fixture ---------- */
html[data-ui-fixture="reference"],
html[data-ui-fixture="reference"] body.room {
  width: 1448px;
  min-width: 1448px;
  height: 1086px;
  min-height: 1086px;
  overflow: hidden;
}

html[data-ui-fixture="reference"] .archive-shell,
html[data-ui-fixture="reference"] .archive-stage {
  width: 1448px !important;
  height: 1086px !important;
  min-height: 1086px !important;
  transform: none !important;
}

html[data-ui-fixture="reference"] .papa-answer {
  gap: 26px;
}

.papa-loading--fixture {
  min-height: 32px;
}

@media (min-width: 861px) and (max-width: 1220px) {
  body.room--compact .archive-links {
    display: none;
  }

  body.room--compact .topbar {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  body.room--compact .source-nav {
    grid-column: 2;
  }
}

@media (max-width: 860px) {
  body.room {
    min-width: 0;
    overflow-x: hidden;
    font-size: 16px;
  }

  .archive-stage {
    width: 100%;
    min-height: 100vh;
    overflow: visible;
    transform: none !important;
  }

  .archive-shell {
    width: 100% !important;
    height: auto !important;
    min-height: 100vh;
    margin: 0;
  }

  .topbar {
    height: auto;
    grid-template-columns: 1fr;
    padding: 6px 10px 7px;
    gap: 6px;
    border-radius: 0;
  }

  .brand {
    justify-content: center;
    gap: 7px;
  }

  .brand__mark {
    display: none;
  }

  .brand__copy {
    padding-left: 0;
  }

  .brand__copy::before {
    display: none;
  }

  .brand__title {
    font-size: 19px;
    letter-spacing: 0.024em;
    text-transform: none;
    white-space: nowrap;
  }

  .brand__tagline {
    display: none;
  }

  .brand,
  .source-nav {
    grid-column: auto;
    grid-row: auto;
    justify-self: stretch;
  }

  .source-nav {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .source-nav::before {
    display: none;
  }

  .source-nav::-webkit-scrollbar {
    display: none;
  }

  .archive-links {
    display: none;
  }

  .authors {
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 5px;
    min-width: 0;
    padding: 0 2px 1px;
  }

  .author-chip {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 23px;
    padding: 0 7px;
  }

  .author-chip__name {
    font-size: 10px;
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: relative;
    z-index: 4;
    gap: 7px;
    padding: 5px 10px;
    background:
      linear-gradient(180deg, rgba(255, 219, 148, 0.12), rgba(0,0,0,0.10)),
      rgba(38, 24, 14, 0.22);
  }

  .mobile-tabs button {
    flex: 1;
    min-height: 31px;
    border: 1px solid rgba(215, 195, 151, 0.36);
    border-radius: 999px;
    background: rgba(49, 43, 35, 0.72);
    color: #d5c8ad;
    font-size: 13px;
    font-weight: 700;
  }

  .mobile-tabs button.is-on {
    background: var(--red);
    color: #fff1d0;
  }

  .columns {
    display: block;
    padding: 5px 8px 14px;
  }

  .desk-prop--left {
    display: none;
  }

  .col {
    display: none;
  }

  .col.is-mobile-on {
    display: block;
  }

  .book-panel,
  .library-panel {
    height: calc(100dvh - 124px);
    min-height: 0;
    padding: 18px 14px 82px 17px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow:
      5px 0 0 -3px rgba(239, 221, 176, 0.62),
      8px 0 0 -4px rgba(214, 187, 127, 0.48),
      0 1px 0 rgba(255,255,255,0.62) inset,
      0 18px 28px -20px rgba(0,0,0,0.72),
      0 0 0 5px rgba(21, 16, 12, 0.30);
  }

  .book-panel {
    display: flex;
    flex-direction: column;
  }

  .library-panel {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 124px);
    min-height: 0;
    padding: 18px 14px 22px;
  }

  .panel__title {
    font-size: 27px;
    line-height: 0.98;
  }

  .col--dialog .panel__head {
    display: none;
  }

  .panel__head::after {
    width: 96px;
    margin-top: 9px;
  }

  .book-lead {
    display: none;
    width: auto;
    margin-top: 0;
    font-size: 16px;
    line-height: 1.30;
    white-space: normal;
  }

  .book-panel::before {
    right: 4px;
    width: 7px;
    opacity: 0.52;
  }

  .lamp-sketch {
    display: none;
  }

  .thread {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    margin-top: 0;
    padding: 0 4px 18px 0;
  }

  .composer {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 20;
    grid-template-columns: minmax(0, 1fr) 92px;
    gap: 7px;
    min-height: 0;
    padding: 9px 8px;
    border-radius: 10px;
  }

  .composer::before {
    display: none;
  }

  .composer::after {
    display: none;
  }

  .composer__input {
    min-height: 44px;
    max-height: 104px;
    padding: 7px 0 5px;
    font-size: 16px;
    line-height: 1.18;
  }

  .composer__btn {
    min-height: 44px;
    font-size: 14px;
  }

  .msg--you .msg__text {
    min-height: 48px;
    padding: 10px 14px;
    font-size: 18px;
    line-height: 1.28;
  }

  .msg--you .msg__text::before {
    display: none;
  }

  .msg--you .msg__text::after {
    display: none;
  }

  .answer-lead,
  .papa-loading {
    gap: 10px;
    font-size: 16px;
  }

  .answer-lead::before,
  .papa-loading::before {
    font-size: 24px;
  }

  .papa-loading {
    position: relative;
    align-self: flex-start;
    max-width: 100%;
    padding: 12px 14px;
    overflow: hidden;
    border: 1px solid rgba(88, 59, 30, 0.14);
    border-radius: 8px;
    background:
      radial-gradient(260px 120px at 35% 0%, rgba(255,255,255,0.34), transparent 76%),
      linear-gradient(180deg, rgba(248, 236, 210, 0.92), rgba(239, 224, 191, 0.92));
    box-shadow:
      0 1px 0 rgba(255,255,255,0.48) inset,
      0 12px 18px -16px rgba(67, 43, 22, 0.72);
  }

  .papa-loading::after {
    display: none;
    content: none;
  }

  .papa-loading__text {
    font-size: 16px;
    line-height: 1.25;
  }

  .papa-loading__dots {
    gap: 8px;
    margin-left: 2px;
  }

  .papa-loading__dots i {
    width: 7px;
    height: 7px;
  }

  .vypiska {
    padding: 16px 33px 18px 38px;
  }

  .vypiska::before {
    left: 14px;
    top: 16px;
    font-size: 43px;
  }

  .vypiska::after {
    right: 14px;
    top: 17px;
    font-size: 19px;
  }

  .vypiska__text {
    font-size: 18px;
    line-height: 1.30;
  }

  .vypiska__sign {
    font-size: 18px;
  }

  .shelf__head {
    margin-bottom: 10px;
  }

  .shelf__title {
    font-size: 22px;
  }

  .shelf__count {
    min-width: 31px;
    height: 26px;
    font-size: 13px;
  }

  .tagcloud {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 5px;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 10px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .tagcloud::-webkit-scrollbar {
    display: none;
  }

  .tag {
    flex: 0 0 auto;
    min-height: 23px;
    padding: 0 8px;
    font-size: 12px;
  }

  .tag__n {
    min-width: 18px;
    height: 16px;
    font-size: 10px;
  }

  .shelf__divider {
    margin: 0 8px 10px;
    gap: 8px;
    font-size: 13px;
  }

  .shelf__list {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    max-height: none;
    padding-right: 6px;
  }

  .vypiska--compact {
    padding: 13px 30px 13px 15px;
  }

  .vypiska--compact::after {
    top: 14px;
    right: 12px;
    font-size: 16px;
  }

  .vypiska--compact .vypiska__text {
    font-size: 16px;
    line-height: 1.24;
  }

  .vypiska--compact .vypiska__sign {
    font-size: 14px;
  }
}

@media (max-width: 380px) {
  .topbar {
    padding-top: 5px;
    padding-bottom: 6px;
  }

  .brand__mark {
    display: none;
  }

  .brand__title {
    font-size: 18px;
  }

  .brand__tagline {
    display: none;
  }

  .authors {
    gap: 3px 4px;
  }

  .author-chip {
    min-height: 22px;
    padding: 0 6px;
  }

  .author-chip__name {
    font-size: 9px;
  }

  .composer__input {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vypiska--fresh,
  .composer--shake,
  .papa-loading__dots i,
  .papa-loading::after {
    animation: none;
  }
}
