/* Небо Києва — implements "Nebo Kyiv.dc.html", turn 2 (polished 1a).
   Dark palette is the design's; light palette comes from direction 1b. */

:root {
  --bg: #0e1420;
  --card: #161e2e;
  --text: #e8edf5;
  --muted: #8b95a8;
  --faint: #5d6778;
  --accent: #ffd34d;
  --on-accent: #0e1420;
  --good: #7fd18b;
  --bar: #31405c;
  --seg-on-bg: #31405c;
  --seg-on-fg: #e8edf5;
  --tgl-off: #2a3447;
  --knob-off: #5d6778;
  --divider: rgba(255, 255, 255, .05);
  --h0: #1b2433;
  --h1: #6e3a35;
  --h2: #9c453c;
  --h3: #c74f41;
  --h4: #ef5a46;
  --day-hit-fg: #ffe9e6;
  --page: #090d15;
}

:root[data-theme="light"] {
  --bg: #faf7f0;
  --card: #f1ecdf;
  --text: #26251f;
  --muted: #8c8674;
  --faint: #a89f8b;
  --accent: #3f7fd1;
  --on-accent: #faf7f0;
  --good: #3f7fd1;
  --bar: #d8cfba;
  --seg-on-bg: #e6e0d2;
  --seg-on-fg: #26251f;
  --tgl-off: #d8cfba;
  --knob-off: #8c8674;
  --divider: rgba(0, 0, 0, .06);
  --h0: #efe9dc;
  --h1: #e5b9a0;
  --h2: #d98f6e;
  --h3: #c96844;
  --h4: #b34324;
  --day-hit-fg: #fff6ef;
  --page: #efeade;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--page);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.disp { font-family: 'Unbounded', sans-serif; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  user-select: none;
}

#app {
  max-width: 428px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
}

.screen {
  min-height: 100dvh;
  padding: calc(8px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: screen-in .18s ease;
}

.screen.settings { gap: 16px; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- main: header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  font-family: 'Unbounded', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .18em;
}

.iconbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin: -8px;
  border-radius: 50%;
}

/* ---------- main: hero ---------- */

.hero { text-align: center; padding: 10px 0 2px; }
.hero-num { font-size: 92px; font-weight: 800; line-height: 1; color: var(--accent); }
.hero-sub { font-size: 16px; font-weight: 500; margin-top: 10px; }
.hero-cap { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- cards ---------- */

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px 16px;
}

.last-card { display: flex; flex-direction: column; gap: 10px; }
.last-head { display: flex; justify-content: space-between; align-items: baseline; }
.last-date { font-size: 13px; font-weight: 600; }
.last-nums { display: flex; gap: 24px; }
.last-num { font-size: 22px; font-weight: 600; }
.last-unit { font-size: 12px; color: var(--muted); margin-left: 6px; }

.kicker {
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ---------- map section ---------- */

.map-sec, .cal-wrap, .heat-wrap { display: flex; flex-direction: column; gap: 10px; }
.map-head { display: flex; justify-content: space-between; align-items: center; }

.seg {
  display: flex;
  gap: 4px;
  background: var(--card);
  border-radius: 100px;
  padding: 3px;
}

.seg button {
  font-size: 11px;
  padding: 3px 12px;
  border-radius: 100px;
  color: var(--muted);
}

.seg button.on {
  font-weight: 600;
  background: var(--accent);
  color: var(--on-accent);
}

.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 5px);
  grid-auto-columns: 5px;
  gap: 1.5px;
}

.hm-c { border-radius: 1px; }
.l0 { background: var(--h0); }
/* days before the documented range: an empty slot, not a calm day */
.nd { background: transparent; box-shadow: inset 0 0 0 1px var(--h0); }
.l1 { background: var(--h1); }
.l2 { background: var(--h2); }
.l3 { background: var(--h3); }
.l4 { background: var(--h4); }

.heat-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--faint);
}

.legend { display: flex; align-items: center; gap: 3px; }
.legend i { width: 7px; height: 7px; border-radius: 1px; display: block; }

/* month calendar */

