:root {
  --bg: #0a0e15;
  --panel: #121926;
  --panel-soft: #0f1521;
  --line: #212d40;
  --line-soft: #1a2434;
  --text: #e7edf7;
  --muted: #8ba0bd;
  --faint: #63758f;

  --sun: #f5b544;
  --vitd: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --sky: #58c4f0;

  --radius: 14px;
  --radius-sm: 9px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 88% -14%, rgba(245, 181, 68, 0.13), transparent),
    radial-gradient(700px 360px at 4% -6%, rgba(88, 196, 240, 0.08), transparent),
    var(--bg);
  font-family: "Segoe UI", "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.page {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 0.9rem 0.9rem 2.5rem;
  display: grid;
  gap: 0.75rem;
}

/* ---------- верхняя панель ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding-top: 0.3rem;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.15rem, 4.6vw, 1.5rem);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #0d1420;
  color: var(--muted);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  color: var(--text);
  border-color: #33465f;
}

#info-open {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
}

/* ---------- строка контекста ---------- */

.context-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.6rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: linear-gradient(168deg, var(--panel), var(--panel-soft));
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.context-bar:hover {
  border-color: #33465f;
}

.context-place {
  font-weight: 600;
}

.context-meta {
  color: var(--faint);
  font-size: 0.83rem;
}

/* ---------- выбор времени старта ---------- */

.start-picker {
  border: 1px solid var(--line);
  background: linear-gradient(168deg, var(--panel), var(--panel-soft));
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem 0.6rem;
  display: grid;
  gap: 0.45rem;
}

.start-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.start-head label {
  font-size: 0.83rem;
  color: var(--muted);
}

.start-head input[type="time"] {
  width: auto;
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0.28rem 0.5rem;
}

.start-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.exposure-row {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.45rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line-soft);
}

.exposure-row > label {
  font-size: 0.83rem;
  color: var(--muted);
}

/* ---------- вкладки ---------- */

.tabs {
  display: flex;
  gap: 0.35rem;
}

.tab-btn {
  flex: 1;
  border: 1px solid var(--line);
  background: #0d1420;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.48rem 0.6rem;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  color: #10161f;
  background: var(--sun);
  border-color: var(--sun);
  font-weight: 600;
}

/* ---------- панели ---------- */

.view {
  display: grid;
  gap: 0.75rem;
}

