:root {
  --bg: #0c1c2c;
  --desk: #0a1826;
  --paper: #e8eef4;
  --paper-2: #d5e0ea;
  --ink: #0c1c2c;
  --mute: rgba(232, 238, 244, 0.62);
  --ink-dim: rgba(232, 238, 244, 0.66);
  --faint: rgba(232, 238, 244, 0.42);
  --panel: #dce6ee;
  --accent: #c5281c;
  --stamp: #c5281c;
  --gold: #c4a35a;
  --form: #0c1c2c;
  --line: rgba(232, 238, 244, 0.16);
  --font-d: "Anek Latin", "Segoe UI", sans-serif;
  --font-t: "Source Sans 3", "Segoe UI", sans-serif;
  --font-m: "Source Sans 3", ui-sans-serif, sans-serif;
  --fs-hero: clamp(2.9rem, 1.15rem + 6.4vw, 5.8rem);
  --fs-title: clamp(1.5rem, 1.05rem + 1.8vw, 2.2rem);
  --fs-base: clamp(1.05rem, 1rem + 0.22vw, 1.12rem);
  --space: clamp(1rem, 3vw, 1.7rem);
  --bar: 3.45rem;
  --dock: calc(4.4rem + env(safe-area-inset-bottom, 0px));
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --z-nav: 20;
  --z-overlay: 30;
  --z-sheet: 40;
  --z-cookie: 80;
  --z-busy: 50;
  --wrap: min(100% - (var(--space) * 2), 68rem);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; height: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-t);
  color: #e8eef4;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 12% -8%, rgba(197, 40, 28, 0.18), transparent 52%),
    radial-gradient(ellipse 70% 45% at 92% 0%, rgba(196, 163, 90, 0.12), transparent 48%),
    linear-gradient(180deg, #0e2438 0%, #0c1c2c 38%, #0a1622 100%);
  line-height: 1.5;
  font-size: var(--fs-base);
  letter-spacing: 0.01em;
  font-synthesis: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(20, 10, 4, 0.22), transparent 18%, transparent 82%, rgba(20, 10, 4, 0.35));
}

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

body.is-locked {
  overflow: hidden;
  height: 100svh;
}

dialog.sheet:not([open]) { display: none !important; }

img, svg:not(.brand__mark) { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
p, h1, h2, h3, ul, figure { margin: 0; }

.skip { position: absolute; left: -999px; }
.skip:focus {
  left: 1rem;
  top: 1rem;
  background: var(--paper);
  color: var(--ink);
  padding: .5rem .8rem;
  z-index: var(--z-nav);
}

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: var(--bar) 1fr;
  position: relative;
  z-index: 1;
}
body.is-locked .app {
  height: 100svh;
  max-height: 100svh;
  overflow: hidden;
}

.bar,
.top {
  background:
    linear-gradient(180deg, #3a2618 0%, var(--form) 40%, #24160e 100%);
  color: #f0e0b8;
  min-height: var(--bar);
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  border-bottom: 2px solid var(--gold);
  box-shadow:
    0 3px 0 #5a3e22,
    0 4px 0 var(--gold);
}
.bar__inner,
.top__inner {
  min-height: var(--bar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-inline: var(--space);
  width: 100%;
}
.brand {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
}
.brand__mark {
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 2.25rem;
  display: block;
  object-fit: cover;
  background: transparent;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(232, 238, 244, 0.18);
  font-size: 0;
  line-height: 0;
  animation: none;
  transition: transform 280ms var(--ease);
}
.brand:hover .brand__mark,
.brand:focus-visible .brand__mark {
  animation: none;
  transform: rotate(-14deg) scale(1.08);
}
.brand__name {
  font-family: var(--font-d);
  font-weight: 400;
  font-size: clamp(1.15rem, 0.85rem + 1.2vw, 1.42rem);
  letter-spacing: 0.02em;
  line-height: 1;
}
.bar__nav {
  display: flex;
  gap: 1.15rem;
  align-items: center;
}
.bar__nav a,
.top__nav {
  color: inherit;
  text-decoration: none;
  font-size: 0.82rem;
  font-family: var(--font-m);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: relative;
}
.bar__nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -5px;
  height: 2px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 240ms var(--ease);
}
.bar__nav a:hover::after,
.bar__nav a[aria-current="page"]::after {
  transform: scaleX(1);
}
.bar__nav a[aria-current="page"] {
  box-shadow: none;
}
.top .btn--ghost,
.bar .btn--ghost {
  color: #e8dcc0;
  border-color: rgba(232, 220, 192, 0.4);
}
.bar__nav a:focus-visible,
.brand:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.stage { min-height: 0; }
body.is-locked .stage {
  overflow: auto;
  height: 100%;
}

.home {
  display: grid;
  justify-items: center;
  gap: clamp(1.7rem, 4vw, 2.8rem);
  padding: clamp(1.2rem, 3vw, 2.2rem) 0 3rem;
}
.home > * {
  width: var(--wrap);
  max-width: 100%;
  margin-inline: auto;
  justify-self: center;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(15rem, 0.72fr);
  gap: clamp(1.4rem, 4vw, 2.8rem);
  align-items: start;
  padding-block: 0.55rem 0.2rem;
}
.kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  font-family: var(--font-m);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(232, 220, 192, 0.62);
  margin-bottom: 0.85rem;
}
.kicker span + span::before {
  content: "·";
  margin-right: 0.9rem;
  color: var(--gold);
}
.hero h1 {
  font-family: var(--font-d);
  font-size: var(--fs-hero);
  line-height: 0.92;
  letter-spacing: -0.01em;
  font-weight: 400;
  color: #f6e6c0;
  text-wrap: balance;
  text-shadow: 0 2px 0 rgba(20, 10, 4, 0.45);
}
.hero__copy > p,
.lead {
  max-width: 38ch;
  color: rgba(232, 220, 192, 0.7);
  font-size: clamp(1.02rem, 0.95rem + 0.32vw, 1.14rem);
  line-height: 1.45;
  margin-top: 0.75rem;
}
}
.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.05rem;
}

