/* Tracker Mini App — "Soft" look (D-027): the shape of the high-end-visual-design skill (double-bezel cards,
   floating island tabs, pills, Geist, spring motion) in the colours of the user's Telegram theme (D-012).
   Rules kept from the design skill pass (R-030): 16px reading text, nothing under 13px, 44px targets, 48px fields,
   sentence case, a focus ring that never animates, reduced motion respected. */
[hidden] { display: none !important; }

@font-face { font-family: "Geist"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/geist/geist-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Geist"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/geist/geist-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
                 U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Geist"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/geist/geist-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                 U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  /* Telegram sets --tg-theme-* and keeps them in step with its theme; the fallbacks are for a browser. */
  --bg: var(--tg-theme-secondary-bg-color, #efeff3); --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --fg: var(--tg-theme-text-color, #000000); --muted: var(--tg-theme-hint-color, #707579);
  --accent: var(--tg-theme-button-color, #3390ec); --accent-fg: var(--tg-theme-button-text-color, #ffffff);
  --warn: var(--tg-theme-destructive-text-color, #e53935); --in: #0f7a54;
  /* Soft surfaces, derived from the theme */
  --shell: color-mix(in srgb, var(--fg) 3%, var(--bg));   /* opaque, so the hairline under it shows only at the outer edge */
  --hair: color-mix(in srgb, var(--fg) 5%, transparent);
  --track: color-mix(in srgb, var(--fg) 8%, transparent);
  --chip: color-mix(in srgb, var(--fg) 5%, var(--card));
  --press: color-mix(in srgb, var(--fg) 5%, transparent);
  --glass: color-mix(in srgb, var(--card) 80%, transparent);
  --muted-bg: color-mix(in srgb, var(--muted) 80%, var(--fg));   /* grey text on the page ground keeps 4.5:1 */
  --highlight: rgba(255, 255, 255, .9); --glow: rgba(24, 40, 70, .18);
  --r-in: 22px; --r-field: 16px; --tap: 44px; --field: 48px;
  --ease: cubic-bezier(.32, .72, 0, 1); --m-press: 500ms; --m-in: 900ms;
  /* safe areas: the device's and, in full-screen mode, Telegram's own header (Bot API 8.0) */
  --inset-top: max(env(safe-area-inset-top), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
  --inset-bottom: max(env(safe-area-inset-bottom), calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
  font-family: "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
/* dark: Telegram's colour scheme (set by app.js from WebApp.colorScheme), else the system's in a browser */
:root[data-scheme="dark"] { --highlight: rgba(255, 255, 255, .05); --glow: rgba(0, 0, 0, .55); --in: #5fd3a0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    --bg: var(--tg-theme-secondary-bg-color, #0e1621); --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #17212b));
    --fg: var(--tg-theme-text-color, #f5f5f5); --muted: var(--tg-theme-hint-color, #8b9bb0);
    --accent: var(--tg-theme-button-color, #5288c1);
    --highlight: rgba(255, 255, 255, .05); --glow: rgba(0, 0, 0, .55); --in: #5fd3a0;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { padding-bottom: calc(104px + var(--inset-bottom)); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }

/* the double bezel: an inner core on an outer shell with a hairline, drawn with spreads so the radii stay concentric */
.card { background: var(--card); border-radius: var(--r-in); padding: 16px; margin: 8px 18px 22px;
  box-shadow: inset 0 1px 1px var(--highlight), 0 0 0 6px var(--shell), 0 0 0 7px var(--hair), 0 24px 48px -30px var(--glow); }
.gate { width: min(360px, 100%); margin: 0; text-align: center; }

/* focus: 2px ring in the action colour, 2px off the control, no transition */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* fields: 48px, 16px text (iOS never zooms), soft wells */
input:not([type="checkbox"]):not([type="radio"]), select, textarea { width: 100%; min-height: var(--field); padding: 12px 16px;
  border: 0; border-radius: var(--r-field); background: var(--bg); box-shadow: inset 0 0 0 1px var(--hair); font-size: 16px;
  transition: box-shadow 300ms var(--ease); }
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus { outline: none;
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--warn) !important; }
input[type="color"] { padding: 6px; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--accent); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; }

/* buttons: pills; one primary (the theme's button colour), one tonal secondary; danger = secondary with a red label */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border: 0; border-radius: 999px; background: var(--chip); font-size: 16px; font-weight: 600; text-align: center; }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.danger { color: var(--warn); }
.btn.quiet { display: flex; margin: 0 14px 10px; background: none; color: var(--accent); padding: 0 12px; }
.btn.wide { display: flex; width: calc(100% - 36px); margin: 0 18px 8px; }
.icon { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex: none; border: 0; border-radius: 50%;
  background: var(--card); box-shadow: 0 0 0 1px var(--hair); font-size: 18px; line-height: 1; }
.icon.danger { color: var(--warn); }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row > * { flex: 1; }
.row > .narrow { flex: .5; }
.row.wrap { flex-wrap: wrap; align-items: center; }
.row.wrap > * { flex: 1 1 auto; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
       padding: calc(10px + var(--inset-top)) 18px 10px; background: color-mix(in srgb, var(--bg) 82%, transparent);
       backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.month { font-weight: 600; font-size: 17px; letter-spacing: -0.02em; }

/* overview */
.alert { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: calc(100% - 36px); border: 0; text-align: left;
  min-height: var(--tap); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.alert b { color: var(--accent); font-weight: 600; white-space: nowrap; }
.hero { padding: 20px 18px 16px; }
.hero .label { color: var(--muted); font-size: 14px; font-weight: 500; margin: 0; }
.hero .value { font-size: 52px; font-weight: 600; letter-spacing: -0.045em; margin: 4px 0 14px; line-height: 1; }
.hero .value small { margin-left: 4px; font-size: 22px; color: var(--muted); font-weight: 400; letter-spacing: -0.01em; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kpi { background: var(--bg); border-radius: 16px; padding: 10px 12px; box-shadow: inset 0 0 0 1px var(--hair); }
.kpi b { display: block; font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.kpi span { font-size: 13px; color: var(--muted); }
.in { color: var(--in); }
.other-cur { margin-top: 10px; font-size: 14px; color: var(--muted); }

/* chart: soft pill bars */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 104px; padding-top: 16px; }
.chart .bar { flex: 1; background: var(--accent); border-radius: 999px; min-height: 4px; }
.chart .bar.empty { background: var(--track); }
.chart .bar.today { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.chart-axis { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 6px; }

/* headings: sentence case */
h2 { font-size: 15px; font-weight: 600; color: var(--muted-bg); margin: 24px 26px 10px; }
h2.view-title { font-size: 30px; font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; color: var(--fg); margin: calc(24px + var(--inset-top)) 26px 8px; }
.sheet-title { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; color: var(--fg); margin: 0; }
.hint { margin: 0 26px 12px; font-size: 14px; color: var(--muted-bg); }
.meta { font-size: 14px; }

/* lists: a row is a whole-width button (or a label for toggles) inside a card */
.list { padding: 4px 0; overflow: hidden; }
.item { display: flex; width: 100%; align-items: center; gap: 14px; min-height: 60px; padding: 10px 16px;
  border: 0; background: none; text-align: left; border-radius: 0; transition: background-color 300ms var(--ease); }
.item + .item { box-shadow: inset 0 1px 0 var(--hair); }
.item.static { cursor: default; }
.item.toggle { cursor: pointer; }
.item.device { flex-wrap: wrap; }
.item.device .s { white-space: normal; }
.item.device .actions { display: flex; gap: 8px; width: 100%; justify-content: flex-end; }
.item:has(.raw) { align-items: flex-start; }
.item .ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); flex: none; font-size: 18px; }
.item .main { flex: 1; min-width: 0; display: block; }
.item .t { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { display: block; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .amt { font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; text-align: right; }
.item .amt.in { color: var(--in); }
.item .amt small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.meter { display: block; height: 6px; background: var(--track); border-radius: 999px; margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 999px; }
.day { display: flex; justify-content: space-between; margin: 22px 26px 10px; font-size: 14px; color: var(--muted-bg); font-weight: 500; }
.raw { display: block; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; white-space: pre-wrap; background: var(--bg);
  padding: 10px 12px; border-radius: 14px; margin-top: 8px; color: var(--fg); word-break: break-word; box-shadow: inset 0 0 0 1px var(--hair); }
.raw.full { flex: 1 1 100%; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 20px; }
.search { margin: 6px 18px 4px; width: calc(100% - 36px) !important; border-radius: 999px !important; background: var(--card) !important; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 18px 6px; scrollbar-width: none; }
.chip { flex: none; min-height: var(--tap); border: 0; background: var(--card); box-shadow: 0 0 0 1px var(--hair); padding: 0 18px;
  border-radius: 999px; font-size: 15px; font-weight: 500; transition: transform var(--m-press) var(--ease), background-color 300ms var(--ease); }
.chip.on { background: var(--accent); color: var(--accent-fg); box-shadow: none; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); vertical-align: middle; margin-left: 4px; }

/* tabs: a floating glass island; the current tab is an accent pill with its label, the others are icons */
.tabs { position: fixed; left: 50%; bottom: calc(14px + var(--inset-bottom)); transform: translateX(-50%); z-index: 6;
  display: flex; gap: 2px; padding: 6px; border-radius: 999px; background: var(--glass);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 0 0 1px var(--hair), 0 20px 40px -18px var(--glow); }
.tabs button { position: relative; flex: none; display: flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 48px; height: 48px; padding: 0 12px; border: 0; border-radius: 999px; background: none; color: var(--muted);
  font-size: 14px; font-weight: 500; transition: background-color 400ms var(--ease), color 400ms var(--ease), transform var(--m-press) var(--ease); }
.tabs button span { display: grid; place-items: center; }
.tabs button b { display: none; font-weight: 500; }
.tabs button.on { background: var(--accent); color: var(--accent-fg); padding: 0 16px; }
.tabs button.on b { display: inline; }
.badge { position: absolute; top: 4px; right: 4px; background: var(--warn); color: #fff; font-style: normal; font-size: 12px; font-weight: 600;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; line-height: 18px; text-align: center; }
.fab { position: fixed; right: 18px; bottom: calc(84px + var(--inset-bottom)); width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-fg); font-size: 28px; font-weight: 300; line-height: 1; z-index: 6;
  box-shadow: 0 20px 40px -16px var(--glow); transition: transform var(--m-press) var(--ease); }

/* sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .3); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 9; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 90vh; overflow-y: auto; background: var(--card); z-index: 10;
         border-radius: 30px 30px 0 0; padding: 10px 18px calc(22px + var(--inset-bottom)); display: flex; flex-direction: column; gap: 14px;
         box-shadow: 0 0 0 1px var(--hair), 0 -24px 60px -30px var(--glow); animation: sheet-up 700ms var(--ease); }
@media (min-width: 640px) { .sheet { left: 50%; width: 540px; transform: translateX(-50%); bottom: 20px; border-radius: 30px; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0 } }
.sheet .grab { width: 36px; height: 5px; border-radius: 999px; background: var(--track); margin: 0 auto 2px; }
.sheet label, .sheet legend { font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.sheet label.check { flex-direction: row; align-items: center; gap: 12px; min-height: var(--tap); color: var(--fg); font-size: 15px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.cat-grid button { min-height: 64px; border: 0; background: var(--bg); box-shadow: inset 0 0 0 1px var(--hair); border-radius: var(--r-field);
  padding: 8px 6px; font-size: 13px; transition: transform var(--m-press) var(--ease), background-color 300ms var(--ease); }
.cat-grid button.on { background: color-mix(in srgb, var(--accent) 14%, var(--card)); box-shadow: inset 0 0 0 2px var(--accent); }
.cat-grid button b { display: block; font-size: 18px; font-weight: 400; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + var(--inset-bottom)); max-width: calc(100% - 32px);
  background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 20; font-size: 15px; }
.setup ol { padding-left: 20px; margin: 0; line-height: 1.55; }
.setup li + li { margin-top: 6px; }
.setup code { background: var(--bg); padding: 1px 6px; border-radius: 6px; font-size: 14px; overflow-wrap: anywhere; }

/* entrance: when a view opens its blocks rise once, staggered (route() sets .enter for a moment) */
@keyframes rise { from { opacity: 0; transform: translateY(16px) } }
#view.enter > * { animation: rise var(--m-in) var(--ease) both; }
#view.enter > :nth-child(2) { animation-delay: 50ms; } #view.enter > :nth-child(3) { animation-delay: 100ms; }
#view.enter > :nth-child(4) { animation-delay: 150ms; } #view.enter > :nth-child(5) { animation-delay: 200ms; }
#view.enter > :nth-child(6) { animation-delay: 250ms; } #view.enter > :nth-child(n+7) { animation-delay: 300ms; }

/* press: a spring squeeze; a row darkens instead of moving */
.btn, .icon, .alert { transition: transform var(--m-press) var(--ease), background-color 300ms var(--ease), filter 300ms var(--ease); }
.btn:active, .chip:active, .icon:active, .fab:active, .cat-grid button:active, .tabs button:active, .alert:active { transform: scale(.97); }
.item:not(.static):active { background: var(--press); }

/* hover: only for a fine pointer (Telegram Desktop) */
@media (hover: hover) and (pointer: fine) {
  .btn:hover, .chip:hover, .icon:hover, .alert:hover { filter: brightness(.96); }
  .item:not(.static):hover { background: var(--press); }
}

/* reduced motion: nothing moves, colours still change */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
  .btn:active, .chip:active, .icon:active, .fab:active, .cat-grid button:active, .tabs button:active, .alert:active { transform: none; filter: brightness(.9); }
}
