/* Дело №45 — папка дела. Одна тема: картон и бумага. */

:root {
  /* картон папки */
  --board: #b39b78;
  --board-deep: #8f7858;
  --board-light: #c7b18c;
  --folder: #bea683;
  --tab: #aa9270;
  --tab-active: #bea683;
  --board-edge: rgba(62, 44, 24, .28);

  /* бумага */
  --paper: #eee6d4;
  --paper-warm: #e6dcc5;
  --paper-edge: #cfc0a0;
  --paper-line: rgba(70, 90, 140, .16);

  /* чернила и штампы */
  --ink: #26221e;
  --ink-soft: #4a4238;
  --ink-faded: #5f564a;
  --ink-blue: #243f8f;
  --stamp-red: #b1232b;
  --stamp-red-deep: #8e1a20;
  --stamp-purple: #5a3e9d;
  --stamp-grey: #5f5b55;
  --clip-metal: #6f757a;
  --redact: #1d1a17;

  /* подложки */
  --shade: rgba(40, 26, 12, .35);
  --backdrop: rgba(58, 44, 28, .72);
  --lightbox: rgba(18, 14, 10, .95);
  --on-dark: #efe7d6;

  --font-title: "Roboto Slab", "Rockwell", Georgia, serif;
  --font-type: "PT Mono", "Courier New", monospace;
  --font-hand: "Caveat", "Segoe Print", cursive;
  --font-stamp: "Oswald", "Arial Narrow", sans-serif;

  --gutter: 16px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* шум: мелкие волокна бумаги и картона */
  --noise: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .22 0 0 0 0 .15 0 0 0 0 .08 0 0 0 .6 -.2'/></filter><rect width='180' height='180' filter='url(%23n)'/></svg>");
  --fibers: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='.008 .22' numOctaves='2' seed='4' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .3 0 0 0 0 .2 0 0 0 0 .1 0 0 0 .9 -.38'/></filter><rect width='320' height='320' filter='url(%23f)'/></svg>");
  /* потёртость штемпельной краски: маска с проплешинами */
  --worn: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='3' seed='9' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -5.5 3.95'/></filter><rect width='140' height='140' filter='url(%23g)'/></svg>");
  --worn-soft: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -4 3.3'/></filter><rect width='120' height='120' filter='url(%23g)'/></svg>");
}

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

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font-type);
  font-size: 15px;
  line-height: 1.5;
  background-color: var(--board);
  background-image:
    var(--noise),
    var(--fibers),
    radial-gradient(120% 60% at 20% 0%, rgba(255, 244, 220, .22), transparent 60%),
    radial-gradient(90% 50% at 90% 100%, rgba(70, 48, 20, .22), transparent 70%);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

body.is-locked { overflow: hidden; }

/* затемнение по краям картона */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(140% 90% at 50% 40%, transparent 55%, rgba(60, 40, 18, .32) 100%);
}

/* корешок папки с тесёмкой справа */
body::after {
  content: "";
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  width: 9px;
  pointer-events: none;
  z-index: 3;
  background:
    repeating-linear-gradient(-58deg, #d7bf93 0 2px, #a88b5f 2px 4px, #7c6443 4px 5px),
    #a88b5f;
  box-shadow: -2px 0 3px rgba(40, 26, 12, .35), inset 1px 0 0 rgba(255, 240, 210, .4);
  border-radius: 4px 0 0 4px;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.page {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) calc(var(--gutter) + 4px) max(20px, env(safe-area-inset-bottom)) var(--gutter);
}

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--ink-blue);
  outline-offset: 2px;
}

/* ─── Штампы ───────────────────────────────────────────── */

.stamp {
  margin: 0;
  font-family: var(--font-stamp);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1.05;
  -webkit-mask-image: var(--worn);
  mask-image: var(--worn);
}

.stamp--red {
  color: var(--stamp-red);
  border: 3px solid currentColor;
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px transparent, inset 0 0 0 3.5px currentColor;
}