.hero__docket { min-width: 0; }
.docket {
  position: relative;
  background:
    repeating-linear-gradient(
      to bottom,
      #e8d09a 0 1.55rem,
      rgba(90, 40, 30, 0.12) 1.55rem 1.62rem
    );
  background-color: var(--paper);
  color: var(--ink);
  padding: 1.45rem 1.25rem 1.2rem 1.85rem;
  min-height: 14.8rem;
  border: 1px solid rgba(42, 24, 16, 0.28);
  box-shadow:
    0 0 0 1px #f0dcab,
    10px 12px 0 rgba(24, 12, 6, 0.32);
}
.docket::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0.55rem;
  background: repeating-linear-gradient(
    90deg,
    var(--stamp) 0 0.7rem,
    #2a4a6a 0.7rem 1.4rem
  );
}
.docket::before {
  content: "";
  position: absolute;
  left: 0.7rem;
  top: 1.1rem;
  bottom: 0.7rem;
  width: 2px;
  background: #c45a4a;
}
.docket__hole {
  position: absolute;
  left: 0.35rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px rgba(22, 18, 12, 0.35);
}
.docket__hole:first-child { top: 1.15rem; }
.docket__hole:nth-child(2) { bottom: 1.15rem; top: auto; }
.docket__stamp {
  position: absolute;
  right: 0.85rem;
  top: 1.15rem;
  width: 3.75rem;
  height: 3.75rem;
  border: 3px double var(--stamp);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-d);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--stamp);
  transform: rotate(-14deg);
  opacity: 0.88;
  box-shadow: inset 0 0 0 1px var(--stamp);
}
.docket b {
  display: block;
  font-family: var(--font-d);
  font-size: 1.28rem;
  letter-spacing: 0.01em;
  margin: 2.5rem 3.8rem 0.35rem 0;
  max-width: 11ch;
  line-height: 1.15;
}
.docket p {
  font-family: var(--font-m);
  font-size: 0.75rem;
  color: var(--mute);
  margin: 0;
}
.docket ul {
  list-style: none;
  padding: 0;
  margin-top: 1rem;
  display: grid;
  gap: 0.2rem;
  font-family: var(--font-m);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.group {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.35rem;
  padding: 0 0.75rem 0.85rem;
  background:
    linear-gradient(180deg, rgba(90, 62, 34, 0.45), rgba(24, 12, 6, 0.38));
  box-shadow:
    inset 0 0 0 1px rgba(201, 162, 77, 0.22),
    0 10px 0 rgba(16, 8, 4, 0.28);
}
.group__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.45rem 1rem;
  padding-top: 0.15rem;
}
.group__tab {
  font-family: var(--font-d);
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  background: var(--paper);
  margin: 0;
  padding: 0.45rem 1.05rem 0.4rem;
  border: 1px solid rgba(42, 24, 16, 0.2);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  box-shadow: 3px 0 0 rgba(24, 12, 6, 0.16);
  transform: translateY(1px);
}
.group__note {
  font-family: var(--font-m);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(240, 224, 184, 0.78);
  padding-bottom: 0.35rem;
}

