/* Справочники: telescopes.html, constellations.html, history.html.
   Только переменные тем из site.css; схемы SVG рисуются currentColor и переменными, поэтому работают
   и в светлой теме «Daylight», и в ночном (красном) режиме. */

/* ── общее для справочников ── */
.guide-hero .lead b { color: var(--fg); }
.guide-toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.guide-toc a { font-weight: 700; }
.guide-body { display: block; }
.guide-body > .section { scroll-margin-top: calc(var(--head-h) + 12px); }
.guide-body h2[id], .guide-body h3[id] { scroll-margin-top: calc(var(--head-h) + 12px); }
.prose.wide { max-width: none; }
.prose .lead-in { font-size: 19.5px; color: var(--muted); }
.prose ul.tight li { margin: 3px 0; }
.kicker { color: var(--muted); font-size: 15.5px; margin: 4px 0 0; }

.duo { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); margin: 16px 0; }
.duo .card { box-shadow: none; }
.duo h4 { margin: 0 0 6px; font: 800 14px/1.2 var(--body); letter-spacing: .1em; text-transform: uppercase; }
.duo ul { margin: 0; padding-left: 20px; }
.duo li { margin: 4px 0; font-size: 16.5px; line-height: 1.5; }
.pros h4 { color: var(--good); }
.cons h4 { color: var(--poor); }