.stamp--grey {
  color: var(--stamp-grey);
  border: 2px solid currentColor;
  border-radius: 2px;
  font-family: var(--font-type);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.stamp--status {
  color: var(--stamp-red);
  border: 2.5px solid currentColor;
  border-radius: 3px;
  padding: 3px 8px 2px;
  font-size: 14px;
  background: rgba(238, 230, 212, .62);
  white-space: nowrap;
}

/* ─── Шапка ───────────────────────────────────────────── */

.masthead {
  position: relative;
  padding-top: 62px;
  text-align: center;
}

.masthead__tag {
  position: absolute;
  top: 6px;
  left: -2px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px 5px 6px;
  font-size: 14px;
  text-align: left;
  transform: rotate(-7deg);
}

.masthead__lime { width: 26px; height: 26px; flex: none; }

.masthead__own {
  position: absolute;
  top: 10px;
  right: 2px;
  padding: 3px 8px;
  font-size: 14px;
  line-height: 1.15;
  transform: rotate(-5deg);
  opacity: .85;
}

.masthead__title {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 900;
  font-size: clamp(44px, 15.2vw, 72px);
  line-height: 1;
  white-space: nowrap;
  letter-spacing: -.01em;
  color: var(--ink);
  text-shadow: 0 0 1px rgba(20, 16, 12, .5);
  -webkit-mask-image: var(--worn-soft);
  mask-image: var(--worn-soft);
  -webkit-mask-size: 90px;
  mask-size: 90px;
}

.masthead__title::after {
  content: "";
  display: block;
  height: 3px;
  margin: 6px auto 0;
  width: 92%;
  background: var(--stamp-red);
  border-radius: 2px;
  transform: rotate(-.4deg);
  opacity: .85;
}

.masthead__status {
  margin: 10px auto 0;
  max-width: 40ch;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  text-wrap: balance;
}

.masthead__new {
  margin: 2px 0 0;
  font-family: var(--font-hand);
  font-weight: 600;
  font-size: 21px;
  line-height: 1.2;
  color: var(--ink-blue);
  transform: rotate(-2deg);
}

.masthead.is-closed { padding-bottom: 74px; }

.stamp--closed {
  position: absolute;
  left: 50%;
  bottom: 6px;
  z-index: 2;
  padding: 6px 16px 4px;
  font-size: clamp(34px, 11vw, 48px);
  font-weight: 700;
  color: var(--stamp-red);
  white-space: nowrap;
  border: 4px double currentColor;
  border-width: 6px;
  border-radius: 6px;
  background: rgba(190, 166, 131, .18);
  mix-blend-mode: multiply;
  transform: translateX(-50%) rotate(-7deg);
  pointer-events: none;
}

/* ─── Закладки ────────────────────────────────────────── */

.tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  margin: 18px calc(var(--gutter) * -1) 0;
  padding: 10px var(--gutter) 0 calc(var(--gutter) - 2px);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  scroll-padding-inline: var(--gutter);
  background-color: var(--board);
  background-image: var(--noise), var(--fibers);
  box-shadow: inset 0 -2px 0 var(--board-edge);
}

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

.tabs.is-stuck { box-shadow: inset 0 -2px 0 var(--board-edge), 0 6px 10px -6px var(--shade); }

.tab {
  position: relative;
  flex: none;
  min-height: 44px;
  margin-right: -4px;
  padding: 11px 16px 8px;
  border: 0;
  background: none;
  font-family: var(--font-type);
  font-size: 15px;
  line-height: 1.2;
  color: var(--ink-soft);
  cursor: pointer;
  isolation: isolate;
  transform: translateY(3px);
  transition: transform .25s var(--ease-out), color .2s;
}

/* трапеция язычка */
.tab::before {
  content: "";
  position: absolute;
  inset: 0 0 -4px;
  z-index: -1;
  background-color: var(--tab);
  background-image: var(--noise);
  border: 1px solid var(--board-edge);
  border-bottom: 0;
  border-radius: 9px 12px 0 0;
  transform: perspective(60px) rotateX(5deg);
  transform-origin: bottom;
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, .35), inset 0 -8px 10px -8px rgba(40, 26, 12, .35);
}