.catalog {
  display: grid;
  gap: 0.48rem;
  border: 0;
}
.tile {
  position: relative;
  background: var(--paper);
  border: 1px solid rgba(42, 24, 16, 0.2);
  border-left: 0.42rem solid var(--stamp);
  text-align: left;
  padding: 0.85rem 1rem 0.9rem 0.95rem;
  min-height: 0;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: baseline;
  gap: 0.2rem;
  color: var(--ink);
  width: 100%;
  box-shadow: 3px 4px 0 rgba(24, 12, 6, 0.22);
  transition: transform 280ms var(--ease), box-shadow 280ms var(--ease), background 280ms var(--ease);
}
.tile:last-child { border-bottom: 1px solid rgba(42, 24, 16, 0.2); }
.tile:hover,
.tile:focus-visible {
  background: #ead29a;
  transform: translateY(-4px);
  box-shadow: 5px 10px 0 rgba(24, 12, 6, 0.22);
  z-index: 2;
}
.tile__icon { display: none; }
.tile__title {
  font-family: var(--font-d);
  font-size: 1.12rem;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0;
}
.tile__blurb {
  color: rgba(12, 28, 44, 0.62);
  font-size: 0.9rem;
  line-height: 1.4;
  max-width: 46ch;
}

.group--organize .tile {
  margin-top: 0.45rem;
}
.group--organize .tile::before {
  content: "";
  position: absolute;
  top: -0.52rem;
  left: 0.75rem;
  width: 2.7rem;
  height: 0.55rem;
  background: var(--paper);
  border: 1px solid rgba(42, 24, 16, 0.2);
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
}
.group--organize .tile:hover,
.group--organize .tile:focus-visible {
  transform: translateY(-3px);
}

.group--convert .tile {
  border-left: 0;
  border-top: 2px dashed #3a5a6a;
  background-color: #d7cdb0;
  background-image:
    repeating-linear-gradient(
      to bottom,
      transparent 0 1.4rem,
      rgba(42, 74, 106, 0.12) 1.4rem 1.48rem
    );
  box-shadow:
    inset 7px 0 0 #2a4a6a,
    3px 4px 0 rgba(24, 12, 6, 0.22);
}
.group--convert .tile:hover,
.group--convert .tile:focus-visible {
  background-color: #e4d9b8;
  transform: translateY(-4px);
}

.group--edit .tile {
  min-height: 8.2rem;
  align-content: start;
  border-left: 0;
  border-top: 0.42rem solid var(--stamp);
  overflow: hidden;
}
.group--edit .tile::after {
  content: "К";
  position: absolute;
  right: 0.55rem;
  bottom: 0.4rem;
  width: 2.55rem;
  height: 2.55rem;
  border: 2px solid var(--stamp);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-d);
  font-size: 0.78rem;
  color: var(--stamp);
  opacity: 0.2;
  transform: rotate(-16deg);
  pointer-events: none;
  transition: opacity 280ms var(--ease), transform 280ms var(--ease);
}
.group--edit .tile:hover,
.group--edit .tile:focus-visible {
  transform: translateY(-4px);
}
.group--edit .tile:hover::after,
.group--edit .tile:focus-visible::after {
  opacity: 0.55;
  transform: rotate(-8deg) scale(1.06);
}

@keyframes drawer-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes card-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes card-fan {
  from { opacity: 0; transform: translateY(12px) rotate(0deg); }
  to { opacity: 1; transform: rotate(var(--fan)); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes card-drift {
  from { transform: translateY(0) rotate(-0.6deg); }
  to { transform: translateY(-7px) rotate(0.85deg); }
}
@keyframes stamp-idle {
  from { transform: rotate(-16deg); }
  to { transform: rotate(-7deg); }
}

@media (min-width: 860px) {
  .group--convert .catalog {
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
  }
  .group--edit .catalog {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem 0.65rem;
    padding: 0.4rem 0.1rem 0.25rem;
  }
}

.steps {
  position: relative;
  display: grid;
  grid-template-columns: 1.55rem repeat(3, minmax(0, 1fr));
  gap: 0;
  padding: 0;
  border: 1px solid rgba(42, 24, 16, 0.28);
  background: var(--paper);
  color: var(--ink);
  box-shadow:
    0 0 0 1px #f0dcab,
    10px 12px 0 rgba(24, 12, 6, 0.32);
}
.steps::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0.5rem;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    90deg,
    var(--stamp) 0 0.7rem,
    #2a4a6a 0.7rem 1.4rem
  );
}
.steps__spine {
  grid-row: 1 / -1;
  background:
    radial-gradient(circle closest-side, var(--bg) 54%, transparent 57%) 50% 1.55rem / 0.72rem 2.15rem repeat-y,
    var(--paper);
  box-shadow: inset -2px 0 0 #c45a4a;
  border-right: 1px solid rgba(42, 24, 16, 0.12);
}
.step {
  position: relative;
  display: grid;
  align-content: start;
  gap: 0.35rem;
  min-height: 11.2rem;
  padding: 1.55rem 1.15rem 1.15rem 1.2rem;
  transition: background 280ms var(--ease);
}
.step + .step {
  border-left: 2px dashed rgba(42, 24, 16, 0.28);
}
.step__tag {
  font-family: var(--font-m);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--stamp);
}
.step b {
  font-family: var(--font-d);
  font-size: 1.28rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.1;
  color: var(--ink);
}
.step p {
  color: var(--mute);
  font-size: 0.95rem;
  line-height: 1.4;
  max-width: 22ch;
  margin: 0;
}

