:root {
  color-scheme: light dark;
  --bg: #f2f4f7;
  --surface: #ffffff;
  --ink: #15202b;
  --muted: #4f5b67;
  --line: #cdd4dc;
  --accent: #1d5c9e;
  --accent-ink: #ffffff;
  --error: #a3211b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --surface: #1b232c;
    --ink: #eef2f6;
    --muted: #aab4bf;
    --line: #34404d;
    --accent: #7fb2ee;
    --accent-ink: #11161c;
    --error: #ff9a92;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

.site-header { padding: 16px 0; }
.logo { color: var(--ink); font-weight: 750; letter-spacing: -0.01em; text-decoration: none; display: inline-flex; gap: 8px; align-items: center; min-height: 44px; }

h1 { font-size: clamp(30px, 6vw, 44px); line-height: 1.1; letter-spacing: -0.02em; margin: 8px 0 12px; }
h2 { font-size: 24px; line-height: 1.2; margin: 40px 0 10px; letter-spacing: -0.01em; }
h3 { font-size: 18px; margin: 24px 0 4px; }
.lead { color: var(--muted); max-width: 64ch; margin: 0 0 20px; }

/* Инструмент */
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; display: grid; gap: 20px; }
.tool h2 { margin: 0 0 14px; }
.tool .disclaimer { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 12px; margin: 0; }

.choice { border: 0; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; min-width: 0; }
.choice-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice legend { font-size: 15px; font-weight: 600; margin-bottom: 4px; padding: 0; }
.choice label { display: block; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: flex; min-height: 44px; align-items: center; justify-content: center; text-align: center; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; font-weight: 600; font-size: 15px; cursor: pointer; }
.choice input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choice input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 1px; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.field label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 4px; }
input[type="text"] { width: 100%; min-height: 44px; padding: 8px 10px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; font-variant-numeric: tabular-nums; }
input::placeholder { color: var(--muted); opacity: 0.7; }
input[aria-invalid="true"] { border-color: var(--error); }
input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.error { display: block; color: var(--error); font-size: 14px; margin: 4px 0 0; }

.output { border-top: 1px solid var(--line); padding-top: 18px; }
.hint { color: var(--muted); margin: 0; }
.tool-error { font-size: 16px; font-weight: 600; }
.results { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px 16px; margin: 0; }
.results dt { font-size: 14px; font-weight: 600; color: var(--muted); }
.results dd { margin: 0; font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; }
.results .side { font-size: 15px; font-weight: 600; color: var(--muted); }
.small { color: var(--muted); font-size: 14px; margin: 4px 0 0; }

@media (min-width: 760px) {
  .tool:not(.navlog) { grid-template-columns: 1fr 1fr; align-items: start; }
  .tool:not(.navlog) .output { border-top: 0; border-left: 1px solid var(--line); padding: 0 0 0 24px; min-height: 100%; }
}

/* Навлог */
.navlog { display: block; }
.navlog .hint { margin-bottom: 14px; }
.navlog-scroll { overflow-x: auto; }
.navlog-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 15px; }
.navlog-table th, .navlog-table td { border: 1px solid var(--line); padding: 4px; text-align: center; vertical-align: top; }
.navlog-table thead th { font-size: 13px; line-height: 1.2; background: var(--bg); padding: 6px 4px; }
.navlog-table input[type="text"] { min-width: 4.2em; padding: 6px; text-align: center; }
.navlog-table [data-leg-input="wind"] { min-width: 6em; }
.navlog-table .cell-out, .navlog-table .total-cell { font-weight: 700; white-space: nowrap; vertical-align: middle; }
.navlog-table .cell-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.navlog-table .error { font-size: 12px; text-align: left; min-width: 9em; }
.no-wind { display: block; font-size: 12px; color: var(--muted); }
.total-row th { text-align: right; padding-right: 10px; }
.navlog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 16px 0; }
.navlog .disclaimer { border-top: 1px solid var(--line); padding-top: 12px; }

button { font: inherit; min-height: 44px; border-radius: 6px; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
button:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.primary { padding: 8px 18px; font-weight: 700; color: var(--accent-ink); background: var(--accent); border: 0; }
.secondary { padding: 8px 18px; font-weight: 700; color: var(--accent); background: transparent; border: 2px solid var(--accent); }
.remove { padding: 4px 10px; font-size: 14px; color: var(--accent); background: none; border: 1px solid var(--line); }

/* Навлог на телефоне: этап — карточка, поля с подписями */
@media screen and (max-width: 759px) {
  .navlog-table, .navlog-table tbody, .navlog-table tfoot { display: block; }
  .navlog-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .navlog-table tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 12px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
  .navlog-table th, .navlog-table td { display: block; border: 0; padding: 0; text-align: left; }
  .navlog-table .cell-label { position: static; width: auto; height: auto; overflow: visible; clip-path: none; display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; white-space: normal; }
  .navlog-table .cell-leg { grid-column: 1 / -1; font-size: 16px; font-weight: 750; display: flex; gap: 6px; align-items: baseline; }
  .navlog-table .cell-leg .cell-label { display: inline; font-size: 16px; color: var(--ink); }
  .navlog-table .cell-out { font-size: 17px; }
  .navlog-table input[type="text"] { min-width: 0; text-align: left; background: var(--surface); }
  .navlog-table .error { min-width: 0; }
  .navlog-table .cell-action { grid-column: 1 / -1; }
  .total-row th { grid-column: 1 / -1; text-align: left; font-size: 16px; padding: 0; }
  .total-gap { display: none !important; }
  .navlog-scroll { overflow: visible; }
}

/* Статьи */
.table-scroll { overflow-x: auto; margin: 12px 0; }
table { border-collapse: collapse; width: 100%; background: var(--surface); font-variant-numeric: tabular-nums; }
.table-scroll th, .table-scroll td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
caption { text-align: left; color: var(--muted); font-size: 15px; padding-bottom: 6px; }
.formula { background: var(--surface); border-left: 4px solid var(--accent); padding: 10px 14px; margin: 10px 0; overflow-wrap: anywhere; }
.related { padding-left: 20px; }
.related li { margin: 6px 0; }
.legal { max-width: 70ch; }

.site-footer { margin-top: 56px; padding: 20px 0 32px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.footer-row { display: grid; gap: 8px; }
.footer-note { margin: 0; max-width: 80ch; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0 16px; }
.site-footer a { display: inline-block; padding: 10px 0; }

/* Печать навлога: только таблица этапов и итог на Letter, поля этапов печатаются со значениями */
@page { size: letter landscape; margin: 0.4in; }

@media print {
  :root { --bg: #ffffff; --surface: #ffffff; --ink: #000000; --muted: #333333; --line: #777777; --accent: #000000; }
  body { font-size: 10pt; }
  .site-header, .site-footer { display: none !important; }
  .navlog-page > :not(h1):not(.navlog) { display: none !important; }
  .navlog-page h1 { font-size: 16pt; margin: 0 0 8pt; }
  .navlog { border: 0; padding: 0; }
  .navlog > h2, .navlog > .hint, .navlog .disclaimer, .navlog-actions, .navlog noscript, .cell-action, .navlog-table thead th:last-child, .total-gap:last-child { display: none !important; }
  .navlog-scroll { overflow: visible; }
  .navlog-table { font-size: 10pt; }
  .navlog-table input[type="text"] { border: 0; background: none; padding: 0; min-height: 0; min-width: 0; text-align: center; font-size: 10pt; }
  .navlog-table input::placeholder { color: transparent; }
  .navlog-table tr { break-inside: avoid; }
}
