/* ── полка с фигурками (hero после поиска/фильтров) ── */
.shelfhero {
  position: relative;
  margin: 12px 0 2px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(90, 60, 20, .16);
}
.shelfhero img {
  display: block;
  width: 100%;
  aspect-ratio: 1672 / 734;
  height: auto;
  max-height: 540px;
  object-fit: cover;
  object-position: center;
}
@media (max-width: 560px) {
  .shelfhero { border-radius: 14px; }
  .shelfhero img { max-height: 340px; }
}
/* Читательский дневник — тёплая книжная тема */
:root {
  --bg: #f8f2e9;
  --card: #fffdf8;
  --soft: #f1e8dc;
  --line: #e7dcc9;
  --ink: #3d3229;
  --muted: #8d7c6b;
  --accent: #a4543f;
  --accent-ink: #fff;
  --ok: #2e7d43;      --ok-bg: rgba(46,125,67,.13);
  --mid: #a06a17;     --mid-bg: rgba(176,112,26,.14);
  --bad: #b23b3b;     --bad-bg: rgba(178,59,59,.13);
  --shadow: 0 2px 12px rgba(90,66,40,.09);
  --serif: Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1914;
    --card: #2a231c;
    --soft: #342c23;
    --line: #43382c;
    --ink: #efe6da;
    --muted: #a5947f;
    --accent: #d08163;
    --accent-ink: #241a14;
    --ok: #82c992;      --ok-bg: rgba(82,150,96,.2);
    --mid: #d9a95e;     --mid-bg: rgba(200,150,70,.18);
    --bad: #e08c8c;     --bad-bg: rgba(190,90,90,.18);
    --shadow: 0 2px 14px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
  max-width: 1000px;
  margin: 0 auto;
  padding: 18px 16px calc(90px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--ink); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; }

/* ── шапка ── */
.topbar h1 { font-size: 27px; margin: 4px 0 2px; letter-spacing: .2px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px; font-size: 13.5px;
  color: var(--muted); box-shadow: var(--shadow);
}
.stat b { color: var(--ink); font-weight: 600; }

/* ── вкладки ── */
.tabs {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg); padding: 6px 0 8px;
  border-bottom: 1px solid var(--line);
}
.seg {
  display: flex; gap: 2px;
  background: var(--soft); border-radius: 12px; padding: 3px;
}
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 9px;
  padding: 8px 6px; color: var(--muted); font-size: 14.5px; white-space: nowrap;
}
.seg button.on {
  background: var(--card); color: var(--ink); font-weight: 600;
  box-shadow: var(--shadow);
}
#tabs .seg { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
#tabs .seg::-webkit-scrollbar { display: none; }
#tabs .seg button { flex: 0 0 auto; padding: 8px 14px; }

/* ── поиск и теги ── */
.toolbar { margin: 14px 0 4px; display: grid; gap: 10px; }
#q {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--card);
}
.month {
  grid-column: 1 / -1;
  font-family: var(--serif); font-size: 15px; color: var(--muted);
  margin: 8px 2px 0; padding-bottom: 4px; border-bottom: 1px dashed var(--line);
}
.month::first-letter { text-transform: uppercase; }
#q:focus, input:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
}
.tagrow { display: flex; flex-wrap: wrap; gap: 7px; }
.tagrow .tag { cursor: pointer; }
.tagrow .tag.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.tag {
  display: inline-block; background: var(--soft); color: var(--muted);
  border: 1px solid transparent; border-radius: 999px;
  padding: 2px 11px; font-size: 13px; white-space: nowrap;
}

/* ── сетка карточек ── */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px; margin-top: 14px;
}
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