.step--in {
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0 1.45rem,
      rgba(90, 40, 30, 0.1) 1.45rem 1.52rem
    );
}
.step--in::after {
  content: "";
  position: absolute;
  top: 0.85rem;
  right: 0.95rem;
  width: 0.72rem;
  height: 1.7rem;
  border: 2.5px solid #6a4a28;
  border-radius: 0.42rem;
  box-shadow: 1px 1px 0 rgba(232, 208, 154, 0.7);
  pointer-events: none;
}

.step--make {
  background-color: #cfd6c4;
  background-image:
    repeating-linear-gradient(
      to bottom,
      transparent 0 1.4rem,
      rgba(42, 74, 106, 0.14) 1.4rem 1.47rem
    );
  box-shadow: inset 6px 0 0 #2a4a6a;
}
.step--make .step__tag { color: #2a4a6a; }

.step--out {
  background: #e8c8b4;
  overflow: hidden;
  padding-right: 1.35rem;
  padding-bottom: 1.4rem;
}
.step--out p { padding-right: 2.4rem; }
.step--out::after {
  content: "Выдано";
  position: absolute;
  right: 0.35rem;
  bottom: 0.55rem;
  width: 5.4rem;
  height: 5.4rem;
  display: grid;
  place-items: center;
  border: 3px double var(--stamp);
  border-radius: 50%;
  font-family: var(--font-d);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--stamp);
  opacity: 0.38;
  transform: rotate(-18deg);
  pointer-events: none;
}

.step--in:hover { background-color: #ead29a; }
.step--make:hover { background-color: #d9e0d0; }
.step--out:hover { background-color: #f0d2c0; }
.step--out:hover::after { opacity: 0.62; }

.room {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 0.85rem var(--space) calc(0.9rem + env(safe-area-inset-bottom, 0px));
  gap: 0.7rem;
  color: var(--ink);
  background: var(--desk);
}
.room__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.55rem;
  align-items: end;
}
.room__head h1 {
  font-family: var(--font-d);
  font-size: var(--fs-title);
  line-height: 1.08;
  font-weight: 400;
  letter-spacing: 0;
  color: #f6e6c0;
}
.room__head p { color: rgba(232, 220, 192, 0.68); max-width: 52ch; font-size: 0.92rem; }

.dropzone {
  border: 2px dashed color-mix(in srgb, var(--ink) 28%, var(--paper));
  background: var(--paper);
  color: var(--ink);
  min-height: 0;
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1.4rem 1rem;
  cursor: pointer;
  box-shadow: 6px 7px 0 rgba(0, 0, 0, 0.22);
  transition: transform 280ms var(--ease), box-shadow 280ms var(--ease), background 220ms var(--ease);
}
.dropzone:hover {
  transform: translateY(-3px);
  box-shadow: 8px 10px 0 rgba(0, 0, 0, 0.22);
}
.dropzone.is-over {
  background: #e2d2a8;
  outline: 2px solid var(--accent);
  transform: translateY(-2px);
}
.dropzone img {
  width: min(14rem, 62%);
  margin: 0 auto 0.65rem;
}
.dropzone b {
  font-family: var(--font-d);
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  display: block;
  font-weight: 400;
  letter-spacing: 0.01em;
}
.dropzone span { color: var(--mute); }

.filelist {
  display: grid;
  gap: 0.35rem;
  align-content: start;
  overflow: auto;
  min-height: 0;
}
.file-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 0.35rem;
  align-items: center;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 0.5rem 0.65rem;
}
.file-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-m);
  font-size: 0.84rem;
}
.file-row button {
  border: 1px solid var(--ink);
  background: transparent;
  min-height: 2.2rem;
  min-width: 2.2rem;
  padding: 0 0.5rem;
  cursor: pointer;
}

