/* ═══════════════════════════════════════════════════════════════════
   Bunko features v3 — расширения дизайна и интерфейса
   Подключается ПОСЛЕ инлайн-стилей index.html, чтобы переопределять
   что нужно. Большинство правил не конфликтует, добавляет новое.
   ═══════════════════════════════════════════════════════════════════ */

/* ───────── 1. Washi — текстура «японской бумаги» поверх фона ───── */
:root {
  --washi-opacity: .6;
}
html[data-theme="dark"] {
  --washi-opacity: .35;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--washi-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='280' height='280' viewBox='0 0 280 280'><g fill='%23b8a878' opacity='0.18'><circle cx='14' cy='22' r='0.6'/><circle cx='58' cy='86' r='0.5'/><circle cx='124' cy='38' r='0.7'/><circle cx='200' cy='60' r='0.5'/><circle cx='250' cy='130' r='0.6'/><circle cx='40' cy='160' r='0.5'/><circle cx='96' cy='220' r='0.6'/><circle cx='170' cy='200' r='0.5'/><circle cx='230' cy='260' r='0.7'/><circle cx='80' cy='110' r='0.4'/><circle cx='160' cy='140' r='0.5'/><circle cx='270' cy='30' r='0.5'/></g><g stroke='%23b8a878' stroke-width='0.4' fill='none' opacity='0.22'><path d='M0 38 Q70 36 140 40 T280 38'/><path d='M0 112 Q70 114 140 110 T280 112'/><path d='M0 188 Q70 186 140 190 T280 188'/><path d='M0 252 Q70 254 140 250 T280 252'/></g><g stroke='%23a07a2c' stroke-width='0.3' fill='none' opacity='0.1'><path d='M30 0 Q34 70 32 140 T30 280'/><path d='M150 0 Q146 70 148 140 T150 280'/><path d='M218 0 Q222 70 220 140 T218 280'/></g></svg>");
  background-size: 280px 280px;
  background-repeat: repeat;
}
html[data-theme="dark"] body::before { filter: invert(.85) hue-rotate(160deg); }
.app, main.main { position: relative; z-index: 1; }
/* На десктопе сайдбар на уровне контента, на мобильном — выезжает поверх (z:90 из основного CSS).
   Раньше тут было aside.side {z-index:1} без media query — перекрывало мобильную панель,
   из-за чего на телефоне она вылазила ПОД карточками. */
@media (min-width: 901px) {
  aside.side { z-index: 1; }
}
.scrim, .reader-scrim, .cmdk-scrim { z-index: 100; }
.cmdk-scrim { z-index: 250; }
.toast { z-index: 200; }

/* ───────── 2. Section dividers — тонкая полоса с ромбом ───────── */
.side-section h3 .ornament {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-3); flex: 1;
}
.side-section h3 .ornament::before,
.side-section h3 .ornament::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line) 30%, var(--line) 70%, transparent);
}
.side-section h3 .ornament::before { margin-right: 8px; }
.side-section h3 .ornament::after  { margin-left: 8px; }
.side-section h3 .ornament i {
  width: 5px; height: 5px; transform: rotate(45deg);
  background: var(--line-2); flex: 0 0 auto;
}