.panel {
  background: linear-gradient(168deg, var(--panel), var(--panel-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 0.95rem;
}

.panel h2 {
  margin: 0 0 0.6rem;
  font-size: 0.98rem;
  font-weight: 600;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.panel-head h2 {
  margin: 0;
}

/* ---------- карточки итога ---------- */

.headline {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem;
}

.headline-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(168deg, var(--panel), var(--panel-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.75rem 0.75rem 0.9rem;
  display: grid;
  gap: 0.15rem;
  align-content: start;
}

.headline-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--muted);
}

.headline-card.accent::before { background: var(--sky); }
.headline-card.good::before { background: var(--vitd); }
.headline-card.warn::before { background: var(--warn); }
.headline-card.danger::before { background: var(--danger); }

.card-label {
  font-size: 0.72rem;
  color: var(--faint);
}

.card-value {
  font-size: 1.4rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.card-note {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---------- тексты ---------- */

.status {
  margin: 0;
  font-size: 0.83rem;
  color: var(--faint);
  padding-left: 0.15rem;
  min-height: 1.2em;
}

.status.error {
  color: var(--danger);
}

.summary {
  margin: 0;
  font-size: 0.89rem;
  color: var(--muted);
}

.uva-note {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--faint);
}

.uva-note.costly {
  color: var(--warn);
}

.link-btn {
  margin-top: 0.55rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--sky);
  font: inherit;
  font-size: 0.83rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.chart-caption {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  color: var(--faint);
  line-height: 1.45;
}

/* ---------- окна дня ---------- */

.window-group {
  margin-bottom: 0.95rem;
}

.window-group:last-child {
  margin-bottom: 0;
}

.group-title {
  font-size: 0.76rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.group-explainer {
  margin: 0.15rem 0 0.5rem;
  font-size: 0.78rem;
  color: var(--faint);
  line-height: 1.45;
}

.window-row {
  display: grid;
  gap: 0.2rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.026);
  border: 1px solid var(--line-soft);
  margin-bottom: 0.35rem;
}

.window-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.window-row .range {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}

.window-row .meta {
  color: var(--faint);
  font-size: 0.79rem;
  line-height: 1.4;
}

.window-row.flagged {
  border-color: rgba(251, 191, 36, 0.32);
}

.empty {
  color: var(--faint);
  font-size: 0.83rem;
  font-style: italic;
  margin: 0;
}

.uv-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  color: #10161f;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- факты ---------- */

.facts {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.45rem 0.8rem;
  font-size: 0.85rem;
}

.facts dt {
  color: var(--faint);
}

.facts dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.facts dd small {
  display: block;
  color: var(--faint);
  font-size: 0.73rem;
  font-variant-numeric: normal;
  line-height: 1.35;
}

/* ---------- графики ---------- */

.chart-wrap {
  width: 100%;
}

canvas {
  width: 100%;
  display: block;
}

#timeline { height: 220px; }
#curves { height: 240px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
}

.swatch.vitd { background: rgba(74, 222, 128, 0.55); }
.swatch.optimal { background: rgba(245, 181, 68, 0.75); }
.swatch.soft { background: rgba(88, 196, 240, 0.5); }

.line {
  width: 15px;
  height: 2.5px;
  border-radius: 2px;
}

.line.uvi { background: var(--danger); }
.line.vitd { background: var(--vitd); }

/* ---------- диапазон дат ---------- */

.range-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.range-grid {
  display: grid;
  gap: 0.5rem;
}

.day-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  background: rgba(255, 255, 255, 0.022);
  display: grid;
  gap: 0.25rem;
}

.day-card h3 {
  margin: 0;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.day-card p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.day-card .row-label {
  color: var(--faint);
}

/* ---------- шторки ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 14, 0.72);
  backdrop-filter: blur(2px);
}

.sheet-body {
  position: relative;
  width: min(640px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 0.9rem 1rem 1.4rem;
  display: grid;
  gap: 0.9rem;
  animation: slide-up 0.2s ease;
}

@keyframes slide-up {
  from { transform: translateY(14px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: -0.9rem;
  background: var(--panel);
  padding: 0.3rem 0 0.5rem;
  margin: -0.3rem 0 0;
  z-index: 1;
}

.sheet-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.sheet-section {
  display: grid;
  gap: 0.5rem;
}

.block-title {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}

/* ---------- проза справки ---------- */

.prose {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.62;
}

.prose h3 {
  margin: 0.5rem 0 -0.2rem;
  font-size: 0.92rem;
  color: var(--text);
}

.prose p {
  margin: 0;
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- формы ---------- */

label.stack,
.coord-row label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  background: #0c121c;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.55rem 0.6rem;
  font: inherit;
  font-size: 16px; /* меньше 16px iOS зумит поле при фокусе */
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--sun);
  box-shadow: 0 0 0 3px rgba(245, 181, 68, 0.16);
}

input[type="range"] {
  padding: 0;
  border: none;
  background: transparent;
  accent-color: var(--sun);
  height: 26px;
  cursor: pointer;
}

.coord-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.tz-chip {
  font-size: 0.76rem;
  color: var(--faint);
  background: rgba(88, 196, 240, 0.08);
  border: 1px solid rgba(88, 196, 240, 0.18);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  justify-self: start;
}

.hint {
  margin: -0.1rem 0 0;
  font-size: 0.77rem;
  color: var(--faint);
  min-height: 1.05em;
}

.slider-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.slider-line output {
  font-variant-numeric: tabular-nums;
  font-size: 0.84rem;
  color: var(--muted);
  min-width: 3rem;
  text-align: right;
}

.search-wrap {
  position: relative;
}

.city-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: #0d1521;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.55);
  max-height: 240px;
  overflow-y: auto;
}

.city-results li {
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
}

.city-results li:hover {
  background: rgba(245, 181, 68, 0.14);
}

.city-results .place-sub {
  color: var(--faint);
  font-size: 0.79rem;
}

.primary-btn {
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, #f8c25f, var(--sun));
  color: #14181f;
  font: inherit;
  font-weight: 650;
  font-size: 0.95rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: #0d1420;
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.ghost-btn:hover {
  color: var(--text);
  border-color: #33465f;
}

.wide {
  width: 100%;
}

.hidden {
  display: none !important;
}

/* ---------- широкие экраны ---------- */

@media (min-width: 620px) {
  .page {
    padding: 1.4rem 1.2rem 3rem;
    gap: 0.9rem;
  }
  .headline {
    grid-template-columns: repeat(4, 1fr);
  }
  .card-value {
    font-size: 1.5rem;
  }
  .sheet {
    align-items: center;
  }
  .sheet-body {
    border-radius: 18px;
    max-height: 86vh;
  }
  .range-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

a.icon-btn {
  text-decoration: none;
}
