:root {
  --bg: var(--tg-theme-secondary-bg-color, #EDF1EF);
  --surface: var(--tg-theme-bg-color, #FFFFFF);
  --ink: var(--tg-theme-text-color, #15211D);
  --muted: var(--tg-theme-hint-color, #6B7A74);
  --line: rgba(120, 135, 130, .2);
  --line-soft: rgba(120, 135, 130, .11);

  --spruce: #0F6B58;
  --spruce-2: #3E9A82;
  --spruce-tint: #D5ECE4;
  --spruce-wash: #EAF5F1;
  --spruce-mid: #9FD3C1;
  --health: #2B79A8;
  --sun: #F0A23B;
  --sun-deep: #DD8216;
  --sun-tint: #FCEACB;
  --iris: #6D55D0;
  --iris-tint: #E8E3FB;
  --coral: #D9463E;
  --coral-tint: #FBE0DD;
  --amber: #E2AE34;
  --slate: #9AA8A3;

  --r-l: 20px;
  --r-m: 14px;
  --r-s: 9px;
  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

:root[data-scheme="dark"] {
  --bg: var(--tg-theme-secondary-bg-color, #0E1513);
  --surface: var(--tg-theme-bg-color, #18211E);
  --ink: var(--tg-theme-text-color, #E8EFEC);
  --muted: var(--tg-theme-hint-color, #8A9A94);
  --line: rgba(160, 175, 170, .18);
  --line-soft: rgba(160, 175, 170, .09);
  --spruce: #45BC9F;
  --spruce-2: #2F8F78;
  --spruce-tint: #18403A;
  --spruce-wash: #142D29;
  --spruce-mid: #24695B;
  --health: #6DB6E0;
  --sun: #F4B04F;
  --sun-deep: #F59E2B;
  --sun-tint: #3E2D15;
  --iris: #A08CF5;
  --iris-tint: #2B2548;
  --coral: #F2675C;
  --coral-tint: #46211E;
  --amber: #E9BE52;
  --slate: #66746F;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.45 var(--font);
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--spruce); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }

#app { max-width: 760px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 12px); }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  padding: 10px 16px 0;
}
@supports not (background: color-mix(in srgb, red, blue)) { .top { background: var(--bg); } }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand svg { width: 34px; height: 34px; color: var(--spruce); flex: none; }
.brand strong { display: block; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.brand span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-pill {
  flex: none; font-size: 12.5px; font-weight: 600; padding: 6px 11px; border-radius: 99px;
  background: var(--sun-tint); color: var(--sun-deep);
}
.status-pill.approved { background: var(--spruce-tint); color: var(--spruce); }

.depts { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 10px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.depts::-webkit-scrollbar { display: none; }
.depts button {
  flex: none; display: flex; align-items: center; gap: 6px; padding: 7px 12px 7px 10px; border-radius: 99px;
  background: var(--surface); font-size: 13.5px; font-weight: 500; white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--line-soft);
  transition: background .15s, color .15s;
}
.depts button .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--spruce-2); }
.depts button .dot.bad { background: var(--coral); }
.depts button.on { background: var(--ink); color: var(--surface); box-shadow: none; }

/* ---------- layout ---------- */
#view { padding: 4px 16px 24px; outline: none; }
.section { margin-top: 26px; }
.section:first-child { margin-top: 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 10px; }
.section-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.section-head .aside { font-size: 13px; color: var(--muted); }
.section-head button.aside { color: var(--link, var(--spruce)); font-weight: 500; }
.lead { color: var(--muted); font-size: 13.5px; margin: -4px 4px 12px; max-width: 60ch; }

.group { background: var(--surface); border-radius: var(--r-l); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; position: relative; text-align: left; width: 100%; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--line-soft); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; font-size: 15px; }
.row .sub { color: var(--muted); font-size: 13px; margin-top: 1px; }
.row .end { flex: none; text-align: right; font-size: 13.5px; color: var(--muted); }
.row.tap:active { background: var(--line-soft); }
.chev { width: 8px; height: 13px; flex: none; color: var(--slate); }

/* ---------- hero: ватерлиния ---------- */
.hero { margin: 6px -16px 0; padding: 18px 16px 6px; position: relative; }
.hero h1 { font-size: 27px; line-height: 1.12; font-weight: 800; letter-spacing: -.025em; max-width: 15em; }
.hero h1 .soft { color: var(--muted); font-weight: 600; }
.hero .verdict { margin-top: 8px; font-size: 14.5px; color: var(--muted); max-width: 46ch; }
.hero .verdict b { color: var(--ink); font-weight: 600; }
.tide { margin-top: 14px; position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.tide svg { width: 100%; height: auto; overflow: visible; }
.tide .lbl { font-size: 10.5px; fill: var(--muted); font-family: var(--font); }
.tide .lbl-strong { font-size: 11px; font-weight: 700; font-family: var(--font); }
.tide-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin: 8px 2px 0; }
.tide-legend i { display: inline-block; width: 14px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
.tide-tip {
  position: absolute; top: 0; pointer-events: none; z-index: 3;
  background: var(--ink); color: var(--surface); border-radius: 12px; padding: 8px 11px;
  font-size: 12.5px; line-height: 1.35; min-width: 150px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  transform: translateX(-50%); white-space: nowrap;
}
.tide-tip b { font-weight: 700; }
.tide-tip .bad { color: #FF9B92; }
.mini-tide { padding: 10px 0 2px; }
.mini-tide + .mini-tide { border-top: 1px solid var(--line-soft); }
.mini-tide header { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.mini-tide header span { font-weight: 500; color: var(--muted); font-size: 12.5px; }
.mini-tide header .bad { color: var(--coral); font-weight: 600; }

/* ---------- figures row ---------- */
.figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; background: var(--surface); border-radius: var(--r-l); padding: 14px 4px; }
.figures div { padding: 0 12px; border-left: 1px solid var(--line-soft); }
.figures div:first-child { border-left: 0; }
.figures b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.figures span { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.25; }
.figures .bad b { color: var(--coral); }
@media (max-width: 420px) {
  .figures { grid-template-columns: repeat(2, 1fr); row-gap: 14px; }
  .figures div:nth-child(3) { border-left: 0; }
}

/* ---------- attention ---------- */
.alert { background: var(--surface); border-radius: var(--r-l); padding: 14px 16px 12px; position: relative; overflow: hidden; }
.alert + .alert { margin-top: 10px; }
.alert::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--coral); }
.alert.soft::before { background: var(--amber); }
.alert h3 { font-size: 15.5px; font-weight: 700; display: flex; justify-content: space-between; gap: 10px; }
.alert h3 span { font-size: 13px; color: var(--coral); font-weight: 700; white-space: nowrap; }
.alert .when { font-size: 13px; color: var(--muted); margin-top: 2px; }
.alert .who { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.alert .who .chip, .sheet .chip { white-space: normal; text-align: left; line-height: 1.3; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 4px 9px; border-radius: 99px; background: var(--bg); white-space: nowrap; }
.chip.law { background: var(--iris-tint); color: var(--iris); font-weight: 500; }
.chip.sun { background: var(--sun-tint); color: var(--sun-deep); font-weight: 500; }
.chip.coral { background: var(--coral-tint); color: var(--coral); font-weight: 500; }
.chip.spruce { background: var(--spruce-tint); color: var(--spruce); font-weight: 500; }
.recs { margin: 12px 0 0; padding: 0; list-style: none; }
.recs li { position: relative; padding-left: 22px; font-size: 13.5px; margin-top: 6px; }
.recs li::before { content: ""; position: absolute; left: 3px; top: 7px; width: 9px; height: 9px; border-radius: 3px; border: 2px solid var(--spruce); }

/* ---------- monthly ---------- */
.months { background: var(--surface); border-radius: var(--r-l); padding: 16px 14px 10px; }
.months svg { width: 100%; height: auto; }
.months .lbl { font-size: 10.5px; fill: var(--muted); font-family: var(--font); }

/* ---------- compliance ---------- */
.check .mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--spruce-tint); color: var(--spruce); }
.check .mark.no { background: var(--coral-tint); color: var(--coral); }
.check .mark svg { width: 14px; height: 14px; }
.law-ref { font-size: 12px; color: var(--iris); font-weight: 500; }

/* ---------- now ---------- */
.now { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.now::-webkit-scrollbar { display: none; }
.now div { flex: none; background: var(--surface); border-radius: var(--r-m); padding: 10px 14px; min-width: 104px; }
.now b { font-size: 20px; font-weight: 700; display: block; }
.now span { font-size: 12px; color: var(--muted); }

/* ---------- gantt ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 10px; }
.seg { display: inline-flex; background: var(--surface); border-radius: 11px; padding: 3px; box-shadow: inset 0 0 0 1px var(--line-soft); }
.seg button { padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--bg); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.gantt { background: var(--surface); border-radius: var(--r-l); overflow: hidden; position: relative; }
.gantt-scroll { overflow-x: auto; overflow-y: visible; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.g-inner { position: relative; }
.g-head, .g-row, .g-sect, .g-cover { display: flex; }
.g-name {
  position: sticky; left: 0; z-index: 4; flex: none; width: 132px; background: var(--surface);
  padding: 0 10px 0 12px; display: flex; flex-direction: column; justify-content: center; min-width: 0;
  box-shadow: 1px 0 0 var(--line-soft);
}
.g-name strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-name small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-name .badges { font-size: 11px; }
.g-head { position: sticky; top: 0; z-index: 5; height: 28px; background: var(--surface); border-bottom: 1px solid var(--line-soft); }
.g-head .g-name { font-size: 11.5px; color: var(--muted); }
.g-track { position: relative; flex: none; }
.g-month { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line-soft); font-size: 11px; color: var(--muted); padding: 6px 0 0 5px; white-space: nowrap; }
.g-row { height: 42px; border-top: 1px solid var(--line-soft); }
.g-row.tap .g-name:active { background: var(--bg); }
.g-sect { height: 30px; background: var(--bg); }
.g-sect .g-name { background: var(--bg); font-size: 12px; font-weight: 600; color: var(--muted); flex-direction: row; align-items: center; justify-content: flex-start; gap: 6px; width: auto; min-width: 132px; box-shadow: none; white-space: nowrap; }
.g-cover { height: 22px; border-bottom: 1px solid var(--line-soft); }
.g-cover .g-name { font-size: 11px; color: var(--muted); }
.g-grid { position: absolute; inset: 0; pointer-events: none; }
.g-grid i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line-soft); }
.g-grid i.hol { background: rgba(217, 70, 62, .35); }
.g-grid b { position: absolute; top: 0; bottom: 0; background: var(--line-soft); opacity: .55; }
.bar {
  position: absolute; top: 9px; height: 24px; border-radius: 6px; background: var(--sun);
  display: flex; align-items: center; padding: 0 6px; overflow: hidden; color: #3A2A0E;
  font-size: 11px; font-weight: 600; white-space: nowrap; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.05);
}
.bar.main { background: var(--sun-deep); color: #fff; }
.gantt.compact .bar { border-radius: 3px; padding: 0 3px; font-size: 10px; justify-content: center; }
.bar.legal { background: var(--iris); color: #fff; }
.bar.locked::after { content: ""; position: absolute; right: 4px; top: 4px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .7; }
.bar.fixed { background: repeating-linear-gradient(-45deg, var(--slate) 0 3px, transparent 3px 7px); color: var(--muted); cursor: default; box-shadow: inset 0 0 0 1px var(--line); }
.bar.sel { outline: 2px solid var(--ink); outline-offset: 1px; }
.cov-cell { position: absolute; top: 5px; height: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin: 10px 4px 0; }
.legend i { display: inline-block; width: 16px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

/* ---------- coverage heatmap ---------- */
.heat { background: var(--surface); border-radius: var(--r-l); padding: 6px 0 10px; }
.heat-row { padding: 10px 14px 4px; }
.heat-row + .heat-row { border-top: 1px solid var(--line-soft); }
.heat-row header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.heat-row header strong { font-size: 14px; font-weight: 600; }
.heat-row header small { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }
.heat-row header span { font-size: 13px; font-weight: 700; color: var(--spruce); white-space: nowrap; }
.heat-row header span.bad { color: var(--coral); }
.cells { display: grid; grid-template-columns: repeat(53, 1fr); gap: 2px; }
.cells button { height: 18px; border-radius: 3px; background: var(--line-soft); }
.cells button:active { transform: scale(1.25); }
.heat-months { display: grid; grid-template-columns: repeat(12, 1fr); font-size: 10.5px; color: var(--muted); padding: 2px 14px 0; }
.kind-tag { font-size: 11px; color: var(--muted); font-weight: 500; }
.scale { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin: 10px 4px 0; flex-wrap: wrap; }
.scale i { width: 18px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- people ---------- */
.search { position: relative; margin: 6px 0 10px; }
.search input {
  width: 100%; border: 0; border-radius: 12px; padding: 11px 14px 11px 38px; font: inherit; font-size: 15px;
  background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-soft);
}
.search svg { position: absolute; left: 12px; top: 12px; width: 18px; height: 18px; color: var(--muted); }
.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; }
.filters::-webkit-scrollbar { display: none; }
.filters button { flex: none; padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 500; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft); }
.filters button.on { background: var(--spruce); color: #fff; box-shadow: none; }
.ava {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: #fff; letter-spacing: .02em;
}
.year-strip { position: relative; height: 6px; border-radius: 3px; background: var(--line-soft); margin-top: 7px; overflow: hidden; }
.year-strip i { position: absolute; top: 0; bottom: 0; background: var(--sun); border-radius: 2px; }
.year-strip i.legal { background: var(--iris); }
.year-strip i.fixed { background: var(--slate); }
.risk-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }

/* ---------- sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(8, 14, 12, .42); z-index: 40; opacity: 0; transition: opacity .2s; }
.scrim.on { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; max-width: 760px; margin: 0 auto;
  background: var(--bg); border-radius: 22px 22px 0 0; transform: translateY(102%);
  transition: transform .28s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0,0,0,.18);
}
.sheet.on { transform: translateY(0); }
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 2px; flex: none; }
.sheet-body { overflow-y: auto; padding: 8px 16px calc(24px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.sheet-hero { display: flex; gap: 14px; align-items: center; padding: 8px 2px 4px; }
.sheet-hero .ava { width: 56px; height: 56px; font-size: 19px; }
.sheet-hero h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.sheet-hero p { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.sheet h3 { font-size: 15px; font-weight: 700; margin: 22px 4px 8px; }
.close-x { position: absolute; right: 14px; top: 12px; width: 30px; height: 30px; border-radius: 50%; background: var(--line-soft); display: grid; place-items: center; color: var(--muted); }

.balance { background: var(--surface); border-radius: var(--r-l); padding: 14px 16px; }
.balance-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line-soft); margin: 10px 0 8px; }
.balance-bar i { display: block; height: 100%; }
.balance-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); }
.balance-legend b { color: var(--ink); font-weight: 600; }
.balance-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.part { background: var(--surface); border-radius: var(--r-l); padding: 14px 16px; }
.part + .part { margin-top: 10px; }
.part header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.part header strong { font-size: 16px; font-weight: 700; }
.part header .chip { font-size: 12px; }
.part .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.reasons { list-style: none; padding: 0; margin: 10px 0 0; }
.reasons li { display: flex; gap: 10px; font-size: 13.5px; padding: 5px 0; line-height: 1.4; }
.reasons li i { flex: none; width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-style: normal; font-size: 12px; }
.r-law i { background: var(--iris-tint); color: var(--iris); }
.r-family i { background: #FDE3EC; color: #C2416C; }
.r-fair i, .r-habit i { background: var(--sun-tint); color: var(--sun-deep); }
.r-bonus i { background: var(--sun-tint); color: var(--sun-deep); }
.r-health i { background: #DFF0FA; color: #2B79A8; }
.r-cover i { background: var(--spruce-tint); color: var(--spruce); }
.r-warn i { background: var(--coral-tint); color: var(--coral); }
:root[data-scheme="dark"] .r-family i { background: #44202D; color: #F38DB0; }
:root[data-scheme="dark"] .r-health i { background: #17323F; color: #7CC3EA; }

.risk-bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 76px; margin-top: 12px; }
.risk-bars div { border-radius: 4px 4px 2px 2px; background: var(--spruce-2); position: relative; min-height: 3px; }
.risk-bars div.peak { background: var(--coral); }
.risk-months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; font-size: 10.5px; color: var(--muted); text-align: center; margin-top: 4px; }
.factor { display: flex; justify-content: space-between; font-size: 13.5px; padding: 7px 0; border-top: 1px solid var(--line-soft); }
.factor:first-of-type { border-top: 0; }
.factor span:last-child { color: var(--muted); }

.hist-year { display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 10px; padding: 7px 0; }
.hist-year span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.hist-track { position: relative; height: 14px; background: var(--line-soft); border-radius: 4px; }
.hist-track i { position: absolute; top: 2px; bottom: 2px; border-radius: 2px; min-width: 2px; }
.hist-track i.vac { background: var(--sun); }
.hist-track i.own { background: var(--coral); }
.hist-track i.family_care { background: #C2416C; }
.hist-track i.quarantine { background: #2B79A8; }
.hist-track i.injury { background: var(--slate); }

/* ---------- forms ---------- */
.field { background: var(--surface); border-radius: var(--r-l); padding: 14px 16px; }
.field + .field { margin-top: 10px; }
.field label { display: flex; justify-content: space-between; font-weight: 600; font-size: 14.5px; }
.field label b { color: var(--spruce); }
.field p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
input[type="range"] { width: 100%; margin: 12px 0 2px; accent-color: var(--spruce); }
.toggle { position: relative; width: 46px; height: 28px; flex: none; }
.toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .18s; }
.toggle span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.toggle input:checked + span { background: var(--spruce); }
.toggle input:checked + span::after { transform: translateX(18px); }
.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--bg); border-radius: 10px; padding: 2px; flex: none; }
.stepper button { width: 30px; height: 28px; border-radius: 8px; font-size: 18px; font-weight: 500; color: var(--spruce); }
.stepper button:active { background: var(--line-soft); }
.stepper output { min-width: 26px; text-align: center; font-weight: 700; font-size: 14px; }
.date-input { width: 100%; border: 0; font: inherit; font-size: 16px; padding: 11px 12px; border-radius: 11px; background: var(--bg); color: var(--ink); margin-top: 10px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; border-radius: 14px; font-weight: 600; font-size: 15.5px; background: var(--spruce); color: #fff; }
.btn:active { filter: brightness(.94); }
.btn.ghost { background: var(--surface); color: var(--spruce); box-shadow: inset 0 0 0 1px var(--line); }
.btn.warn { background: var(--coral); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.link-btn { margin-top: 8px; padding: 6px 0; color: var(--link, var(--spruce)); font-weight: 600; font-size: 14px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.preview { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--spruce-wash); font-size: 13.5px; }
.preview.bad { background: var(--coral-tint); }
.preview.mid { background: var(--sun-tint); }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-width: 760px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  box-shadow: 0 -1px 0 var(--line-soft);
}
@supports not (background: color-mix(in srgb, red, blue)) { .tabs { background: var(--surface); } }
.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 500; }
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--spruce); }
.tabs button.on svg { stroke-width: 2.2; }