/* ───────── 3. Hanko — печать на завершённых книгах ─────────────── */
.hanko {
  position: absolute; top: 12px; right: 12px;
  width: 56px; height: 56px;
  pointer-events: none;
  opacity: .88;
  transform: rotate(-8deg);
  filter: drop-shadow(0 0 1px rgba(0,0,0,.1));
  z-index: 3;
}
.hanko svg { width: 100%; height: 100%; display: block; }
.hanko text {
  font-family: var(--jp);
  fill: #a82a3a;
  font-weight: 700;
  text-anchor: middle;
}
.hanko circle { fill: none; stroke: #a82a3a; stroke-width: 4; }
html[data-theme="dark"] .hanko { opacity: .78; }
html[data-theme="dark"] .hanko text { fill: var(--gold); }
html[data-theme="dark"] .hanko circle { stroke: var(--gold); fill: none; }
.note-card .hanko { top: 8px; right: 10px; width: 44px; height: 44px; }

/* ───────── 4. Bookmark ribbon — закладка-ленточка на reading ──── */
.bookmark-ribbon {
  position: absolute; top: 0; right: 22px;
  width: 14px; height: 38px;
  background: linear-gradient(180deg, var(--gold) 0%, var(--accent) 100%);
  z-index: 4; pointer-events: none;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
}
.bookmark-ribbon::after {
  content: ""; position: absolute; bottom: -7px; left: 0;
  border-left: 7px solid var(--gold);
  border-right: 7px solid var(--accent);
  border-bottom: 7px solid transparent;
  width: 0; height: 0;
}

/* ───────── 5. Spine — улучшенные корешки книг ───────────────────── */
.shelf .spine {
  background-image:
    linear-gradient(180deg, rgba(255,255,255,.08) 0%, transparent 30%, transparent 70%, rgba(0,0,0,.08) 100%),
    repeating-linear-gradient(180deg, transparent 0, transparent 18px, rgba(0,0,0,.04) 18px, rgba(0,0,0,.04) 19px),
    linear-gradient(180deg, var(--card) 0%, var(--paper-2) 100%);
  box-shadow: inset -2px 0 0 rgba(0,0,0,.07), inset 2px 0 0 rgba(255,255,255,.18);
}
.spine[data-thick="thin"]   { width: 26px; }
.spine[data-thick="medium"] { width: 36px; }
.spine[data-thick="thick"]  { width: 46px; }
.spine[data-thick="tome"]   { width: 56px; min-height: 200px; }
.spine[data-tone="warm"]    { filter: hue-rotate(-8deg) brightness(1.02); }
.spine[data-tone="cool"]    { filter: hue-rotate(20deg) brightness(.96); }
.spine[data-tone="dark"]    { filter: brightness(.78); }
.spine[data-tone="bright"]  { filter: brightness(1.12) saturate(1.1); }
.spine .sp-cap {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  font-family: var(--jp); font-size: 10px;
  color: var(--accent); opacity: .7; line-height: 1;
}
.spine .sp-cap.done { color: var(--green); }
.spine .sp-cap.reading { color: var(--gold); }

/* ───────── 6. Quote of the day ────────────────────────────────── */
.qotd {
  margin: 0 0 22px;
  padding: 20px 24px;
  background:
    linear-gradient(180deg, rgba(160,122,44,.04), transparent 60%),
    var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  position: relative;
  display: grid; grid-template-columns: 1fr auto; gap: 14px;
  align-items: end;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.qotd:hover { border-color: var(--line-2); }
.qotd .qotd-mark {
  position: absolute; top: -12px; left: 18px;
  width: 26px; height: 26px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--jp); color: var(--accent); font-size: 13px;
}
.qotd .qotd-text {
  font-family: var(--serif); font-style: italic; font-size: 18px;
  line-height: 1.45; color: var(--ink); text-wrap: pretty;
  margin: 0;
}
.qotd .qotd-meta {
  font-family: var(--serif); font-size: 13px; color: var(--ink-3);
  text-align: right; white-space: nowrap;
}
.qotd .qotd-meta b { color: var(--ink-2); font-style: normal; font-weight: 600; font-family: var(--sans); font-size: 13px; display: block; margin-bottom: 2px; }
.qotd .qotd-actions { position: absolute; top: 8px; right: 10px; display: flex; gap: 4px; }
.qotd .qotd-actions button {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--ink-3); border-radius: 50%; opacity: .6; transition: opacity .15s, color .15s;
}
.qotd:hover .qotd-actions button { opacity: 1; }
.qotd .qotd-actions button:hover { color: var(--accent); background: var(--paper-2); }

/* ───────── 7. Inline status badge — кликабельный цикл ─────────── */
.status-badge.cyc {
  cursor: pointer; padding: 3px 8px; margin: -3px -8px;
  border-radius: 99px; transition: background .12s;
  user-select: none;
}
.status-badge.cyc:hover { background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); }
.status-badge.cyc:active { background: var(--paper-2); }