.opts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  align-items: end;
  color: rgba(232, 220, 192, 0.78);
}
.opts label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.78rem;
  font-family: var(--font-m);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.opts input, .opts select {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  min-height: 2.5rem;
  padding: 0.3rem 0.55rem;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-t);
}

.room__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}
.status { color: rgba(232, 220, 192, 0.7); font-size: 0.9rem; }
.editor-room .status,
.scan-room .status { color: rgba(232, 220, 192, 0.7); }
.status.is-err { color: #f0a090; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.35rem 1.2rem;
  border: 1px solid #4a120e;
  background:
    linear-gradient(180deg, #9a3228 0%, var(--accent) 55%, #5c1612 100%);
  color: #f8ead0;
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.8rem;
  font-family: var(--font-m);
  text-decoration: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 180, 0.28),
    0 3px 0 #3a0e0c;
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease);
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 180, 0.32),
    0 5px 0 #3a0e0c;
}
.btn--ghost {
  background: transparent;
  color: var(--paper);
  border-color: rgba(232, 220, 192, 0.45);
}
.room .btn--ghost,
.editor-room .btn--ghost,
.scan-room .btn--ghost {
  color: #f3e6c6;
  border-color: rgba(232, 220, 192, 0.4);
}
.btn--wide { min-width: min(100%, 14rem); }
.btn:disabled { opacity: 0.4; transform: none; box-shadow: none; }

.editor-room {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  padding: 0.55rem var(--space) 0;
  gap: 0.4rem;
  background: var(--desk);
  color: var(--ink);
}
.editor-room .room__head { align-items: center; }
.editor-room .room__head h1 { font-size: clamp(1.15rem, 2vw, 1.55rem); }
.editor-room .room__head .head-actions,
.scan-room .room__head .head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.tools {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 0.35rem;
  color: var(--ink);
}
.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  align-items: center;
}
.tool-row + .tool-row {
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px solid var(--line);
}
.tool-k {
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  flex: 0 0 auto;
  font-family: var(--font-m);
}
.tool-row button {
  background: transparent;
  border: 1px solid var(--line);
  min-height: 2.15rem;
  padding: 0.15rem 0.55rem;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.82rem;
}
.tool-row button.is-on,
.tool-row .btn {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-t);
  font-weight: 600;
}
.sep { width: 1px; height: 1.1rem; background: var(--line); flex: 0 0 auto; }
.tiny { font-size: 0.75rem; color: var(--mute); display: inline-flex; gap: 0.3rem; align-items: center; }
.hint { font-size: 0.8rem; color: var(--mute); }
.zoom-label { font-size: 0.78rem; min-width: 2.6rem; text-align: center; font-family: var(--font-m); }
.swatches { display: inline-flex; gap: 0.28rem; }
.swatches button {
  width: 1.2rem;
  height: 1.2rem;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--line);
}
.selbar { display: inline-flex; gap: 0.28rem; }
[hidden] { display: none !important; }
.selbar[hidden], .cam[hidden], .text-overlay[hidden], .busy[hidden], .crop-bar[hidden] { display: none !important; }

.crop-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem 0.8rem;
  background: var(--form);
  color: #e8dcc0;
  padding: 0.5rem 0.7rem;
}
.crop-bar p {
  font-size: 0.84rem;
  color: rgba(232, 220, 192, 0.82);
  max-width: 42ch;
}
.crop-bar__actions {
  display: flex;
  gap: 0.4rem;
}
.crop-bar .btn--ghost {
  color: #e8dcc0;
  border-color: rgba(232, 220, 192, 0.4);
}
.crop-bar .btn:not(.btn--ghost) {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  overflow: auto;
  background:
    repeating-linear-gradient(
      90deg,
      #241c14 0 11px,
      #2c2418 11px 22px
    );
  border: 1px solid rgba(0, 0, 0, 0.35);
  padding: clamp(0.55rem, 2vw, 1.2rem);
  -webkit-overflow-scrolling: touch;
}
.canvas-wrap canvas {
  display: block;
  max-width: none;
  margin-inline: auto;
  background: #fff;
  touch-action: none;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}
.page-sheet {
  position: relative;
  display: block;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
}
.page-sheet canvas { margin-inline: 0; }
.text-overlay {
  position: absolute;
  z-index: var(--z-overlay);
  border: 1px solid var(--accent);
  background: rgba(255, 255, 255, 0.94);
  font-family: var(--font-t);
  color: var(--ink);
  resize: both;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
}
.empty-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  gap: 0.45rem;
  color: rgba(232, 220, 192, 0.72);
  padding: 1rem;
  cursor: pointer;
}
.empty-hint img {
  width: min(13rem, 70%);
  margin-inline: auto;
}

