/*
 * Светлая тема по умолчанию: сервисом пользуются на улице, а тёмный экран на
 * ярком солнце читается хуже. Тема остаётся светлой независимо от настройки системы.
 */
:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #f0ebe3;
  --line: #e7e0d5;
  --text: #1c1a17;
  --muted: #625c53;
  --faint: #978f84;
  --accent: #e07b12;
  --accent-soft: #fdf0de;

  --good: #178a4c;
  --good-soft: #e3f4ea;
  --warn: #c56a00;
  --warn-soft: #fdf1dd;
  --bad: #cf2e2e;
  --bad-soft: #fde6e4;
  --calm: #4a6a8c;
  --calm-soft: #e8eef5;
  --night: #4b4f7a;
  --night-soft: #e9e9f4;

  --shadow: 0 1px 2px rgba(60, 45, 20, 0.05), 0 6px 20px rgba(60, 45, 20, 0.06);
  --radius: 20px;
  color-scheme: light;
}


* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

button {
  font: inherit;
  color: inherit;
}

.app {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
}

.label {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- шапка ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.place {
  flex: 1;
  min-width: 0;
  display: grid;
  text-align: left;
  border: none;
  background: none;
  padding: 4px 2px;
  cursor: pointer;
}

.place-name {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.place-name::after {
  content: " ›";
  color: var(--faint);
  font-weight: 400;
}

.place-sub {
  font-size: 0.85rem;
  color: var(--muted);
}

.round {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.round:hover {
  color: var(--text);
}

/* ---------- главный ответ ---------- */

.hero {
  --tone: var(--calm);
  --tone-soft: var(--calm-soft);
  border-radius: 26px;
  padding: 20px 20px 18px;
  background: var(--tone-soft);
  border: 1px solid color-mix(in srgb, var(--tone) 22%, transparent);
  display: grid;
  gap: 2px;
  transition: background 0.25s ease;
}

.hero[data-kind="good"] { --tone: var(--good); --tone-soft: var(--good-soft); }
.hero[data-kind="caution"] { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.hero[data-kind="harsh"] { --tone: var(--bad); --tone-soft: var(--bad-soft); }
.hero[data-kind="weak"] { --tone: var(--calm); --tone-soft: var(--calm-soft); }
.hero[data-kind="night"] { --tone: var(--night); --tone-soft: var(--night-soft); }

.uv-badge {
  justify-self: start;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  margin-bottom: 10px;
}

.hero-kicker {
  margin: 0;
  font-size: 1.05rem;
  color: var(--muted);
}

.hero-main {
  margin: 0;
  font-size: clamp(2.6rem, 14vw, 3.6rem);
  line-height: 1.02;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--tone);
  font-variant-numeric: tabular-nums;
}

.hero-main.text {
  font-size: clamp(1.9rem, 9vw, 2.4rem);
  letter-spacing: -0.025em;
}

.hero-main small {
  font-size: 0.42em;
  font-weight: 700;
  letter-spacing: 0;
  margin-left: 4px;
}

.hero-sub {
  margin: 4px 0 0;
  font-size: 1rem;
  color: var(--text);
}

.hero-sub:empty {
  display: none;
}

/* Полоса сеанса: польза, запас, пора в тень, ожог */
.session {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.session[hidden] {
  display: none;
}

.session-bar {
  position: relative;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: var(--surface);
}

.seg {
  height: 100%;
}

.seg.vitd { background: var(--good); }
.seg.ok { background: color-mix(in srgb, var(--good) 35%, var(--surface)); }
.seg.shade { background: var(--warn); }
.seg.burn { background: var(--bad); }

.session-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.session-list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 0.97rem;
}

.session-list .dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translateY(1px);
}

.dot.vitd { background: var(--good); }
.dot.shade { background: var(--warn); }
.dot.burn { background: var(--bad); }
.dot.none { background: var(--faint); }

.session-list .what {
  flex: 1;
}

.session-list .when {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

.session-list .when small {
  display: block;
  font-size: 0.82em;
  color: var(--faint);
}

.hero-hint {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface);
  font-size: 0.92rem;
  color: var(--text);
}

.hero-hint[hidden] {
  display: none;
}

/* ---------- карточки ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* ---------- когда выходите ---------- */

.when-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.when-time {
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.when-head .chip {
  margin-left: auto;
  align-self: center;
}

.sun-hill {
  position: relative;
  height: 76px;
  margin-top: 10px;
}

/*
 * Бегунок ползунка ходит не от края до края, а с отступом в половину своей
 * ширины. Холм сдвинут на те же 13px, чтобы бегунок стоял точно над своим
 * временем, а не уезжал к краям.
 */
.sun-hill svg {
  position: absolute;
  inset: 0 13px;
  width: calc(100% - 26px);
  height: 100%;
  overflow: visible;
}

.hill-base {
  stroke: var(--line);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.hill-best {
  fill: var(--good);
  opacity: 0.1;
}

.hill-cursor {
  stroke: var(--text);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

/* Ползунок лежит поверх холма: дорожка прозрачная, виден только бегунок. */
#start-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  touch-action: pan-y;
}

#start-slider::-webkit-slider-runnable-track {
  height: 100%;
  background: transparent;
}

#start-slider::-moz-range-track {
  height: 100%;
  background: transparent;
}

#start-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  margin-top: calc(76px - 13px);
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

#start-slider::-moz-range-thumb {
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--text);
  transform: translateY(38px);
}

