@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/cormorant-400-it-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/cormorant-400-it-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/cormorant-400-it-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/cormorant-400-it-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/cormorant-400-it-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/cormorant-500-it-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/cormorant-500-it-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/cormorant-500-it-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/cormorant-500-it-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/cormorant-500-it-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/cormorant-400-rg-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/cormorant-400-rg-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/cormorant-400-rg-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/cormorant-400-rg-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/cormorant-400-rg-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/cormorant-500-rg-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/cormorant-500-rg-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/cormorant-500-rg-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/cormorant-500-rg-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/cormorant-500-rg-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/cormorant-600-rg-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/cormorant-600-rg-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/cormorant-600-rg-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/cormorant-600-rg-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/cormorant-600-rg-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/cormorant-700-rg-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/cormorant-700-rg-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/cormorant-700-rg-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/cormorant-700-rg-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/cormorant-700-rg-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Marck Script';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/marck-400-rg-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Marck Script';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/marck-400-rg-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Marck Script';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/marck-400-rg-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============ Гримуар: Вторая Жизнь — стиль ============ */
:root {
  --ink: #2b1d14;
  --ink-soft: #5a4632;
  --ink-faint: #8a7457;
  --parch: #f3e6c8;
  --parch-2: #ead9b2;
  --parch-3: #dcc597;
  --wine: #6b1e2a;
  --wine-2: #8c2a39;
  --gold: #b8902f;
  --gold-2: #d8b65a;
  --gold-3: #f1d98a;
  --leather: #4a1a1f;
  --night: #0f0a12;
  --serif: 'Cormorant Garamond', 'Georgia', 'Times New Roman', serif;
  --hand: 'Marck Script', 'Cormorant Garamond', cursive;
  --book-w: min(94vw, 560px);
  --book-h: min(88vh, 880px);
}
@supports (height: 1dvh) { :root { --book-h: min(88dvh, 880px); } }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background:
    radial-gradient(ellipse at 50% 30%, #2a1a2e 0%, transparent 60%),
    radial-gradient(ellipse at 20% 90%, #2b1418 0%, transparent 50%),
    radial-gradient(ellipse at 85% 80%, #1a1430 0%, transparent 50%),
    var(--night);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.45;
  user-select: none;
  -webkit-user-select: none;
}
input, textarea { user-select: text; -webkit-user-select: text; }
button { font-family: inherit; }
#particles { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

#stage { position: relative; z-index: 1; height: 100%; display: flex; align-items: center; justify-content: center; }
#book-wrap { position: relative; width: var(--book-w); height: var(--book-h); }

/* ============ Книга ============ */
#book {
  position: absolute; inset: 0;
  perspective: 2200px;
  border-radius: 4px 10px 10px 4px;
  filter: drop-shadow(0 30px 40px rgba(0,0,0,.55)) drop-shadow(0 0 60px rgba(184,144,47,.08));
}
.book-edge {
  position: absolute; top: 6px; bottom: 6px; right: -7px; width: 10px;
  background: repeating-linear-gradient(to bottom, #e9d8b0 0 2px, #cdb486 2px 3px);
  border-radius: 0 6px 6px 0; box-shadow: inset -2px 0 3px rgba(0,0,0,.25);
}
.book-edge::before { /* корешок */
  content: ''; position: absolute; top: -6px; bottom: -6px; left: calc(-1 * var(--book-w) - 6px); width: 14px;
  background: linear-gradient(90deg, #2a0c10, var(--leather) 60%, #2a0c10); border-radius: 6px 0 0 6px;
}

.page {
  position: absolute; inset: 0;
  /* flat, а не preserve-3d: иначе Chromium на телефоне не создаёт нативный
     скролл для .page-inner внутри 3D-контекста с backface-visibility —
     прокрутка Свитка (и любой длинной страницы) мёртва и пальцем, и колесом.
     Перелистывание не меняется: rotateY идёт по самой .page, перспектива живёт в #book. */
  transform-style: flat;
  transform-origin: left center;
  z-index: 2;
}
.page.under { z-index: 1; }
.page.turning { z-index: 3; }
.page .front, .page .back {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 3px 8px 8px 3px;
  overflow: hidden;
}
.page .front {
  background:
    radial-gradient(ellipse at 80% 10%, rgba(255,255,255,.35), transparent 40%),
    radial-gradient(ellipse at 10% 95%, rgba(150,100,40,.18), transparent 45%),
    radial-gradient(ellipse at 95% 85%, rgba(120,80,30,.14), transparent 35%),
    radial-gradient(circle at 30% 40%, rgba(160,120,60,.06) 0 2px, transparent 3px),
    linear-gradient(90deg, rgba(90,60,20,.22) 0%, rgba(90,60,20,0) 6%, rgba(0,0,0,0) 94%, rgba(90,60,20,.12) 100%),
    var(--parch);
  box-shadow: inset 0 0 50px rgba(120,80,30,.25), inset 0 0 6px rgba(80,50,20,.3);
}
.page .back {
  transform: rotateY(180deg);
  background: linear-gradient(270deg, rgba(90,60,20,.25), transparent 10%), var(--parch-2);
  box-shadow: inset 0 0 50px rgba(120,80,30,.3);
}
.page .front::after { /* тень во время переворота */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0) 30%, rgba(40,20,5,.35));
}
.page.flip-out { animation: flipOut .9s cubic-bezier(.45,.05,.3,1) forwards; }
.page.flip-out .front::after { animation: shade .9s ease forwards; }
.page.flip-in { animation: flipIn .9s cubic-bezier(.45,.05,.3,1) forwards; }
.page.flip-in .front::after { animation: shadeIn .9s ease forwards; }
.page.under .front::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: linear-gradient(90deg, rgba(40,20,5,.35), transparent 60%);
  animation: underShade .9s ease forwards;
}
@keyframes flipOut {
  0% { transform: rotateY(0); }
  100% { transform: rotateY(-180deg); }
}
@keyframes flipIn {
  0% { transform: rotateY(-180deg); }
  100% { transform: rotateY(0); }
}
@keyframes shade { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 1; } }
@keyframes shadeIn { 0% { opacity: 1; } 60% { opacity: .6; } 100% { opacity: 0; } }
@keyframes underShade { 0% { opacity: 1; } 100% { opacity: 0; } }

.page-inner {
  position: absolute; inset: 0;
  padding: 26px 26px 22px 34px;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: var(--parch-3) transparent;
}
.page-inner::-webkit-scrollbar { width: 6px; }
.page-inner::-webkit-scrollbar-thumb { background: var(--parch-3); border-radius: 3px; }
.with-ribbons .page-inner { padding-top: 56px; }
.page-center .page-inner { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }

/* ============ Типографика ============ */
.p-title {
  font-family: var(--serif); font-weight: 700; font-size: 30px; line-height: 1.1;
  color: var(--wine); text-align: center; margin: 0 0 6px; letter-spacing: .5px;
}
.p-sub { text-align: center; color: var(--ink-faint); font-style: italic; margin: 0 0 14px; font-size: 16px; }
.hand { font-family: var(--hand); }
.divider { text-align: center; color: var(--gold); margin: 10px 0 14px; letter-spacing: 6px; font-size: 14px; }
.divider::before { content: '❦ ✦ ❦'; }
.sys { font-family: var(--serif); color: var(--wine); font-weight: 600; letter-spacing: .3px; }
.muted { color: var(--ink-faint); }
.small { font-size: 15px; }
.tiny { font-size: 13px; }
.center { text-align: center; }
.page-num { position: absolute; bottom: 8px; left: 0; right: 0; text-align: center; color: var(--ink-faint); font-size: 13px; font-style: italic; pointer-events: none; }
.drop::first-letter { float: left; font-size: 3.2em; line-height: .85; padding: 4px 6px 0 0; color: var(--wine); font-weight: 700; }