.card {
  position: relative;
  display: flex; gap: 13px; background: var(--card);
  border: 1px solid var(--line); border-radius: 17px; padding: 14px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .08s ease;
}
.card:active { transform: scale(.985); }
.cover {
  flex: 0 0 54px; width: 54px; height: 72px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; user-select: none;
}
.card-body { flex: 1; min-width: 0; }
.card-top { display: flex; align-items: baseline; gap: 8px; }
.card-top h3 { margin: 0; font-size: 17px; line-height: 1.25; flex: 1; min-width: 0; }
.card-meta { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.card-mind {
  font-family: var(--serif); font-style: italic; color: var(--ink);
  opacity: .85; font-size: 14px; margin-top: 6px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-sum {
  color: var(--ink); opacity: .82; font-size: 14px; margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.ex-label {
  font-size: 11.5px; color: var(--muted); border: 1px dashed var(--line);
  border-radius: 6px; padding: 0 6px; margin-left: 4px; align-self: center;
}

.badge {
  font-size: 13px; font-weight: 700; border-radius: 999px; padding: 2px 10px;
  white-space: nowrap; flex: 0 0 auto;
}
.b-high { color: var(--ok);  background: var(--ok-bg); }
.b-mid  { color: var(--mid); background: var(--mid-bg); }
.b-bad  { color: var(--bad); background: var(--bad-bg); }
.b-none { color: var(--muted); background: var(--soft); }

/* ── пустой список ── */
.empty { text-align: center; color: var(--muted); padding: 46px 20px 30px; }
.empty .big { font-size: 40px; }

/* ── кнопка ＋ ── */
.fab {
  position: fixed; right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink); font-size: 30px;
  line-height: 1; box-shadow: 0 6px 20px rgba(0,0,0,.22); z-index: 20;
}
.fab:active { transform: scale(.94); }

/* ── модальные листы ── */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(30,20,10,.42); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 700px) { .overlay { align-items: center; } }
.sheet {
  background: var(--card); width: 100%; max-width: 580px;
  max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  border-radius: 22px 22px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) { .sheet { border-radius: 18px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; font-size: 21px; }
.icon-btn {
  border: 0; background: var(--soft); border-radius: 50%; width: 34px; height: 34px;
  font-size: 15px; color: var(--muted);
}

/* ── форма ── */
#form { display: grid; gap: 12px; }
#form input, #form textarea {
  width: 100%; padding: 11px 13px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  color: var(--ink);
}
#form textarea { resize: vertical; min-height: 54px; }
#f-summary { min-height: 110px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.row2 input[type="date"] { min-height: 47px; }

#form .seg button { font-size: 13.5px; padding: 7px 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wrappedbtn {
  margin-top: 10px; width: 100%; padding: 11px; border-radius: 12px;
  border: 1px dashed var(--line); background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
}
.wrappedbtn:active { color: var(--accent); border-color: var(--accent); }
.sheet-wrapped { max-width: min(560px, 94vw); max-height: 88vh; overflow: auto; }
#wCanvas { display: none; }
#wImg { width: 100%; height: auto; display: block; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); }
#wImg.hidden { display: none; }
.w-yearrow { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 2px 0 10px; }
.w-yearrow b { font-size: 17px; min-width: 56px; text-align: center; }
.chips button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px;
  padding: 4px 12px; font-size: 14px; color: var(--muted);
}
.chips button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