/* ---------- boot / overlay ---------- */
.boot { min-height: 60vh; display: grid; place-content: center; text-align: center; gap: 18px; color: var(--muted); }
.boot-wave { width: 120px; height: 40px; margin: 0 auto; background:
  radial-gradient(circle at 85% 30%, var(--sun) 0 7px, transparent 8px),
  repeating-linear-gradient(90deg, var(--spruce) 0 2px, transparent 2px 6px);
  -webkit-mask: linear-gradient(transparent 55%, #000 55%); mask: linear-gradient(#000, #000);
  border-radius: 8px; opacity: .85; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.steps { list-style: none; margin: 8px 0 0; padding: 0; }
.steps li { display: flex; gap: 12px; align-items: center; padding: 9px 2px; font-size: 14.5px; color: var(--muted); transition: color .2s; }
.steps li i { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px var(--line); display: grid; place-items: center; }
.steps li.doing { color: var(--ink); font-weight: 600; }
.steps li.doing i { box-shadow: inset 0 0 0 2px var(--spruce); border-top-color: transparent; animation: spin .9s linear infinite; background: conic-gradient(var(--spruce) 0 25%, transparent 25%); -webkit-mask: radial-gradient(circle, transparent 7px, #000 7.5px); mask: radial-gradient(circle, transparent 7px, #000 7.5px); }
.steps li.done { color: var(--ink); }
.steps li.done i { background: var(--spruce); box-shadow: none; }
.steps li.done i::after { content: ""; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 14px); transform: translateX(-50%);
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 60;
  max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.empty { text-align: center; padding: 34px 20px; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); }
.coral { color: var(--coral); }
.spruce { color: var(--spruce); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 600px) {
  .hero h1 { font-size: 32px; }
  .g-name { width: 180px; }
  .g-sect .g-name { min-width: 180px; }
}

/* ---------- editor ---------- */
.form-card { background: var(--surface); border-radius: var(--r-l); padding: 2px 14px; }
.form-card.pad { padding: 12px 14px; }
.f { display: block; padding: 10px 0; border-top: 1px solid var(--line-soft); min-width: 0; }
.form-card > .f:first-child, .list-card > .f:first-of-type, .f-row .f { border-top: 0; }
.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border-top: 1px solid var(--line-soft); align-items: end; }
.form-card > .f-row:first-child, .list-card .f-row { border-top: 0; }
.f-row.three { grid-template-columns: 1fr 1fr 1fr; }
.f > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.f > span b { color: var(--ink); }
.f > small { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.35; }
.in {
  width: 100%; min-width: 0; border: 0; border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 15px;
  background: var(--bg); color: var(--ink); -webkit-appearance: none; appearance: none;
}
select.in { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input[type="date"].in { min-height: 42px; }
.f .seg { display: flex; width: 100%; }
.f .seg button { flex: 1; }
.list-card { background: var(--surface); border-radius: var(--r-l); padding: 8px 14px 6px; position: relative; margin-bottom: 10px; }
.list-card.compact { padding: 4px 40px 2px 14px; }
.list-card .seg { margin-right: 36px; }
.del-x { position: absolute; right: 10px; top: 10px; width: 28px; height: 28px; border-radius: 50%; background: var(--line-soft); color: var(--muted); font-size: 12px; z-index: 1; }
.list-card.compact .del-x { top: 50%; transform: translateY(-20%); }
.add-btn { width: 100%; padding: 12px; border-radius: 14px; border: 1.5px dashed var(--line); color: var(--link, var(--spruce)); font-weight: 600; font-size: 14.5px; margin-bottom: 4px; }
.chips-edit { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-edit .chip { cursor: pointer; padding: 6px 11px; font-size: 13px; box-shadow: inset 0 0 0 1px var(--line); background: transparent; white-space: normal; text-align: left; }
.chips-edit .chip.on { background: var(--spruce); color: #fff; box-shadow: none; }
.inline-add { display: flex; gap: 8px; margin-top: 10px; }
.inline-add .btn { width: auto; padding: 0 16px; flex: none; font-size: 14px; }
.sect-toggle { display: flex; justify-content: space-between; align-items: baseline; width: 100%; text-align: left; }
.sect-toggle span { font-size: 13px; color: var(--muted); margin-right: 4px; }
.sect-toggle + .list-card { margin-top: 2px; }
.btn.danger-soft { background: var(--coral-tint); color: var(--coral); }
.form-foot {
  position: sticky; bottom: calc(-24px - var(--safe-b)); z-index: 3; display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px;
  margin: 18px -16px 0; padding: 12px 16px calc(12px + var(--safe-b)); background: var(--bg); box-shadow: 0 -1px 0 var(--line-soft);
}
.form-foot .btn { padding: 13px; }
#formError { margin-top: 16px; }
@media (max-width: 380px) { .f-row.three { grid-template-columns: 1fr 1fr; } }