/* ───────── 8. Command palette ─────────────────────────────────── */
.cmdk-scrim {
  position: fixed; inset: 0;
  background: rgba(15,12,8,.55);
  backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center;
  padding-top: 12vh; z-index: 250;
}
.cmdk-scrim.open { display: flex; }
.cmdk {
  width: 100%; max-width: 620px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.45);
  overflow: hidden;
  animation: slideUp .2s ease;
}
.cmdk-input-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.cmdk-input-wrap .kanji {
  font-family: var(--jp); font-size: 22px; color: var(--accent); line-height: 1;
}
.cmdk-input {
  flex: 1; border: 0; background: transparent; outline: none;
  font-size: 16px; color: var(--ink); font-family: inherit;
}
.cmdk-input::placeholder { color: var(--ink-3); }
.cmdk-input-wrap kbd {
  font-family: var(--mono); font-size: 11px; padding: 2px 6px;
  border: 1px solid var(--line); border-radius: 2px; color: var(--ink-3);
}
.cmdk-list { max-height: 56vh; overflow-y: auto; padding: 6px 0; }
.cmdk-group {
  font-family: var(--serif); font-style: italic; color: var(--ink-3);
  font-size: 11px; text-transform: uppercase; letter-spacing: .14em;
  padding: 12px 20px 4px; font-style: normal; font-weight: 600;
}
.cmdk-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 20px; cursor: pointer;
  font-size: 14px; color: var(--ink-2);
}
.cmdk-item.on, .cmdk-item:hover { background: var(--card); color: var(--ink); }
.cmdk-item.on { box-shadow: inset 3px 0 0 var(--accent); }
.cmdk-item .icon { font-family: var(--jp); width: 22px; color: var(--accent); flex: 0 0 auto; text-align: center; font-size: 15px; }
.cmdk-item .text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item .hint { font-family: var(--mono); font-size: 11px; color: var(--ink-3); flex: 0 0 auto; }
.cmdk-item .sub { font-family: var(--serif); font-style: italic; color: var(--ink-3); font-size: 12px; }
.cmdk-empty {
  padding: 30px 20px; text-align: center; color: var(--ink-3);
  font-family: var(--serif); font-style: italic; font-size: 14px;
}
.cmdk-foot {
  display: flex; gap: 14px; justify-content: flex-end;
  padding: 8px 20px; border-top: 1px solid var(--line);
  background: var(--paper-2); font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}
.cmdk-foot kbd {
  font-family: var(--mono); font-size: 10px; padding: 1px 5px;
  border: 1px solid var(--line); border-radius: 2px; margin: 0 3px;
}

/* ───────── 9. Reader view — полноэкранный просмотр ───────────── */
.reader-scrim {
  position: fixed; inset: 0;
  background: rgba(15,12,8,.62);
  backdrop-filter: blur(4px);
  display: none; align-items: stretch; justify-content: center;
  padding: 20px; z-index: 150;
  overflow-y: auto;
}
.reader-scrim.open { display: flex; }
.reader {
  width: 100%; max-width: 1180px; align-self: flex-start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 40px 80px -20px rgba(0,0,0,.5);
  overflow: hidden;
  animation: slideUp .22s ease;
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 420px;
}
.reader .reader-head {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--card), var(--paper));
}
.reader .reader-crumb {
  font-family: var(--serif); font-style: italic; font-size: 13px; color: var(--ink-3);
  display: flex; align-items: center; gap: 10px;
}
.reader .reader-crumb .kanji { font-family: var(--jp); font-style: normal; color: var(--accent); font-size: 16px; }
.reader .reader-crumb a { color: inherit; border-bottom: 1px dotted var(--line); }
.reader .reader-crumb a:hover { color: var(--accent); border-color: var(--accent); }
.reader .reader-actions { display: flex; gap: 4px; align-items: center; }
.reader .reader-actions .icon-btn { width: 34px; height: 34px; }
.reader .reader-left {
  padding: 26px 22px 26px 26px;
  border-right: 1px solid var(--line);
  background: var(--paper-2);
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}
.reader .reader-cover {
  aspect-ratio: 2 / 3; width: 100%;
  background: var(--card); border: 1px solid var(--line);
  overflow: hidden; position: relative;
  box-shadow: 0 8px 24px -10px rgba(0,0,0,.3);
}
.reader .reader-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reader .reader-cover .ph {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-family: var(--jp); font-size: 62px; color: var(--ink-3); opacity: .35;
  background: linear-gradient(135deg, var(--paper-2), var(--card));
}
.reader .reader-cover .hanko { top: 14px; right: 14px; width: 64px; height: 64px; }
.reader .reader-meta {
  display: flex; flex-direction: column; gap: 8px;
  font-family: var(--serif); color: var(--ink-2); font-size: 14px;
}
.reader .reader-meta .row {
  display: flex; gap: 10px; justify-content: space-between;
  padding: 5px 0; border-bottom: 1px dashed var(--line);
}
.reader .reader-meta .row:last-child { border-bottom: 0; }
.reader .reader-meta .row .k {
  font-style: italic; color: var(--ink-3); font-size: 13px;
}
.reader .reader-meta .row .v {
  text-align: right; color: var(--ink); font-family: var(--sans); font-style: normal; font-size: 13px;
}
.reader .reader-right {
  padding: 26px 32px 30px; min-width: 0;
  overflow: hidden;
}
.reader .reader-author {
  font-family: var(--serif); font-style: italic; color: var(--ink-3);
  font-size: 16px; margin-bottom: 4px;
}
.reader .reader-title {
  font-family: var(--serif); font-weight: 500; font-size: 30px;
  line-height: 1.1; margin: 0 0 10px; letter-spacing: -.01em; text-wrap: pretty;
}
.reader .reader-desc {
  font-family: var(--serif); font-size: 16px; line-height: 1.55; color: var(--ink-2);
  margin: 0 0 18px; text-wrap: pretty;
}
.reader-block { margin-top: 22px; }
.reader-block-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line); padding-bottom: 6px;
}
.reader-block-head h3 {
  font-family: var(--serif); font-weight: 500; font-size: 18px; margin: 0;
  letter-spacing: .01em;
}
.reader-block-head h3 .kanji {
  font-family: var(--jp); color: var(--accent); margin-right: 7px; font-size: 16px;
}
.reader-block-head .add {
  font-family: var(--serif); font-style: italic; color: var(--accent);
  font-size: 13px; cursor: pointer;
}
.reader-block-head .add:hover { color: var(--accent-2); }

