:root {
    color-scheme: light;
    /* Approximate colours from the supplied brand board, not its printed codes. */
    --paper: #e8ddca;
    --ink: #29241e;
    --wine: #882b21;
    --line: #bcaa90;
    --brown: #553d2c;
    --charcoal: #1c1b18;
    --brass: #89683c;
    --surface: #f1e8d8;
    --panel: #d9c4a5;
    --muted: #635340;
    --font-display: Georgia, 'Times New Roman', serif;
    --font-body: Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.65 var(--font-display); }
a { color: var(--wine); text-underline-offset: .22em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 3px solid var(--wine); outline-offset: 5px; }
header, main, footer { width: min(1120px, 90%); margin-inline: auto; }
header { display: flex; align-items: center; justify-content: space-between; gap: 24px; width: 100%; margin: 0; padding: 24px max(5%, calc((100% - 1120px) / 2)); border-bottom: 2px solid var(--brass); background: var(--brown); color: var(--paper); }

main { min-height: 70vh; padding-block: 48px 80px; }
h1, h2 { font-weight: normal; line-height: 1.15; overflow-wrap: anywhere; }
h1 { font-size: clamp(36px, 5vw, 64px); margin: 20px 0 28px; }
h2 { font-size: 28px; }

.button { display: inline-block; margin-top: 20px; padding: 13px 25px; border-radius: 3px; background: var(--wine); color: var(--surface); text-decoration: none; }
.button:hover { background: #6b211a; }
.button span { margin-left: 18px; }
.note { padding: 24px 30px; background: var(--panel); border-left: 3px solid var(--wine); }
.note h2 { margin-top: 0; }
.note p:last-child { margin-bottom: 0; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 24px; }

.tag { display: inline-block; padding: 3px 12px; border: 1px solid var(--line); border-radius: 20px; font-size: 14px; }
.pagination { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 36px; }
footer { width: 100%; margin: 0; padding: 24px max(5%, calc((100% - 1120px) / 2)); border-top: 1px solid var(--brass); background: var(--charcoal); color: var(--paper); font-size: 14px; }
.skip-link { position: absolute; top: -100px; padding: 10px; background: var(--paper); }
.skip-link:focus { top: 0; }
@media (max-width: 520px) { header { align-items: flex-start; } header nav { padding-top: 8px; font-size: 15px; } main { padding-top: 30px; } }

header a:focus-visible { outline-color: var(--paper); }

h3 { font-weight: normal; font-size: 24px; line-height: 1.25; overflow-wrap: anywhere; }

.book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.tag { text-decoration: none; font: 12px/1.6 Arial, sans-serif; padding: 4px 10px; }
.tag:hover { background: var(--panel); }
.demo-label { font: 11px/1.5 Arial, sans-serif; color: var(--wine); }
.catalog-filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1.3fr; gap: 18px; padding: 24px; background: var(--panel); margin-top: 30px; }
.form-field { min-width: 0; }
.form-field label { display: block; font: 13px/1.5 Arial, sans-serif; margin-bottom: 8px; }
input, select { width: 100%; min-height: 44px; padding: 10px; background: var(--surface); border: 1px solid var(--brass); border-radius: 3px; color: var(--ink); font: 14px/1.5 var(--font-body); }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--wine); outline-offset: 3px; }
.filter-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 20px; }
.filter-actions .button { margin: 0; border: 0; font: 15px/1.6 Arial, sans-serif; cursor: pointer; }
.errorlist { color: #8c152c; padding-left: 18px; font: 13px/1.5 Arial, sans-serif; }
.result-count { margin-block: 28px; font: 13px/1.6 Arial, sans-serif; }
.book-grid > .note { grid-column: 1 / -1; }

footer p { max-width: 640px; font-size: 13px; }
@media (max-width: 900px) {  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .catalog-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }  }
@media (max-width: 620px) {     .book-grid, .catalog-filters { grid-template-columns: 1fr; }     }