.chaprow { display: flex; align-items: center; gap: 8px; }
.chaprow input {
  width: 100%; padding: 9px 10px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
}
.chap-of { color: var(--muted); font-size: 13px; flex: 0 0 auto; }
.langrow { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 2px; }
.langlbl { font-size: 13px; color: var(--muted); }
.langrow .tag { cursor: pointer; }
.langrow .tag.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.prog { height: 4px; border-radius: 3px; background: var(--soft); margin-top: 10px; overflow: hidden; }
.prog span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.proglbl { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.vol { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* ── фильтры ── */
.filterbtn {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 8px 16px; font-size: 14px; color: var(--muted);
  box-shadow: var(--shadow);
}
.filterbtn.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.toolbarrow { display: flex; }
.filterpanel {
  border: 1px solid var(--line); border-radius: 15px; background: var(--card);
  box-shadow: var(--shadow); padding: 12px 14px;
  display: grid; gap: 9px;
}
.frow { display: flex; align-items: flex-start; gap: 10px; }
.frow > label { flex: 0 0 72px; font-size: 13px; color: var(--muted); padding-top: 6px; }
.frow .chips { flex: 1; }
.frow .chips button { font-size: 13.5px; padding: 4px 11px; }
.fstats {
  border-top: 1px dashed var(--line); margin-top: 2px; padding-top: 9px;
  font-size: 13px; color: var(--muted);
}
.fstats b { color: var(--ink); }
.favbtn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  border: 0; background: none; font-size: 19px; line-height: 1;
  padding: 3px 4px; cursor: pointer; opacity: .9;
}

.quote-row { display: flex; gap: 8px; margin-bottom: 8px; }
.quote-row input { flex: 1; }
.quote-row .icon-btn { flex: 0 0 34px; }
.ghost-btn {
  border: 1px dashed var(--line); background: transparent; border-radius: 10px;
  padding: 7px 12px; color: var(--muted); font-size: 14px; margin-top: 2px;
}
.cover { overflow: hidden; }
.cov-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.coverbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.coverbar .ghost-btn { margin-top: 0; }
.mini-cover { width: 42px; height: 56px; object-fit: cover; border-radius: 8px; }
.tagadd { display: flex; gap: 8px; margin-top: 9px; }
.tagadd input {
  flex: 1; padding: 9px 12px; font-size: 16px; min-width: 0;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink);
}
.tagadd .ghost-btn { margin-top: 0; flex: 0 0 auto; }
#f-tagsel { min-height: 10px; }
.filebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filebar .ghost-btn { margin-top: 0; }
.file-tag {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--soft); border-radius: 999px; padding: 5px 13px;
  font-size: 13.5px; color: var(--ink); max-width: 100%;
}
.file-tag button { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 0; }
.file-tag .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-file a { color: var(--accent); text-decoration: none; font-weight: 600; }
.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }
.wide-btn {
  flex: 1; border: 1px solid var(--line); border-radius: 13px; padding: 13px;
  font-size: 16px; font-weight: 600; background: var(--card); color: var(--ink);
}
.wide-btn:disabled { opacity: .65; }
.primary { background: var(--accent); color: var(--accent-ink); }
.danger  { flex: 0 0 auto; padding: 13px 18px; background: var(--bad-bg); color: var(--bad); }

/* ── просмотр карточки ── */
.d-head { display: flex; gap: 14px; }
.d-head .cover { flex-basis: 62px; width: 62px; height: 84px; font-size: 30px; }
.d-head h2 { margin: 0; font-size: 22px; line-height: 1.25; }
.d-meta { color: var(--muted); font-size: 14px; margin-top: 4px; }
.d-link { font-size: 14px; margin-top: 6px; }
.d-link a { color: var(--accent); text-decoration: none; }
.d-sec { margin-top: 16px; }
.d-sec > h4 {
  margin: 0 0 8px; font-size: 12.5px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted); font-weight: 600;
}
.d-sum { white-space: pre-wrap; }
blockquote {
  margin: 0 0 10px; padding: 9px 14px;
  border-left: 3px solid var(--accent);
  background: var(--soft);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  font-family: var(--serif); font-style: italic; font-size: 15.5px; line-height: 1.55;
  border-radius: 0 10px 10px 0;
}
.d-thoughts { white-space: pre-wrap; }
.d-actions { display: flex; gap: 10px; margin-top: 22px; }
.d-note {
  margin-top: 18px; font-size: 12.5px; color: var(--muted);
  border-top: 1px dashed var(--line); padding-top: 10px;
}

/* ── тост ── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 14.5px; z-index: 50;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.hidden { display: none !important; }