/* таблица, которая на узком экране превращается в карточки (подписи — из data-k) */
.stack-table { width: 100%; }
.stack-table th[scope="row"] { font: 800 16px/1.3 var(--display); color: var(--fg); text-transform: none; letter-spacing: 0; }
.stack-table td { font-size: 15.5px; line-height: 1.5; }
.stack-table th[scope="row"] { vertical-align: top; }
@media (min-width: 761px) {
  .table-wrap.boxed { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  .table-wrap.boxed .table th:first-child, .table-wrap.boxed .table td:first-child { padding-left: 16px; }
}
@media (max-width: 760px) {
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table th, .stack-table td { display: block; width: 100%; }
  .stack-table thead { display: none; }
  .stack-table tr { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; margin: 0 0 10px; background: var(--surface); }
  .stack-table td, .stack-table th[scope="row"] { border: 0; padding: 3px 0; }
  .stack-table th[scope="row"] { font-size: 18px; padding-bottom: 6px; }
  .stack-table td[data-k]::before {
    content: attr(data-k); display: block; color: var(--faint);
    font: 800 11px/1.4 var(--body); letter-spacing: .1em; text-transform: uppercase;
  }
}

/* схемы хода лучей */
.diagram { margin: 20px 0; padding: 14px 16px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.diagram svg { display: block; width: 100%; height: auto; color: var(--fg); overflow: visible; }
.diagram figcaption { color: var(--muted); font-size: 14.5px; margin-top: 8px; }
.diagram .tube { fill: color-mix(in srgb, var(--fg) 5%, transparent); stroke: currentColor; stroke-opacity: .45; stroke-width: 1.5; }
.diagram .glass { fill: color-mix(in srgb, var(--accent-2) 22%, transparent); stroke: var(--accent-2); stroke-width: 1.6; }
.diagram .mirror { fill: none; stroke: var(--accent-2); stroke-width: 4; stroke-linecap: round; }
.diagram .ray { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.diagram .ray.in { stroke-dasharray: none; }
.diagram .focus { fill: var(--accent); }
.diagram .lbl { fill: currentColor; font: 700 14px/1 var(--body); }
.diagram .lbl.dim { fill: var(--muted); font-weight: 600; }
.diagram .part { fill: none; stroke: currentColor; stroke-opacity: .6; stroke-width: 1.4; }
.diagram .arrow { fill: var(--accent); }
.diagram .lead { fill: none; stroke: currentColor; stroke-opacity: .35; stroke-width: 1; stroke-dasharray: 2 3; }
/* на телефоне схема сжимается вдвое — подписи крупнее, чтобы оставались читаемыми */
@media (max-width: 560px) { .diagram .lbl { font-size: 21px; } .diagram { padding: 12px 10px 10px; } }

/* ── телескопы: калькулятор ── */
.calc { scroll-margin-top: calc(var(--head-h) + 12px); }
.calc-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
@media (max-width: 900px) { .calc-grid { grid-template-columns: 1fr; } }
.calc-form { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.calc-form .full { grid-column: 1 / -1; }
.calc-form select, .calc-form input[type="number"] { width: 100%; }
.calc-form .unit { position: relative; }
.calc-form .unit input { padding-right: 40px; }
.calc-form .unit i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--faint); font-size: 14.5px; pointer-events: none; }
.calc-form .field > span { font-size: 14px; color: var(--muted); }
@media (max-width: 340px) { .calc-form { grid-template-columns: 1fr; } }

.calc-out { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
.stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); min-width: 0; }
.stat b { display: block; font: 800 24px/1.15 var(--mono); letter-spacing: -0.02em; color: var(--fg); overflow-wrap: anywhere; }
.stat span { display: block; color: var(--muted); font-size: 13.5px; font-weight: 700; letter-spacing: .02em; margin-bottom: 4px; }
.stat small { display: block; color: var(--faint); font-size: 13.5px; margin-top: 4px; line-height: 1.4; }
.stat.key { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.stat.key b { color: var(--accent); }
.calc-msgs { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.calc-msgs li { display: flex; gap: 10px; align-items: baseline; font-size: 15.5px; color: var(--muted); }
.calc-msgs .badge { flex: none; }

.sizes { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 16px; }
.sizes figure { margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: center; }
.sizes svg { width: 100%; max-width: 150px; height: auto; display: block; margin: 0 auto; }
.sizes figcaption { font-size: 13.5px; color: var(--muted); line-height: 1.4; margin-top: 6px; }
.sizes figcaption b { color: var(--fg); display: block; font-size: 14.5px; }
.sizes .sz-note { grid-column: 1 / -1; margin: 0; }
@media (max-width: 420px) { .sizes { grid-template-columns: 1fr 1fr; } .sizes figure:first-child { grid-column: 1 / -1; } }
/* рисунки размеров: тёмное «поле окуляра» и естественные цвета планет — одинаково во всех темах */
.sz-sky { fill: #05070d; stroke: var(--line-strong); stroke-width: 1.5; }
.sz-ref { fill: none; stroke: rgba(255, 255, 255, .78); stroke-width: 1.3; stroke-dasharray: 4 3; }
.sz-moon { fill: #d9d6cc; }
.sz-mare { fill: #a29f95; }
.sz-jup { fill: #e6d3ad; }
.sz-belt { fill: #a8825c; }
.sz-sat { fill: #e8d7a2; }
.sz-ring { fill: none; stroke: #cbb68a; }
.calc noscript p, .calc .formulas { font-size: 15.5px; color: var(--muted); }
.calc .formulas { margin: 14px 0 0; }
.calc .formulas code { font-family: var(--mono); font-size: 14px; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; color: var(--fg); }

.tiers { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); margin: 16px 0; }
.tiers .card { box-shadow: none; }
.tiers .card h3 { display: flex; align-items: center; gap: 8px; }
.tiers .card p, .tiers .card li { font-size: 16px; line-height: 1.55; color: var(--muted); }
.tiers .card ul { margin: 6px 0 0; padding-left: 18px; }
.tiers .step { font: 500 13px/1 var(--mono); color: var(--accent); }

.checklist { list-style: none; padding: 0; margin: 14px 0; counter-reset: ck; }
.checklist li { position: relative; padding: 10px 12px 10px 48px; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); line-height: 1.5; }
.checklist li::before {
  counter-increment: ck; content: counter(ck);
  position: absolute; left: 12px; top: 10px; width: 26px; height: 26px; border-radius: 999px;
  display: grid; place-items: center; font: 800 14px/1 var(--mono);
  background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent);
}
.checklist li b { color: var(--fg); }

.next-links { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); margin-top: 14px; }
.next-links a.card { padding: 16px 18px; box-shadow: none; }
.next-links a.card b { display: block; font: 800 17.5px/1.25 var(--display); color: var(--fg); }
.next-links a.card span { display: block; color: var(--muted); font-size: 15px; margin-top: 4px; line-height: 1.45; }

/* ── созвездия ── */
.stories { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); margin-top: 6px; }
.story { display: flex; flex-direction: column; gap: 6px; box-shadow: none; }
.story h3 { margin: 0; }
.story .when { color: var(--accent); font: 800 12px/1.3 var(--body); letter-spacing: .1em; text-transform: uppercase; }
.story p { color: var(--muted); font-size: 16px; line-height: 1.6; margin: 0; }
.story p b { color: var(--fg); }
.story .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 8px; }
.story .acts .chip { font-size: 13.5px; padding: 6px 10px; }

.finders { display: grid; gap: 14px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); margin: 18px 0; align-items: start; }
@media (max-width: 760px) { .finders { grid-template-columns: 1fr; } }
.finder { margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.finder svg.fs { max-width: 420px; margin: 0 auto; }
@media (max-width: 560px) { .finder svg.fn .lbl.minor { display: none; } .finder svg.fn .lbl.big { font-size: 26px; } }
.finder svg { display: block; width: 100%; height: auto; color: var(--fg); }
.finder figcaption { color: var(--muted); font-size: 14.5px; margin-top: 8px; }
.finder .st { fill: currentColor; }
.finder .ln { stroke: var(--accent-2); stroke-width: 1.3; stroke-opacity: .7; fill: none; }
.finder .pt { stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 5 4; fill: none; }
.finder .lbl { fill: var(--muted); font: 700 13.5px/1 var(--body); }
.finder .lbl.big { fill: var(--fg); font-size: 15px; font-weight: 800; }
.finder .pole { fill: var(--accent); }

.con-app { scroll-margin-top: calc(var(--head-h) + 12px); }
.con-tools { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) auto; align-items: end; margin: 0 0 12px; }
.con-tools .field > span { font-size: 13.5px; color: var(--muted); }
.con-tools input[type="search"] { width: 100%; }
.con-tools .seg { flex-wrap: wrap; border-radius: 18px; }
.con-tools .row { gap: 8px 14px; }
@media (max-width: 760px) { .con-tools { grid-template-columns: 1fr; } }
.con-status { margin: 0 0 12px; color: var(--muted); font-size: 15.5px; }
.con-status b { color: var(--fg); }
.con-status .btn { margin-left: 6px; vertical-align: baseline; }

.con-table { font-size: 15px; }
.con-table th[scope="row"] a { font: 800 16px/1.25 var(--display); text-decoration: none; color: var(--fg); }
.con-table th[scope="row"] a:hover { color: var(--accent); text-decoration: underline; }
.con-table th[scope="row"] small, .con-table td small { display: block; color: var(--faint); font: 600 13px/1.3 var(--body); margin-top: 2px; }
.con-table td.num small { font-family: var(--mono); }
.con-table thead th { background: color-mix(in srgb, var(--surface-solid) 70%, transparent); }
@media (min-width: 761px) {
  .con-table td[data-k="Whole of it from"], .con-table td[data-k="Part of it from"], .con-table td.num { white-space: nowrap; }
  .con-table td[data-k="Meaning"] { min-width: 120px; }
  .con-table td.con-now { min-width: 180px; }
  .con-table th, .con-table td { padding-left: 8px; padding-right: 8px; }
}
.con-table tbody tr { transition: background-color .2s ease; }
.con-table tr.is-high { background: color-mix(in srgb, var(--good) 9%, transparent); }
.con-table tr.is-high th[scope="row"] { box-shadow: inset 3px 0 0 var(--good); }
.con-table tr.is-never { opacity: .55; }
.con-table tr.is-never th[scope="row"] a { color: var(--muted); }
.con-now .badge { margin: 0 0 3px; }
.con-now small { display: block; margin-top: 2px; line-height: 1.4; }
.con-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
@media (min-width: 761px) { .con-wrap .table th:first-child, .con-wrap .table td:first-child { padding-left: 14px; } }
@media (max-width: 760px) {
  .con-wrap { overflow: visible; border: 0; background: none; }
  .con-table tr { display: grid !important; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
  .con-table tr > * { min-width: 0; }
  .con-table th[scope="row"], .con-table td[data-k="Meaning"] { grid-column: 1 / -1; }
  .con-table td.con-now { grid-column: 1 / -1; order: -1; }
  .con-table td.con-now[hidden] { display: none !important; }
  .con-table td.num small { display: inline; margin-left: 6px; }
  .con-table tr.is-high th[scope="row"] { box-shadow: none; }
  .con-table tr.is-high { border-color: color-mix(in srgb, var(--good) 55%, transparent); }
}
.con-empty { padding: 18px; text-align: center; color: var(--muted); }

/* ── история: хронология ── */
.tl-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 22px 0 10px; }
.tl-filters .lbl { color: var(--faint); font: 800 12px/1 var(--body); letter-spacing: .12em; text-transform: uppercase; margin-right: 2px; }
.tl-filters .chip small { color: var(--faint); font: 600 12px/1 var(--body); }
.tl-filters .chip[aria-pressed="true"] { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.tl-filters .chip[aria-pressed="true"] small { color: inherit; opacity: .75; }

.tl-jump {
  position: sticky; top: var(--head-h); z-index: 5;
  display: flex; gap: 4px; align-items: center; overflow-x: auto; scrollbar-width: thin;
  margin: 0 calc(-1 * var(--edge)) 8px calc(-1 * var(--edge-r)); padding: 8px var(--edge-r) 8px var(--edge);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.tl-jump-label { flex: none; color: var(--faint); font: 800 11.5px/1 var(--body); letter-spacing: .12em; text-transform: uppercase; margin-right: 6px; }
.tl-jump a {
  flex: none; padding: 6px 10px; border-radius: 999px; text-decoration: none; white-space: nowrap;
  color: var(--muted); font: 700 14px/1 var(--body); border: 1px solid transparent;
}
.tl-jump a:hover { color: var(--fg); background: var(--surface); }
.tl-jump a.on { color: var(--fg); border-color: var(--line-strong); background: var(--surface-2); }
.tl-jump a.off { opacity: .4; }

.tl-era { margin: 26px 0 0; scroll-margin-top: calc(var(--head-h) + 60px); }
.tl-era-head { font: 800 clamp(22px, 3vw, 30px)/1.2 var(--display); letter-spacing: -0.015em; margin: 0 0 14px; }
.tl-era-head small { color: var(--faint); font: 700 14px/1 var(--body); letter-spacing: .04em; margin-left: 8px; white-space: nowrap; }
.tl { list-style: none; margin: 0; padding: 0; position: relative; max-width: 920px; }
.tl::before {
  content: ""; position: absolute; top: 6px; bottom: 6px; left: 128px; width: 2px; border-radius: 2px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 60%, transparent), color-mix(in srgb, var(--accent-2) 40%, transparent));
}
.tl-item { position: relative; display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 0 38px; padding: 0 0 18px; scroll-margin-top: calc(var(--head-h) + 64px); }
.tl-item::before {
  content: ""; position: absolute; left: 122px; top: 18px; width: 14px; height: 14px; border-radius: 999px;
  background: var(--bg); border: 3px solid var(--accent); box-sizing: border-box;
}
.tl-when { text-align: right; padding-top: 14px; }
.tl-year { display: block; font: 800 18px/1.2 var(--display); color: var(--fg); }
.tl-date { display: block; color: var(--muted); font-size: 13.5px; margin-top: 4px; line-height: 1.3; }
.tl-body {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.tl-title { font: 800 20px/1.25 var(--display); margin: 0 0 6px; letter-spacing: -0.01em; }
.tl-body > p { margin: 6px 0 0; font-size: 16.5px; line-height: 1.65; }
.tl-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px !important; }
.tl-acts .btn svg { width: 15px; height: 15px; }
.tl-note { color: var(--faint); font-size: 13.5px !important; line-height: 1.45 !important; }
.tl-item:target .tl-body, .tl-item.flash .tl-body { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent), var(--shadow); }
.tl-count { color: var(--muted); font-size: 15px; margin: 0 0 4px; }
@media (max-width: 700px) {
  .tl::before { left: 6px; }
  .tl-item { grid-template-columns: 1fr; gap: 6px; padding-left: 28px; }
  .tl-item::before { left: 0; top: 3px; }
  .tl-when { text-align: left; padding-top: 0; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
  .tl-date { margin-top: 0; }
  .tl-body { padding: 14px 15px; }
}

@media print {
  .tl-jump, .tl-filters, .con-tools, .calc-form { display: none; }
  .tl-body, .card, .stat { box-shadow: none; }
}