.thumbs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.15rem 0 0.35rem;
  scrollbar-width: thin;
}
.thumbs__nav {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  flex: 0 0 auto;
  padding-right: 0.45rem;
  margin-right: 0.15rem;
  border-right: 1px solid rgba(232, 220, 192, 0.2);
  font-size: 0.78rem;
  color: rgba(232, 220, 192, 0.7);
  white-space: nowrap;
  font-family: var(--font-m);
}
.thumbs__nav button {
  min-width: 2rem;
  min-height: 2rem;
  padding: 0 0.4rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
}
.thumbs button {
  border: 1px solid var(--line);
  padding: 0;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  flex: 0 0 auto;
  min-width: 2.6rem;
  min-height: 3.4rem;
  font-size: 0.78rem;
}
.thumbs button.is-on { outline: 2px solid var(--gold); outline-offset: 1px; }
.thumbs img { width: 2.6rem; height: 3.4rem; object-fit: cover; }

.dock {
  display: none;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.25rem;
  padding: 0.4rem var(--space) calc(0.45rem + env(safe-area-inset-bottom, 0px));
  background: var(--paper);
  color: var(--ink);
  border-top: 3px solid var(--gold);
}
.dock button {
  min-height: 3.1rem;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  gap: 0.12rem;
  font-size: 0.68rem;
  color: var(--mute);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-m);
}
.dock button.is-on,
.dock button[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 650;
}
.dock .dock-save {
  background: var(--accent);
  color: #f8ead0;
  font-weight: 650;
}