.tab[aria-selected="true"] {
  z-index: 2;
  color: var(--ink);
  transform: translateY(0);
  text-shadow: .35px 0 0 currentColor;
}

.tab[aria-selected="true"]::before {
  background-color: var(--tab-active);
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, .5), -2px -1px 5px rgba(40, 26, 12, .18);
  inset: 0 0 -6px;
}

.tab__label { position: relative; display: inline-block; }

.tab[aria-selected="true"] .tab__label::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: -5px;
  height: 2.5px;
  background: var(--stamp-red);
  border-radius: 2px;
  transform: rotate(-.8deg);
}

.tab__dot {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stamp-red);
  box-shadow: 0 0 0 1.5px var(--tab);
}

@media (hover: hover) {
  .tab:not([aria-selected="true"]):hover { color: var(--ink); transform: translateY(1px); }
}

/* ─── Папка ───────────────────────────────────────────── */

.folder {
  position: relative;
  margin: 0 calc(var(--gutter) * -1 + 6px);
  padding: 22px 12px 26px;
  min-height: 320px;
  background-color: var(--folder);
  background-image:
    var(--noise),
    var(--fibers),
    linear-gradient(180deg, rgba(255, 244, 220, .16), transparent 120px);
  border-radius: 0 0 6px 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 220, .3),
    0 10px 18px -12px rgba(40, 26, 12, .5);
  outline: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 520px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.grid > li { display: flex; min-width: 0; }

/* ─── Карточки ────────────────────────────────────────── */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 10px 9px 11px;
  border: 0;
  border-radius: 3px;
  text-align: left;
  background-color: var(--paper);
  background-image:
    var(--noise),
    radial-gradient(130% 110% at 50% 45%, transparent 55%, rgba(120, 90, 50, .22) 100%);
  box-shadow:
    0 1px 1px rgba(40, 26, 12, .25),
    0 6px 12px -4px rgba(40, 26, 12, .45);
}

.grid > li:nth-child(4n+1) .card { transform: rotate(-.6deg); }
.grid > li:nth-child(4n+2) .card { transform: rotate(.5deg); }
.grid > li:nth-child(4n+3) .card { transform: rotate(.35deg); }
.grid > li:nth-child(4n) .card { transform: rotate(-.4deg); }

.card--open {
  cursor: pointer;
  transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out);
}

.card--open:active {
  transform: translateY(1px) scale(.985);
  box-shadow: 0 1px 1px rgba(40, 26, 12, .25), 0 3px 6px -3px rgba(40, 26, 12, .45);
}

@media (hover: hover) {
  .card--open:hover {
    transform: translateY(-2px) rotate(0deg);
    box-shadow: 0 1px 1px rgba(40, 26, 12, .25), 0 12px 18px -6px rgba(40, 26, 12, .5);
  }
}

.clip {
  position: absolute;
  top: -17px;
  left: 7px;
  z-index: 3;
  width: 15px;
  height: 40px;
  transform: rotate(-10deg);
  filter: drop-shadow(1px 1.5px 1px rgba(30, 20, 10, .35));
  pointer-events: none;
}

.card__title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  min-height: calc(2 * 1.2em);
  margin: 0 0 7px 14px;
  overflow: hidden;
  font-family: var(--font-type);
  font-size: 14px;
  line-height: 1.2;
  color: var(--ink);
  text-shadow: .3px 0 0 currentColor;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.card__media {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 2px;
  background: var(--paper-warm);
  box-shadow: inset 0 0 0 1px rgba(60, 44, 24, .18);
}

.card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(.12) contrast(1.02);
}