/* ============ Кнопки ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--gold); background: linear-gradient(180deg, #fbf1d6, #ecd9ab);
  color: var(--wine); font-weight: 700; font-size: 17px; padding: 10px 20px; border-radius: 6px;
  cursor: pointer; box-shadow: 0 2px 0 #b89a5c, 0 3px 8px rgba(0,0,0,.15);
  transition: transform .12s, box-shadow .12s, filter .2s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 #b89a5c, 0 1px 3px rgba(0,0,0,.2); }
.btn.primary { background: linear-gradient(180deg, var(--wine-2), var(--wine)); color: var(--gold-3); border-color: #3c0f17; box-shadow: 0 2px 0 #3c0f17, 0 4px 12px rgba(107,30,42,.35); }
.btn.ghost { background: transparent; box-shadow: none; border-style: dashed; }
.btn[disabled] { filter: grayscale(.8) opacity(.55); cursor: not-allowed; }
.btn.block { display: flex; width: 100%; }
.btn.sm { font-size: 14px; padding: 6px 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.mt { margin-top: 14px; } .mt2 { margin-top: 24px; }

.tap-hint { margin-top: 18px; color: var(--ink-faint); font-style: italic; font-size: 15px; animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

/* ============ Обложка ============ */
.cover {
  position: absolute; inset: 0; z-index: 20; transform-origin: left center; transform-style: preserve-3d;
  perspective: 2200px;
}
.cover-face {
  position: absolute; inset: 0; border-radius: 4px 12px 12px 4px; overflow: hidden;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.08), transparent 50%),
    radial-gradient(ellipse at 70% 90%, rgba(0,0,0,.4), transparent 60%),
    repeating-radial-gradient(circle at 40% 60%, rgba(0,0,0,.05) 0 1px, transparent 1px 4px),
    linear-gradient(135deg, #5a2026, var(--leather) 50%, #2e0e12);
  box-shadow: inset 0 0 0 2px #2a0b0f, inset 0 0 40px rgba(0,0,0,.6), 0 30px 60px rgba(0,0,0,.6);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  backface-visibility: hidden;
}
.cover-face::before {
  content: ''; position: absolute; inset: 18px; border: 2px solid rgba(216,182,90,.75);
  border-radius: 6px; box-shadow: inset 0 0 0 5px transparent, inset 0 0 0 6px rgba(216,182,90,.4);
}
.cover-face::after { /* корешок */
  content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 26px;
  background: linear-gradient(90deg, rgba(0,0,0,.45), rgba(0,0,0,0)); border-right: 1px solid rgba(216,182,90,.25);
}
.cover-corner { position: absolute; width: 46px; height: 46px; color: var(--gold-2); font-size: 30px; display: flex; align-items: center; justify-content: center; opacity: .9; }
.cover-corner.tl { top: 22px; left: 30px; } .cover-corner.tr { top: 22px; right: 24px; }
.cover-corner.bl { bottom: 22px; left: 30px; } .cover-corner.br { bottom: 22px; right: 24px; }
.cover-emblem { font-size: 48px; color: var(--gold-2); text-shadow: 0 0 20px rgba(241,217,138,.4); margin-bottom: 10px; }
.cover-title {
  font-family: var(--serif); font-weight: 700; font-size: clamp(40px, 11vw, 64px); line-height: .95; text-align: center;
  background: linear-gradient(180deg, #fff2c2 0%, var(--gold-2) 45%, #8a6420 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,.6)); letter-spacing: 2px;
}
.cover-subtitle { font-family: var(--hand); color: var(--gold-3); font-size: clamp(24px, 7vw, 34px); margin-top: 6px; opacity: .95; }
.cover-line { width: 50%; height: 1px; margin: 22px auto; background: linear-gradient(90deg, transparent, var(--gold-2), transparent); }
.cover-slogan { color: rgba(241,217,138,.8); font-style: italic; text-align: center; max-width: 76%; font-size: 16px; }
.seal {
  margin-top: 34px; width: 92px; height: 92px; border-radius: 50%; position: relative; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #c43a3a, #8e1c22 55%, #5a0f14);
  box-shadow: 0 4px 10px rgba(0,0,0,.6), inset 0 -4px 8px rgba(0,0,0,.4), inset 0 3px 6px rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center; color: #f2c7a0; font-size: 38px; font-weight: 700;
  transition: transform .2s; animation: sealGlow 2.6s ease-in-out infinite;
}
.seal::before { content: ''; position: absolute; inset: 9px; border-radius: 50%; border: 2px dashed rgba(255,210,170,.35); }
.seal::after { /* «натёки» воска */
  content: ''; position: absolute; inset: -6px; border-radius: 46% 54% 50% 50% / 55% 48% 52% 45%;
  background: inherit; z-index: -1; filter: brightness(.85);
}
.seal:hover { transform: scale(1.05); }
@keyframes sealGlow { 0%,100% { box-shadow: 0 4px 10px rgba(0,0,0,.6), 0 0 0 rgba(255,80,60,0), inset 0 -4px 8px rgba(0,0,0,.4); } 50% { box-shadow: 0 4px 10px rgba(0,0,0,.6), 0 0 26px rgba(255,90,60,.45), inset 0 -4px 8px rgba(0,0,0,.4); } }
.seal.cracked { animation: sealCrack .7s ease forwards; }
.seal.cracked::before { border-color: transparent; }
@keyframes sealCrack {
  0% { transform: scale(1); } 20% { transform: scale(1.12) rotate(-4deg); } 40% { transform: scale(.96) rotate(3deg); clip-path: polygon(0 0,100% 0,100% 100%,0 100%); }
  100% { transform: scale(.7) rotate(12deg); opacity: 0; clip-path: polygon(0 0,48% 0,60% 40%,45% 55%,58% 100%,0 100%); }
}
.seal-hint { margin-top: 12px; color: rgba(241,217,138,.6); font-style: italic; font-size: 14px; animation: pulse 2.4s infinite; }
.cover.opening { animation: coverOpen 1.4s cubic-bezier(.6,.05,.3,1) forwards; }
@keyframes coverOpen { 0% { transform: rotateY(0); } 100% { transform: rotateY(-160deg); opacity: 0; } }

/* ============ Пролог ============ */
.ink-lines { max-width: 440px; margin: 0 auto; text-align: center; font-size: 21px; line-height: 1.5; }
.ink-lines .ln { opacity: 0; filter: blur(4px); transform: translateY(6px); animation: inkIn 1.1s ease forwards; min-height: 1em; }
.ink-lines .ln.gap { height: 14px; }
@keyframes inkIn { to { opacity: 1; filter: blur(0); transform: none; } }
.prologue-title { font-family: var(--serif); font-weight: 700; color: var(--wine); font-size: 28px; text-align: center; margin-bottom: 18px; }
.ornament { color: var(--gold); font-size: 26px; text-align: center; margin: 12px 0; }

/* ============ Пробуждение ============ */
.sys-box {
  border: 1px solid var(--wine); padding: 14px 18px; border-radius: 4px; text-align: center;
  background: rgba(107,30,42,.05); color: var(--wine); font-weight: 600; font-size: 20px; position: relative;
}
.sys-box::before, .sys-box::after { content: '◆'; position: absolute; top: 50%; transform: translateY(-50%); color: var(--gold); font-size: 12px; }
.sys-box::before { left: -6px; } .sys-box::after { right: -6px; }
.kitsu-portrait { width: 100%; max-width: 420px; border-radius: 8px; border: 2px solid var(--gold); box-shadow: 0 6px 18px rgba(0,0,0,.25); display: block; margin: 0 auto 12px; }
.kitsu-portrait-round { width: 120px; height: 120px; border-radius: 50%; border: 3px solid var(--gold); object-fit: cover; box-shadow: 0 0 0 4px rgba(216,182,90,.25), 0 6px 16px rgba(0,0,0,.3); }
.speech { font-family: var(--hand); font-size: 25px; line-height: 1.3; color: var(--ink); text-align: center; min-height: 2.6em; }
.speech-name { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: var(--wine); text-align: center; margin-top: 8px; }
.choice-list { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 420px; margin: 16px auto 0; }
.choice {
  text-align: left; border: 1px solid var(--parch-3); background: rgba(255,250,235,.55); padding: 12px 16px; border-radius: 6px;
  font-size: 18px; color: var(--ink); cursor: pointer; transition: all .2s; font-family: var(--serif);
}
.choice:hover { border-color: var(--gold); background: rgba(255,250,235,.95); transform: translateX(3px); }
.choice.chosen { border-color: var(--wine); background: rgba(107,30,42,.08); color: var(--wine); font-weight: 700; }
.q-counter { text-align: center; color: var(--gold); letter-spacing: 4px; font-size: 13px; margin-bottom: 8px; }
.branch-reveal { font-size: 64px; animation: popIn .9s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes popIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.branch-name { font-size: 36px; font-weight: 700; margin-top: 4px; }
.name-input {
  width: 100%; max-width: 340px; border: none; border-bottom: 2px solid var(--ink-soft); background: transparent;
  font-family: var(--hand); font-size: 32px; text-align: center; color: var(--ink); padding: 6px; outline: none;
}
.name-input:focus { border-color: var(--wine); }
.dissolve-wrap { font-family: var(--hand); font-size: 40px; min-height: 60px; display: flex; justify-content: center; gap: 1px; }
.dissolve-wrap span { display: inline-block; animation: dissolve 1.6s ease forwards; }
@keyframes dissolve { 0% { opacity: 1; filter: blur(0); transform: none; } 100% { opacity: 0; filter: blur(8px); transform: translateY(-24px) rotate(10deg); } }
.qqq { font-size: 54px; font-weight: 700; color: var(--wine); letter-spacing: 6px; animation: popIn .8s ease both; }
.letter-area {
  width: 100%; min-height: 160px; border: 1px solid var(--parch-3); border-radius: 4px; padding: 12px;
  background: repeating-linear-gradient(transparent 0 31px, rgba(90,70,50,.18) 31px 32px), rgba(255,250,235,.4);
  font-family: var(--hand); font-size: 21px; line-height: 32px; color: var(--ink); resize: vertical; outline: none;
}
.letter-sealed { position: relative; width: 220px; height: 150px; margin: 0 auto; background: linear-gradient(160deg, #f6ecd2, #e0c995); border: 1px solid #c7ad79; box-shadow: 0 6px 14px rgba(0,0,0,.2); animation: popIn .6s ease both; }
.letter-sealed::before { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom right, transparent 49.5%, #c7ad79 50%, transparent 50.5%), linear-gradient(to bottom left, transparent 49.5%, #c7ad79 50%, transparent 50.5%); background-size: 100% 60%; background-repeat: no-repeat; }
.letter-sealed .mini-seal { position: absolute; left: 50%; top: 56%; transform: translate(-50%,-50%); width: 50px; height: 50px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #c43a3a, #7a1820); box-shadow: 0 3px 6px rgba(0,0,0,.4); color: #f2c7a0; display: flex; align-items: center; justify-content: center; font-weight: 700; animation: stamp .5s .3s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes stamp { from { transform: translate(-50%,-50%) scale(2.5); opacity: 0; } to { transform: translate(-50%,-50%) scale(1); opacity: 1; } }

/* ============ Закладки ============ */
#ribbons { position: absolute; top: 0; left: 26px; right: 18px; height: 0; z-index: 10; display: none; justify-content: space-between; pointer-events: none; }
#ribbons.show { display: flex; }
.ribbon {
  pointer-events: auto; position: relative; width: calc((100% - 7 * 4px) / 8); max-width: 48px; height: 38px; border: none; cursor: pointer;
  background: var(--rc, var(--wine)); color: #fff7dc; font-size: 17px; padding: 0 0 8px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.2); transition: height .25s ease, filter .2s;
  display: flex; align-items: center; justify-content: center; filter: saturate(.75) brightness(.92);
  background-image: linear-gradient(90deg, rgba(0,0,0,.18), rgba(255,255,255,.12) 50%, rgba(0,0,0,.18));
}
.ribbon:hover { height: 44px; filter: none; }
.ribbon.active { height: 52px; filter: none; }
.ribbon .r-badge { position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold-3); box-shadow: 0 0 6px var(--gold-3); }
.ribbon-label { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; color: var(--wine); font-weight: 700; letter-spacing: .5px; pointer-events: none; opacity: 0; }
.ribbon.active .ribbon-label { opacity: 0; }

/* ============ Окно Статуса ============ */
.status {
  position: relative; padding: 16px 16px 14px; border-radius: 6px; margin-bottom: 12px;
  background: rgba(255,250,235,.45); border: 1px solid var(--parch-3);
}
.status.rank-1 { border: 1px solid var(--gold); }
.status.rank-2 { border: 3px double var(--gold); }
.status.rank-3 { border: 3px double var(--gold); box-shadow: 0 0 0 4px rgba(184,144,47,.12); }
.status.rank-4 { border: 3px double var(--gold); box-shadow: 0 0 0 4px rgba(107,30,42,.15), inset 0 0 30px rgba(184,144,47,.12); }
.status.rank-5 { border: 3px double var(--gold-2); box-shadow: 0 0 22px rgba(216,182,90,.35), inset 0 0 30px rgba(216,182,90,.18); }
.status.rank-6 { border: 3px double var(--gold-2); animation: authorGlow 3s ease-in-out infinite; }
@keyframes authorGlow { 0%,100% { box-shadow: 0 0 18px rgba(216,182,90,.35); } 50% { box-shadow: 0 0 40px rgba(241,217,138,.7); } }
.status.rank-3::before, .status.rank-4::before, .status.rank-5::before, .status.rank-6::before,
.status.rank-3::after, .status.rank-4::after, .status.rank-5::after, .status.rank-6::after {
  content: '❧'; position: absolute; top: -12px; color: var(--gold); font-size: 20px; background: var(--parch); padding: 0 4px;
}
.status.rank-3::before, .status.rank-4::before, .status.rank-5::before, .status.rank-6::before { left: 10px; transform: scaleX(-1); }
.status.rank-3::after, .status.rank-4::after, .status.rank-5::after, .status.rank-6::after { right: 10px; }
.status-head { display: flex; gap: 14px; align-items: center; }
.rank-seal {
  flex: 0 0 auto; width: 70px; height: 70px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, #a42d38, var(--wine) 60%, #3c0f17); color: var(--gold-3);
  box-shadow: 0 3px 8px rgba(0,0,0,.35), inset 0 2px 4px rgba(255,255,255,.18); border: 2px solid var(--gold);
}
.rank-seal b { font-size: 30px; line-height: 1; }
.rank-seal span { font-size: 9px; letter-spacing: 1px; text-transform: uppercase; opacity: .85; }
.status-name { font-size: 26px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.status-name.hidden-name { letter-spacing: 4px; color: var(--ink-soft); }
.status-rank { color: var(--wine); font-weight: 600; font-size: 16px; }
.status-motto { color: var(--ink-faint); font-style: italic; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 13px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--parch-3); background: rgba(255,250,235,.7); color: var(--ink-soft); white-space: nowrap; }
.chip.mark { border-color: var(--wine); color: var(--wine); background: rgba(107,30,42,.07); font-weight: 700; }
.chip.gold { border-color: var(--gold); color: #7a5a14; }

.stat-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; margin: 9px 0; }
.stat-ico { font-size: 18px; text-align: center; }
.stat-label { display: flex; justify-content: space-between; font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.stat-label .lim { color: var(--ink-faint); font-weight: 400; }
.bar { height: 9px; border-radius: 6px; background: rgba(90,70,50,.14); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.15); }
.bar > i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--c, var(--wine)), color-mix(in srgb, var(--c, var(--wine)) 60%, #fff)); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.stat-row.weak .stat-label { color: var(--wine); }
.weak-note { font-size: 12px; font-style: italic; color: var(--wine); margin-top: 2px; }
.stat-val { font-weight: 700; min-width: 34px; text-align: right; }

.panel { margin-top: 12px; padding: 12px 14px; border-radius: 6px; border: 1px solid var(--parch-3); background: rgba(255,250,235,.35); }
.panel h4 { margin: 0 0 6px; font-size: 17px; color: var(--wine); }
.panel.danger { border-color: rgba(107,30,42,.5); background: rgba(107,30,42,.06); }
.panel.gate { border-color: var(--gold); background: linear-gradient(135deg, rgba(241,217,138,.25), rgba(255,250,235,.3)); }
.shadow-meter { height: 10px; border-radius: 6px; background: rgba(90,70,50,.14); overflow: hidden; margin-top: 4px; }
.shadow-meter > i { display: block; height: 100%; background: linear-gradient(90deg, #4b3a5a, #1a0f22); transition: width .8s; }
.gate-dots { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.gate-dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--gold); background: transparent; }
.gate-dots i.on { background: radial-gradient(circle, var(--gold-3), var(--gold)); box-shadow: 0 0 8px rgba(216,182,90,.6); }

.npc-dialog { margin-top: 10px; border: 2px solid var(--ink-soft); background: #fffaf0; padding: 10px 12px; font-family: 'Courier New', monospace; font-size: 14px; border-radius: 2px; }
.npc-dialog .row { margin-top: 8px; }

/* ============ Квесты ============ */
.day-head { text-align: center; margin-bottom: 8px; }
.day-head .d1 { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: var(--gold); }
.day-head .d2 { font-size: 24px; font-weight: 700; color: var(--wine); }
.window-title { display: flex; align-items: center; gap: 8px; margin: 16px 0 8px; font-weight: 700; color: var(--ink-soft); font-size: 16px; letter-spacing: 1px; text-transform: uppercase; }
.window-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--parch-3), transparent); }
.window-title .lock { font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 400; font-style: italic; color: var(--ink-faint); }
.quest {
  position: relative; display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center;
  padding: 11px 12px; border-radius: 6px; margin-bottom: 8px; cursor: pointer;
  background: rgba(255,250,235,.6); border: 1px solid var(--parch-3); border-left: 4px solid var(--c, var(--wine));
  transition: transform .15s, background .2s;
}
.quest:hover { transform: translateX(2px); background: rgba(255,250,235,.9); }
.quest .q-ico { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; background: color-mix(in srgb, var(--c, var(--wine)) 14%, transparent); }
.quest .q-name { font-weight: 700; font-size: 17px; line-height: 1.15; }
.quest .q-act { font-size: 14px; color: var(--ink-soft); }
.quest .q-note { font-size: 13px; color: var(--ink-faint); font-style: italic; }
.quest .q-side { text-align: right; font-size: 13px; color: var(--ink-faint); }
.quest.locked { opacity: .5; filter: grayscale(.6); cursor: default; }
.quest.done { background: rgba(232,222,190,.5); }
.quest.done .q-name { text-decoration: line-through; text-decoration-color: rgba(107,30,42,.6); text-decoration-thickness: 2px; }
.quest.done::after { content: '✓'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%) rotate(-12deg); font-size: 34px; color: var(--wine); opacity: .75; font-weight: 700; animation: stampIn .4s cubic-bezier(.2,1.6,.4,1); }
.quest.done .q-side { visibility: hidden; }
@keyframes stampIn { from { transform: translateY(-50%) scale(2.5) rotate(-12deg); opacity: 0; } }
.credit-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px dashed rgba(107,30,42,.45); border-radius: 6px; margin-bottom: 6px; background: rgba(107,30,42,.04); font-size: 15px; }
.tomorrow { margin-top: 18px; text-align: center; padding: 16px; border: 1px dashed var(--parch-3); border-radius: 8px; color: var(--ink-faint); }
.tomorrow .wax { width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 6px; background: radial-gradient(circle at 35% 30%, #b53440, #6b1e2a); box-shadow: 0 2px 5px rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; color: #f2c7a0; font-size: 18px; }

/* ============ Выбор Свитка ============ */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding-top: 6px; margin: 0 0 8px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 1px solid var(--parch-3); background: rgba(255,250,235,.5); border-radius: 6px; padding: 7px 4px; font-size: 14px; cursor: pointer; color: var(--ink-soft); position: relative; white-space: nowrap; font-family: var(--serif); }
.missing-link { border: none; background: none; color: #a32020; font-family: var(--serif); font-size: 13px; text-decoration: underline; cursor: pointer; padding: 0 3px; }
.tab.active { background: var(--c, var(--wine)); color: #fff7dc; border-color: transparent; }
.tab .cnt { display: inline-block; min-width: 18px; padding: 0 4px; border-radius: 9px; background: rgba(0,0,0,.12); font-size: 12px; margin-left: 3px; }
.tab.need::after { content: '!'; position: absolute; top: -6px; right: -4px; width: 16px; height: 16px; border-radius: 50%; background: var(--wine); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.pick { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--parch-3); margin-bottom: 7px; background: rgba(255,250,235,.5); cursor: pointer; transition: all .15s; }
.pick:hover { border-color: var(--gold); }
.pick.on { border-color: var(--c, var(--wine)); background: color-mix(in srgb, var(--c, var(--wine)) 9%, rgba(255,250,235,.8)); box-shadow: inset 4px 0 0 var(--c, var(--wine)); }
.pick .pn { font-weight: 700; font-size: 16px; }
.pick .pa { font-size: 14px; color: var(--ink-soft); }
.pick .pf { font-size: 13px; color: var(--c, var(--wine)); font-weight: 700; white-space: nowrap; }
.star { color: var(--gold); }
.scroll-summary { position: sticky; bottom: -22px; margin: 12px -26px -22px -34px; padding: 10px 18px 14px; background: linear-gradient(180deg, rgba(243,230,200,0), var(--parch) 22%); }
.counter { display: flex; justify-content: center; gap: 14px; font-size: 14px; margin-bottom: 8px; flex-wrap: wrap; }
.counter b { color: var(--wine); }
.counter .bad { color: #a32020; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--gold); border-radius: 6px; overflow: hidden; }
.stepper button { width: 38px; height: 36px; border: none; background: #f6e9c8; font-size: 20px; color: var(--wine); cursor: pointer; }
.stepper span { min-width: 54px; text-align: center; font-weight: 700; font-size: 17px; }
.seg { display: inline-flex; border: 1px solid var(--gold); border-radius: 6px; overflow: hidden; }
.seg button { border: none; background: #f6e9c8; padding: 8px 10px; font-size: 14px; cursor: pointer; color: var(--ink-soft); }
.seg button.on { background: var(--wine); color: var(--gold-3); }
.field-label { font-size: 13px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-faint); margin: 12px 0 4px; }
.text-input { width: 100%; border: 1px solid var(--parch-3); background: rgba(255,250,235,.7); border-radius: 6px; padding: 9px 11px; font-family: var(--serif); font-size: 16px; color: var(--ink); outline: none; }
.text-input:focus { border-color: var(--gold); }
.growth { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin-top: 4px; }
.growth div { text-align: center; font-size: 12px; padding: 4px 2px; border-radius: 4px; background: rgba(90,70,50,.07); }
.growth div b { display: block; color: var(--wine); font-size: 11px; }
.growth div.cur { background: rgba(107,30,42,.12); outline: 1px solid var(--wine); }

/* ============ Модальные окна ============ */
#modal-root { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.modal-overlay { position: absolute; inset: 0; background: rgba(10,6,12,.6); display: flex; align-items: center; justify-content: center; padding: 14px; opacity: 0; transition: opacity .25s; pointer-events: auto; backdrop-filter: blur(2px); }
.modal-overlay.show { opacity: 1; }
.modal {
  width: min(520px, 100%); max-height: 88vh; overflow-y: auto; border-radius: 8px; padding: 20px 20px 18px; position: relative;
  background: radial-gradient(ellipse at 80% 0%, rgba(255,255,255,.4), transparent 50%), var(--parch);
  box-shadow: 0 20px 50px rgba(0,0,0,.6), inset 0 0 40px rgba(120,80,30,.25); border: 1px solid var(--gold);
  transform: translateY(14px) scale(.98); transition: transform .3s cubic-bezier(.2,.9,.3,1.2);
}
.modal-overlay.show .modal { transform: none; }
.modal h3 { margin: 0 0 2px; font-size: 24px; color: var(--wine); line-height: 1.15; }
.modal .x { position: absolute; top: 8px; right: 10px; border: none; background: transparent; font-size: 24px; color: var(--ink-faint); cursor: pointer; }
.timer-face { font-size: 58px; font-weight: 700; text-align: center; color: var(--wine); font-variant-numeric: tabular-nums; letter-spacing: 2px; }
.timer-ring { width: 180px; height: 180px; margin: 6px auto; position: relative; }
.timer-ring svg { transform: rotate(-90deg); }
.timer-ring .timer-face { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 42px; }
.count-big { font-size: 64px; font-weight: 700; color: var(--wine); text-align: center; line-height: 1; }
.photo-prev { max-width: 100%; max-height: 220px; border-radius: 6px; border: 1px solid var(--gold); display: block; margin: 8px auto; }
.method-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.method-tabs button { flex: 1; border: 1px solid var(--parch-3); background: rgba(255,250,235,.6); border-radius: 6px; padding: 7px 6px; font-size: 14px; cursor: pointer; }
.method-tabs button.on { border-color: var(--wine); background: rgba(107,30,42,.09); color: var(--wine); font-weight: 700; }
.bonus-note { font-size: 13px; color: #7a5a14; text-align: center; margin-top: 6px; }

/* ============ Кицу и системные сообщения ============ */
#toast-root { position: fixed; left: 0; right: 0; top: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 10px 0; pointer-events: none; }
.kitsu-toast {
  pointer-events: auto; width: min(520px, 100%); display: flex; gap: 12px; align-items: center; padding: 10px 14px 10px 10px;
  background: linear-gradient(180deg, #fbf3dc, #efdfb6); border: 1px solid var(--gold); border-radius: 50px 14px 14px 50px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); transform: translateY(-140%); transition: transform .45s cubic-bezier(.2,1.2,.3,1); cursor: pointer;
}
.kitsu-toast.show { transform: none; }
.kitsu-toast.sad { background: linear-gradient(180deg, #e9e2d6, #d4cab8); border-color: #6a5f74; }
.medallion { flex: 0 0 auto; width: 60px; height: 60px; border-radius: 50%; overflow: hidden; border: 3px solid var(--gold); box-shadow: 0 0 0 3px rgba(216,182,90,.25); }
.medallion img { width: 100%; height: 100%; object-fit: cover; }
.kitsu-name { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--wine); font-weight: 700; }
.kitsu-text { font-family: var(--hand); font-size: 20px; line-height: 1.25; color: var(--ink); min-height: 1.25em; }
.system-note { pointer-events: none; background: rgba(20,10,16,.88); color: var(--gold-3); border: 1px solid var(--gold); padding: 8px 16px; border-radius: 4px; font-weight: 600; font-size: 16px; opacity: 0; transform: translateY(-10px); transition: all .4s; text-align: center; max-width: 92vw; }
.system-note.show { opacity: 1; transform: none; }
.float-text { position: fixed; z-index: 70; font-weight: 700; font-size: 22px; pointer-events: none; text-shadow: 0 1px 0 #fff, 0 0 8px rgba(255,255,255,.8); animation: floatUp 1.6s ease forwards; transform: translateX(-50%); }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 0) scale(.8); } 15% { opacity: 1; transform: translate(-50%, -10px) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -70px); } }

/* ============ Церемонии ============ */
.ceremony { text-align: center; }
.ceremony .big-rank { width: 140px; height: 140px; margin: 10px auto; font-size: 64px; }
.ceremony .big-rank b { font-size: 64px; }
.ceremony .rays { position: relative; }
.ceremony .rays::before { content: ''; position: absolute; left: 50%; top: 50%; width: 320px; height: 320px; transform: translate(-50%,-50%); background: repeating-conic-gradient(rgba(216,182,90,.22) 0 8deg, transparent 8deg 22deg); border-radius: 50%; animation: spin 18s linear infinite; z-index: -1; mask: radial-gradient(circle, #000 30%, transparent 70%); -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%); }
@keyframes spin { to { transform: translate(-50%,-50%) rotate(360deg); } }
.name-reveal { font-family: var(--hand); font-size: 46px; color: var(--wine); }
.name-reveal span { display: inline-block; opacity: 0; animation: inkIn .6s ease forwards; }

/* ============ Заглушки ============ */
.placeholder { text-align: center; padding: 20px 10px; }
.placeholder .ph-ico { font-size: 60px; opacity: .55; }
.placeholder .ph-badge { display: inline-block; margin-top: 10px; padding: 3px 12px; border: 1px solid var(--gold); border-radius: 99px; color: #7a5a14; font-size: 13px; }
.feature-list { text-align: left; max-width: 380px; margin: 14px auto 0; padding-left: 20px; color: var(--ink-soft); }
.feature-list li { margin: 4px 0; }

/* ============ Настройки ============ */
.setting { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid rgba(90,70,50,.15); }
.toggle { width: 50px; height: 28px; border-radius: 14px; background: #cdbb94; position: relative; cursor: pointer; border: none; transition: background .2s; flex: 0 0 auto; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.toggle.on { background: var(--wine); }
.toggle.on::after { left: 25px; }

/* ============ Отладка ============ */
.debug-panel { position: fixed; top: 8px; right: 8px; z-index: 80; background: rgba(15,10,18,.92); color: #f1d98a; border: 1px solid #b8902f; border-radius: 8px; font-family: system-ui, sans-serif; font-size: 12px; padding: 8px; width: 170px; }
.debug-panel summary { cursor: pointer; font-weight: 700; }
.debug-panel button { display: block; width: 100%; margin-top: 5px; background: #2a1a2e; color: #f1d98a; border: 1px solid #6b5a2a; border-radius: 4px; padding: 5px; font-size: 12px; cursor: pointer; text-align: left; }
.debug-panel .dbg-info { margin-top: 6px; opacity: .8; line-height: 1.35; }

/* ============ Адаптив ============ */
@media (max-width: 420px) {
  body { font-size: 17px; }
  .page-inner { padding: 22px 16px 20px 22px; }
  .with-ribbons .page-inner { padding-top: 54px; }
  .scroll-summary { margin: 12px -16px -20px -22px; }
  .p-title { font-size: 26px; }
  #ribbons { left: 16px; right: 10px; }
}
@media (min-width: 900px) and (min-height: 700px) {
  .page-inner { padding: 34px 40px 28px 48px; }
  .with-ribbons .page-inner { padding-top: 64px; }
  .scroll-summary { margin: 12px -40px -28px -48px; padding: 12px 40px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .page.flip-out, .page.flip-in { animation-duration: .01s; }
}

/* =====================================================
   ЭТАП 2 — ГЛУБИНА
   ===================================================== */

/* ---------- Разворот на компьютере ---------- */
#book-wrap { transition: width .9s cubic-bezier(.5,0,.2,1); }
#left-page { display: none; }
#book-wrap.spread { width: min(96vw, 1240px); }
#book-wrap.spread #book { left: 50%; }
#book-wrap.spread .book-edge::before { display: none; }
#book-wrap.spread #ribbons { left: calc(50% + 30px); }
#book-wrap.spread #left-page {
  display: block; position: absolute; top: 0; bottom: 0; left: 0; width: 50%; z-index: 0;
  border-radius: 10px 3px 3px 10px; overflow: hidden; animation: inkIn .8s ease both;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,255,255,.3), transparent 40%),
    radial-gradient(ellipse at 90% 95%, rgba(150,100,40,.16), transparent 45%),
    linear-gradient(270deg, rgba(90,60,20,.3) 0%, rgba(90,60,20,0) 7%),
    var(--parch);
  box-shadow: inset 0 0 50px rgba(120,80,30,.25), 0 30px 40px rgba(0,0,0,.5);
}
#book-wrap.spread #left-page::before { /* стопка страниц слева */
  content: ''; position: absolute; top: 6px; bottom: 6px; left: -7px; width: 10px; z-index: -1;
  background: repeating-linear-gradient(to bottom, #e9d8b0 0 2px, #cdb486 2px 3px); border-radius: 6px 0 0 6px;
}
#book-wrap.spread #left-page::after { /* корешок по центру */
  content: ''; position: absolute; top: 0; bottom: 0; right: -2px; width: 30px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(60,35,10,.28));
}
#book-wrap.spread .page .front { border-radius: 3px 10px 10px 3px; }
.left-inner { position: absolute; inset: 0; overflow-y: auto; padding: 34px 44px 28px 40px; scrollbar-width: thin; scrollbar-color: var(--parch-3) transparent; }
.left-decor { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.left-decor .kitsu-portrait { max-width: 86%; }
.left-quote { font-family: var(--hand); font-size: 28px; color: var(--wine); max-width: 80%; margin-top: 10px; }

/* ---------- Окно Статуса: титул и Метки ---------- */
.status-title { font-family: var(--hand); color: var(--gold); font-size: 19px; line-height: 1; margin-bottom: 2px; }
.status.marked { filter: saturate(.55); }
.status.marked .status-name { opacity: .6; }
.status.cracked { box-shadow: inset 0 0 40px rgba(30,15,40,.35); }
.status.cracked { background-image:
  linear-gradient(115deg, transparent 47%, rgba(40,20,50,.3) 47.5%, transparent 48.5%),
  linear-gradient(60deg, transparent 70%, rgba(40,20,50,.25) 70.5%, transparent 71.5%),
  radial-gradient(ellipse at center, transparent 55%, rgba(30,15,40,.22)); }

/* ---------- Подземелье ---------- */
.panel.dungeon { border-color: #4b3a5a; background: linear-gradient(135deg, rgba(75,58,90,.12), rgba(255,250,235,.3)); }
.panel.dungeon h4 { color: #3c2a4a; }
.boss-hp { position: relative; height: 18px; border-radius: 9px; background: rgba(40,20,50,.15); overflow: hidden; margin-top: 8px; border: 1px solid rgba(60,40,80,.4); }
.boss-hp i { display: block; height: 100%; background: linear-gradient(90deg, #2a1a3a, #6b3a7a); transition: width .8s; }
.boss-hp span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; }
.quest.dg { box-shadow: 0 0 0 1px rgba(75,58,90,.45), 0 0 12px rgba(107,58,122,.18); }
.dg-tag { font-size: 12px; color: #5b3a7a; font-weight: 600; white-space: nowrap; }
.q-menu { display: block; margin: 4px 0 0 auto; border: 1px solid var(--parch-3); background: rgba(255,250,235,.8); border-radius: 6px; width: 30px; height: 22px; line-height: 1; cursor: pointer; color: var(--wine); font-weight: 700; }
.panel.injury { border-color: #3d6b8e; background: rgba(61,107,142,.08); text-align: center; }

/* ---------- Хроника ---------- */
.chapter { position: relative; padding: 16px 4px 6px; margin-bottom: 16px; border-bottom: 1px solid rgba(90,70,50,.15); font-size: 18px; line-height: 1.6; text-align: justify; hyphens: auto; }
.chapter p { margin: 0 0 10px; text-indent: 1.2em; }
.chapter p.drop { text-indent: 0; }
.ch-num { text-align: center; font-size: 12px; letter-spacing: 4px; text-transform: uppercase; color: var(--gold); }
.ch-title { text-align: center; font-size: 24px; font-weight: 700; color: var(--wine); line-height: 1.15; }
.ch-date { text-align: center; font-size: 13px; color: var(--ink-faint); font-style: italic; margin-bottom: 10px; }
.ch-end { text-align: center; color: var(--gold); margin-top: 4px; }
.chapter.shadow { background: linear-gradient(180deg, rgba(30,15,40,.08), rgba(30,15,40,.02)); border-radius: 8px; padding: 16px 14px 6px; color: #2e2238; font-style: italic; }
.chapter.shadow .ch-title, .chapter.shadow .drop::first-letter { color: #3c2a4a; }
.chapter.injured { background: rgba(61,107,142,.06); border-radius: 8px; padding: 16px 14px 6px; }
.chapter.prologue-ch { opacity: .85; }

/* ---------- Отголоски ---------- */
.echo { padding: 12px 14px; border-radius: 8px; margin-bottom: 10px; border: 1px solid var(--parch-3); background: rgba(255,250,235,.5); }
.echo.open { border-color: rgba(91,58,142,.45); background: linear-gradient(135deg, rgba(91,58,142,.07), rgba(255,250,235,.5)); }
.echo-q { font-weight: 700; color: #4a2f72; margin-top: 4px; }
.echo-a { font-family: var(--hand); font-size: 22px; line-height: 1.3; margin-top: 6px; }
.echo.sealed { display: flex; gap: 12px; align-items: center; }
.echo-wax { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #8a5ab8, #4a2f72); color: #f0e0ff; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(0,0,0,.3); }

/* ---------- Воспоминания ---------- */
.memory { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 12px; margin-bottom: 8px; border-radius: 8px; border: 1px solid var(--parch-3); background: rgba(255,250,235,.5); cursor: pointer; transition: transform .15s; }
.memory:hover { transform: translateX(2px); }
.memory.locked { opacity: .55; filter: grayscale(.5); }
.memory.open { border-color: rgba(61,107,53,.5); }
.mem-num { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--gold-3); background: radial-gradient(circle at 35% 30%, #4f7a45, #24401f); border: 2px solid var(--gold); font-size: 15px; }
.memory.locked .mem-num { background: #9a8a70; }
.mem-title { font-weight: 700; font-size: 17px; }
.new-dot { font-size: 12px; color: var(--wine); font-weight: 700; }
.memory-read p.ln-mem { font-size: 19px; line-height: 1.6; margin: 0 0 12px; opacity: 0; animation: inkIn 1s ease forwards; }
.memory-read .ch-num { margin-bottom: 4px; }

/* ---------- Печати ---------- */
.seal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 12px 8px; margin-top: 14px; }
.seal-cell { text-align: center; cursor: pointer; }
.wax-seal { width: 62px; height: 62px; margin: 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; background: radial-gradient(circle at 35% 30%, #cfc3ad, #9c8f78); filter: grayscale(1); opacity: .5; box-shadow: inset 0 -3px 6px rgba(0,0,0,.25); position: relative; }
.wax-seal::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; border: 1.5px dashed rgba(255,255,255,.3); }
.seal-cell.got .wax-seal { background: radial-gradient(circle at 35% 30%, #c43a3a, #7a1820); filter: none; opacity: 1; box-shadow: 0 3px 8px rgba(0,0,0,.35), inset 0 -3px 6px rgba(0,0,0,.3); }
.seal-cell.got.legendary .wax-seal { background: radial-gradient(circle at 35% 30%, #f1d98a, #a07a2a 60%, #6a4c12); animation: authorGlow 3s ease-in-out infinite; }
.seal-name { font-size: 12px; line-height: 1.2; margin-top: 5px; color: var(--ink-soft); }
.seal-cell.got .seal-name { color: var(--ink); font-weight: 600; }
.seal-big { width: 100px; height: 100px; margin: 0 auto 8px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 44px; background: radial-gradient(circle at 35% 30%, #cfc3ad, #9c8f78); filter: grayscale(1); opacity: .6; }
.seal-big.got { background: radial-gradient(circle at 35% 30%, #c43a3a, #7a1820); filter: none; opacity: 1; }
.seal-big.got.legendary { background: radial-gradient(circle at 35% 30%, #f1d98a, #a07a2a 60%, #6a4c12); animation: authorGlow 3s infinite; }

/* ---------- Лавка ---------- */
.gold-big { text-align: center; font-size: 30px; font-weight: 700; color: #7a5a14; margin: 4px 0 6px; }
.shop-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--parch-3); background: rgba(255,250,235,.55); margin-bottom: 8px; }
.shop-item.disabled { opacity: .6; }
.si-ico { font-size: 26px; text-align: center; }
.si-name { font-weight: 700; }
.si-buy { display: flex; flex-direction: column; align-items: flex-end; }
.si-buy .mt { margin-top: 4px; }
.cosm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cosm { display: grid; grid-template-columns: 28px 1fr auto; gap: 6px; align-items: center; text-align: left; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--parch-3); background: rgba(255,250,235,.55); cursor: pointer; font-family: var(--serif); font-size: 14px; color: var(--ink); }
.cosm.on { border-color: var(--wine); box-shadow: inset 0 0 0 1px var(--wine); }
.swatch { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); }
select.text-input { appearance: auto; }

/* ---------- Гиды техник ---------- */
.breath-wrap { width: 200px; height: 200px; margin: 6px auto 4px; display: flex; align-items: center; justify-content: center; }
.breath-orb { width: 70px; height: 70px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff3c4, #e0a33a 45%, #a0412e); box-shadow: 0 0 30px rgba(224,163,58,.6), 0 0 80px rgba(176,65,46,.3); transition-property: width, height, box-shadow; transition-timing-function: ease-in-out; }
.breath-orb.in { width: 190px; height: 190px; }
.breath-orb.hold { width: 190px; height: 190px; box-shadow: 0 0 50px rgba(255,200,90,.9), 0 0 120px rgba(176,65,46,.5); }
.breath-orb.out { width: 70px; height: 70px; }
.breath-label { font-size: 26px; font-weight: 700; color: var(--wine); text-align: center; min-height: 1.3em; }
.palace-words { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; text-align: left; }
.palace-words span { padding: 6px 10px; border-radius: 6px; background: rgba(107,30,42,.07); font-weight: 600; }
.emo-wheel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.emo-group { border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); border-radius: 8px; padding: 6px; text-align: center; background: color-mix(in srgb, var(--c) 7%, transparent); }
.emo-group b { color: var(--c); font-size: 14px; display: block; margin-bottom: 4px; }
.emo { border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); background: rgba(255,250,235,.7); border-radius: 99px; padding: 3px 8px; font-size: 12px; cursor: pointer; font-family: var(--serif); }
.emo.on { background: var(--c); color: #fff; }
.flashcard { margin: 10px auto 0; max-width: 340px; min-height: 140px; border-radius: 10px; border: 1px solid var(--gold); background: linear-gradient(160deg, #fffaf0, #f0e0b8); box-shadow: 0 6px 14px rgba(0,0,0,.15); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px; cursor: pointer; text-align: center; }
.card-front { font-size: 26px; font-weight: 700; color: var(--wine); }
.card-back { font-family: var(--hand); font-size: 22px; margin-top: 6px; }

@media (max-width: 420px) {
  .emo-wheel { grid-template-columns: 1fr; }
  .chapter { font-size: 17px; }
}

/* ===== Баланс «Перо и Пыль» ===== */
.chapter.dust { background: linear-gradient(180deg, #2a1c33, #1e1426); color: #e2d6ea; border-radius: 8px; padding: 16px 14px 6px; font-style: italic; box-shadow: inset 0 0 30px rgba(0,0,0,.45); border-bottom: none; }
.chapter.dust .ch-title, .chapter.dust .drop::first-letter { color: #c7a8e0; }
.chapter.dust .ch-num, .chapter.dust .ch-date, .chapter.dust .ch-end { color: #a893b8; }
.chapter.crossed .ch-body { opacity: .5; text-decoration: line-through; text-decoration-color: rgba(142,43,43,.75); text-decoration-thickness: 1.5px; }
.chapter.dust.crossed { filter: saturate(.6); }
.pen-stamp { display: inline-block; margin: 2px 0 6px; padding: 3px 10px; border: 2px solid #8e2b2b; color: #8e2b2b; border-radius: 6px; font-size: 14px; font-style: normal; font-weight: 700; transform: rotate(-3deg); background: rgba(246,236,214,.92); letter-spacing: .03em; }
.chapter.travel { background: rgba(160,122,42,.07); border-radius: 8px; padding: 16px 14px 6px; }
.chapter.travel p:nth-child(2) { font-family: var(--hand, cursive); font-size: 20px; text-indent: 0; color: #6b4a1f; }
.panel.travel { border-color: rgba(160,122,42,.5); background: rgba(160,122,42,.08); }
.panel.arc { border-color: rgba(107,74,168,.45); background: rgba(107,74,168,.06); }
.kitsu-sleep { position: relative; display: inline-block; }
.kitsu-sleep img { filter: grayscale(.7) brightness(.85); }
.kitsu-sleep .zzz { position: absolute; right: -18px; top: -6px; font-family: var(--hand, cursive); font-size: 22px; color: #6b4aa8; animation: zzz 2.4s ease-in-out infinite; }
@keyframes zzz { 0%,100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-8px); opacity: 1; } }
.dust-quote { margin: 12px auto; max-width: 520px; padding: 12px 16px; border-radius: 8px; background: #241830; color: #e2d6ea; font-style: italic; line-height: 1.55; box-shadow: inset 0 0 24px rgba(0,0,0,.5); }
.kitsu-toast.sleepy .medallion img { filter: grayscale(.6) brightness(.9); }
.kitsu-toast.sleepy .kitsu-name::after { content: ' 💤'; }
.linkish { background: none; border: none; color: #8e2b2b; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
select.inp { width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid rgba(90,70,50,.35); background: rgba(255,250,238,.9); font: inherit; color: inherit; }
.chapter.dust.crossed .ch-body { text-decoration-color: rgba(230,110,100,.85); }

/* ===== Безопасность «Свеча и Щит» ===== */
.candle-modal .modal, .modal.candle-modal { max-width: 460px; }
.candle { text-align: left; }
.candle-flame { text-align: center; font-size: 52px; animation: flicker 2.6s ease-in-out infinite; filter: drop-shadow(0 0 14px rgba(255,190,90,.55)); }
@keyframes flicker { 0%,100% { transform: scale(1) rotate(-1deg); } 50% { transform: scale(1.06) rotate(1.5deg); } }
.candle-kitsu { font-size: 17px; line-height: 1.55; background: rgba(255,250,238,.7); border-left: 3px solid #c9a24a; padding: 10px 12px; border-radius: 6px; }
.helpline { display: grid; grid-template-columns: 74px 1fr; gap: 10px; align-items: center; padding: 10px 12px; margin: 8px 0; border-radius: 10px; border: 1.5px solid rgba(107,30,42,.35); background: rgba(255,250,238,.95); color: inherit; text-decoration: none; }
.helpline b { font-size: 22px; color: #6b1e2a; }
.helpline i { display: block; font-style: normal; font-weight: 700; }
.helpline small { display: block; font-size: 12.5px; opacity: .75; line-height: 1.35; }
.helpline.sos { border-color: rgba(176,65,46,.6); background: rgba(176,65,46,.07); }
.helpline:active { transform: scale(.98); }
.breath { display: flex; flex-direction: column; align-items: center; margin: 14px 0 4px; }
.breath-circle { width: 70px; height: 70px; border-radius: 50%; background: radial-gradient(circle, rgba(47,122,109,.55), rgba(47,122,109,.15)); transition: transform 4s ease-in-out; }
.breath-circle.in, .breath-circle.hold { transform: scale(1.7); }
.breath-circle.out, .breath-circle.rest { transform: scale(1); }
.breath-label { margin-top: 30px; font-family: var(--hand); font-size: 24px; color: #2f7a6d; }
.panel.quiet { border-color: rgba(47,122,109,.45); background: rgba(47,122,109,.07); }
.panel.moon { border-color: rgba(58,106,168,.4); background: rgba(58,106,168,.06); }
.panel.candle-panel { border-color: rgba(201,162,74,.6); background: rgba(255,214,140,.12); }
.quest-warn { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: rgba(176,65,46,.08); border: 1px solid rgba(176,65,46,.25); font-size: 14px; line-height: 1.4; }
.hurt-block { margin-top: 14px; padding-top: 10px; border-top: 1px dashed rgba(90,70,50,.25); text-align: center; }
.hurt-block .tiny { margin-top: 4px; }
.pin-seal { font-size: 44px; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 10px 0 4px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #6b1e2a; }
.pin-dots i.on { background: #6b1e2a; }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.pin-grid { display: grid; grid-template-columns: repeat(3, 64px); gap: 10px; justify-content: center; margin-top: 8px; }
.pin-key { height: 52px; border-radius: 50%; border: 1.5px solid rgba(107,30,42,.35); background: rgba(255,250,238,.95); font: inherit; font-size: 22px; color: #6b1e2a; cursor: pointer; }
.pin-key:active { background: rgba(107,30,42,.12); }

/* ===================== Последняя Глава ===================== */
.shadow-figure { position: relative; width: 110px; height: 140px; margin: 0 auto; border-radius: 50% 50% 38% 38% / 42% 42% 30% 30%;
  background: radial-gradient(ellipse at 50% 30%, #3b2a4a 0%, #1c1226 55%, rgba(20,12,28,0) 72%); filter: blur(.4px);
  animation: shadowBreath 4s ease-in-out infinite; }
.shadow-figure::after { content: ''; position: absolute; left: 50%; bottom: -8px; width: 120%; height: 18px; transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(28,18,38,.55), transparent 70%); }
.shadow-figure .eye { position: absolute; top: 34%; width: 9px; height: 5px; border-radius: 50%; background: #e8c46a; box-shadow: 0 0 10px #e8c46a; animation: blink 6s infinite; }
.shadow-figure .eye.l { left: 36%; } .shadow-figure .eye.r { right: 36%; }
.shadow-figure.small { width: 54px; height: 68px; margin: 0; flex: none; }
.shadow-figure.small .eye { width: 6px; height: 3px; }
@keyframes shadowBreath { 0%,100% { transform: scale(1); opacity: .92; } 50% { transform: scale(1.04) translateY(-3px); opacity: 1; } }
@keyframes blink { 0%,46%,50%,100% { transform: scaleY(1); } 48% { transform: scaleY(.1); } }
.shadow-speech { color: #3c2a4a; font-style: italic; }
.shadow-speech::before { content: '🌑 '; font-style: normal; font-size: .7em; }
.shadow-reply { color: #4a2a5a; font-style: italic; text-align: center; animation: popIn .4s ease both; }

.shadow-hp { position: relative; height: 18px; border-radius: 9px; background: rgba(40,20,50,.15); overflow: hidden; margin: 10px 0 4px; border: 1px solid rgba(60,40,80,.45); }
.shadow-hp i { display: block; height: 100%; background: linear-gradient(90deg, #1c1226, #5a2f6a 70%, #8a4a8a); transition: width 1.1s cubic-bezier(.3,.8,.3,1); }
.shadow-hp span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; }

.tails { display: flex; align-items: center; gap: 3px; font-size: 13px; color: var(--ink-2, #5a4630); margin-top: 6px; justify-content: center; }
.tails i { width: 10px; height: 18px; border-radius: 50% 50% 50% 50% / 70% 70% 30% 30%; background: rgba(200,120,50,.18); border: 1px solid rgba(200,120,50,.45); }
.tails i.on { background: linear-gradient(180deg, #fff3d6 0%, #f0a050 35%, #c8642a 100%); box-shadow: 0 0 6px rgba(240,160,80,.55); }

.panel.battle { border-color: #4a2f5a; background: linear-gradient(180deg, rgba(60,40,80,.07), rgba(255,250,235,.6)); }
.panel.battle h4 { color: #3c2a4a; }
.panel.battle .gate-dots i { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; font-style: normal; border-color: #5a3a6a; filter: grayscale(.6); }
.panel.battle .gate-dots i:empty { width: 20px; height: 20px; }
.panel.battle .gate-dots i.on { filter: none; background: radial-gradient(circle, var(--gold-3), var(--gold)); }
.quest.trial { border: 2px dashed #5a3a6a; margin-top: 10px; background: rgba(60,40,80,.05); }
.quest.trial.done { border-style: solid; opacity: .75; }
.quest.trial .q-note { font-size: 12px; color: #6a4a7a; }
.shard-row { display: flex; justify-content: center; gap: 10px; font-size: 28px; margin: 10px 0; }

.shadow-status { margin-top: 14px; padding: 14px 16px; border-radius: 10px; color: #e9dcf2;
  background: linear-gradient(160deg, #1f1529, #2e1f3c 60%, #1a1122); border: 1px solid #5a3a6a; box-shadow: inset 0 0 30px rgba(0,0,0,.45), 0 6px 18px rgba(20,10,30,.3); }
.shadow-status .ss-head { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.shadow-status .shadow-figure { background: radial-gradient(ellipse at 50% 30%, #6a4a7a 0%, #3b2a4a 50%, rgba(20,12,28,0) 72%); }
.shadow-status .ss-name { font-family: var(--hand); font-size: 26px; color: #f0e2ff; line-height: 1; }
.shadow-status .ss-rank { font-size: 12px; letter-spacing: 1.5px; color: #e8c46a; text-transform: uppercase; }
.shadow-status .tiny { color: #b9a6c9; }
.shadow-status .shadow-hp { background: rgba(255,255,255,.08); border-color: rgba(200,160,230,.3); }
.ss-row { display: grid; grid-template-columns: 22px 78px 1fr 28px; gap: 8px; align-items: center; font-size: 13px; margin: 5px 0; }
.ss-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; }
.ss-bar i { display: block; height: 100%; background: linear-gradient(90deg, #5a2f6a, #b06ab0); }
.ss-row b { text-align: right; color: #f0e2ff; }
.ss-foot { margin-top: 8px; }

.duel { width: 100%; max-width: 460px; margin: 10px auto 0; }
.duel.fade { animation: popIn .45s ease both; }
.evidence { display: grid; gap: 8px; margin-top: 10px; }
.ev-card { display: flex; gap: 10px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 14px;
  background: linear-gradient(160deg, #fffaf0, #f3e4c2); border: 1px solid var(--gold); color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.1); transition: transform .15s; }
.ev-card:hover:not(:disabled) { transform: translateY(-2px); }
.ev-card b { font-size: 20px; }
.ev-card:disabled { opacity: .5; cursor: default; }
.ev-card.chosen { opacity: 1; border-color: var(--wine); box-shadow: 0 0 0 2px rgba(107,30,42,.25), 0 0 16px rgba(216,182,90,.6); }
.choice.tried, .choice:disabled.tried { opacity: .45; text-decoration: line-through; }
.shadow-gone { width: 80px; height: 14px; margin: 10px auto; border-radius: 50%; background: radial-gradient(ellipse, rgba(28,18,38,.45), transparent 70%); }

.big-hand { font-family: var(--hand); font-size: 23px; line-height: 1.3; color: var(--wine); }
.letter-sealed.broken .mini-seal { animation: sealBreak 1.2s .3s ease forwards; }
@keyframes sealBreak { 0% { transform: translate(-50%,-50%) scale(1); } 40% { transform: translate(-50%,-50%) scale(1.15) rotate(-8deg); } 100% { transform: translate(-50%,-50%) scale(.3) rotate(25deg); opacity: 0; } }
.letter-open { margin: 14px auto 0; max-width: 440px; padding: 16px 18px; background: linear-gradient(160deg, #fbf3df, #ecd9ae); border: 1px solid #c7ad79; box-shadow: 0 6px 14px rgba(0,0,0,.15); text-align: left; animation: popIn .8s 1.2s ease both; }
.letter-text { font-size: 22px; line-height: 1.35; white-space: pre-wrap; color: var(--ink); }

.mini-cover { width: 200px; height: 270px; margin: 0 auto; border-radius: 4px 10px 10px 4px; padding: 26px 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, #7a2433, #4a1520 70%); border: 2px solid #b8913f; box-shadow: inset 6px 0 10px rgba(0,0,0,.4), 0 10px 22px rgba(0,0,0,.35); color: var(--gold-3); text-align: center; animation: popIn .8s ease both; }
.mc-emblem { font-size: 22px; } .mc-title { font-family: var(--serif-title, serif); font-size: 30px; letter-spacing: 2px; }
.mc-name { font-family: var(--hand); font-size: 26px; color: #ffe6a8; margin-top: 2px; }
.mc-line { width: 60%; height: 1px; background: var(--gold); margin: 10px 0; opacity: .7; }
.mc-epi { font-family: var(--hand); font-size: 16px; color: #f2d9a6; line-height: 1.2; }

.credits { max-width: 420px; margin: 0 auto; text-align: center; animation: creditsUp 1.4s ease both; }
.cr-title { font-family: var(--hand); font-size: 32px; color: var(--wine); margin-bottom: 14px; }
.cr-role { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--gold, #a8842f); margin-top: 12px; }
.cr-name { font-family: var(--hand); font-size: 24px; color: var(--ink); }
.cr-sep { color: var(--gold); margin: 14px 0; font-size: 18px; }
.cr-stat { font-size: 14px; margin: 3px 0; } .cr-stat b { color: var(--wine); font-size: 16px; }
.cr-last { font-family: var(--hand); font-size: 22px; color: var(--wine); }
.cr-end { margin-top: 16px; font-style: italic; color: var(--muted, #8a7356); }
@keyframes creditsUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }

.cover.authored .cover-subtitle.author-name { color: #ffe6a8; text-shadow: 0 0 12px rgba(255,220,140,.45); }

/* ===================== Том Второй · Режим Автора ===================== */
.cover-tome { font-family: var(--hand); font-size: 20px; color: var(--gold-3); opacity: .75; margin-top: 2px; letter-spacing: 2px; }
.creator h3 { margin: 0 0 4px; }
.creator-field { margin: 10px 0; text-align: left; }
.inp { width: 100%; padding: 9px 12px; border-radius: 7px; border: 1px solid #c7ad79; background: #fbf3df; color: var(--ink); font: inherit; font-size: 14px; }
.inp:focus { outline: 2px solid var(--gold-2); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; margin: 4px 14px 4px 0; cursor: pointer; }
.check input { accent-color: var(--wine); width: 16px; height: 16px; }
.creator-err { color: var(--wine); font-size: 13px; font-weight: 700; margin-top: 8px; min-height: 1em; }
.creator .letter-area { min-height: 56px; font-size: 17px; }
.own-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px dashed rgba(138,100,32,.3); font-size: 14px; text-align: left; }
.row.wrap { flex-wrap: wrap; }

/* ===================== Годовое Кольцо ===================== */
.sm-inp { width: auto; padding: 7px 8px; font-size: 13px; }
.seed-inp { margin: 6px 0; }
.seed-card { margin: 14px auto 4px; max-width: 420px; padding: 14px 16px; background: linear-gradient(160deg, #eff3d8, #e2ecc2); border-left: 3px solid #7ba05b; border-radius: 6px; text-align: left; animation: popIn .5s ease both; }
.seed-text { font-family: var(--hand); font-size: 22px; color: #40501f; }
.memo-candle { text-align: center; filter: drop-shadow(0 0 12px rgba(232,196,106,.8)); animation: shadowBreath 4s ease-in-out infinite; }

/* ===================== Хвост Письма и Ковен ===================== */
.mini-details { margin: 4px 0; }
.mini-details summary { cursor: pointer; color: var(--wine,#6b2a2a); font-weight: 600; }
.scholar { margin-top: 6px; padding: 6px 10px; background: rgba(90,60,20,.06); border-radius: 6px; }
.sch-line { font-size: 13px; }
.letter-arc { margin: 8px 0 12px; padding: 10px 14px; background: linear-gradient(160deg, #efe6cf, #e7dcc0); border-left: 3px solid #8a6f3f; border-radius: 6px; }
.la-head { display: flex; justify-content: space-between; font-weight: 600; color: #5e2a1e; }
.coven-today { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 12px; padding: 10px 14px; background: linear-gradient(160deg, #e9e4d2, #ddd6bd); border-left: 3px solid #4a5a3a; border-radius: 6px; font-size: 14px; }
.coven-lit { color: #4a5a3a; font-weight: 600; }
.coven-days { display: flex; gap: 8px; align-items: center; }
.coven-day { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(0,0,0,.06); color: transparent; }
.coven-day.lit { background: gold; color: #7a5c10; }

/* ===================== Чернильница ===================== */
.ink-shelf { margin-bottom: 18px; }
.ink-cards { display: flex; gap: 10px; flex-wrap: wrap; }
.ink-card { flex: 1; min-width: 140px; background: linear-gradient(160deg, #efe6cf, #e4d8b8); border: 1px solid #8a6f3f; border-radius: 8px; padding: 12px; text-align: center; }
.ink-title { font-weight: 700; color: #5e2a1e; font-size: 14px; }
.ink-price { font-size: 20px; font-weight: 700; margin: 4px 0; color: #3a2c1a; }
.echo-reply { margin-top: 8px; padding: 8px 12px; background: rgba(90,60,20,.07); border-left: 2px solid #8a6f3f; border-radius: 4px; }
.echo-text { font-size: 15px; white-space: pre-wrap; }

/* Хранители Времени */
.ch-smudge { margin-top: 8px; font-style: italic; font-size: 12px; color: #8a6f3f; text-align: center; }

/* PWA: уважение к чёлке и «полоске» */
#ribbons { padding-right: env(safe-area-inset-right); }
#toast-root { padding-bottom: env(safe-area-inset-bottom); }
.debug-panel { padding-bottom: env(safe-area-inset-bottom); }
@supports (padding: max(0px)) {
  .nav-pad { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (display-mode: standalone) {
  body { overscroll-behavior: none; }
}

/* ===== Дневной пергамент (фон вокруг книги) ===== */
body[data-theme='day'] {
  background:
    radial-gradient(ellipse at 50% 25%, rgba(255, 246, 214, .85) 0%, transparent 62%),
    radial-gradient(ellipse at 18% 88%, #dcc59a 0%, transparent 55%),
    radial-gradient(ellipse at 85% 80%, #e3cbb2 0%, transparent 55%),
    #e9dcbd;
}
body[data-theme='day'] .ribbon { filter: saturate(.92) brightness(.97); }
body[data-theme='day'] .debug-panel { background: rgba(120, 90, 40, .18); }
body[data-theme='day'] .system-note, body[data-theme='day'] .kitsu-toast { box-shadow: 0 8px 28px rgba(90, 60, 20, .18); }

/* ===== Тишина движения: prefers-reduced-motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  #particles { display: none; }
}

/* Свиток Переноса: вход на обложке */
.cover-restore { position: absolute; bottom: -44px; left: 50%; transform: translateX(-50%); background: none; border: none; color: rgba(233,220,189,.55); font-family: var(--serif); font-size: 13px; font-style: italic; cursor: pointer; text-decoration: underline dotted; padding: 6px 12px; }
.cover-restore:hover { color: rgba(233,220,189,.9); }