.next-action {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(160,122,44,.06), transparent);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
}
.next-action .icon { font-family: var(--jp); color: var(--gold); font-size: 18px; }
.next-action input {
  flex: 1; border: 0; background: transparent; outline: none;
  font-family: var(--serif); font-size: 16px; color: var(--ink); padding: 4px 0;
}
.next-action .done-btn {
  font-size: 11px; padding: 4px 10px; font-family: var(--mono);
  color: var(--green); border: 1px solid var(--line); border-radius: 99px;
  cursor: pointer; text-transform: uppercase; letter-spacing: .08em;
}
.next-action .done-btn:hover { background: var(--green); color: #fff; border-color: var(--green); }

.quote-list { display: flex; flex-direction: column; gap: 12px; }
.quote-item {
  padding: 12px 14px 12px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  position: relative;
}
.quote-item .qt {
  font-family: var(--serif); font-style: italic; font-size: 16px;
  line-height: 1.55; color: var(--ink); margin: 0; text-wrap: pretty;
}
.quote-item .qf {
  margin-top: 8px; display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono); font-size: 11px; color: var(--ink-3); letter-spacing: .04em;
}
.quote-item .qf .qdate { font-style: italic; font-family: var(--serif); font-size: 12px; }
.quote-item .qact {
  position: absolute; top: 8px; right: 10px; display: flex; gap: 2px; opacity: 0; transition: opacity .15s;
}
.quote-item:hover .qact { opacity: 1; }
.quote-item .qact button { padding: 3px 6px; color: var(--ink-3); font-size: 12px; border-radius: 2px; }
.quote-item .qact button:hover { color: var(--accent); background: var(--paper-2); }
.quote-add {
  display: grid; grid-template-columns: 1fr; gap: 6px;
  padding: 10px; background: var(--paper-2); border: 1px dashed var(--line);
}
.quote-add textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line); background: var(--paper);
  font-size: 14px; color: var(--ink); outline: none; font-family: var(--serif); line-height: 1.5;
  min-height: 60px; resize: vertical;
}
.quote-add input {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); background: var(--paper);
  font-size: 13px; color: var(--ink); outline: none;
}
.quote-add .row { display: flex; gap: 6px; justify-content: flex-end; }

.timeline {
  display: flex; align-items: center; gap: 0;
  padding: 8px 0;
}
.timeline .tl-step {
  flex: 1; display: flex; align-items: center; gap: 8px; font-size: 12px;
}
.timeline .tl-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--paper-2); border: 2px solid var(--line); flex: 0 0 auto;
}
.timeline .tl-step.on .tl-dot { background: var(--accent); border-color: var(--accent); }
.timeline .tl-step.future .tl-dot { background: var(--paper); border-style: dashed; }
.timeline .tl-text {
  font-family: var(--mono); font-size: 10px; color: var(--ink-3); letter-spacing: .04em;
  white-space: nowrap;
}
.timeline .tl-text b {
  display: block; font-family: var(--sans); color: var(--ink-2); font-size: 11px; font-weight: 600;
  letter-spacing: 0;
}
.timeline .tl-line {
  flex: 1; height: 2px; background: var(--line); margin: 0 4px;
}
.timeline .tl-step.on + .tl-line { background: var(--accent); }