/* лист машинописи вместо картинки */
.card__sheet {
  display: block;
  height: 100%;
  padding: 8px 8px 0 10px;
  overflow: hidden;
  font-family: var(--font-type);
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-faded);
  background-color: #f3eddf;
  background-image:
    linear-gradient(90deg, transparent 5px, rgba(177, 35, 43, .35) 5px 6px, transparent 6px),
    repeating-linear-gradient(180deg, transparent 0 19px, var(--paper-line) 19px 20px);
  background-position: 0 0, 0 8px;
  -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent 96%);
  mask-image: linear-gradient(180deg, #000 62%, transparent 96%);
  overflow-wrap: anywhere;
}

/* заглушка кружка, если есть только видео */
.card__reel {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--ink-soft);
}

.card__reel svg {
  width: 58%;
  height: auto;
  aspect-ratio: 1;
  padding: 18%;
  border-radius: 50%;
  background: radial-gradient(circle, #d8ccb3 0 55%, #c9baa0 56% 100%);
  box-shadow: inset 0 2px 6px rgba(40, 26, 12, .3);
}

.card__note {
  position: absolute;
  left: 12px;
  bottom: 6px;
  z-index: 2;
  font-family: var(--font-hand);
  font-weight: 600;
  font-size: 19px;
  line-height: 1;
  color: var(--ink-blue);
  transform: rotate(-4deg);
  text-shadow: 0 0 3px var(--paper), 0 0 6px var(--paper);
}

.card__new {
  position: absolute;
  top: -8px;
  right: -5px;
  z-index: 4;
  padding: 3px 7px 2px;
  font-family: var(--font-stamp);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.1;
  letter-spacing: .06em;
  color: var(--paper);
  background: var(--stamp-red);
  border-radius: 2px;
  box-shadow: 0 2px 3px rgba(40, 26, 12, .35);
  transform: rotate(5deg);
  -webkit-mask-image: var(--worn-soft);
  mask-image: var(--worn-soft);
}

.card__status {
  position: absolute;
  left: 50%;
  bottom: 12%;
  z-index: 2;
  /* Длинный статус («СОВРАЛА РАДИ ПОДАРКА») переносится в две строки, а не обрезается. */
  width: max-content;
  max-width: 88%;
  white-space: normal;
  text-align: center;
  font-size: 13px;
  transform: translateX(-50%) rotate(-7deg);
}

.seal {
  color: var(--stamp-purple);
  font-family: var(--font-stamp);
  mix-blend-mode: multiply;
  -webkit-mask-image: var(--worn);
  mask-image: var(--worn);
  pointer-events: none;
}

.card__seal {
  position: absolute;
  right: -2px;
  bottom: -4px;
  z-index: 2;
  width: 58px;
  height: 58px;
  opacity: .88;
  transform: rotate(-14deg);
}

/* закрытая карточка */
.card--locked {
  cursor: default;
  padding-bottom: 9px;
}

.card--locked .card__media {
  flex: 1;
  aspect-ratio: auto;
  min-height: 176px;
  display: grid;
  place-items: center;
}

.card--locked .card__media img {
  position: absolute;
  inset: -12px;
  width: calc(100% + 24px);
  height: calc(100% + 24px);
  filter: blur(5px) sepia(.25) saturate(.7);
  opacity: .85;
}

.stamp--secret {
  position: relative;
  z-index: 1;
  padding: 4px 9px 2px;
  font-size: 22px;
  font-weight: 700;
  color: var(--stamp-red);
  border: 3px solid currentColor;
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px transparent, inset 0 0 0 3.5px currentColor;
  background: rgba(238, 230, 212, .45);
  transform: rotate(-9deg);
}

.card__due {
  display: block;
  margin-top: 8px;
  text-align: center;
  font-family: var(--font-type);
  font-size: 14px;
  line-height: 1.2;
  color: var(--ink-soft);
  white-space: nowrap;
  letter-spacing: -.035em;
}

.card.is-shaking { animation: shake .42s var(--ease-out); }

@keyframes shake {
  0% { transform: rotate(0); }
  20% { transform: rotate(-2.2deg) translateX(-2px); }
  45% { transform: rotate(1.8deg) translateX(2px); }
  70% { transform: rotate(-1deg) translateX(-1px); }
  100% { transform: rotate(0); }
}

/* ─── Хронология ──────────────────────────────────────── */

.timeline {
  position: relative;
  margin: 4px 2px 0;
  padding: 26px 16px 28px 14px;
  border-radius: 3px;
  background-color: var(--paper);
  background-image:
    var(--noise),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--paper-line) 31px 32px),
    radial-gradient(130% 110% at 50% 45%, transparent 60%, rgba(120, 90, 50, .2) 100%);
  box-shadow: 0 1px 1px rgba(40, 26, 12, .25), 0 8px 14px -6px rgba(40, 26, 12, .45);
  transform: rotate(-.3deg);
}

