:root {
    --bg: #0d0f13;
    --surface: #15181f;
    --surface-2: #1c2029;
    --surface-3: #242935;
    --line: #2b313d;
    --text: #e9ecf2;
    --muted: #8b93a4;
    --accent: #5b8cff;
    --accent-soft: rgba(91, 140, 255, .16);
    --gold: #ffc24a;
    --red: #ff5f6d;
    --green: #3ddc97;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    /* Отступы сжимаются на невысоких экранах, чтобы календарь влезал без прокрутки. */
    --gutter: 24px;
    --cell-gap: 8px;
}

@media (max-height: 820px) {
    :root { --gutter: 14px; --cell-gap: 6px; }
}

@media (max-height: 680px) {
    :root { --gutter: 10px; --cell-gap: 4px; }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
}

body {
    background: radial-gradient(1200px 600px at 80% -10%, #1b2030 0%, var(--bg) 60%);
    color: var(--text);
    font: 400 15px/1.45 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

.app {
    display: grid;
    grid-template-columns: clamp(232px, 22vw, 320px) 1fr;
    gap: var(--gutter);
    height: 100%;
    overflow: hidden;
    padding: var(--gutter);
}

/* ---------- Библиотека ---------- */

.library {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: clamp(12px, 2vh, 20px);
}

.library__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.library__head h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.library__head .btn { flex: none; padding: 8px 14px; }

.shared-hint {
    background: var(--surface-2);
    border-radius: 10px;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.45;
    margin-bottom: 14px;
    padding: 8px 10px;
}

.shared-hint__who {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

/* ---------- Карточка профиля и медали ---------- */

.profile-link {
    border-bottom: 1px dashed currentColor;
    cursor: pointer;
}

.profile-link:hover { color: var(--accent); }

.pstats {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    margin-bottom: 10px;
}

.pstat {
    background: var(--surface-2);
    border-radius: 12px;
    padding: 10px;
    text-align: center;
}

.pstat__value {
    font-size: 19px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pstat__value span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.pstat__label {
    color: var(--muted);
    font-size: 11.5px;
    margin-top: 2px;
}

.pstats__extra {
    color: var(--muted);
    font-size: 12.5px;
    margin-bottom: 16px;
}

.pstats__extra b { color: var(--text); font-weight: 600; }

.medals {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    margin-bottom: 6px;
}

.medal {
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    padding: 10px 8px;
    text-align: center;
    transition: .15s;
}

.medal:hover { border-color: var(--line); }

.medals__empty {
    color: var(--muted);
    font-size: 13px;
    grid-column: 1 / -1;
    margin: 4px 0;
    text-align: center;
}

.medals__toggle {
    background: none;
    border: 1px dashed var(--surface-3);
    border-radius: 10px;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    margin-top: 10px;
    padding: 9px;
    transition: .15s;
    width: 100%;
}

.medals__toggle:hover { border-color: var(--accent); color: var(--text); }

.medal img {
    display: block;
    height: auto;
    margin: 0 auto 6px;
    width: 72px;
}

.medal__title {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
}

.medal__sub {
    color: var(--muted);
    font-size: 11px;
    margin-top: 3px;
}

/* Неполученные — тусклые и обесцвеченные. */
.medal--locked img {
    filter: grayscale(1) brightness(.55);
    opacity: .5;
}

.medal--locked .medal__title { color: var(--muted); font-weight: 500; }

/* ---------- Каталог ---------- */

.catalog__tools { margin-bottom: 12px; }

.catalog__search {
    display: flex;
    gap: 8px;
}

.catalog__search .input { flex: 1; }

.catalog__search .btn { flex: none; white-space: nowrap; }

.catalog__tools .library__filter { margin: 10px 0 0; }

.catalog__sort {
    align-items: center;
    border-top: 1px solid var(--line);
    margin-top: 10px;
    padding-top: 10px;
}

.catalog__sort-label {
    color: var(--muted);
    font-size: 11.5px;
    margin-right: 2px;
}

.catalog {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 4px;
    max-height: 52vh;
    overflow-y: auto;
}

.cat-book {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    display: grid;
    gap: 12px;
    grid-template-columns: 40px 1fr auto;
    padding: 9px 10px;
    transition: .15s;
}

.cat-book:hover {
    background: var(--surface-3);
    border-color: var(--line);
}

.cat-book__cover {
    aspect-ratio: 2 / 3;
    border-radius: 5px;
    overflow: hidden;
    width: 40px;
}

.cat-book__body { min-width: 0; }

.cat-book__title {
    font-size: 13.5px;
    font-weight: 600;
}

.cat-book__author {
    color: var(--muted);
    font-size: 11.5px;
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cat-book__who {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.who {
    background: var(--surface-3);
    border-radius: 999px;
    color: var(--muted);
    font-size: 10.5px;
    padding: 2px 8px;
}

.who.finished { color: var(--green); }
.who.reading { color: #8ab4ff; }

.cat-book__add {
    flex: none;
    font-size: 12px;
    padding: 6px 10px;
}

/* ---------- Профиль ---------- */

.profile {
    border-bottom: 1px solid var(--line);
    margin-top: 12px;
    padding-bottom: 10px;
}

.profile__row {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.profile__who {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile__btn {
    background: none;
    border: 0;
    color: var(--accent);
    cursor: pointer;
    flex: none;
    font-size: 12.5px;
    padding: 2px 0;
}

.profile__btn:hover { text-decoration: underline; }

.profile__switch {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.profile__hint {
    color: var(--muted);
    font-size: 11.5px;
    margin-top: 6px;
}

.chip--all {
    border-color: rgba(61, 220, 151, .4);
    color: var(--green);
}

/* Чей это экземпляр — видно только в сводном режиме. */
.owner {
    background: var(--surface-3);
    border-radius: 999px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 500;
    margin-left: 6px;
    padding: 1px 7px;
    white-space: nowrap;
}

/* Экран выбора профиля для гостя */

.pickers {
    display: grid;
    gap: 8px;
    margin-bottom: 4px;
}

.picker {
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    padding: 12px 14px;
    text-align: left;
    transition: .15s;
}

.picker:hover {
    background: var(--surface-3);
    border-color: var(--accent);
}

.picker__name {
    display: block;
    font-size: 14.5px;
    font-weight: 600;
}

.picker__sub {
    color: var(--muted);
    display: block;
    font-size: 12px;
    margin-top: 2px;
}

.library__filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: clamp(8px, 1.4vh, 16px) 0 10px;
}

.chip {
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
    font-size: 12.5px;
    padding: 5px 12px;
    transition: .15s;
}

.chip:hover { color: var(--text); }

.chip--on {
    background: var(--accent-soft);
    border-color: rgba(91, 140, 255, .4);
    color: #cfdcff;
}

.library__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    margin: 0 -8px;
    padding: 4px 8px;
}

.book-row {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 12px;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    padding: 10px;
    position: relative;
    text-align: left;
    transition: .15s;
}

.book-row:hover {
    border-color: var(--line);
    background: var(--surface-3);
}

.book-row__cover {
    aspect-ratio: 2 / 3;
    width: 44px;
    border-radius: 6px;
    background: var(--surface-3);
    position: relative;
}

.book-row__cover .cover-img,
.book-row__cover .cover-stub {
    border-radius: 6px;
}

/* Точка у книг, где не заполнена обложка, число страниц, автор или оценка. */
.gap-dot {
    background: var(--red);
    border-radius: 50%;
    height: 8px;
    position: absolute;
    right: 8px;
    top: 8px;
    width: 8px;
}

.book-row__title {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.25;
}

.book-row__author {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.book-row__meta {
    align-items: center;
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.bar {
    background: var(--surface);
    border-radius: 999px;
    flex: 1;
    height: 4px;
    overflow: hidden;
}

.bar > i {
    background: linear-gradient(90deg, var(--accent), #8ab4ff);
    display: block;
    height: 100%;
}

.bar--done > i { background: linear-gradient(90deg, #2fae7c, var(--green)); }

.pct {
    color: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.cover-img {
    display: block;
    height: 100%;
    width: 100%;
    object-fit: cover;
}

.cover-stub {
    align-items: center;
    background: linear-gradient(145deg, #2a3040, #1a1e28);
    color: #6d788f;
    display: flex;
    font-size: 9px;
    font-weight: 700;
    height: 100%;
    justify-content: center;
    letter-spacing: .04em;
    line-height: 1.15;
    overflow: hidden;
    padding: 6px;
    text-align: center;
    text-transform: uppercase;
    width: 100%;
}

/* ---------- Календарь ---------- */

.calendar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: clamp(12px, 2vh, 22px) clamp(14px, 1.6vw, 24px) clamp(10px, 1.6vh, 18px);
}

.calendar__head {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.calendar__title h2 {
    font-size: clamp(20px, 2.6vh, 30px);
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0;
    text-transform: capitalize;
}

.calendar__stats {
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 12.5px;
    margin-top: 6px;
}

.calendar__stats b {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.calendar__nav {
    display: flex;
    gap: 6px;
}

.nav-btn {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    height: 36px;
    line-height: 1;
    min-width: 36px;
    transition: .15s;
}

.nav-btn--today {
    font-size: 13px;
    padding: 0 14px;
}

.nav-btn:hover {
    background: var(--surface-3);
    color: var(--text);
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--cell-gap);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    margin: clamp(8px, 1.6vh, 20px) 0 6px;
    text-align: center;
}

.weekdays .weekend { color: #b8657a; }

.grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: 1fr;
    gap: var(--cell-gap);
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.day {
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: .15s;
}

.day:hover {
    background: var(--surface-3);
    border-color: var(--line);
}

.day--out {
    background: transparent;
    cursor: default;
    opacity: .35;
    pointer-events: none;
}

.day--today {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(91, 140, 255, .35);
}

.day__num {
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    left: 8px;
    position: absolute;
    top: 6px;
    z-index: 2;
}

.day--weekend .day__num { color: #cf6b81; }
.day--today .day__num { color: var(--accent); }

/* Тёмная подложка под числом, когда под ним обложка. */
.day--filled .day__num {
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .9);
}

.day--filled.day--weekend .day__num { color: #ffc2ce; }
.day--filled.day--today .day__num { color: #cfdcff; }

.day--filled::before {
    background: linear-gradient(180deg, rgba(8, 10, 14, .75), transparent);
    content: '';
    height: 34px;
    left: 0;
    pointer-events: none;
    position: absolute;
    right: 0;
    top: 0;
    z-index: 1;
}

.day__covers {
    display: flex;
    gap: 2px;
    inset: 0;
    position: absolute;
}

.day-cover {
    align-items: center;
    display: flex;
    flex: 1;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    padding: 6px 4px;
    position: relative;
}

/* Размытая обложка заполняет ячейку, поверх — сама обложка целиком. */
.day-cover__blur {
    filter: blur(16px) saturate(1.3);
    height: 100%;
    inset: 0;
    object-fit: cover;
    opacity: .4;
    position: absolute;
    transform: scale(1.3);
    width: 100%;
}

.day-cover__sheet {
    aspect-ratio: 2 / 3;
    border-radius: 4px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .55);
    height: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

/* Нижняя плашка обложки: процент слева, звёзды справа. */
.day-cover__bar {
    align-items: center;
    background: linear-gradient(0deg, rgba(8, 10, 14, .92) 40%, transparent);
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 1px 5px;
    justify-content: center;
    left: 0;
    padding: 12px 4px 4px;
    position: absolute;
    right: 0;
}

.day-cover__pct {
    color: #eaf0ff;
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.day-cover__stars {
    color: var(--gold);
    font-size: 9px;
    letter-spacing: -.5px;
    white-space: nowrap;
}

/* На невысоких экранах ячейки становятся ниже — ужимаем всё внутри. */
@media (max-height: 820px) {
    .day-cover { padding: 4px 3px; }
    .day__num { font-size: 11px; left: 6px; top: 4px; }
    .day-cover__bar { padding: 10px 3px 3px; }
    .day-cover__pct { font-size: 10px; }
    .day-cover__stars { font-size: 8px; }
}

@media (max-height: 680px) {
    .day-cover { padding: 3px 2px; }
    .day__num { font-size: 10px; }
    .day-cover__bar { padding: 8px 2px 2px; }
    .day--filled::before { height: 22px; }
}

.day__more {
    background: rgba(8, 10, 14, .8);
    border-radius: 999px;
    color: #dfe6f5;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    position: absolute;
    right: 5px;
    top: 5px;
    z-index: 2;
}

/* ---------- Звёзды ---------- */

.stars {
    display: inline-flex;
    gap: 2px;
}

.stars--input { cursor: pointer; }

.stars__star {
    color: var(--line);
    font-size: 22px;
    line-height: 1;
    position: relative;
    width: 1em;
}

.stars__star > i {
    color: var(--gold);
    font-style: normal;
    left: 0;
    overflow: hidden;
    position: absolute;
    top: 0;
    white-space: nowrap;
    width: 0;
}

.stars__star--half > i { width: .5em; }
.stars__star--full > i { width: 1em; }

.stars-value {
    color: var(--gold);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-left: 8px;
}

/* ---------- Модалка ---------- */

.modal {
    align-items: center;
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 24px;
    position: fixed;
    z-index: 50;
}

.modal[hidden] { display: none; }

.modal__backdrop {
    background: rgba(5, 7, 10, .68);
    backdrop-filter: blur(3px);
    inset: 0;
    position: absolute;
}

.modal__box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    max-height: 100%;
    max-width: 520px;
    overflow-y: auto;
    scrollbar-gutter: stable;          /* ширина содержимого не прыгает при появлении скроллбара */
    padding: 24px;
    position: relative;
    width: 100%;
}

.modal__head {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    margin-bottom: 18px;
}

.modal__head h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.modal__head p {
    color: var(--muted);
    font-size: 13px;
    margin: 4px 0 0;
}

.close {
    background: none;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    padding: 2px 6px;
}

.close:hover { color: var(--text); }

.field { margin-bottom: 14px; }

.field > label {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.input, select.input, textarea.input {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    transition: .15s;
    width: 100%;
}

.input:focus {
    border-color: var(--accent);
    outline: none;
}

.row {
    display: flex;
    gap: 12px;
}

.row > * { flex: 1; }

.actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    padding: 9px 16px;
    transition: .15s;
}

.btn:hover { background: var(--surface-3); }

.btn--primary {
    background: var(--accent);
    border-color: transparent;
    color: #fff;
}

.btn--primary:hover { background: #4a7cf0; }

.btn--danger {
    color: var(--red);
    margin-right: auto;
}

.btn--ghost {
    background: none;
    border-color: transparent;
    color: var(--muted);
}

/* Загрузка обложки */

.cover-drop {
    align-items: center;
    display: flex;
    gap: 14px;
}

.cover-drop__preview {
    aspect-ratio: 2 / 3;
    background: var(--surface-2);
    border: 1px dashed var(--line);
    border-radius: 10px;
    overflow: hidden;
    width: 84px;
}

.cover-drop__hint {
    color: var(--muted);
    font-size: 12px;
    margin-top: 6px;
}

/* Записи дня */

.entries {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.entry {
    align-items: center;
    background: var(--surface-2);
    border-radius: 12px;
    display: grid;
    gap: 12px;
    grid-template-columns: 38px 1fr auto auto;
    padding: 8px 10px;
}

.entry__cover {
    aspect-ratio: 2 / 3;
    border-radius: 5px;
    overflow: hidden;
    width: 38px;
}

.entry__title {
    font-size: 13.5px;
    font-weight: 600;
}

.entry__note {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.entry__pct {
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ---------- Цитаты и заметки книги ---------- */

.notes {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.note {
    align-items: baseline;
    background: var(--surface-2);
    border-radius: 10px;
    display: flex;
    font-size: 13px;
    gap: 8px;
    padding: 7px 10px;
}

.note--empty {
    color: var(--muted);
    font-style: italic;
    justify-content: center;
}

.note__page {
    color: var(--muted);
    flex: none;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.note__text {
    flex: 1;
    line-height: 1.4;
}

.note .close { font-size: 16px; line-height: 1; }

.note-add {
    display: flex;
    gap: 6px;
}

.note-add__page { flex: none; width: 74px; }

.note-add .btn { flex: none; padding: 9px 14px; }

/* ---------- Итоги года ---------- */

.goal {
    background: var(--surface-2);
    border-radius: 12px;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.goal__row {
    align-items: center;
    display: flex;
    gap: 12px;
}

.goal__row .bar { height: 8px; }

.goal__row b { font-variant-numeric: tabular-nums; }

.goal__sub {
    color: var(--muted);
    font-size: 12.5px;
    margin-top: 6px;
}

.goal__edit {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.goal__edit .input { width: 150px; }

.year-months {
    align-items: end;
    display: grid;
    gap: 4px;
    grid-template-columns: repeat(12, 1fr);
    margin-bottom: 18px;
}

.year-month {
    background: none;
    border: 0;
    cursor: pointer;
    padding: 0;
}

.year-month__bar {
    align-items: end;
    background: var(--surface-2);
    border-radius: 5px;
    display: flex;
    height: 56px;
    overflow: hidden;
}

.year-month__bar > i {
    background: linear-gradient(180deg, #8ab4ff, var(--accent));
    display: block;
    min-height: 2px;
    width: 100%;
}

.year-month:hover .year-month__bar > i { background: var(--green); }

.year-month__label {
    color: var(--muted);
    display: block;
    font-size: 10px;
    margin-top: 4px;
}

.year-block {
    background: var(--surface-2);
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 10px 12px;
}

.year-block__head {
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    list-style: none;
    text-transform: uppercase;
    user-select: none;
}

.year-block__head::-webkit-details-marker { display: none; }

.year-block__head::before {
    content: '▸';
    display: inline-block;
    margin-right: 6px;
    transition: transform .15s;
}

.year-block[open] .year-block__head::before { transform: rotate(90deg); }

.year-block[open] .year-block__head { margin-bottom: 10px; }

.year-block__head:hover { color: var(--text); }

/* Книги выбранного месяца */

.month-detail {
    background: var(--surface-2);
    border-radius: 12px;
    margin-bottom: 14px;
    padding: 12px;
}

.month-detail[hidden] { display: none; }

.month-detail__head {
    align-items: center;
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.month-detail__head span {
    color: var(--muted);
    flex: 1;
    font-size: 12.5px;
}

.month-detail__head .btn { font-size: 12px; padding: 6px 10px; }

.month-book {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: 34px 1fr;
    padding: 5px 0;
}

.month-book__cover {
    aspect-ratio: 2 / 3;
    border-radius: 5px;
    overflow: hidden;
    width: 34px;
}

/* Тепловая карта: колонка — неделя, 7 строк — дни недели. */
.heatmap {
    display: grid;
    gap: 3px;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, 1fr);
    overflow-x: auto;
    padding-bottom: 4px;
}

.hm {
    aspect-ratio: 1;
    background: var(--surface-2);
    border-radius: 2px;
    display: block;
    min-width: 8px;
}

.hm--void { background: none; }
.hm--0 { background: var(--surface-2); }
.hm--1 { background: rgba(91, 140, 255, .3); }
.hm--2 { background: rgba(91, 140, 255, .55); }
.hm--3 { background: rgba(91, 140, 255, .8); }
.hm--4 { background: var(--green); }

.hm:not(.hm--void):hover { outline: 1px solid var(--text); }

.year-authors { margin-bottom: 18px; }

.year-genre {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(80px, 1fr) 2fr auto;
    font-size: 13px;
    padding: 4px 0;
}

.year-genre__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Жанры книги ---------- */

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.tag {
    align-items: center;
    background: var(--accent-soft);
    border: 1px solid rgba(91, 140, 255, .4);
    border-radius: 999px;
    color: #cfdcff;
    display: inline-flex;
    font-size: 12.5px;
    gap: 4px;
    padding: 4px 10px;
}

.tag--empty {
    background: none;
    border-color: transparent;
    color: var(--muted);
    font-style: italic;
    padding-left: 0;
}

.tag button {
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    opacity: .7;
    padding: 0;
}

.tag button:hover { opacity: 1; }

.year-author {
    align-items: baseline;
    display: flex;
    font-size: 13px;
    gap: 10px;
    justify-content: space-between;
    padding: 4px 0;
}

.year-author__num {
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.pace, .book-row__pace {
    color: var(--muted);
    font-size: 12px;
    margin: 4px 0 0;
}

.book-row__pace {
    font-size: 11px;
    margin-top: 2px;
}

.year-books {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
}

.year-book__cover {
    aspect-ratio: 2 / 3;
    border-radius: 6px;
    overflow: hidden;
}

.year-book__date {
    color: var(--muted);
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    margin-top: 3px;
    text-align: center;
}

.entry__page {
    color: var(--muted);
    display: block;
    font-size: 10.5px;
    font-weight: 400;
}

/* ---------- Автодополнение автора ---------- */

.combo { position: relative; }

.combo__list {
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
    left: 0;
    max-height: 190px;
    overflow-y: auto;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 5;
}

.combo__list[hidden] { display: none; }

.combo__option {
    cursor: pointer;
    font-size: 13.5px;
    padding: 8px 12px;
}

.combo__option:hover,
.combo__option--on { background: var(--accent-soft); }

.combo__hint {
    color: var(--muted);
    font-size: 12px;
    margin-top: 6px;
}

.combo__hint[hidden] { display: none; }

.combo__hint b { color: var(--text); }

.combo__apply {
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}

/* ---------- Автор ---------- */

.publisher-link {
    border-bottom: 1px dashed currentColor;
    color: var(--muted);
    cursor: pointer;
}

.publisher-link:hover { color: var(--text); }

.edition-line {
    color: var(--muted);
    font-size: 12.5px;
    margin: 2px 0 0;
}

.author-link {
    border-bottom: 1px dashed currentColor;
    color: var(--accent);
    cursor: pointer;
}

.author-link:hover { color: #8ab4ff; }

.author-head {
    align-items: center;
    display: flex;
    gap: 14px;
    min-width: 0;
}

.author-photo {
    align-items: center;
    aspect-ratio: 1;
    background: linear-gradient(145deg, #2a3040, #1a1e28);
    border-radius: 50%;
    color: #7d88a0;
    display: flex;
    flex: none;
    font-size: 20px;
    font-weight: 700;
    justify-content: center;
    overflow: hidden;
    width: 68px;
}

.author-bio {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 14px;
}

.author-bio p { margin: 0 0 6px; }

.author-bio--empty { font-style: italic; }

.author-bio__src {
    color: var(--accent);
    font-size: 12px;
    text-decoration: none;
}

.author-bio__src:hover { text-decoration: underline; }

.author-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

/* flex: none — иначе кнопки сжимаются и текст переносится, когда в модалке появляется скроллбар. */
.author-tools .btn {
    flex: none;
    font-size: 12.5px;
    padding: 7px 12px;
    white-space: nowrap;
}

#authorForm[hidden] { display: none; }

/* ---------- Рекомендации ---------- */

.recs { margin-bottom: 18px; }

.recs[hidden] { display: none; }

.recs__head {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px;
}

.recs__list {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
}

.rec {
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    padding: 8px;
    text-align: left;
    transition: .15s;
}

.rec:hover {
    background: var(--surface-3);
    border-color: var(--accent);
}

.rec__cover {
    aspect-ratio: 2 / 3;
    background: var(--surface-3);
    border-radius: 6px;
    margin-bottom: 6px;
    overflow: hidden;
}

.rec__title {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
}

.rec__year {
    color: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

.rec--added {
    border-color: var(--green);
    opacity: .6;
    pointer-events: none;
}

.rec--added .rec__year { color: var(--green); }

.author-books {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.author-book {
    background: var(--surface-2);
    border-radius: 12px;
    display: grid;
    gap: 12px;
    grid-template-columns: 52px 1fr;
    padding: 10px;
}

.author-book__cover {
    aspect-ratio: 2 / 3;
    border-radius: 6px;
    cursor: pointer;
    overflow: hidden;
    width: 52px;
}

.author-book__body { min-width: 0; }

.author-book__title {
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.author-book__title:hover { color: var(--accent); }

.author-book__sub {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.day-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.day-chip {
    background: var(--surface-3);
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    padding: 2px 8px;
    transition: .15s;
}

.day-chip:hover {
    border-color: var(--accent);
    color: var(--text);
}

.empty {
    color: var(--muted);
    font-size: 13px;
    padding: 18px 0;
    text-align: center;
}

.range-row {
    align-items: center;
    display: flex;
    gap: 12px;
}

input[type=range] {
    accent-color: var(--accent);
    flex: 1;
}

.range-val {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 46px;
    text-align: right;
}

.book-modal__top {
    display: grid;
    gap: 16px;
    grid-template-columns: 110px 1fr;
    margin-bottom: 18px;
}

.book-modal__cover {
    aspect-ratio: 2 / 3;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.toast {
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: 12px;
    bottom: 24px;
    box-shadow: var(--shadow);
    font-size: 13.5px;
    left: 50%;
    padding: 10px 18px;
    position: fixed;
    transform: translateX(-50%);
    z-index: 100;
}

.toast[hidden] { display: none; }

/* ---------- Просмотр картинки ---------- */

.zoomable { cursor: zoom-in; }

.lightbox {
    align-items: center;
    background: rgba(5, 7, 10, .88);
    backdrop-filter: blur(4px);
    cursor: zoom-out;
    display: flex;
    flex-direction: column;
    gap: 14px;
    inset: 0;
    justify-content: center;
    padding: 32px;
    position: fixed;
    z-index: 200;
}

.lightbox[hidden] { display: none; }

.lightbox img {
    border-radius: 10px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
    max-height: 88vh;
    max-width: 88vw;
    object-fit: contain;
}

.lightbox__caption {
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    max-width: 460px;
    text-align: center;
}

.lightbox__close {
    background: rgba(20, 24, 30, .7);
    border: 1px solid var(--surface-3);
    border-radius: 50%;
    color: var(--text);
    cursor: pointer;
    font-size: 22px;
    height: 40px;
    line-height: 1;
    position: absolute;
    right: 20px;
    top: 20px;
    width: 40px;
}

.lightbox__close:hover { background: rgba(40, 46, 54, .9); }

/* ---------- Ближайшие медали ---------- */

.nextmedals {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.nextmedals[hidden] { display: none; }

.nextmedals__title {
    align-items: center;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    gap: 8px;
    letter-spacing: .06em;
    padding: 2px 0;
    text-align: left;
    text-transform: uppercase;
    width: 100%;
}

.nextmedals__title:hover { color: var(--text); }
.nextmedals__title > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nextmedals__chevron { flex: none; margin-left: auto; transition: transform .2s; }

/* В свёрнутом виде вместо строк — маленькие значки медалей рядом с заголовком. */
.nextmedals__peek { display: none; flex: none; gap: 2px; }
.nextmedals__peek img { height: 18px; object-fit: contain; width: 18px; }

.nextmedals--collapsed .nextmedal { display: none; }
.nextmedals--collapsed .nextmedals__peek { display: flex; }
.nextmedals--collapsed .nextmedals__chevron { transform: rotate(-90deg); }

.nextmedal {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    gap: 10px;
    padding: 6px 10px 6px 6px;
    text-align: left;
    transition: .15s;
}

.nextmedal:hover { border-color: var(--accent); }
.nextmedal img { flex: none; height: 36px; object-fit: contain; width: 36px; }
.nextmedal__body { display: flex; flex: 1; flex-direction: column; gap: 5px; min-width: 0; }
.nextmedal__text { font-size: 12px; line-height: 1.35; }

.nextmedal__bar {
    background: var(--surface-3);
    border-radius: 2px;
    display: block;
    height: 3px;
    overflow: hidden;
}

.nextmedal__bar span {
    background: linear-gradient(90deg, #f5c542, #ff9f43);
    display: block;
    height: 100%;
}

/* ---------- Поздравление с новой медалью ---------- */

.newmedal {
    align-items: center;
    animation: newmedal-fade .25s ease-out;
    background: rgba(5, 7, 10, .9);
    backdrop-filter: blur(6px);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 24px;
    position: fixed;
    z-index: 220;
}

.newmedal[hidden] { display: none; }

.newmedal__panel {
    background: radial-gradient(circle at 50% 30%, rgba(245, 197, 66, .18), transparent 60%), var(--surface-1);
    border: 1px solid rgba(245, 197, 66, .35);
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .7);
    max-width: 380px;
    overflow: hidden;
    padding: 28px 24px 22px;
    position: relative;
    text-align: center;
    width: 100%;
}

.newmedal__kicker {
    color: #f5c542;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.newmedal__glow {
    margin: 10px auto 6px;
    position: relative;
    width: 200px;
}

.newmedal__glow::before {
    animation: newmedal-pulse 2.4s ease-in-out infinite;
    background: radial-gradient(circle, rgba(245, 197, 66, .55), transparent 65%);
    content: "";
    inset: -20px;
    position: absolute;
}

.newmedal__glow img {
    animation: newmedal-pop .7s cubic-bezier(.2, 1.4, .4, 1) both;
    display: block;
    height: 200px;
    object-fit: contain;
    position: relative;
    width: 200px;
}

.newmedal__title { font-size: 22px; margin: 4px 0; }
.newmedal__about { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.newmedal__actions { display: flex; gap: 8px; justify-content: center; }
.newmedal__more { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

.newmedal__confetti { inset: 0; pointer-events: none; position: absolute; }

.newmedal__confetti i {
    animation: newmedal-confetti linear infinite;
    border-radius: 1px;
    height: 10px;
    opacity: 0;
    position: absolute;
    top: -12px;
    width: 6px;
}

@keyframes newmedal-fade { from { opacity: 0; } }
@keyframes newmedal-pop { from { opacity: 0; transform: scale(.3) rotate(-25deg); } }
@keyframes newmedal-pulse { 50% { opacity: .5; transform: scale(1.08); } }

@keyframes newmedal-confetti {
    0%   { opacity: 1; transform: translateY(0) rotate(0); }
    100% { opacity: 0; transform: translateY(460px) rotate(540deg); }
}

@media (prefers-reduced-motion: reduce) {
    .newmedal, .newmedal__glow img, .newmedal__glow::before { animation: none; }
    .newmedal__confetti { display: none; }
}

/* ---------- Добавить по ссылке ---------- */

.fromlink {
    background: var(--surface-2);
    border: 1px dashed var(--surface-3);
    border-radius: 12px;
    padding: 12px;
}

.fromlink__row { display: flex; gap: 8px; }
.fromlink__row .input { flex: 1; min-width: 0; }

/* ---------- Лента семьи ---------- */

.feed { display: flex; flex-direction: column; gap: 6px; }

.feed__day {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    margin: 10px 0 2px;
    text-transform: uppercase;
}

.feed__day:first-child { margin-top: 0; }

.feed__item {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    text-align: left;
    transition: .15s;
}

.feed__item:hover { border-color: var(--accent); }

.feed__cover {
    border-radius: 4px;
    display: block;
    flex: none;
    height: 48px;
    overflow: hidden;
    width: 32px;
}

.feed__cover img, .feed__cover .cover-stub { height: 100%; object-fit: cover; width: 100%; }
.feed__cover .cover-stub { font-size: 6px; }

.feed__medal { flex: none; height: 44px; object-fit: contain; width: 44px; }

.feed__text { font-size: 13px; line-height: 1.4; }
.feed__user { font-weight: 600; }
.feed__item--medal { background: linear-gradient(90deg, rgba(245, 197, 66, .08), var(--surface-2)); }
.feed__rating { color: #f5c542; white-space: nowrap; }

/* ---------- Все прочитанные ---------- */

.fullview {
    background: var(--bg, #0d1015);
    inset: 0;
    overflow-y: auto;
    position: fixed;
    z-index: 205;
}

.fullview[hidden] { display: none; }

.fullview__panel {
    margin: 0 auto;
    max-width: 1100px;
    padding: 28px 24px 40px;
}

.fullview__head {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.fullview__head h3 { font-size: 22px; margin: 0 0 4px; }
.fullview__head p { color: var(--muted); font-size: 13px; margin: 0; }

.fullview__panel { max-width: 1400px; }

.readspeed {
    background: var(--surface-2);
    border-radius: 12px;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: 13px;
    gap: 6px 24px;
    margin-bottom: 14px;
    padding: 12px 16px;
}

.readspeed b { color: var(--text); }

.readfilters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.readyear {
    border-bottom: 1px solid var(--surface-3);
    font-size: 16px;
    font-weight: 600;
    margin: 22px 0 14px;
    padding-bottom: 8px;
}

.muted { color: var(--muted); }

.readlist {
    display: grid;
    gap: 16px 14px;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.readrow {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding: 0;
    text-align: left;
}

.readrow__cover {
    aspect-ratio: 2 / 3;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 8px;
    display: block;
    margin-bottom: 6px;
    overflow: hidden;
    position: relative;
    transition: .15s;
    width: 100%;
}

.readrow:hover .readrow__cover { border-color: var(--accent); transform: translateY(-2px); }

.readrow__cover img, .readrow__cover .cover-stub {
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.readrow__num, .readrow__rating {
    background: rgba(8, 10, 14, .78);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 7px;
    position: absolute;
    top: 6px;
}

.readrow__num { color: var(--text); left: 6px; }

.readrow__mood {
    background: rgba(8, 10, 14, .78);
    border-radius: 50%;
    bottom: 6px;
    font-size: 16px;
    height: 28px;
    line-height: 28px;
    position: absolute;
    right: 6px;
    text-align: center;
    width: 28px;
}

/* ---------- Настроение книги ---------- */

.moods { display: flex; flex-wrap: wrap; gap: 6px; }

.mood {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--surface-3);
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 13px;
    gap: 6px;
    padding: 5px 11px 5px 8px;
    transition: .15s;
}

.mood:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.mood__emoji { font-size: 17px; line-height: 1; }

.mood--on {
    background: rgba(245, 197, 66, .14);
    border-color: #f5c542;
    color: var(--text);
}

.mood:disabled { cursor: default; }
.mood:disabled:not(.mood--on) { display: none; }   /* в чужой книге — только выбранное */
.readrow__rating { color: #f5c542; right: 6px; }

.readrow__title {
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
}

.readrow__author, .readrow__period {
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .readlist { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px 10px; }
}

/* ---------- Детали медали ---------- */

.medalview {
    align-items: center;
    background: rgba(5, 7, 10, .88);
    backdrop-filter: blur(4px);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 24px;
    position: fixed;
    z-index: 210;
}

.medalview[hidden] { display: none; }

.medalview__panel {
    background: var(--surface-1);
    border: 1px solid var(--surface-3);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
    max-height: 86vh;
    max-width: 440px;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    text-align: center;
    width: 100%;
}

.medalview__close {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    position: absolute;
    right: 14px;
    top: 12px;
}

.medalview__close:hover { color: var(--text); }

.medalview__img {
    height: 300px;
    width: 300px;
    object-fit: contain;
}

.medalview__title {
    font-size: 20px;
    margin: 6px 0 2px;
}

.medalview__about {
    color: var(--muted);
    font-size: 13px;
    margin: 0 0 16px;
}

.medalview__lead {
    color: var(--muted);
    font-size: 13px;
    margin: 0 0 10px;
    text-align: left;
}

.medalview__note {
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

.medalbooks {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.medalbook {
    background: var(--surface-2);
    border: 1px solid var(--surface-3);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    text-align: left;
    transition: border-color .15s, background .15s;
}

.medalbook:hover {
    background: var(--surface-3);
    border-color: var(--accent);
}

.medalbook__title {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.medalbook__meta {
    color: var(--muted);
    font-size: 12px;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* Узкий экран: колонки в стопку, страница снова прокручивается целиком. */
@media (max-width: 900px) {
    html, body { height: auto; }

    .app {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
        padding: 14px;
    }

    .library { max-height: 320px; }

    .grid {
        grid-auto-rows: minmax(104px, 1fr);
        overflow: visible;
    }
}
