/* ===================== Шрифты (свои, без внешних сервисов) ===================== */
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url(fonts/manrope-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url(fonts/manrope-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Playfair Display"; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url(fonts/playfair-display-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Playfair Display"; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url(fonts/playfair-display-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "Playfair Display"; font-style: italic; font-weight: 400 900; font-display: swap;
  src: url(fonts/playfair-display-cyrillic-wght-italic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Playfair Display"; font-style: italic; font-weight: 400 900; font-display: swap;
  src: url(fonts/playfair-display-latin-wght-italic.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url(fonts/unbounded-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url(fonts/unbounded-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2212, U+FEFF, U+FFFD; }

/* ===================== Тема «Библиотека» (по умолчанию) ===================== */
:root {
  --bg: #f3eee4;
  --bg-art:
    radial-gradient(1200px 500px at 85% -10%, rgba(201, 164, 92, .16), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(31, 58, 46, .08), transparent 60%);
  --surface: #fffdf8;
  --surface-2: #f7f2e8;
  --field: #fff;
  --ink: #1e1c17;
  --ink-2: #4a4539;
  --muted: #8a8170;
  --line: rgba(30, 28, 23, .10);
  --line-2: rgba(30, 28, 23, .18);
  --hair: rgba(30, 28, 23, .07);

  --primary: #1f3a2e;
  --primary-hover: #2a4c3c;
  --primary-ink: #f6f0e0;
  --primary-soft: #e3ebe4;
  --accent-text: #9a7232;
  --gold: #c9a45c;
  --gold-hover: #d6b46e;
  --gold-ink: #17251d;

  --ok: #2f7a50; --ok-soft: #e1efe5;
  --warn: #b7791f; --warn-soft: #fbf0d9; --warn-ink: #7a4e0e;
  --danger: #a33a2b; --danger-soft: #f8e3de;

  --sb-bg: linear-gradient(180deg, #1b2e24 0%, #14231b 100%);
  --sb-ink: #eee7d4;
  --sb-muted: rgba(238, 231, 212, .55);
  --sb-line: rgba(238, 231, 212, .10);
  --sb-hover: rgba(255, 255, 255, .06);
  --sb-active: rgba(201, 164, 92, .15);
  --sb-active-ink: #ebcc8a;

  --hero-bg:
    radial-gradient(520px 260px at 92% 0%, rgba(214, 180, 110, .35), transparent 65%),
    linear-gradient(135deg, #22402f 0%, #172a20 100%);
  --hero-ink: #f5efdf;
  --hero-muted: rgba(245, 239, 223, .72);
  --hero-line: rgba(245, 239, 223, .28);
  --hero-paper: #f5efdf;

  --th-bg: #efe8da;
  --th-ink: #4a4539;
  --overlay: rgba(23, 37, 29, .86);
  --backdrop: rgba(20, 18, 12, .45);

  --radius: 18px;
  --r-sm: 10px;
  --r-btn: 12px;
  --bw: 1px;
  --shadow: 0 1px 2px rgba(50, 38, 14, .05), 0 10px 30px -12px rgba(50, 38, 14, .18);
  --shadow-lg: 0 30px 80px -20px rgba(20, 16, 6, .45);
  --shadow-btn: none;
  --lift: translateY(-2px);

  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --display: "Playfair Display", Georgia, "Times New Roman", serif;
  --display-weight: 600;
  --head-case: none;
  --head-track: -0.01em;
  --eyebrow-track: .18em;
  color-scheme: light;
}

/* ===================== Тема «Ночная читальня» ===================== */
[data-theme="night"] {
  --bg: #0c0e11;
  --bg-art:
    radial-gradient(900px 520px at 60% -12%, rgba(216, 178, 106, .10), transparent 62%),
    radial-gradient(700px 500px at 0% 100%, rgba(216, 178, 106, .04), transparent 60%);
  --surface: #14171b;
  --surface-2: #1a1d22;
  --field: #0f1114;
  --ink: #ece6d8;
  --ink-2: #c4bca9;
  --muted: #8b8576;
  --line: rgba(236, 230, 216, .10);
  --line-2: rgba(236, 230, 216, .18);
  --hair: rgba(236, 230, 216, .07);

  --primary: #d8b26a;
  --primary-hover: #e6c483;
  --primary-ink: #16120a;
  --primary-soft: rgba(216, 178, 106, .12);
  --accent-text: #d8b26a;
  --gold: #d8b26a;
  --gold-hover: #e6c483;
  --gold-ink: #16120a;

  --ok: #7cc79a; --ok-soft: rgba(124, 199, 154, .12);
  --warn: #e3b25a; --warn-soft: rgba(227, 178, 90, .12); --warn-ink: #e9c47d;
  --danger: #ef8a78; --danger-soft: rgba(239, 138, 120, .12);

  --sb-bg: #08090b;
  --sb-ink: #ece6d8;
  --sb-muted: rgba(236, 230, 216, .45);
  --sb-line: rgba(216, 178, 106, .16);
  --sb-hover: rgba(236, 230, 216, .05);
  --sb-active: rgba(216, 178, 106, .10);
  --sb-active-ink: #e6c483;

  --hero-bg:
    radial-gradient(420px 240px at 50% -20%, rgba(216, 178, 106, .22), transparent 70%),
    #121418;
  --hero-ink: #ece6d8;
  --hero-muted: rgba(236, 230, 216, .62);
  --hero-line: rgba(216, 178, 106, .45);
  --hero-paper: #1d2026;

  --th-bg: #181b20;
  --th-ink: #d8b26a;
  --overlay: rgba(8, 9, 11, .9);
  --backdrop: rgba(0, 0, 0, .6);

  --radius: 3px;
  --r-sm: 2px;
  --r-btn: 2px;
  --shadow: 0 0 0 1px var(--line);
  --shadow-lg: 0 40px 100px -20px rgba(0, 0, 0, .8), 0 0 0 1px rgba(216, 178, 106, .25);
  --lift: none;
  --head-case: uppercase;
  --head-track: .14em;
  --eyebrow-track: .3em;
  color-scheme: dark;
}

/* ===================== Тема «Яркая» ===================== */
[data-theme="bright"] {
  --bg: #fff5e8;
  --bg-art:
    radial-gradient(circle at 92% 8%, #ffd0e0 0 140px, transparent 141px),
    radial-gradient(circle at 4% 96%, #c8f2ea 0 180px, transparent 181px),
    radial-gradient(circle at 70% 102%, #ffe58a 0 120px, transparent 121px);
  --surface: #ffffff;
  --surface-2: #fff8ee;
  --field: #ffffff;
  --ink: #1b1530;
  --ink-2: #3d3558;
  --muted: #6e6787;
  --line: #1b1530;
  --line-2: #1b1530;
  --hair: rgba(27, 21, 48, .12);

  --primary: #5b3df5;
  --primary-hover: #4a2ee0;
  --primary-ink: #fff;
  --primary-soft: #ece7ff;
  --accent-text: #e2456f;
  --gold: #ffd23f;
  --gold-hover: #ffdc63;
  --gold-ink: #1b1530;

  --ok: #13836a; --ok-soft: #d4f5ea;
  --warn: #c76a00; --warn-soft: #fff0c7; --warn-ink: #8a4a00;
  --danger: #d7263d; --danger-soft: #ffe1e5;

  --sb-bg: linear-gradient(170deg, #6a4dff 0%, #5534f0 55%, #4a28dd 100%);
  --sb-ink: #ffffff;
  --sb-muted: rgba(255, 255, 255, .7);
  --sb-line: rgba(255, 255, 255, .22);
  --sb-hover: rgba(255, 255, 255, .12);
  --sb-active: #ffd23f;
  --sb-active-ink: #1b1530;

  --hero-bg:
    radial-gradient(circle at 88% 20%, rgba(255, 255, 255, .25) 0 70px, transparent 71px),
    linear-gradient(120deg, #ff7a59 0%, #ff4f8b 100%);
  --hero-ink: #ffffff;
  --hero-muted: rgba(255, 255, 255, .88);
  --hero-line: rgba(255, 255, 255, .7);
  --hero-paper: #ffffff;

  --th-bg: #ffd23f;
  --th-ink: #1b1530;
  --overlay: rgba(91, 61, 245, .9);
  --backdrop: rgba(27, 21, 48, .5);

  --radius: 22px;
  --r-sm: 12px;
  --r-btn: 14px;
  --bw: 2px;
  --shadow: 5px 5px 0 #1b1530;
  --shadow-lg: 8px 8px 0 #1b1530;
  --shadow-btn: 3px 3px 0 #1b1530;
  --lift: translate(-2px, -2px);
  --display: "Unbounded", "Manrope", sans-serif;
  --display-weight: 700;
  --head-track: -0.02em;
  --eyebrow-track: .12em;
}

/* ===================== База ===================== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg-art), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--primary); }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
::selection { background: var(--gold); color: var(--gold-ink); }

h1, h2, h3, .display { font-family: var(--display); font-weight: var(--display-weight); letter-spacing: var(--head-track); }

/* ===================== Каркас ===================== */
.shell { display: grid; grid-template-columns: 284px minmax(0, 1fr); min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 40px 44px 40px; flex: 1; }
.wrap:has(.table-wrap:not([hidden])) { max-width: 1640px; }
.topbar { display: none; }

/* ----- Боковая панель ----- */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  display: flex; flex-direction: column; gap: 14px;
  padding: 22px 16px 16px;
  background: var(--sb-bg); color: var(--sb-ink);
  border-right: 1px solid var(--sb-line);
}
.sidebar::before { /* тонкая латунная линия у корешка */
  content: ""; position: absolute; inset: 0 0 0 auto; width: 1px;
  background: linear-gradient(180deg, transparent, var(--gold), transparent); opacity: .35;
}
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 2px 6px 10px; }
.logo { width: 42px; height: 42px; flex: none; display: block; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .35)); }
.sb-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sb-brand-text b { font-family: var(--display); font-weight: var(--display-weight); font-size: 19px; letter-spacing: var(--head-track); }
.sb-brand-text small { font-size: 10.5px; text-transform: uppercase; letter-spacing: .2em; color: var(--sb-muted); margin-top: 3px; }
.sidebar .sb-close { display: none; margin-left: auto; color: var(--sb-ink); }

.sb-label { display: flex; align-items: center; justify-content: space-between; margin: 8px 8px -4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .16em; color: var(--sb-muted); }
.sb-count { background: var(--sb-hover); border-radius: 999px; padding: 1px 9px; letter-spacing: 0; font-size: 11.5px; }

.doc-list { list-style: none; margin: 0 -4px; padding: 4px; display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--sb-line) transparent; }
.doc-item { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 2px;
  padding: 9px 6px 9px 14px; border-radius: 12px; cursor: pointer; transition: background .15s; }
.doc-item:hover { background: var(--sb-hover); }
.doc-item.active { background: var(--sb-active); }
.doc-item.active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--gold); }
.doc-item-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-item.active .doc-item-name { color: var(--sb-active-ink); }
.doc-item-meta { font-size: 12px; color: var(--sb-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-item.active .doc-item-meta { color: var(--sb-active-ink); opacity: .75; }
.doc-item .icon-btn { width: 30px; height: 30px; color: inherit; opacity: 0; }
.doc-item:hover .icon-btn, .doc-item.active .icon-btn { opacity: .7; }
.doc-item .icon-btn:hover { opacity: 1; background: var(--sb-hover); }
.doc-item .ic { width: 17px; height: 17px; }
.doc-list .empty-note { color: var(--sb-muted); font-size: 13px; padding: 8px 12px; }

.sb-foot { display: flex; flex-direction: column; gap: 2px; padding-top: 12px; border-top: 1px solid var(--sb-line); }
.sb-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; border: 0; background: none;
  color: var(--sb-ink); opacity: .85; text-decoration: none; font-size: 14px; font-weight: 600; cursor: pointer; text-align: left; width: 100%; }
.sb-link:hover, .sb-link.on { background: var(--sb-hover); opacity: 1; }
.sb-link.on { background: var(--sb-active); color: var(--sb-active-ink); }
.sb-link .ic { width: 19px; height: 19px; }
.me-card { margin-top: 8px; display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px; text-align: left; cursor: pointer;
  background: var(--sb-hover); border: 1px solid var(--sb-line); border-radius: 14px; color: var(--sb-ink); }
.me-card:hover { border-color: var(--gold); }
.me-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.me-text b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { font-size: 12px; color: var(--sb-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small.warn { color: #f0c46a; }
.me-text small.bad { color: #ff9b8a; }
.chev { width: 16px; height: 16px; opacity: .5; }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(145deg, var(--gold-hover), var(--gold)); color: var(--gold-ink);
  font-weight: 800; font-size: 13px; letter-spacing: .02em; text-transform: uppercase; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar-btn { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; }
.sb-backdrop { display: none; }

/* ===================== Кнопки ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--r-btn);
  border: var(--bw) solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: 14.5px; text-decoration: none; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-btn); transition: background .15s, border-color .15s, transform .12s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.gold:hover { background: var(--gold-hover); }
.btn.light { background: rgba(255, 255, 255, .1); border-color: var(--hero-line); color: var(--hero-ink); }
.btn.light:hover { background: rgba(255, 255, 255, .18); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.block { width: 100%; }
.btn.sm, .small-btn { height: 34px; padding: 0 12px; font-size: 13px; border-radius: calc(var(--r-btn) - 2px); }
.btn[aria-disabled="true"], .btn:disabled { opacity: .45; pointer-events: none; }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ===================== Заголовок описи ===================== */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; border-radius: var(--r-sm); margin-bottom: 22px; font-size: 14px;
  border: var(--bw) solid; }
.banner.warn { background: var(--warn-soft); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.banner.bad { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.banner b { display: block; }

.doc-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px 28px; flex-wrap: wrap; margin-bottom: 26px; }
.doc-head-text { min-width: 0; flex: 1 1 380px; }
.eyebrow { margin: 0; display: flex; gap: 10px; font-size: 11.5px; font-weight: 800; letter-spacing: var(--eyebrow-track); text-transform: uppercase; color: var(--accent-text); }
.eyebrow span + span::before { content: "·"; margin-right: 10px; opacity: .6; }
.eyebrow span:empty { display: none; }
.doc-title-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.doc-name { margin: 0; font-size: clamp(28px, 3.6vw, 46px); line-height: 1.08; outline: none; cursor: text; min-width: 0; overflow-wrap: anywhere;
  border-radius: 8px; padding: 2px 6px; margin-left: -6px; transition: background .15s, box-shadow .15s; }
.doc-name:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); }
.doc-name[contenteditable="true"] { background: var(--surface); box-shadow: 0 0 0 2px var(--gold); }
.doc-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===================== Сводка ===================== */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 16px 18px 15px; overflow: hidden;
  background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 0; height: 2px; border-radius: 2px 2px 0 0; background: var(--gold); opacity: 0; transition: opacity .2s; }
.stat.hot::after { opacity: 1; }
.stat-num { font-family: var(--display); font-weight: var(--display-weight); font-size: 30px; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ===================== Загрузка ===================== */
.upload { position: relative; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 30px;
  padding: 30px 34px; margin-bottom: 34px; border-radius: var(--radius); background: var(--hero-bg); color: var(--hero-ink);
  box-shadow: var(--shadow); border: var(--bw) solid var(--line); transition: transform .2s, box-shadow .2s; }
.upload::after { /* тонкие «строки» как на карточке каталога */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(0deg, transparent 0 27px, rgba(255, 255, 255, .035) 27px 28px);
}
.upload.drag { transform: scale(1.01); box-shadow: 0 0 0 3px var(--gold), var(--shadow-lg); }
.upload-art svg { width: 128px; height: 128px; display: block; }
.upload-art .ring { fill: none; stroke: var(--hero-line); stroke-width: 1; stroke-dasharray: 3 5; }
.upload-art .back { fill: rgba(255, 255, 255, .08); stroke: var(--hero-line); stroke-width: 1.2; }
.upload-art .front { fill: var(--hero-paper); }
.upload-art .lines { stroke: var(--gold); stroke-width: 2.2; stroke-linecap: round; }
.upload-art .spark { fill: var(--gold); }
.upload-text { position: relative; z-index: 1; }
.upload-title { margin: 0; font-family: var(--display); font-weight: var(--display-weight); font-size: 26px; line-height: 1.15; letter-spacing: var(--head-track); }
.upload-hint { margin: 6px 0 0; color: var(--hero-muted); }
.upload-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 14px; }
.upload-tip { margin: 0; font-size: 13px; color: var(--hero-muted); max-width: 640px; }
.upload-tip b { color: var(--hero-ink); }

/* ===================== Список книг ===================== */
.books-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.books-head h2 { margin: 0; font-size: 24px; }
.list-tools { display: flex; gap: 10px; align-items: center; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: calc(var(--r-btn) + 2px); background: var(--surface-2); border: var(--bw) solid var(--line); }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: var(--r-btn); font-size: 13.5px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.select-wrap { position: relative; }
.select-wrap::after { content: ""; position: absolute; right: 13px; top: 50%; width: 7px; height: 7px; margin-top: -5px;
  border: solid var(--muted); border-width: 0 1.8px 1.8px 0; transform: rotate(45deg); pointer-events: none; }
select { appearance: none; -webkit-appearance: none; height: 40px; padding: 0 34px 0 14px; border-radius: var(--r-btn);
  border: var(--bw) solid var(--line); background: var(--surface); font-weight: 600; font-size: 13.5px; cursor: pointer; }

.book-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 14px; }
.book { position: relative; display: grid; grid-template-columns: 82px minmax(0, 1fr) auto; gap: 16px; padding: 16px;
  background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  cursor: pointer; transition: transform .18s, box-shadow .18s; animation: rise .35s ease both; }
.book:hover { transform: var(--lift); }
.book.warn { box-shadow: inset 3px 0 0 var(--warn), var(--shadow); }
.book.error { box-shadow: inset 3px 0 0 var(--danger), var(--shadow); }
.book-thumb { width: 82px; height: 110px; object-fit: cover; border-radius: 4px 8px 8px 4px; background: var(--surface-2); display: block;
  box-shadow: inset 4px 0 6px -3px rgba(0, 0, 0, .25), 0 6px 14px -6px rgba(0, 0, 0, .35); }
.book-body { min-width: 0; }
.book-title { margin: 0 0 4px; font-family: var(--display); font-weight: var(--display-weight); font-size: 17px; line-height: 1.25; letter-spacing: 0; }
.book-line { margin: 2px 0 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.book-err { color: var(--danger); font-size: 13.5px; margin: 0; }
.book-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; max-width: 360px; }
.quick label { display: flex; flex-direction: column; gap: 3px; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.quick input { width: 100%; height: 36px; padding: 0 10px; border: var(--bw) solid var(--line); border-radius: var(--r-sm); background: var(--field);
  font-size: 15px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink); transition: background .3s, border-color .15s; }
.quick input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.quick input.saved, .grid .saved { background: var(--ok-soft) !important; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.badge.proc { background: var(--primary-soft); color: var(--primary); }
[data-theme="night"] .badge.proc { color: var(--gold); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.spinner { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.skeleton { height: 12px; border-radius: 6px; margin: 9px 0; background: linear-gradient(90deg, var(--surface-2), var(--hair), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }

/* ----- Таблица ----- */
.table-wrap { overflow: auto; max-height: 76vh; background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
.grid th { position: sticky; top: 0; z-index: 2; background: var(--th-bg); color: var(--th-ink); text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: 12px 10px; border-bottom: var(--bw) solid var(--line-2); }
.grid td { border-bottom: 1px solid var(--hair); padding: 5px 6px; vertical-align: top; }
.grid tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.grid tr.warn td { background: var(--warn-soft); }
.grid tr.err td { background: var(--danger-soft); }
.grid td input:not([type="checkbox"]), .grid td textarea { width: 100%; min-width: 0; border: 1px solid transparent; background: transparent; padding: 6px 8px; border-radius: 6px; font-size: 14px; line-height: 1.35; }
.grid td textarea { resize: vertical; min-height: 34px; display: block; }
.grid td input:hover, .grid td textarea:hover { border-color: var(--hair); }
.grid td input:focus, .grid td textarea:focus { outline: none; border-color: var(--primary); background: var(--field); box-shadow: 0 0 0 3px var(--primary-soft); }
.grid input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--warn); margin-top: 7px; }
.grid .w-n { width: 46px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 12px; }
.grid th.w-n { padding-top: 12px; }
.grid .w-ph { width: 62px; }
.grid .w-ph img { width: 40px; height: 54px; object-fit: cover; border-radius: 2px 5px 5px 2px; display: block; cursor: zoom-in; box-shadow: 0 3px 8px -3px rgba(0, 0, 0, .4); }
.grid .w-xs { width: 78px; }
.grid .w-s { width: 112px; }
.grid .w-m { width: 170px; }
.grid .w-l { min-width: 300px; }
.grid .extra input, .grid .extra textarea { color: var(--muted); }
.grid .c { text-align: center; }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty svg { width: 58px; height: 58px; fill: none; stroke: var(--gold); stroke-width: 1.5; stroke-linejoin: round; margin-bottom: 8px; }
.empty p { max-width: 420px; margin: 0 auto; }
.empty b { color: var(--ink); }

.site-footer { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: .06em; padding: 20px 16px 28px; }

/* ===================== Слои: панели, тосты, перетаскивание ===================== */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--backdrop); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .2s; }
.sheet-panel { position: relative; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 22px 24px 24px;
  background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.2, .9, .3, 1.2); }
.sheet-panel.wide { width: min(1000px, 100%); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.sheet-head h3 { margin: 0; font-size: 22px; text-transform: var(--head-case); }
.sheet.side { justify-content: flex-end; align-items: stretch; padding: 0; }
.sheet.side .sheet-panel { width: min(560px, 100%); max-height: none; height: 100%; border-radius: 0; animation: slide-in .26s cubic-bezier(.2, .8, .2, 1); border-width: 0 0 0 var(--bw); }

.toast { position: fixed; left: 50%; bottom: 26px; z-index: 90; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--surface); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.drop-overlay { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; background: var(--overlay); color: #fff; }
.drop-overlay div { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 64px; border: 2px dashed var(--gold); border-radius: var(--radius);
  font-family: var(--display); font-size: 26px; }
.drop-overlay .ic { width: 40px; height: 40px; color: var(--gold); }
body.dragging .drop-overlay { display: grid; }
.fab { display: none; }

/* ----- Темы ----- */
.theme-list { display: grid; gap: 10px; }
.theme-opt { display: grid; grid-template-columns: 124px 1fr; gap: 16px; align-items: center; text-align: left; padding: 12px; cursor: pointer;
  background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius); transition: border-color .15s, box-shadow .15s; }
.theme-opt:hover { border-color: var(--line-2); }
.theme-opt.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.theme-name { display: block; font-weight: 800; font-size: 16px; margin-bottom: 2px; }
.theme-desc { display: block; font-size: 13px; color: var(--muted); }
.tp { position: relative; display: block; width: 124px; height: 80px; border-radius: 10px; overflow: hidden; }
.tp i { position: absolute; display: block; }
.tp-side { left: 0; top: 0; bottom: 0; width: 30px; }
.tp-card { left: 40px; top: 10px; right: 10px; height: 42px; border-radius: 5px; }
.tp-l1 { left: 47px; top: 18px; width: 52px; height: 6px; border-radius: 3px; }
.tp-l2 { left: 47px; top: 30px; width: 34px; height: 4px; border-radius: 2px; }
.tp-btn { left: 40px; bottom: 9px; width: 38px; height: 13px; border-radius: 4px; }
.tp-classic { background: #f3eee4; }
.tp-classic .tp-side { background: #1b2e24; box-shadow: inset -1px 0 #c9a45c; }
.tp-classic .tp-card { background: linear-gradient(135deg, #22402f, #172a20); }
.tp-classic .tp-l1 { background: #f5efdf; } .tp-classic .tp-l2 { background: #c9a45c; }
.tp-classic .tp-btn { background: #1f3a2e; }
.tp-night { background: #0c0e11; box-shadow: inset 0 0 0 1px #2a2a2a; }
.tp-night .tp-side { background: #08090b; box-shadow: inset -1px 0 rgba(216, 178, 106, .4); }
.tp-night .tp-card { background: #14171b; box-shadow: inset 0 0 0 1px rgba(216, 178, 106, .4); border-radius: 1px; }
.tp-night .tp-l1 { background: #ece6d8; border-radius: 0; } .tp-night .tp-l2 { background: #d8b26a; border-radius: 0; }
.tp-night .tp-btn { background: #d8b26a; border-radius: 1px; }
.tp-bright { background: #fff5e8; }
.tp-bright .tp-side { background: #5b3df5; }
.tp-bright .tp-card { background: linear-gradient(120deg, #ff7a59, #ff4f8b); border: 2px solid #1b1530; box-shadow: 3px 3px 0 #1b1530; border-radius: 8px; }
.tp-bright .tp-l1 { background: #fff; } .tp-bright .tp-l2 { background: #ffd23f; }
.tp-bright .tp-btn { background: #ffd23f; border: 2px solid #1b1530; border-radius: 6px; }

/* ----- Профиль ----- */
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.profile-head b { display: block; font-size: 18px; }
.profile-head small { font-size: 13px; }
.sub-card { padding: 16px 18px; border-radius: var(--r-sm); border: var(--bw) solid var(--line); background: var(--surface-2); margin-bottom: 18px; }
.sub-card .sub-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.sub-card .sub-date { font-family: var(--display); font-weight: var(--display-weight); font-size: 22px; margin: 2px 0; }
.sub-card.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.sub-card.bad { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.sub-card p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.pw-form { display: flex; flex-direction: column; gap: 12px; padding: 16px 0; border-top: 1px solid var(--hair); }
.pw-form .btn { align-self: flex-start; }
.form-title { margin: 0; font-weight: 800; }
.logout-form { margin: 4px 0 0; }

/* ----- Поля форм ----- */
.field label { display: block; margin-bottom: 6px; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.field input, .field textarea, .field select { width: 100%; padding: 11px 13px; border: var(--bw) solid var(--line-2); border-radius: var(--r-sm); background: var(--field); font-size: 15px; height: auto; }
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

/* ----- Редактор книги ----- */
.editor { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
.ed-photo { display: block; position: sticky; top: 0; }
.ed-photo img { width: 100%; border-radius: var(--r-sm); display: block; box-shadow: 0 16px 40px -16px rgba(0, 0, 0, .5); background: var(--surface-2); }
.ed-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.ed-form .full { grid-column: 1 / -1; }
.ed-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--hair); flex-wrap: wrap; }
.ed-actions .danger { margin-right: auto; }

/* ===================== Вход и регистрация ===================== */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-art { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  padding: 44px 52px 0; background: var(--sb-bg); color: var(--sb-ink); }
.auth-art::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(600px 400px at 80% 10%, rgba(214, 180, 110, .22), transparent 65%); }
.auth-logo { position: relative; display: block; width: min(300px, 70%); height: auto; filter: drop-shadow(0 18px 40px rgba(0, 0, 0, .45)); }
.auth-quote { position: relative; max-width: 520px; }
.auth-quote h1 { margin: 0 0 16px; font-size: clamp(34px, 4vw, 54px); line-height: 1.06; text-transform: var(--head-case); }
.auth-quote h1 em { color: var(--gold); font-style: italic; }
[data-theme="bright"] .auth-quote h1 em { font-style: normal; color: var(--gold); }
.auth-quote p { margin: 0; color: var(--sb-muted); font-size: 16px; max-width: 440px; }
.auth-points { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 10px; color: var(--sb-ink); font-size: 14px; }
.auth-points li { display: flex; gap: 10px; align-items: center; }
.auth-points li::before { content: ""; width: 18px; height: 1px; background: var(--gold); flex: none; }
.shelf-art { position: relative; display: flex; align-items: flex-end; gap: 5px; height: 150px; padding: 0 4px; border-bottom: 6px solid rgba(201, 164, 92, .55); }
.shelf-art i { display: block; width: var(--w, 22px); height: var(--h, 120px); border-radius: 3px 3px 0 0; background: var(--c, #2c4a3b);
  box-shadow: inset -3px 0 0 rgba(0, 0, 0, .18), inset 0 10px 0 -6px rgba(255, 255, 255, .12); transform: rotate(var(--r, 0deg)); transform-origin: bottom left; }
.shelf-art i::after { content: ""; display: block; margin: 18px 4px 0; height: 2px; background: rgba(255, 255, 255, .35); }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: min(410px, 100%); }
.auth-card h2 { margin: 0 0 6px; font-size: 32px; line-height: 1.1; text-transform: var(--head-case); }
.auth-card > p { margin: 0 0 24px; color: var(--muted); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form .btn { height: 50px; font-size: 15.5px; margin-top: 4px; }
.form-msg { padding: 12px 14px; border-radius: var(--r-sm); font-size: 14px; margin: 0 0 18px; border: var(--bw) solid; }
.form-msg.err { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.form-msg.info { background: var(--primary-soft); color: var(--ink-2); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.auth-foot { margin-top: 26px; font-size: 13px; color: var(--muted); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* ===================== Админка ===================== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head h1 { margin: 8px 0 0; font-size: clamp(28px, 3.4vw, 42px); line-height: 1.08; text-transform: var(--head-case); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.tile { position: relative; padding: 16px 18px; background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tile-label { font-size: 12px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.tile-num { font-family: var(--display); font-weight: var(--display-weight); font-size: 32px; line-height: 1.15; margin-top: 4px; font-variant-numeric: lining-nums tabular-nums; }
.tile-sub { font-size: 12.5px; color: var(--muted); }
.tile.accent { background: var(--hero-bg); color: var(--hero-ink); }
.tile.accent .tile-label, .tile.accent .tile-sub { color: var(--hero-muted); }
.panel { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 26px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 18px; border-bottom: 1px solid var(--hair); }
.panel-head h2 { margin: 0; font-size: 20px; text-transform: var(--head-case); }
.search { position: relative; flex: 1 1 220px; max-width: 320px; }
.search input { width: 100%; height: 40px; padding: 0 12px 0 38px; border-radius: var(--r-btn); border: var(--bw) solid var(--line); background: var(--field); }
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--hair); }
.chip { border: var(--bw) solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.chip span { color: var(--muted); font-weight: 600; margin-left: 4px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip.on span { color: inherit; opacity: .7; }

.utable { width: 100%; border-collapse: collapse; font-size: 14px; }
.utable th { text-align: left; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; background: var(--surface-2); white-space: nowrap; }
.utable td { padding: 13px 14px; border-top: 1px solid var(--hair); vertical-align: middle; }
.utable tbody tr { cursor: pointer; transition: background .12s; }
.utable tbody tr:hover { background: var(--surface-2); }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { display: block; color: var(--muted); font-size: 12.5px; }
.who > span:last-child { min-width: 0; }
.avatar.u { background: var(--primary-soft); color: var(--primary); }
[data-theme="night"] .avatar.u { color: var(--gold); }
.avatar.u.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ok); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--primary-soft); color: var(--primary); }
[data-theme="night"] .pill.info { color: var(--gold); }
.pill.mute { background: var(--surface-2); color: var(--muted); }
.paybar { width: 120px; height: 4px; border-radius: 4px; background: var(--hair); margin-top: 6px; overflow: hidden; }
.paybar i { display: block; height: 100%; background: var(--ok); border-radius: inherit; }
.paybar.warn i { background: var(--warn); }
.seen { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2s infinite; }
.cell-sub { color: var(--muted); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.empty-row td { text-align: center; color: var(--muted); padding: 40px 16px; cursor: default; }

.drawer-head { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.drawer-head b { display: block; font-size: 20px; line-height: 1.2; }
.drawer-head .pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.section-title { margin: 24px 0 10px; font-size: 11.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-text); }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 14px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.link-box { display: flex; gap: 8px; align-items: center; padding: 10px; border: 1.5px dashed var(--gold); border-radius: var(--r-sm); background: color-mix(in srgb, var(--gold) 8%, var(--surface)); }
.link-box input { flex: 1; min-width: 0; border: 0; background: transparent; font: 13px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink); outline: none; }
.link-note { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pay-form { display: grid; gap: 12px; padding: 16px; border-radius: var(--r-sm); background: var(--surface-2); border: var(--bw) solid var(--line); }
.periods { display: flex; gap: 6px; flex-wrap: wrap; }
.periods button { border: var(--bw) solid var(--line-2); background: var(--surface); border-radius: var(--r-btn); padding: 7px 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.periods button.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--hair); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .amt { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline small { display: block; color: var(--muted); font-size: 12.5px; }
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rc { position: relative; display: block; padding: 12px 14px; border: var(--bw) solid var(--line-2); border-radius: var(--r-sm); cursor: pointer; background: var(--surface); }
.rc input { position: absolute; opacity: 0; pointer-events: none; }
.rc b { display: block; font-size: 14px; margin-bottom: 2px; }
.rc small { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.rc:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.rc:has(input:focus-visible) { outline: 2px solid var(--primary); }
.danger-zone { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--hair); }
.orphans li { cursor: default; }

/* ===================== Анимации ===================== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ===================== «Ночная читальня»: характер ===================== */
[data-theme="night"] .eyebrow, [data-theme="night"] .books-head h2, [data-theme="night"] .panel-head h2,
[data-theme="night"] .sb-brand-text b { text-transform: uppercase; letter-spacing: .16em; font-size: 15px; }
[data-theme="night"] .books-head h2 { font-size: 16px; font-weight: 600; }
[data-theme="night"] .doc-name, [data-theme="night"] .page-head h1 { font-style: italic; font-weight: 500; text-transform: none; letter-spacing: 0; }
[data-theme="night"] .auth-card h2, [data-theme="night"] .auth-quote h1 { font-style: italic; font-weight: 500; text-transform: none; letter-spacing: 0; }
[data-theme="night"] .btn { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 700; }
[data-theme="night"] .btn.primary, [data-theme="night"] .btn.gold { box-shadow: 0 0 24px -6px rgba(216, 178, 106, .55); }
[data-theme="night"] .btn:not(.primary):not(.gold):not(.danger) { background: transparent; }
[data-theme="night"] .upload { border-color: rgba(216, 178, 106, .35); outline: 1px solid rgba(216, 178, 106, .18); outline-offset: -8px; }
[data-theme="night"] .upload::after { display: none; }
[data-theme="night"] .grid tbody tr:nth-child(even) td { background: rgba(255, 255, 255, .015); }
[data-theme="night"] .grid .w-ph img, [data-theme="night"] .book-thumb { box-shadow: 0 0 0 1px rgba(216, 178, 106, .5); border-radius: 1px; }
[data-theme="night"] .stat-num, [data-theme="night"] .tile-num { color: var(--gold); font-weight: 500; }
[data-theme="night"] .doc-item, [data-theme="night"] .sb-link, [data-theme="night"] .me-card { border-radius: 2px; }
[data-theme="night"] .avatar { background: transparent; color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
[data-theme="night"] .shelf-art i { background: #15181c !important; box-shadow: inset 0 0 0 1px rgba(216, 178, 106, .45); }
[data-theme="night"] .seg button.on { background: var(--primary-soft); color: var(--gold); box-shadow: none; }
[data-theme="night"] .chip.on { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }

/* ===================== «Яркая»: характер ===================== */
[data-theme="bright"] body { font-weight: 500; }
[data-theme="bright"] .btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 #1b1530; }
[data-theme="bright"] .btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 #1b1530; }
[data-theme="bright"] .btn.light { background: #fff; color: #1b1530; border-color: #1b1530; }
[data-theme="bright"] .btn.ghost, [data-theme="bright"] .seg button, [data-theme="bright"] .icon-btn { box-shadow: none; }
[data-theme="bright"] .sidebar { border-right: 2px solid #1b1530; }
[data-theme="bright"] .sidebar::before { display: none; }
[data-theme="bright"] .sidebar .btn.gold { border-color: #1b1530; }
[data-theme="bright"] .doc-item.active::before { display: none; }
[data-theme="bright"] .doc-item.active { border: 2px solid #1b1530; box-shadow: 3px 3px 0 #1b1530; }
[data-theme="bright"] .me-card { background: rgba(255, 255, 255, .14); border: 2px solid rgba(255, 255, 255, .4); }
[data-theme="bright"] .avatar { background: #ffd23f; color: #1b1530; border: 2px solid #1b1530; }
[data-theme="bright"] .stat:nth-child(1) { background: #ece7ff; }
[data-theme="bright"] .stat:nth-child(2) { background: #fff0c7; }
[data-theme="bright"] .stat:nth-child(3) { background: #d4f5ea; }
[data-theme="bright"] .tile:nth-child(4n+1):not(.accent) { background: #ece7ff; }
[data-theme="bright"] .tile:nth-child(4n+2) { background: #d4f5ea; }
[data-theme="bright"] .tile:nth-child(4n+3) { background: #fff0c7; }
[data-theme="bright"] .tile:nth-child(4n+4) { background: #ffe1ea; }
[data-theme="bright"] .stat::after { display: none; }
[data-theme="bright"] .upload::after { background: radial-gradient(circle at 12% 110%, rgba(255, 210, 63, .9) 0 60px, transparent 61px); opacity: 1; }
[data-theme="bright"] .upload-art .front { stroke: #1b1530; stroke-width: 2.5; }
[data-theme="bright"] .upload-art .back { fill: #ffd23f; stroke: #1b1530; stroke-width: 2.5; }
[data-theme="bright"] .upload-art .lines { stroke: #5b3df5; }
[data-theme="bright"] .upload-art .spark { fill: #ffd23f; stroke: #1b1530; stroke-width: 1.5; }
[data-theme="bright"] .book { border-top-width: 8px; }
[data-theme="bright"] .book:nth-child(4n+1) { border-top-color: #5b3df5; }
[data-theme="bright"] .book:nth-child(4n+2) { border-top-color: #ff4f8b; }
[data-theme="bright"] .book:nth-child(4n+3) { border-top-color: #13b98f; }
[data-theme="bright"] .book:nth-child(4n+4) { border-top-color: #ffb020; }
[data-theme="bright"] .book.warn, [data-theme="bright"] .book.error { box-shadow: var(--shadow); }
[data-theme="bright"] .book.warn { background: #fffaf0; }
[data-theme="bright"] .book-thumb { border: 2px solid #1b1530; border-radius: 8px; box-shadow: 3px 3px 0 #1b1530; transform: rotate(-2deg); }
[data-theme="bright"] .book-title { font-size: 15px; line-height: 1.35; }
[data-theme="bright"] .grid th:nth-child(4n+1) { background: #ffd23f; }
[data-theme="bright"] .grid th:nth-child(4n+2) { background: #c8f2ea; }
[data-theme="bright"] .grid th:nth-child(4n+3) { background: #ffd0e0; }
[data-theme="bright"] .grid th:nth-child(4n+4) { background: #dcd3ff; }
[data-theme="bright"] .grid th { border-bottom: 2px solid #1b1530; }
[data-theme="bright"] .grid .w-ph img { border: 2px solid #1b1530; border-radius: 6px; }
[data-theme="bright"] .seg { border-width: 2px; }
[data-theme="bright"] .seg button.on { background: #ffd23f; color: #1b1530; box-shadow: none; }
[data-theme="bright"] .chip { border-width: 2px; }
[data-theme="bright"] .chip.on { background: #5b3df5; border-color: #1b1530; color: #fff; }
[data-theme="bright"] .pill { border: 1.5px solid #1b1530; }
[data-theme="bright"] .doc-name::after { content: "✦"; color: #ff4f8b; font-size: .55em; margin-left: .3em; vertical-align: .5em; }
[data-theme="bright"] .doc-name[contenteditable="true"]::after { content: none; }
[data-theme="bright"] .shelf-art { border-bottom-color: #ffd23f; }
[data-theme="bright"] .shelf-art i { border: 2px solid #1b1530; box-shadow: none; }
[data-theme="bright"] .auth-quote h1 em { color: #ffd23f; }
[data-theme="bright"] .sheet-panel { border-width: 2px; }
[data-theme="bright"] .fab { border: 2px solid #1b1530; box-shadow: 4px 4px 0 #1b1530 !important; }
[data-theme="bright"] .toast { border: 2px solid #1b1530; box-shadow: 4px 4px 0 #ffd23f; }

/* ===================== Телефон и планшет ===================== */
@media (min-width: 901px) {
  .mobile-only { display: none !important; }
}
@media (max-width: 900px) {
  .desktop-only { display: none !important; }
  .shell { display: block; }
  .sidebar { position: fixed; z-index: 70; left: 0; top: 0; bottom: 0; height: auto; width: min(86vw, 320px);
    transform: translateX(-102%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow-lg);
    padding-top: calc(18px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  body.sb-open .sidebar { transform: none; }
  .sb-backdrop { position: fixed; inset: 0; z-index: 65; background: var(--backdrop); opacity: 0; pointer-events: none; transition: opacity .25s; display: block; }
  body.sb-open .sb-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar .sb-close { display: inline-grid; }
  .doc-item .icon-btn { opacity: .7; }

  .topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--hair); }
  .topbar .icon-btn { color: var(--ink); }
  .topbar-brand { flex: 1; display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: var(--display-weight); font-size: 18px; letter-spacing: var(--head-track); }
  .topbar-brand .logo { width: 34px; height: 34px; }
  [data-theme="night"] .topbar-brand { text-transform: uppercase; letter-spacing: .14em; font-size: 14px; }

  .wrap { padding: 20px 16px 110px; }
  .doc-head { margin-bottom: 18px; gap: 14px; }
  .doc-head-text { flex-basis: 100%; }
  .doc-actions { width: 100%; }
  .doc-actions .btn { flex: 1; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat-label { font-size: 11.5px; }
  .stat { padding: 12px 14px; }
  .stat-num { font-size: 24px; }
  .upload { grid-template-columns: 1fr; gap: 6px; padding: 22px 20px; margin-bottom: 26px; }
  .upload-art { position: absolute; right: -26px; top: -26px; opacity: .3; }
  .upload-art svg { width: 110px; height: 110px; }
  .upload-title { font-size: 22px; padding-right: 70px; }
  .upload-buttons .btn { flex: 1; }
  .books-head h2 { font-size: 20px; }
  .list-tools { width: 100%; }
  .select-wrap { flex: 1; }
  .select-wrap select { width: 100%; }
  .book-list { grid-template-columns: 1fr; gap: 12px; }
  .book { grid-template-columns: 64px minmax(0, 1fr); gap: 12px; padding: 13px; }
  .book-thumb { width: 64px; height: 88px; }
  .book-side { grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; }
  .book-side:empty { display: none; }
  .quick { grid-column: 1 / -1; max-width: none; }
  .book-title { font-size: 16px; }

  .sheet { padding: 0; align-items: flex-end; }
  .sheet-panel, .sheet-panel.wide { width: 100%; max-height: 92vh; border-radius: var(--radius) var(--radius) 0 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .26s cubic-bezier(.2, .8, .2, 1); }
  .sheet.side .sheet-panel { border-radius: var(--radius) var(--radius) 0 0; height: auto; max-height: 94vh; border-width: var(--bw) 0 0; }
  .sheet.side { align-items: flex-end; }
  .editor { grid-template-columns: 1fr; gap: 16px; }
  .ed-photo { position: static; }
  .ed-photo img { max-height: 240px; object-fit: contain; }
  .ed-form { grid-template-columns: 1fr 1fr; gap: 12px; }
  .ed-actions .btn { flex: 1; }
  .ed-actions .danger { flex: 0 0 auto; }
  .theme-opt { grid-template-columns: 96px 1fr; }
  .tp { width: 96px; height: 66px; }
  .tp-card { left: 34px; } .tp-l1 { left: 40px; width: 40px; } .tp-l2 { left: 40px; } .tp-btn { left: 34px; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }

  .fab { position: fixed; z-index: 40; right: 18px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 64px; height: 64px; border-radius: 50%;
    display: grid; place-items: center; background: var(--gold); color: var(--gold-ink); cursor: pointer;
    box-shadow: 0 14px 30px -10px rgba(0, 0, 0, .55), 0 0 0 6px color-mix(in srgb, var(--gold) 22%, transparent); }
  .fab .ic { width: 28px; height: 28px; stroke-width: 2; }
  .fab:active { transform: scale(.95); }
  body.sb-open .fab { display: none; }

  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: calc(22px + env(safe-area-inset-top)) 22px 0; gap: 20px; }
  .auth-logo { width: 190px; margin: 0 auto; }
  .auth-quote h1 { font-size: 30px; margin-bottom: 8px; }
  .auth-quote p { font-size: 14.5px; }
  .auth-points { display: none; }
  .shelf-art { height: 70px; gap: 4px; }
  .shelf-art i { height: calc(var(--h, 120px) * .5); width: calc(var(--w, 22px) * .75); }
  .shelf-art i::after { margin-top: 10px; }
  .auth-panel { place-items: start center; padding: 28px 20px 40px; }
  .auth-card h2 { font-size: 26px; }

  .page-head .btn { flex: 1; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile-num { font-size: 26px; }
  .search { max-width: none; }
  .utable thead { display: none; }
  .utable, .utable tbody, .utable tr, .utable td { display: block; width: 100%; }
  .utable tbody tr { padding: 14px 16px; border-top: 1px solid var(--hair); display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; }
  .utable td { padding: 0; border: 0; }
  .utable td.c-who { grid-column: 1 / 2; }
  .utable td.c-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .utable td.c-pay, .utable td.c-seen { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
  .utable td.c-dev, .utable td.c-books { display: none; }
  .utable td .paybar { margin: 0; }
  .kv { grid-template-columns: 120px minmax(0, 1fr); }
  .radio-cards, .two { grid-template-columns: 1fr; }
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }

/* Доступ истёк: загрузка выключена */
.upload.locked { filter: grayscale(.7); opacity: .75; }
.upload.locked .upload-buttons { pointer-events: none; opacity: .5; }
.drawer-head .small { display: block; }
.utable .c-pay .num, .utable .c-pay .cell-sub { white-space: nowrap; }
.tile.wide { grid-column: span 2; }
