/* Time Machine меню. Раскладка: шапка с датой → лента по линиям (горизонтальная шкала лет) → меню на выбранную дату карточками. */
:root {
  --bg: #f5f3ef; --surface: #ffffff; --fg: #1d1b18; --muted: #6e685f; --line: #e3ded5; --chip: #eeeae3;
  --accent: #d2332a;            /* красный Высоко */
  --l-main: #d2332a; --l-breakfast: #e08a1e; --l-season: #3c8a5a; --l-bar: #6b4fa3; --l-dessert: #c4508c; --l-kids: #2f7fb5; --l-en: #8a8173;
  --special: #1d1b18;
  --display: "Unbounded", "IBM Plex Sans", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #161513; --surface: #1f1d1a; --fg: #ece8e1; --muted: #a39c91; --line: #34302b; --chip: #2a2723;
  --accent: #ef5a4f; --l-main: #ef5a4f; --l-breakfast: #eda04a; --l-season: #5cb37d; --l-bar: #9a7fd6; --l-dessert: #e07ab0; --l-kids: #5aa6dc; --l-en: #a89f92;
  --special: #ece8e1; color-scheme: dark } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--body);
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
h1, h2, h3 { font-family: var(--display); font-weight: 500; text-wrap: balance; margin: 0; }
h2 { font-size: 18px; } h3 { font-size: 17px; }
.muted { color: var(--muted); }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible, .bar:focus-visible, .page:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--fg); border-radius: 8px; padding: 6px 12px; text-decoration: none; display: inline-flex; align-items: center; }
.ghost:hover { background: var(--chip); }

.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-block: 12px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.mark { width: 30px; height: 30px; border-radius: 6px; background: var(--accent); color: #fff; display: grid; place-items: center; font-family: var(--display); font-weight: 700; }
.name { font-family: var(--display); font-weight: 500; }
.when { display: flex; align-items: center; gap: 8px; }
.when input { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 8px; padding: 5px 8px; font-family: var(--mono); }

.login { display: grid; place-items: center; min-height: 70vh; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: min(380px, 100%); display: grid; gap: 8px; }
.card h1 { font-size: 22px; }
.card input { border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 8px; padding: 9px 10px; }
.card button { margin-top: 8px; background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 10px; font-weight: 500; }
.error { color: var(--accent); margin: 0; }

main { display: grid; gap: 28px; max-width: 1400px; margin: 20px auto 0; }
.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }

/* Лента: колонка подписей + прокручиваемая шкала */
.timeline { display: grid; grid-template-columns: 128px minmax(0, 1fr); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.tl-labels { display: grid; border-right: 1px solid var(--line); }
.tl-label { height: 44px; display: flex; align-items: center; padding: 0 10px; font-size: 13px; font-weight: 500; border-bottom: 1px solid var(--line); }
.tl-label:first-child { height: 28px; }
.tl-scroll { overflow-x: auto; position: relative; }
.tl-canvas { position: relative; min-width: 1200px; cursor: crosshair; }
.tl-years { height: 28px; position: relative; border-bottom: 1px solid var(--line); }
.tl-year { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--line); font: 12px var(--mono); color: var(--muted); padding: 6px 0 0 4px; }
.tl-row { height: 44px; position: relative; border-bottom: 1px solid var(--line); }
.bar { position: absolute; top: 9px; height: 26px; border-radius: 4px; border: 1px solid var(--surface); padding: 0 4px; overflow: hidden; white-space: nowrap; font: 11px/26px var(--mono); color: #fff; }
.bar.weak { opacity: .45; }
.bar.special { top: 30px; height: 10px; background: var(--special) !important; border-radius: 2px; font-size: 0; }
.bar[aria-current="true"] { box-shadow: 0 0 0 2px var(--fg); z-index: 2; }
.cursor { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--fg); pointer-events: none; z-index: 3; }
.legend { font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 8px 0 0; }
.sw { display: inline-block; width: 18px; height: 10px; border-radius: 2px; background: var(--l-main); vertical-align: middle; margin-right: 4px; }
.sw.faint { opacity: .45; } .sw.special { background: var(--special); height: 6px; }

/* Меню на дату */
.ondate { display: grid; gap: 16px; }
.line-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 10px; min-width: 0; }
.line-head { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.line-head h3 { font-size: 16px; }
.line-head .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dates { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.badge.warn { color: var(--accent); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.pages { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; align-items: flex-start; }
.page { flex: 0 0 auto; display: grid; gap: 4px; background: none; border: 0; padding: 0; text-align: left; color: var(--fg); }
.page .frame { position: relative; overflow: hidden; height: 420px; background: #fff; border: 1px solid var(--line); border-radius: 4px; }
.page .frame img { position: absolute; display: block; max-width: none; }
.page .cap { font-size: 12px; color: var(--muted); }
.page .low { color: var(--accent); }
.empty { color: var(--muted); font-size: 14px; }

/* Карточка издания */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: grid; place-items: start center; overflow-y: auto; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.sheet { background: var(--bg); border-radius: 12px; width: min(1200px, 100%); margin-top: 24px; border: 1px solid var(--line); }
.sheet-head { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 16px; border-bottom: 1px solid var(--line); }
.sheet-nav { display: flex; gap: 6px; }
.sheet-body { padding: 16px; display: grid; gap: 16px; min-width: 0; }
.ev { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 14px; }
.ev li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; }
.ev .d { font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* Просмотр страницы */
.lightbox { position: fixed; inset: 0; z-index: 30; background: rgba(10,10,10,.92); display: grid; grid-template-rows: auto minmax(0, 1fr); }
.lb-bar { display: flex; gap: 8px; justify-content: flex-end; padding: max(10px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px 16px; }
.lb-bar .ghost { color: #eee; border-color: #555; }
.lb-stage { overflow: auto; display: grid; place-items: center; padding: 8px 16px 24px; }
.lb-stage .frame { position: relative; overflow: hidden; background: #fff; }
.lb-stage .frame img { position: absolute; display: block; max-width: none; }
.lb-stage > img { max-width: 100%; height: auto; background: #fff; }

.status { text-align: center; color: var(--muted); font-size: 14px; min-height: 1.5em; }
@media (max-width: 640px) {
  .timeline { grid-template-columns: 92px minmax(0, 1fr); }
  .tl-label { font-size: 12px; }
  .page .frame { height: 300px; }
}
@media (prefers-reduced-motion: no-preference) { .bar { transition: box-shadow .12s; } }