.scan-room {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  padding: 0.6rem var(--space) 0;
  gap: 0.5rem;
  background: var(--desk);
  color: var(--ink);
}
.scan-view {
  min-height: 0;
  background: #100e0b;
  color: #ece8e0;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(176, 138, 66, 0.35);
}
.scan-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
}
.scan-frame__page {
  width: min(72%, 22rem);
  height: min(78%, 86%);
  aspect-ratio: 210 / 297;
  max-height: 78%;
  border: 1.5px solid rgba(232, 220, 192, 0.88);
  box-shadow: 0 0 0 80vmax rgba(8, 7, 6, 0.42);
}
.scan-frame[hidden] { display: none !important; }
.scan-view video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.scan-view video[hidden] { display: none !important; }
.scan-review {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.scan-review[hidden] { display: none !important; }
.scan-review canvas {
  display: block;
  max-width: none;
  background: #000;
}
.scan-quad {
  position: absolute;
  overflow: visible;
  touch-action: none;
}
.scan-quad__dim { fill: rgba(8, 7, 6, 0.52); }
.scan-quad__line {
  fill: none;
  stroke: #e8dcc0;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.scan-quad__handle {
  fill: #e8dcc0;
  stroke: var(--stamp);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  cursor: grab;
  pointer-events: auto;
}
.scan-fallback {
  height: 100%;
  min-height: 12rem;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.55rem;
  text-align: center;
  padding: 1.2rem;
}
.scan-fallback img { width: min(11rem, 70%); margin-inline: auto; }
.scan-fallback p { max-width: 28ch; color: rgba(236, 232, 224, 0.78); font-size: 0.92rem; }
.scan-tray {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  min-height: 4.6rem;
  padding: 0.15rem 0;
}
.scan-tray:has(.empty) { display: none; }
.scan-room.is-live,
.scan-room.is-review {
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.scan-room.is-live .scan-tray,
.scan-room.is-live .scan-actions,
.scan-room.is-review .scan-tray,
.scan-room.is-review .scan-actions {
  display: none;
}
.scan-tray button {
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  flex: 0 0 3.4rem;
  position: relative;
}
.scan-tray .scan-del {
  position: absolute;
  top: 0.12rem;
  right: 0.12rem;
  width: 1.15rem;
  height: 1.15rem;
  min-width: 0;
  padding: 0;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.72rem;
  line-height: 1;
}
.scan-tray img {
  width: 3.4rem;
  height: 4.4rem;
  object-fit: cover;
}
.scan-tray > div {
  flex: 0 0 3.4rem;
  position: relative;
}
.scan-tray > div > button:first-child {
  width: 100%;
}
.scan-tray .empty {
  color: rgba(232, 220, 192, 0.65);
  font-size: 0.85rem;
  padding: 0.8rem 0.2rem;
}
.scan-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}
.scan-dock {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 0.4rem;
  padding: 0.45rem 0 calc(0.55rem + env(safe-area-inset-bottom, 0px));
}
.scan-dock .btn { min-height: 3.05rem; }
.scan-dock .btn--shot {
  border-radius: 2px;
}
.scan-dock.is-review {
  grid-template-columns: 1fr 1fr 1.35fr;
}

.sheet {
  border: 3px solid var(--gold);
  background: var(--paper);
  color: var(--ink);
  padding: 1.1rem 1.15rem;
  max-width: min(40rem, calc(100% - 1.4rem));
  width: min(40rem, calc(100% - 1.4rem));
}
.sheet::backdrop { background: rgba(12, 10, 8, 0.62); }
.sheet h3 {
  font-family: var(--font-d);
  font-size: 1.4rem;
  letter-spacing: 0;
  margin-bottom: 0.3rem;
}
.sheet canvas {
  width: 100%;
  height: min(38vh, 14rem);
  background: #fff;
  border: 1px solid var(--ink);
  touch-action: none;
  cursor: crosshair;
}
.sheet__row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }
.sheet .btn--ghost {
  color: var(--ink);
  border-color: var(--ink);
}
.more-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-top: 0.7rem;
}
.more-grid button {
  min-height: 2.8rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.home > .site-footer {
  width: 100%;
  max-width: none;
  margin-top: 1.2rem;
  justify-self: stretch;
}

.site-footer {
  background:
    linear-gradient(180deg, #2c1c12, #1a100a);
  color: rgba(240, 224, 184, 0.72);
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  line-height: 1.5;
  margin-top: 0;
  border-top: 2px solid var(--gold);
  box-shadow: 0 -3px 0 #5a3e22;
}
.site-footer__inner {
  width: var(--wrap);
  margin-inline: auto;
  padding-block: clamp(2.2rem, 5vw, 3.1rem) 0;
}
.site-footer__main {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.7fr) minmax(0, 0.9fr);
  gap: clamp(1.6rem, 4vw, 3rem) clamp(1.4rem, 3vw, 2.8rem);
  padding-bottom: clamp(1.6rem, 3vw, 2.2rem);
}
.site-footer__logo {
  display: inline-block;
  font-family: var(--font-d);
  font-weight: 400;
  font-size: clamp(1.7rem, 1.15rem + 1.9vw, 2.35rem);
  letter-spacing: 0.01em;
  color: #f6e6c0;
  text-decoration: none;
  line-height: 0.95;
  margin-bottom: 0.85rem;
}
.site-footer__brand p {
  max-width: 36ch;
  color: rgba(232, 220, 192, 0.58);
}
.site-footer__contacts {
  margin-top: 1.05rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1.15rem;
}
.site-footer__contacts a,
.site-footer a {
  color: rgba(232, 220, 192, 0.88);
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(232, 220, 192, 0.32);
}
.site-footer a:hover {
  color: #fff;
  text-decoration-color: #fff;
}
.site-footer a:focus-visible {
  outline: 2px solid #f3e6c6;
  outline-offset: 3px;
}
.site-footer__h {
  font-family: var(--font-m);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(232, 220, 192, 0.42);
  margin-bottom: 0.85rem;
}
.site-footer__links {
  display: grid;
  gap: 0.42rem;
  justify-items: start;
}
.site-footer__links a {
  text-decoration: none;
  color: rgba(232, 220, 192, 0.82);
}
.site-footer__links a:hover {
  color: #fff;
  text-decoration: underline;
}
.site-footer__ad {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem 1.4rem;
  padding-block: 1.05rem;
  border-top: 1px solid rgba(232, 220, 192, 0.12);
  font-size: 0.86rem;
  color: rgba(232, 220, 192, 0.58);
}
@media (min-width: 860px) {
  .site-footer__ad {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1100px) {
  .site-footer__ad {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.site-footer__ad b {
  font-weight: 650;
  color: rgba(232, 220, 192, 0.88);
  margin-right: 0.35rem;
}
.site-footer__ad .ad-legal__kicker,
.ad-legal p:first-child b {
  letter-spacing: 0.08em;
}
.site-footer__bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.7rem 1.4rem;
  padding-block: 1rem 1.35rem;
  border-top: 1px solid rgba(232, 220, 192, 0.12);
  font-size: 0.8rem;
  color: rgba(232, 220, 192, 0.45);
}
.site-footer__short {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.15rem;
}
.site-footer__short a {
  color: rgba(232, 220, 192, 0.55);
  text-decoration: none;
}
.site-footer__short a:hover {
  color: #fff;
}

body:has(#cookieBar):not(.is-locked) {
  padding-bottom: 5.8rem;
}
body.is-locked .cookie-bar {
  display: none !important;
}

.cookie-bar {
  position: fixed;
  z-index: var(--z-cookie);
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.9rem 1.2rem;
  align-items: center;
  padding: 0.95rem var(--space) calc(0.95rem + env(safe-area-inset-bottom, 0px));
  background: #2c1c12;
  color: rgba(240, 224, 184, 0.8);
  font-size: 0.9rem;
  line-height: 1.45;
  border-top: 2px solid var(--gold);
  box-shadow: 0 -3px 0 #5a3e22;
}
.cookie-bar p { max-width: 72ch; }
.cookie-bar a {
  color: #f3e6c6;
  text-underline-offset: 0.18em;
}
.cookie-bar__ok {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #f8ead0;
  min-height: 2.6rem;
  padding: 0.45rem 1.15rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font-m);
  font-size: 0.78rem;
  cursor: pointer;
}
.cookie-bar__ok:hover { filter: brightness(1.08); }
.cookie-bar__ok:focus-visible {
  outline: 2px solid #f3e6c6;
  outline-offset: 3px;
}

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero__docket { max-width: 22rem; }
  .site-footer__main,
  .site-footer__ad {
    grid-template-columns: 1fr;
  }
  .cookie-bar {
    grid-template-columns: 1fr;
  }
  .cookie-bar__ok { justify-self: start; }
}

.legal {
  padding-block: 3rem 3.5rem;
  max-width: 42rem;
  color: rgba(232, 220, 192, 0.82);
}
.legal h1 {
  font-family: var(--font-d);
  font-size: clamp(1.9rem, 1.15rem + 2vw, 2.5rem);
  letter-spacing: 0;
  line-height: 1.12;
  margin-bottom: 0.7rem;
  color: #f6e6c0;
}
.legal .lead { color: rgba(232, 220, 192, 0.62); margin-bottom: 1.2rem; }
.legal ul {
  display: grid;
  gap: 0.85rem;
  padding: 0;
  list-style: none;
  color: rgba(232, 220, 192, 0.7);
}
.legal a { text-underline-offset: 0.16em; }

.wrap {
  width: var(--wrap);
  margin-inline: auto;
  position: relative;
  z-index: 1;
}

.busy {
  position: fixed;
  inset: auto 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-busy);
  background: var(--accent);
  color: #f8ead0;
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-family: var(--font-m);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.78rem;
  pointer-events: none;
}