.cal-head { display: flex; justify-content: space-between; align-items: center; }
.cal-title { font-size: 13px; font-weight: 600; }
.cal-nav { color: var(--muted); font-size: 18px; padding: 0 8px; }
.cal-nav:disabled { opacity: .35; cursor: default; }

.cal-week, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-week { font-size: 10px; color: var(--faint); text-align: center; }

.cal-note { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--faint); }
.cal-note i { width: 7px; height: 7px; border-radius: 1px; display: block; }

.cal-c {
  aspect-ratio: 1;
  border-radius: 9px;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
}

.cal-c.blank { background: transparent; }
.cal-c.nd { background: transparent; box-shadow: inset 0 0 0 1px var(--card); color: var(--faint); }
.cal-c.hit { color: var(--day-hit-fg); }
.cal-c.l1 { background: var(--h1); }
.cal-c.l2 { background: var(--h2); }
.cal-c.l3 { background: var(--h3); }
.cal-c.l4 { background: var(--h4); }

/* ---------- stats ---------- */

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-num { font-size: 22px; font-weight: 600; }
.stat-num.acc { color: var(--accent); }
.stat-num.good { color: var(--good); }
.stat-num.bad { color: var(--h4); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- trend ---------- */

.trend { display: flex; flex-direction: column; gap: 8px; }
.trend-chart { display: flex; align-items: flex-end; gap: 5px; height: 86px; }
.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}
.trend-bar { width: 100%; border-radius: 3px; background: var(--bar); }
.trend-bar.nd { background: transparent; box-shadow: inset 0 0 0 1px var(--h0); }
.trend-lbl { font-size: 9px; color: var(--faint); }

/* ---------- settings ---------- */

.set-top { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.set-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .06em;
}

.group { display: flex; flex-direction: column; gap: 8px; }
.group-label {
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--muted);
  text-transform: uppercase;
  padding-left: 4px;
}

.group-card { background: var(--card); border-radius: 16px; overflow: hidden; }

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  width: 100%;
  text-align: left;
}

.row:not(:last-child) { border-bottom: 1px solid var(--divider); }

.row-label { font-size: 14px; font-weight: 500; }
.row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row-val { font-size: 13px; color: var(--muted); }
.row-end { display: flex; align-items: center; gap: 8px; }
.chevron { color: var(--faint); font-size: 16px; }

.tgl {
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 100px;
  background: var(--tgl-off);
  position: relative;
  transition: background .15s;
}

.tgl::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--knob-off);
  transition: left .15s, background .15s;
}

.tgl.on { background: var(--accent); }
.tgl.on::after { left: 21px; background: var(--on-accent); }

.seg2 {
  display: flex;
  gap: 3px;
  background: var(--bg);
  border-radius: 100px;
  padding: 3px;
}

.seg2 button {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 100px;
  color: var(--muted);
}

.seg2 button.on { background: var(--seg-on-bg); color: var(--seg-on-fg); }

/* ---------- day detail sheet ---------- */

.sheet-veil {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 5;
  animation: veil-in .18s ease;
}

.sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 428px;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 6;
  animation: sheet-in .22s ease;
}

@keyframes veil-in { from { opacity: 0; } }
@keyframes sheet-in { from { transform: translate(-50%, 24px); opacity: 0; } }

.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; }
.sheet-title { font-size: 16px; font-weight: 700; margin-top: 4px; }
.sheet-time { color: var(--muted); font-weight: 500; }
.sheet-close { color: var(--muted); font-size: 24px; line-height: 1; padding: 0 2px; }

.sheet-cas { display: flex; gap: 16px; font-size: 13px; font-weight: 600; }
.sheet-cas .cas-bad { color: var(--h4); }

.sheet-sites { font-size: 12px; color: var(--muted); line-height: 1.6; }

.sheet-src { display: flex; flex-wrap: wrap; gap: 8px; }
.src {
  font-size: 12px;
  color: var(--accent);
  background: var(--card);
  padding: 6px 10px;
  border-radius: 8px;
  text-decoration: none;
}

/* tappable calendar cells and last-attack card */
button.cal-c { cursor: pointer; }
button.last-card { display: flex; text-align: left; width: 100%; }
.last-date .chevron { color: var(--muted); }