.timeline__head {
  margin: 0 0 18px 20px;
  font-family: var(--font-hand);
  font-weight: 600;
  font-size: 24px;
  line-height: 1.1;
  color: var(--ink-blue);
  transform: rotate(-2deg);
}

.timeline__list {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline__list::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 71px;
  width: 2px;
  background: var(--stamp-red);
  opacity: .7;
}

.timeline__row {
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr;
  column-gap: 28px;
  align-items: start;
  padding: 7px 0;
  font-size: 15px;
  line-height: 1.45;
}

.timeline__row::before {
  content: "";
  position: absolute;
  left: 67px;
  top: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--stamp-red);
}

.timeline__row--open::before { background: var(--stamp-red); }

.timeline__time {
  font-weight: 400;
  text-shadow: .35px 0 0 currentColor;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.timeline__row--closed .timeline__time { color: var(--ink-faded); }

.timeline__redacted {
  color: var(--redact);
  letter-spacing: -.12em;
  line-height: 1;
  user-select: none;
}

.timeline .seal {
  position: absolute;
  right: 10px;
  bottom: 8px;
  width: 64px;
  height: 64px;
  opacity: .7;
  transform: rotate(12deg);
}

/* ─── Заметки: загрузка, ошибки, пусто ────────────────── */

.note {
  position: relative;
  max-width: 330px;
  margin: 18px auto 10px;
  padding: 26px 22px 24px;
  text-align: center;
  background-color: var(--paper);
  background-image:
    var(--noise),
    radial-gradient(130% 110% at 50% 45%, transparent 55%, rgba(120, 90, 50, .22) 100%);
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(40, 26, 12, .25), 0 8px 14px -6px rgba(40, 26, 12, .45);
  transform: rotate(-.8deg);
}

.note__text {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
  text-wrap: balance;
}

.note__hint {
  margin: 12px 0 0;
  font-family: var(--font-hand);
  font-size: 21px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink-blue);
}

.note .stamp--status {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 16px;
  transform: rotate(-4deg);
}

.caret {
  display: inline-block;
  width: .55em;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -.15em;
  background: var(--ink);
  animation: caret 1s steps(1) infinite;
}

@keyframes caret { 50% { opacity: 0; } }

.retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-top: 18px;
  padding: 8px 26px 6px;
  border: 3px solid var(--stamp-red);
  border-radius: 4px;
  background: rgba(177, 35, 43, .06);
  font-family: var(--font-stamp);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--stamp-red);
  cursor: pointer;
  transform: rotate(-2deg);
  transition: transform .2s var(--ease-out), background-color .2s;
}

.retry:active { transform: rotate(-2deg) scale(.96); background: rgba(177, 35, 43, .14); }

/* ─── Подвал ──────────────────────────────────────────── */

.motto {
  position: relative;
  margin-top: 28px;
  text-align: center;
}

.motto::before {
  /* след от чашки */
  content: "";
  position: absolute;
  left: -34px;
  top: -64px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 7px solid rgba(96, 64, 30, .16);
  box-shadow: inset 0 0 0 2px rgba(96, 64, 30, .1), 0 0 0 1px rgba(96, 64, 30, .08);
  -webkit-mask-image: var(--worn);
  mask-image: var(--worn);
  pointer-events: none;
}

.motto p {
  display: inline-block;
  margin: 0;
  padding: 8px 14px;
  font-size: 15px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink);
  border-top: 2px solid var(--stamp-red);
  border-bottom: 2px solid var(--stamp-red);
}