.panel textarea {
  width: 100%;
  min-height: 7rem;
  border: 1px solid var(--line);
  padding: 0.6rem;
  background: var(--paper);
  color: var(--ink);
}

@media (max-width: 720px) {
  .bar__nav a[data-nav="home"] { display: none; }
  .file-row { grid-template-columns: 1fr auto auto; }
  .file-row [data-file="up"] { display: none; }
  .steps {
    grid-template-columns: 1.45rem 1fr;
  }
  .steps__spine { grid-row: 1 / 4; }
  .step {
    min-height: 0;
    padding: 1.2rem 1.1rem 1.1rem 1.15rem;
  }
  .step + .step {
    border-left: 0;
    border-top: 2px dashed rgba(42, 24, 16, 0.28);
  }
  .group--convert .catalog,
  .group--edit .catalog { grid-template-columns: 1fr; }
  .group--edit .tile { min-height: 0; }
  .tools--desk { display: block; padding: 0.25rem 0.4rem; }
  .tools--desk .tool-row:not(.tool-row--meta) { display: none; }
  .dock { display: grid; }
  .editor-room {
    grid-template-rows: auto 1fr auto auto;
    padding-inline: 0.7rem;
  }
  .editor-room .head-actions [data-go],
  #savePdfDesk { display: none; }
  .room {
    padding-inline: 0.75rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }
  .scan-actions { grid-template-columns: 1fr; }
  .scan-dock.is-review { grid-template-columns: 1fr 1fr; }
  .scan-dock.is-review .btn:last-child { grid-column: 1 / -1; }
  .sheet {
    margin: 0;
    max-width: 100%;
    width: 100%;
    max-height: 92dvh;
  }
  .more-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 721px) {
  .scan-room {
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 1fr 12.5rem;
  }
  .scan-room:has(.scan-tray .empty) {
    grid-template-columns: 1fr;
  }
  .scan-room.is-live,
  .scan-room.is-review {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .scan-view { grid-row: span 2; }
  .scan-room.is-live .scan-view,
  .scan-room.is-review .scan-view { grid-row: auto; }
  .scan-tray {
    grid-column: 2;
    grid-row: 2;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
  }
  .scan-tray button { flex: 0 0 auto; width: 100%; }
  .scan-tray img { width: 100%; height: 7rem; }
  .scan-actions, .scan-dock { grid-column: 1 / -1; }
  .scan-dock { grid-template-columns: 1fr 1.35fr; }
}