.marginalia { display: flex; flex-direction: column; gap: 8px; }
.marginalia .marg {
  padding: 10px 14px; background: var(--paper-2);
  border: 1px solid var(--line); border-left: 3px solid var(--ink-3);
  font-size: 14px; line-height: 1.5; color: var(--ink-2); cursor: pointer;
}
.marginalia .marg:hover { border-left-color: var(--accent); background: var(--card); }
.marginalia .marg .mt { font-family: var(--serif); font-weight: 500; color: var(--ink); margin-bottom: 2px; }
.marginalia .marg .md { font-family: var(--mono); font-size: 10px; color: var(--ink-3); letter-spacing: .04em; }

.nearby { display: flex; flex-wrap: wrap; gap: 10px; }
.nearby .nb {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  padding: 10px; background: var(--card); border: 1px solid var(--line);
  width: calc(50% - 5px); min-width: 0; transition: border-color .15s, background .15s;
}
.nearby .nb:hover { border-color: var(--line-2); background: var(--card-hover); }
.nearby .nb .nbc {
  width: 38px; height: 52px; flex: 0 0 auto;
  background: var(--paper-2); border: 1px solid var(--line); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.nearby .nb .nbc img { width: 100%; height: 100%; object-fit: cover; }
.nearby .nb .nbc .k { font-family: var(--jp); font-size: 16px; color: var(--ink-3); opacity: .5; }
.nearby .nb .nbm { min-width: 0; flex: 1; }
.nearby .nb .nbt {
  font-family: var(--serif); font-weight: 500; font-size: 14px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.nearby .nb .nba { font-family: var(--serif); font-style: italic; font-size: 12px; color: var(--ink-3); }
.nearby .nb .nbr { font-family: var(--mono); font-size: 10px; color: var(--ink-3); letter-spacing: .04em; margin-top: 4px; }

.reader-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.reader-tags .t {
  font-size: 12px; color: var(--ink-3); padding: 3px 10px;
  background: var(--paper-2); border-radius: 99px; cursor: pointer;
  font-family: var(--mono);
}
.reader-tags .t:hover { color: var(--accent); }

.sessions {
  display: flex; align-items: flex-end; gap: 3px;
  height: 60px; padding: 6px 0;
}
.sessions .sn {
  flex: 1; background: var(--accent); opacity: .5;
  min-height: 2px; border-radius: 1px;
  transition: opacity .15s;
  position: relative;
}
.sessions .sn:hover { opacity: 1; }
.sessions .sn[title] { cursor: help; }
.sessions-empty { color: var(--ink-3); font-style: italic; font-family: var(--serif); font-size: 13px; padding: 6px 0; }

/* ───────── 10. Year-in-review (年報) ──────────────────────────── */
.nenpou {
  display: flex; flex-direction: column; gap: 32px;
  padding-bottom: 60px;
}
.nenpou-section {
  display: grid; grid-template-columns: 200px 1fr; gap: 32px;
}
.nenpou-section .nh {
  font-family: var(--serif); font-weight: 500; font-size: 26px;
  letter-spacing: -.01em; line-height: 1.1; padding-right: 18px;
  border-right: 1px solid var(--line); position: relative;
}
.nenpou-section .nh .kanji {
  font-family: var(--jp); display: block; color: var(--accent);
  font-size: 30px; line-height: 1; margin-bottom: 8px;
}
.nenpou-section .nh .sub {
  font-family: var(--serif); font-style: italic; color: var(--ink-3);
  font-size: 13px; margin-top: 6px; display: block;
}
.nenpou-card {
  background: var(--card); border: 1px solid var(--line);
  padding: 18px 22px; min-height: 80px;
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 14px; }
.stat-tile {
  background: var(--card); border: 1px solid var(--line);
  padding: 16px 18px;
}
.stat-tile .v {
  font-family: var(--serif); font-weight: 500; font-size: 28px; line-height: 1;
  color: var(--ink); display: block; margin-bottom: 6px;
}
.stat-tile .l { font-family: var(--serif); font-style: italic; color: var(--ink-3); font-size: 13px; }
.stat-tile .accent { color: var(--accent); }

.year-picker {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px;
}
.year-picker button {
  padding: 6px 14px; font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  border-radius: var(--radius); cursor: pointer; letter-spacing: .05em;
}
.year-picker button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.year-picker button:hover { border-color: var(--line-2); }
.year-picker button.on:hover { background: var(--accent-2); }

.tag-cloud {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  line-height: 1.4;
}
.tag-cloud a {
  font-family: var(--serif); color: var(--ink-2);
  border: 0; cursor: pointer; padding: 2px 4px;
  transition: color .12s;
}
.tag-cloud a:hover { color: var(--accent); }
.tag-cloud a .n {
  font-family: var(--mono); font-size: .68em; color: var(--ink-3);
  margin-left: 2px; vertical-align: super;
}

.chrono-axis {
  position: relative; padding: 24px 0 12px;
  border-top: 1px solid var(--line);
}
.chrono-marks { display: flex; justify-content: space-between; padding: 0 6px; margin-bottom: 8px; }
.chrono-marks span { font-family: var(--mono); font-size: 10px; color: var(--ink-3); letter-spacing: .04em; }
.chrono-track {
  position: relative; height: 70px;
  background:
    linear-gradient(90deg, transparent calc(50% - .5px), var(--line) calc(50% - .5px), var(--line) calc(50% + .5px), transparent calc(50% + .5px));
}
.chrono-track .cm {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--paper);
  cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.chrono-track .cm:hover { transform: translate(-50%, -50%) scale(1.6); z-index: 2; box-shadow: 0 0 0 4px rgba(139,38,53,.15); }
.chrono-track .cm[data-type="article"] { background: var(--indigo); }
.chrono-track .cm[data-type="lecture"] { background: var(--gold); }
.chrono-track .cm[data-type="video"], .chrono-track .cm[data-type="interview"] { background: var(--green); }
.chrono-track .cm[data-type="note"] { background: var(--ink-3); }
.chrono-tip {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%) translateY(-6px);
  background: var(--ink); color: var(--paper);
  padding: 6px 10px; font-size: 11px; white-space: nowrap;
  border-radius: 2px; opacity: 0; pointer-events: none;
  transition: opacity .15s;
  font-family: var(--serif); font-style: italic;
}
.chrono-track .cm:hover .chrono-tip { opacity: 1; }

.coverage-grid {
  /* фикс: было repeat(auto-fit, ...) — колонки не совпадали с числом типов
     и таблица «ехала». Теперь жёстко: подпись + N колонок данных. */
  display: grid;
  grid-template-columns: minmax(120px, 200px) repeat(var(--cov-cols, 6), minmax(0, 1fr));
  gap: 4px;
  margin-top: 6px;
}
.coverage-grid .ch {
  font-family: var(--mono); font-size: 10px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .06em; padding: 6px 2px; text-align: center;
  align-self: end;
}
.coverage-grid .crow-h {
  font-family: var(--serif); font-size: 13px; color: var(--ink-2);
  padding: 6px 0; align-self: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.coverage-grid .cv {
  aspect-ratio: 1; background: var(--paper-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 12px; color: var(--ink-3);
  cursor: pointer; transition: transform .15s;
  min-width: 0;
}
@media (max-width: 700px) {
  .coverage-grid { grid-template-columns: minmax(90px, 140px) repeat(var(--cov-cols, 6), minmax(0, 1fr)); }
  .coverage-grid .ch { font-size: 9px; letter-spacing: .02em; }
  .coverage-grid .crow-h { font-size: 12px; }
}
.coverage-grid .cv:hover { transform: scale(1.1); z-index: 1; }
.coverage-grid .cv[data-n="0"] { background: var(--paper-2); color: var(--ink-3); opacity: .5; }
.coverage-grid .cv[data-n="low"] { background: rgba(139,38,53,.22); color: var(--ink); }
.coverage-grid .cv[data-n="mid"] { background: rgba(139,38,53,.5); color: #fff; }
.coverage-grid .cv[data-n="hi"] { background: var(--accent); color: #fff; }

/* ───────── 11. Smart shelves ───────────────────────────────────── */
.smart-shelf .side-link .icon {
  font-family: var(--jp); color: var(--gold); font-size: 13px; opacity: .8;
}
.smart-shelf .side-link { padding-left: 6px; }
.smart-shelf-add {
  font-family: var(--serif); font-style: italic; font-size: 13px;
  color: var(--ink-3); cursor: pointer; padding: 6px 10px; margin: 1px -10px;
  display: flex; align-items: center; gap: 6px;
}
.smart-shelf-add:hover { color: var(--accent); }

/* ───────── 12. Category tree (parent → child) ─────────────────── */
.cat-child { padding-left: 20px; position: relative; }
.cat-child::before {
  content: ""; position: absolute; left: 10px; top: 12px;
  width: 6px; height: 1px; background: var(--line-2);
}
.cat-row-wrap { position: relative; }
.cat-toggle {
  position: absolute; left: -16px; top: 6px;
  width: 16px; height: 16px; display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); font-size: 10px; cursor: pointer; user-select: none;
}
.cat-toggle.collapsed { transform: rotate(-90deg); }

/* ───────── 13. Undo toast with action button ──────────────────── */
.toast.action {
  display: flex; align-items: center; gap: 14px;
  pointer-events: auto;
}
.toast.action button {
  font-family: var(--mono); font-size: 11px; padding: 4px 10px;
  border: 1px solid rgba(255,255,255,.4); border-radius: 99px;
  color: var(--paper); background: transparent;
  letter-spacing: .08em; text-transform: uppercase; cursor: pointer;
  transition: background .12s;
}
.toast.action button:hover { background: rgba(255,255,255,.15); }


/* ───────── 15. Cover dropzone ─────────────────────────────────── */
.cover-preview { transition: border-color .15s, background .15s; }
.cover-preview.dz-over {
  border-color: var(--accent); background: rgba(139,38,53,.06);
}
.card .cover.dz-over::after {
  content: "Опустить — стать обложкой";
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(139,38,53,.78); color: #fff;
  font-family: var(--serif); font-style: italic; font-size: 14px;
  z-index: 3;
}


/* ───────── 17. Search operator hints ──────────────────────────── */
.search-hint {
  font-family: var(--mono); font-size: 10px; color: var(--ink-3);
  letter-spacing: .04em; padding: 6px 14px;
  background: var(--paper-2); border-top: 1px solid var(--line);
}
.search-hint code {
  background: var(--paper); padding: 1px 4px; border: 1px solid var(--line);
  border-radius: 2px; color: var(--accent); margin: 0 2px;
}

/* ───────── 18. Responsive ─────────────────────────────────────── */
@media (max-width: 1000px) {
  .reader { grid-template-columns: 1fr; }
  .reader .reader-left { border-right: 0; border-bottom: 1px solid var(--line); }
  .reader .reader-cover { aspect-ratio: 16/10; max-height: 280px; }
  .nearby .nb { width: 100%; }
}
@media (max-width: 700px) {
  .nenpou-section { grid-template-columns: 1fr; gap: 12px; }
  .nenpou-section .nh { border-right: 0; border-bottom: 1px solid var(--line); padding-right: 0; padding-bottom: 12px; }
  .reader .reader-title { font-size: 28px; }
  .qotd { grid-template-columns: 1fr; }
  .qotd .qotd-meta { text-align: left; }
  .cmdk { max-width: 92vw; }
  .reader-scrim { padding: 10px; }
}

/* ───────── 19. Print refinements ──────────────────────────────── */
@media print {
  body::before, .qotd, .cmdk-scrim, .reader-scrim, .smart-shelf-add { display: none !important; }
  .hanko { opacity: 1 !important; }
}

/* ───────── 21. Chronology gridlines & lifeline rows ──────────── */
.chrono-track .chrono-gridline {
  position: absolute; top: 0; bottom: 0;
  width: 1px; background: var(--line);
  opacity: .5; pointer-events: none;
}
html[data-theme="dark"] .chrono-track .chrono-gridline { opacity: .35; }

.lifeline-legend {
  font-family: var(--serif); font-style: italic; color: var(--ink-3);
  font-size: 13px; margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.lifeline-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr minmax(110px, 140px);
  gap: 14px; align-items: center;
  margin-bottom: 10px;
}
.lifeline-row:last-child { margin-bottom: 0; }
.lifeline-row .ll-name {
  font-family: var(--serif); font-size: 14px; cursor: pointer;
  color: var(--ink-2); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; transition: color .12s;
}
.lifeline-row .ll-name:hover { color: var(--accent); }
.lifeline-row .ll-track {
  position: relative; height: 10px;
  background: var(--paper-2); border-radius: 5px;
}
.lifeline-row .ll-bar {
  position: absolute; top: 0; bottom: 0;
  background: var(--accent); border-radius: 5px; opacity: .55;
}
.lifeline-row .ll-dot {
  position: absolute; top: 50%;
  width: 9px; height: 9px;
  background: var(--paper); border: 2px solid var(--accent);
  border-radius: 50%; transform: translate(-50%, -50%);
  cursor: pointer; transition: transform .12s, box-shadow .12s;
  z-index: 2;
}
.lifeline-row .ll-dot:hover {
  transform: translate(-50%, -50%) scale(1.4);
  box-shadow: 0 0 0 3px rgba(139,38,53,.2);
}
.lifeline-row .ll-meta {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-3); text-align: right;
  letter-spacing: .04em; white-space: nowrap;
}
@media (max-width: 700px) {
  .lifeline-row {
    grid-template-columns: 1fr;
    gap: 4px; padding: 8px 0;
    border-bottom: 1px dashed var(--line);
  }
  .lifeline-row .ll-meta { text-align: left; }
}

/* шкала хронологии: подписи делений равномерно (а не только три) */
.chrono-marks span { flex: 0 0 auto; }

/* ───────── 20. Readability fixes ──────────────────────────────── */

/* Бейджи на обложке карточки: тип и язык были 10–11px — нечитаемо */
.card-type      { font-size: 12px; }
.card-badge     { font-size: 11px; letter-spacing: .05em; }

/* Прогресс под карточкой: 11px → 12px */
.progress-text  { font-size: 12px; }

/* Заголовки разделов сайдбара: 12px uppercase + огромный letter-spacing */
.side-section h3 {
  font-size: 13px;
  letter-spacing: .12em;
}

/* Автор на корешке: 10px нечитаемо даже при ховере */
.spine .sp-author { font-size: 11px; }

/* Статус-капсула на корешке */
.spine .sp-cap { font-size: 11px; }

/* Заголовок страницы 34px слишком доминирует над контентом */
.page-head h1   { font-size: 29px; }

/* Строки списка: автор 13px рядом с заголовком 17px — контраст слишком резкий */
.row .ra { font-size: 14px; }

/* Метаданные в карточке читателя: 13px читается, но добавим чуть воздуха */
.reader .reader-meta .row .k,
.reader .reader-meta .row .v { font-size: 14px; }

/* Метки тегов в читателе */
.reader-tags .t { font-size: 13px; }

/* Граф: подписи узлов 11px на тёмном фоне почти невидимы */
.graph-svg .glabel { font-size: 12px; }

/* ───────── 22. Sync с Google Drive ────────────────────────────── */
#btnSync { position: relative; }
#btnSync .sync-pip {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-3); opacity: .55;
  transition: background .15s, opacity .15s, transform .15s;
}
#btnSync.sync-on  .sync-pip { background: var(--green); opacity: 1; }
#btnSync.sync-err .sync-pip { background: var(--accent); opacity: 1; }
#btnSync.sync-busy .sync-pip {
  background: var(--gold); opacity: 1;
  animation: syncPulse 1s ease-in-out infinite;
}
@keyframes syncPulse {
  0%,100% { transform: scale(1);   opacity: 1; }
  50%     { transform: scale(1.4); opacity: .5; }
}

.sync-popup {
  position: fixed; z-index: 200;
  min-width: 280px; max-width: 320px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px -10px rgba(0,0,0,.35);
  padding: 14px 16px;
  display: none;
  font-family: var(--sans);
}
.sync-popup.open { display: block; }
.sync-popup .sync-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--ink); margin-bottom: 6px;
}
.sync-popup .sync-dot {
  width: 9px; height: 9px; border-radius: 50%;
  flex: 0 0 auto;
}
.sync-popup .sync-dot-gray  { background: var(--ink-3); opacity: .5; }
.sync-popup .sync-dot-gold  { background: var(--gold); }
.sync-popup .sync-dot-green { background: var(--green); }
.sync-popup .sync-dot-red   { background: var(--accent); }
.sync-popup .sync-meta {
  font-family: var(--serif); font-style: italic;
  font-size: 13px; color: var(--ink-3); line-height: 1.5;
  margin-bottom: 12px;
}
.sync-popup .sync-err-msg {
  display: block; margin-top: 4px;
  color: var(--accent); font-style: normal;
  font-family: var(--mono); font-size: 11px;
  word-break: break-word;
}
.sync-popup .sync-actions {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 12px;
}
.sync-popup .sync-actions .btn { width: 100%; text-align: center; }
.sync-popup .sync-foot {
  font-family: var(--serif); font-style: italic;
  font-size: 11px; color: var(--ink-3); line-height: 1.45;
  padding-top: 10px; border-top: 1px dashed var(--line);
}
@media (max-width: 600px) {
  .sync-popup {
    right: 10px !important; left: 10px !important;
    min-width: 0; max-width: none;
  }
}