#start-slider:focus-visible::-webkit-slider-thumb {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

.hill-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  padding: 0 2px;
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.when-note {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--faint);
}

/* ---------- лучшее время ---------- */

.best {
  display: grid;
  gap: 2px;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.best:hover {
  border-color: color-mix(in srgb, var(--good) 40%, var(--line));
}

.best-value {
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.015em;
  color: var(--good);
  font-variant-numeric: tabular-nums;
}

.best-sub {
  font-size: 0.9rem;
  color: var(--muted);
}

.best.disabled {
  cursor: default;
}

.best.disabled .best-value {
  color: var(--muted);
  font-size: 1.05rem;
}

/* ---------- чипы ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.92rem;
  cursor: pointer;
  line-height: 1.2;
}

.chip[aria-checked="true"],
.chip.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 600;
}

.date-chip {
  position: relative;
  overflow: hidden;
}

.date-chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ---------- низ ---------- */

.status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.88rem;
  color: var(--bad);
  text-align: center;
}

.foot {
  padding: 6px 4px 0;
  font-size: 0.82rem;
  color: var(--faint);
  display: grid;
  gap: 8px;
}

.foot p {
  margin: 0;
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-size: inherit;
}

/* ---------- шторки ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet[hidden] {
  display: none;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 12, 8, 0.45);
}

.sheet-body {
  position: relative;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 8px 18px max(22px, env(safe-area-inset-bottom));
  display: grid;
  gap: 20px;
  animation: rise 0.2s ease;
}

@keyframes rise {
  from { transform: translateY(20px); opacity: 0.5; }
  to { transform: none; opacity: 1; }
}

.sheet-head {
  position: sticky;
  top: -8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  padding: 12px 0 6px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

.sheet-section {
  display: grid;
  gap: 10px;
}

.sheet-section h3 {
  margin: 0;
  font-size: 1rem;
}

.sheet-section .chips {
  margin-top: 0;
}

.sheet-note {
  margin: -4px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

input[type="search"],
input[type="number"] {
  width: 100%;
  font: inherit;
  font-size: 16px; /* меньше 16px iOS зумит поле при фокусе */
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
}

.search {
  position: relative;
}

.city-results {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
  max-height: 260px;
  overflow-y: auto;
}

.city-results[hidden] {
  display: none;
}

.city-results li {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.city-results li:hover {
  background: var(--surface-2);
}

.city-results .sub {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.wide-button {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font-weight: 600;
}

.coords summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

.coord-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.coord-row label {
  display: grid;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.skins {
  display: grid;
  gap: 8px;
}

.skin {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.skin[aria-checked="true"] {
  border-color: var(--text);
}

.skin-tone {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.skin-text {
  display: grid;
}

.skin-text strong {
  font-size: 0.98rem;
}

.skin-text span {
  font-size: 0.84rem;
  color: var(--muted);
}

.done {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 16px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.prose {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.prose h3 {
  margin: 8px 0 -4px;
  color: var(--text);
  font-size: 1rem;
}

.prose p {
  margin: 0;
}

.prose-link {
  padding-top: 6px;
}