/* ─── Документ ────────────────────────────────────────── */

.doc {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(14px, env(safe-area-inset-top)) 10px max(18px, env(safe-area-inset-bottom));
  background: var(--backdrop);
  -webkit-overflow-scrolling: touch;
}

.doc[hidden], .lightbox[hidden] { display: none; }

.doc__sheet {
  position: relative;
  max-width: 620px;
  min-height: calc(100% - 4px);
  margin: 10px auto 0;
  padding: 22px 18px 26px;
  border-radius: 3px;
  background-color: var(--paper);
  background-image:
    var(--noise),
    radial-gradient(140% 100% at 50% 40%, transparent 65%, rgba(120, 90, 50, .2) 100%);
  box-shadow: 0 2px 2px rgba(40, 26, 12, .3), 0 18px 34px -10px rgba(20, 12, 4, .6);
  animation: sheet-in .42s var(--ease-out);
}

@keyframes sheet-in {
  from { transform: translateY(36px) rotate(1.2deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.clip--doc { top: -16px; left: 22px; width: 20px; height: 52px; }

.doc__close {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.doc__close svg { width: 22px; height: 22px; }
.doc__close:active { background: rgba(60, 44, 24, .1); }

.doc__title {
  outline: none;
  margin: 8px 44px 16px 0;
  font-family: var(--font-type);
  font-weight: 400;
  font-size: 21px;
  line-height: 1.25;
  text-shadow: .5px 0 0 currentColor;
  text-wrap: balance;
}

.doc__status {
  display: inline-block;
  margin: -4px 0 16px;
  font-size: 17px;
  transform: rotate(-3deg);
}

.doc__media { display: grid; gap: 14px; }
.doc__media:empty { display: none; }

.doc__img {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--paper-warm);
  cursor: zoom-in;
  box-shadow: 0 0 0 1px rgba(60, 44, 24, .2), 0 4px 10px -4px rgba(40, 26, 12, .45);
}

.doc__img img { display: block; width: 100%; height: auto; }

.doc__reel {
  position: relative;
  width: min(76vw, 300px);
  aspect-ratio: 1;
  margin: 6px auto 4px;
  border-radius: 50%;
  overflow: hidden;
  background: #2b2621;
  box-shadow: 0 0 0 5px var(--paper), 0 0 0 7px rgba(60, 44, 24, .35), 0 8px 16px -6px rgba(40, 26, 12, .6);
}

.doc__reel video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doc__reel-label {
  margin: 8px 0 0;
  text-align: center;
  font-family: var(--font-hand);
  font-size: 20px;
  color: var(--ink-blue);
}

.doc__text {
  margin-top: 18px;
  font-size: 16px;
  line-height: 1.6;
  max-width: 62ch;
  overflow-wrap: break-word;
}

.doc__text p { margin: 0 0 .9em; }
.doc__text b { font-weight: 700; }

.doc__sign {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 18px;
}

.doc__signature {
  font-family: var(--font-hand);
  font-size: 21px;
  color: var(--ink-blue);
  transform: rotate(-4deg) translateY(6px);
}

.doc__seal { width: 88px; height: 88px; opacity: .85; transform: rotate(-12deg); }

/* ─── Снимок крупно ───────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--lightbox);
  animation: fade-in .25s var(--ease-out);
}

.lightbox__scroll {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.lightbox__img {
  display: block;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  cursor: zoom-in;
}

.lightbox.is-zoomed .lightbox__img {
  max-width: none;
  max-height: none;
  width: 250%;
  cursor: zoom-out;
}

.lightbox__close {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: 10px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .45);
  color: var(--on-dark);
  cursor: pointer;
}

.lightbox__close svg { width: 22px; height: 22px; }

.lightbox__hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(12px, env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: var(--on-dark);
  opacity: .75;
  pointer-events: none;
}

.lightbox.is-zoomed .lightbox__hint { display: none; }

@keyframes fade-in { from { opacity: 0; } }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