/* Book web: persistent graph with scrollable SVG threads and native buttons. */
.web-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; }
.web-viewport { position: relative; z-index: 1; height: 640px; min-width: 0; overflow: auto; border: 1px solid var(--brass); border-radius: 3px; background: transparent; }
.web-viewport:focus-visible { outline: 3px solid var(--wine); outline-offset: 3px; }
.web-stage { position: relative; }
.web-lines, .web-nodes { position: absolute; inset: 0; width: 100%; height: 100%; }
.web-lines { pointer-events: none; }
.web-thread { stroke: var(--brass); stroke-width: 1.7; }
.web-thread-active { stroke: var(--wine); stroke-width: 3; }
.web-node { position: absolute; transform: translate(-50%, -50%); width: 184px; min-height: 126px; border: 1px solid var(--brass); border-radius: 4px; background: var(--surface); color: var(--ink); padding: 14px 12px; box-shadow: 0 6px 20px #35272212; font: 13px/1.4 var(--font-display); cursor: pointer; }
.web-node strong { display: block; font-size: 16px; line-height: 1.25; margin: 7px 0; overflow-wrap: anywhere; }
.web-node-author, .web-node-reason { display: block; }
.web-node-author { font-size: 11px; }
.web-node-reason { margin-top: 9px; color: var(--wine); font: 10px/1.5 Arial, sans-serif; }
.web-node-root { background: #dfcfb2; color: var(--ink); border-color: var(--brass); }
.web-node-root .web-node-reason { color: var(--wine); }
.web-node:focus-visible { outline: 3px solid #352722; outline-offset: 5px; }
.web-node:hover { box-shadow: 0 6px 22px #35272230; }
.web-thread-new { animation: web-thread-grow 420ms ease-out both; }
.web-node-new { animation: web-node-appear 280ms ease-out both; }
@keyframes web-thread-grow {
    from { stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; }
    to { stroke-dasharray: 1; stroke-dashoffset: 0; opacity: 1; }
}
@keyframes web-node-appear {
    from { opacity: 0; transform: translate(-50%, -50%) scale(.92); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .web-thread-new, .web-node-new { animation: none; }
}
.web-panel { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 3px; overflow-wrap: anywhere; }
.web-panel h2 { margin-block: 10px; font-size: 28px; }
.web-panel h3 { font-size: 20px; }
#web-description { font-size: 14px; line-height: 1.65; white-space: pre-line; }
#web-status { min-height: 2em; font: 14px/1.6 Arial, sans-serif; }
@media (max-width: 900px) { .web-layout { grid-template-columns: 1fr; } .web-viewport { height: 560px; } .web-panel { display: block; } }
@media (max-width: 620px) { .web-start { grid-template-columns: 1fr; } .web-viewport { height: 480px; } }

/* Вход и предпочтения используют ту же палитру, что каталог и паутина. */
.field-help { margin: 6px 0; font: 12px/1.5 var(--font-body); color: var(--muted); }
.preference-actions .button { border: 0; cursor: pointer; font: 15px/1.5 var(--font-body); }
.account-name { color: var(--muted); }
.messages { border-left: 3px solid var(--brass); padding: 1px 18px; margin-bottom: 24px; background: var(--surface); }
.preference-section { margin-bottom: 36px; }
.preference-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 80px; align-content: start; gap: 10px; min-height: 190px; padding: 5px; }
.preference-choice { position: relative; display: flex; align-items: center; gap: 10px; padding: 14px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 16px; }
/* Флажок остаётся доступным для клавиатуры; сердечко показывает его состояние. */
.preference-heart { font: 23px/1 var(--font-body); color: #998a77; }
.preference-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 24px; }
.preference-actions .button { margin: 0; }

/* Ссылки разделов выглядят как вкладки и сохраняют обычную навигацию по страницам. */
.button-small { margin: 0; padding: 9px 15px; border: 1px solid var(--wine); font: 14px/1.5 var(--font-body); cursor: pointer; }
.button-outline { background: transparent; color: var(--wine); }
.button-outline:hover { background: var(--surface); }
.web-map-shell { position: relative; min-width: 0; background: #1c1b18; border-radius: 3px; }
/* Фон неподвижен при прокрутке карты и не перехватывает нажатия на книги. */
/* Управление находится вне прокручиваемого полотна и остаётся поверх карты. */
.web-map-controls { position: absolute; top: 12px; right: 26px; z-index: 3; }
.web-map-controls .button { box-shadow: 0 3px 10px #29241e25; }
.search-label { display: block; font: 13px/1.5 var(--font-body); margin-bottom: 7px; }
.preference-search { max-width: 560px; }
button.preference-choice { text-align: left; font-family: var(--font-display); padding: 10px; min-width: 0; }
button.preference-choice > span:last-child { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; line-height: 1.2; }
.preference-choice[aria-pressed="true"] { border-color: var(--wine); background: #ead0bb; }
.preference-choice[aria-pressed="true"] .preference-heart { color: var(--wine); }
.preference-pages { display: flex; gap: 16px; align-items: center; margin-top: 16px; }
.preference-pages .button { min-width: 46px; }
.preference-pages .button:disabled { opacity: .4; cursor: default; }
.preference-pages > span { min-width: 55px; text-align: center; font: 13px/1.5 var(--font-body); }
@media (max-width: 900px) { .preference-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: 280px; } }
@media (max-width: 620px) {
    header { flex-wrap: wrap; }
}

/* Сердечко сохраняет предпочтение отдельно от открытия книги или ветви. */
.book-like-form { display: inline-block; margin: 0; }
.book-like { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--wine); font: 27px/1 var(--font-body); text-decoration: none; cursor: pointer; }
.book-like[aria-pressed="true"] { background: #ead0bb; border-color: var(--wine); }
.book-like:disabled { opacity: .5; cursor: wait; }
.web-node { padding-top: 40px; }
.match-icon { width: 20px; height: 20px; object-fit: contain; vertical-align: middle; filter: brightness(0); }
.match-reason { display: inline-flex; align-items: center; gap: 5px; margin: 3px 7px 3px 0; }
.web-node-reason .match-icon { width: 15px; height: 15px; flex-shrink: 0; }
.web-node-open { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: inherit; cursor: pointer; }
.web-node-like { position: absolute; right: 7px; top: 6px; width: 29px; height: 29px; font-size: 23px; }
/* У круглых кнопок один контур сердечка: при лайке меняется только заливка. */
.web-node-like, .catalog-personalize { font-size: 0; }
.web-node-like::before, .catalog-personalize::before { content: ''; display: block; flex: 0 0 auto; width: var(--heart-icon-size, 22px); height: var(--heart-icon-size, 22px); background: url('icons/heart-outline.svg') center / contain no-repeat; }
.web-node-like { --heart-icon-size: 18px; }
.web-node-like[aria-pressed="true"]::before, .catalog-personalize[aria-pressed="true"]::before { background-image: url('icons/heart-filled.svg'); }
.like-feedback { position: fixed; bottom: 20px; right: 20px; z-index: 10; padding: 12px 18px; border: 1px solid var(--wine); background: var(--surface); color: var(--wine); max-width: calc(100% - 40px); }

/* Рисунок покрывает страницу, а полотно карты остаётся прозрачным. */
.web-page { height: 100svh; overflow: hidden; display: flex; flex-direction: column; background: #1c1b18 url('images/web-background-full.svg') center / cover no-repeat; }
.web-page > .site-header { flex-shrink: 0; }
.web-page main { width: 100%; flex: 1; min-height: 0; padding: 16px; display: flex; flex-direction: column; }
.web-page main > p { margin: 0 0 12px; }
.web-page .web-layout { position: relative; flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; }
.web-page .web-map-shell { background: transparent; min-height: 0; border: 0; border-radius: 0; }
/* Кнопка возврата перекрывает только собственную область карты. */
.web-page .web-map-controls { inset: 0 0 auto; display: grid; grid-template-columns: minmax(0, 168px); justify-content: start; pointer-events: none; }
.web-page .web-map-controls .button { display: flex; align-items: center; justify-content: center; min-height: 44px; margin: 0; padding: 9px 15px; text-align: center; pointer-events: auto; }
.web-page .web-viewport { height: 100%; overflow: hidden; border: 0; border-radius: 0; touch-action: none; cursor: grab; }
.web-page .web-viewport:active { cursor: grabbing; }
.web-page .web-stage { transform-origin: 0 0; }
.web-page .web-panel { align-self: start; margin-top: 0; max-height: 100%; padding: 22px; border: 0; }
.web-page .web-node { border: 0; }
.web-page footer { display: none; }
.web-node-exhausted, .web-node-exhausted .web-node-reason { background: var(--wine); color: #fff; }
.web-node-exhausted .match-icon { filter: brightness(0) invert(1); }
@media (max-width: 700px) {
    .web-page main { padding: 10px; }
    .web-page .web-layout { grid-template-columns: minmax(0, 1fr) minmax(150px, 34%); gap: 8px; }
    .web-page .web-panel { padding: 12px; font-size: 13px; }
    .web-page .web-panel h2 { font-size: 20px; }
}
