/* Пульт Такедика — iOS 26 look inside Telegram, on top of liquid-kit tokens.css + glass.css.
 * UIKit light colours, Inter with optical sizes as the stand-in for SF Pro (the same look in
 * Telegram on iPhone, Android and desktop), Takeda pink as the app tint.
 * Glass: tab bar, the round toolbar button, sheets, the action sheet and the HUD. Lists are paper. */

:root {
  --tint: #ff2d7a;
  --tint-press: #e0186a;
  --font-text: "Inter", -apple-system, "Segoe UI", sans-serif;
  --font-display: "Inter", -apple-system, "Segoe UI", sans-serif;
  --r-group: 24px;
  --r-tile: 8px;
  --gutter: 16px;
  --tab-space: calc(86px + env(safe-area-inset-bottom, 0px));
  scroll-padding-block: 16px calc(var(--tab-space) + 16px);
}

/* UIKit light appearance — the only theme (Pasha, 09.11). Text greys and tints are the
 * accessible variants: Apple's secondaryLabel (#3c3c43 @ 60 %) is 3.4:1 on white. Same specificity as tokens.css's
 * light block, so loading later wins. */
:root[data-theme="light"] {
  color-scheme: light;
  --color-bg: #f2f2f7;
  --cell: #ffffff;
  --cell-press: #e5e5ea;
  --label: #000000;
  --label-2: #636366;
  --label-3: rgb(60 60 67 / 0.3);
  --sep: rgb(60 60 67 / 0.29);
  --fill: rgb(120 120 128 / 0.16);
  --fill-2: rgb(118 118 128 / 0.12);
  --thumb: #ffffff;
  --green: #34c759; --red: #ff3b30; --blue: #007aff;
  --red-text: #d70015; --blue-text: #0066cc; --green-text: #1f7a36; --orange: #ff9500; --yellow: #ffcc00;
  --purple: #af52de; --indigo: #5856d6; --teal: #30b0c7; --pink: #ff2d55; --gray: #8e8e93;
  --tint-text: #c20f56; /* the tint as text: #ff2d7a is 3.5:1 on white, this is 6:1 (4.8:1 on glass) */
}
:root {
  --color-ink: var(--label);
  --color-ink-muted: var(--label-2);
  --color-accent: var(--tint);
  --color-focus: var(--blue);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--color-bg); color-scheme: light; font-optical-sizing: auto; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--color-bg);
  color: var(--label);
  font: 400 17px/1.29 var(--font-text);
  letter-spacing: -0.022em;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) var(--gutter) calc(var(--tab-space) + 24px);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in oklab, var(--tint) 32%, transparent); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 10px; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { -webkit-tap-highlight-color: transparent; }
svg { width: 1em; height: 1em; fill: currentColor; flex: none; }
p, h1, h2, h3, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
[hidden] { display: none !important; }

.num { font-variant-numeric: tabular-nums; }
.secondary { color: var(--label-2); }
.small { font-size: 15px; line-height: 1.33; }
.caption { color: var(--label-2); font-size: 13px; line-height: 1.38; letter-spacing: -0.006em; }

main { max-width: 640px; margin: 0 auto; }

/* ---------------------------------------------------------------- navigation bar */
.nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 14px; }
.large-title { font: 700 34px/1.2 var(--font-display); letter-spacing: 0.011em; }
.nav__sub { color: var(--label-2); font-size: 15px; margin-top: 2px; }
.tool {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; color: var(--label); font-size: 20px; cursor: pointer; flex: none;
}
.tool[aria-busy="true"] svg { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
:where([data-motion="reduce"]) .tool[aria-busy="true"] svg { animation: none; opacity: 0.5; }

.screen { display: grid; gap: 0; }

/* ---------------------------------------------------------------- inset grouped lists */
.section-header {
  color: var(--label-2); font-size: 13px; line-height: 1.38; letter-spacing: -0.006em;
  text-transform: uppercase; font-weight: 400; padding: 22px 16px 7px;
}
.section-header:first-child { padding-top: 4px; }
.section-footer { color: var(--label-2); font-size: 13px; line-height: 1.38; letter-spacing: -0.006em; padding: 7px 16px 0; }
.cell-group { background: var(--cell); border-radius: var(--r-group); overflow: hidden; }
.cell {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 16px; width: 100%;
  background: none; border: 0; text-align: left; color: var(--label);
}
.cell + .cell::before {
  content: ""; position: absolute; top: 0; right: 0; left: 58px; height: 0.5px; background: var(--sep);
}
.cell--no-tile + .cell::before, .cell--no-tile::before { left: 16px; }
button.cell { cursor: pointer; transition: background var(--dur-hover); }
button.cell:hover { background: color-mix(in oklab, var(--cell-press) 50%, var(--cell)); }
button.cell:active { background: var(--cell-press); transition: none; }
button.cell:focus-visible { outline-offset: -3px; border-radius: var(--r-group); }
.cell__text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.cell__label { overflow-wrap: normal; hyphens: manual; }
.cell__sub { color: var(--label-2); font-size: 13px; line-height: 1.33; letter-spacing: -0.006em; overflow-wrap: normal; }
.cell--stepper .cell__sub { font-size: 15px; line-height: 1.33; }
.cell__sub--bad { color: var(--red-text); }
.cell:has(.stepper) { padding-block: 4px; }
.cell__value { color: var(--label-2); white-space: nowrap; }
.cell__chev { color: var(--label-3); font-size: 15px; margin-right: -4px; }
.cell--tint .cell__label { color: var(--tint-text); }
.cell--danger .cell__label { color: var(--red-text); }

/* iOS Settings tiles: a coloured squircle with a white glyph */
.tile {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r-tile);
  color: #fff; font-size: 18px; flex: none; background: var(--gray);
}
.tile--lg { width: 64px; height: 64px; border-radius: 16px; font-size: 36px; }
.tile--pink { background: var(--tint); } .tile--red { background: var(--red); } .tile--orange { background: var(--orange); }
.tile--yellow { background: var(--yellow); } .tile--green { background: var(--green); } .tile--teal { background: var(--teal); }
.tile--blue { background: var(--blue); } .tile--indigo { background: var(--indigo); } .tile--purple { background: var(--purple); }
.tile--gray { background: var(--gray); }

.avatar {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex: none;
  color: var(--av-ink, #fff); font-size: 16px; font-weight: 600; letter-spacing: 0;
  background: linear-gradient(180deg, var(--av, var(--gray)), color-mix(in oklab, var(--av, var(--gray)) 82%, #000));
}
.cell--avatar::before { left: 68px !important; }

/* Switch: the kit knob (solid at rest, a glass drop while it moves) on iOS green */
.lk-switch {
  --lk-switch-on: var(--green); --lk-switch-off: var(--fill); --lk-knob-rest: #fff;
  border: 0; background: none; padding: 0; cursor: pointer; flex: none;
}

/* Stepper: UIStepper, two halves on a system fill */
.stepper { position: relative; display: inline-flex; align-items: center; height: 44px; flex: none; }
.stepper::before { content: ""; position: absolute; inset: 6px 0; border-radius: 9px; background: var(--fill-2); }
.stepper button {
  position: relative; display: grid; place-items: center; width: 46px; height: 44px; border: 0; background: none;
  color: var(--label); font-size: 17px; cursor: pointer; border-radius: 9px;
}
.stepper button:active { background: radial-gradient(closest-side, var(--fill) 70%, transparent 71%); }
.stepper button:disabled { color: var(--label-3); cursor: default; }
.stepper i { position: relative; width: 1px; height: 18px; background: var(--sep); }
.cell__num { color: var(--label-2); min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }

/* Fields inside sheets */
.field-cell { display: grid; gap: 4px; }
.text-input {
  width: 100%; min-height: 44px; border: 0; outline: none; background: none; color: var(--label);
  padding: 0; text-align: right;
}
.text-input--left { text-align: left; }
.text-input::placeholder { color: var(--label-3); }
.text-input:focus-visible { outline: none; }
.cell:has(.text-input:focus-visible) { box-shadow: inset 0 0 0 2px var(--blue); border-radius: var(--r-group); }
.textarea { width: 100%; min-height: 220px; resize: vertical; border: 0; outline: none; background: none; padding: 14px 16px; line-height: 1.4; font-size: 16px; }
.select-native { appearance: none; border: 0; background: none; color: var(--label-2); text-align: right; min-height: 44px; padding: 0 18px 0 0; cursor: pointer; max-width: 60%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath fill='%238e8e93' d='M184.49 167.51a12 12 0 0 1 0 17l-48 48a12 12 0 0 1-17 0l-48-48a12 12 0 0 1 17-17L128 207l39.51-39.52a12 12 0 0 1 16.98.03Zm-96-79L128 49l39.51 39.52a12 12 0 0 0 17-17l-48-48a12 12 0 0 0-17 0l-48 48a12 12 0 0 0 17 17Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right center; background-size: 12px; }
.color-input { width: 44px; height: 44px; border: 0; padding: 0; background: none; border-radius: 50%; cursor: pointer; }
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 0; border-radius: 50%; }
.field-error { color: var(--red-text); font-size: 13px; padding: 7px 16px 0; }

/* ---------------------------------------------------------------- overview */
.budget { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 16px 18px; padding: 18px; }
.ring { position: relative; width: 112px; height: 112px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring__track, .ring__fill { fill: none; stroke-width: 16; }
.ring__track { stroke: color-mix(in oklab, var(--tint) 22%, transparent); }
.ring__fill { stroke: url(#ring-grad); stroke-linecap: round; stroke-dasharray: 0 200; filter: drop-shadow(0 1px 1.5px rgb(0 0 0 / 0.18)); }
.ring--ready .ring__fill { stroke-dasharray: var(--ring, 0) 200; transition: stroke-dasharray 1100ms var(--ease-out-expo) 150ms; }
.ring__fill[data-over="true"] { stroke: var(--red); }
.ring__pct { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 600; font-size: 17px; }
.budget__value { font: 700 30px/1.15 var(--font-display); letter-spacing: 0.01em; margin-top: 2px; }
.budget__facts {
  grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  padding-top: 14px; border-top: 0.5px solid var(--sep);
}
.budget__facts dt { color: var(--label-2); font-size: 13px; letter-spacing: -0.006em; }
.budget__facts dd { font-weight: 600; font-size: 17px; margin-top: 2px; }

.usage { margin-top: 20px; padding: 16px 18px 14px; display: grid; gap: 12px; }
.usage__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.usage__avg { font: 700 22px/1.2 var(--font-display); margin-top: 2px; }
.chart { position: relative; height: 128px; }
.chart__bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: var(--bar-gap, 10px); }
.chart__bar { flex: 1; min-height: 3px; border-radius: 4px 4px 2px 2px; background: color-mix(in oklab, var(--tint) 55%, var(--cell)); }
.chart__bar--empty { background: var(--fill-2); opacity: 1; }
.chart__bar--today { background: var(--tint); }
.chart__grid { position: absolute; inset: 0 34px 0 0; display: grid; grid-template-rows: repeat(3, 1fr); pointer-events: none; }
.chart__grid i { border-top: 0.5px solid var(--sep); }
.chart__max { position: absolute; right: 0; top: -7px; color: var(--label-2); font-size: 11px; letter-spacing: 0; }
.chart__bars { right: 34px; }
.chart__axis { padding-right: 34px; }
.chart__avg {
  position: absolute; left: 0; right: 0; bottom: var(--avg, 0%); height: 0;
  border-top: 2px dashed var(--green); pointer-events: none; right: 34px;
}
.chart__avg span { position: absolute; right: 0; top: -18px; color: var(--green-text); font-size: 11px; font-weight: 600; }
.chart__axis { display: flex; gap: var(--bar-gap, 10px); color: var(--label-2); font-size: 11px; letter-spacing: 0; }
.chart__axis span { flex: 1; text-align: center; white-space: nowrap; }

.segmented {
  position: relative; display: inline-flex; padding: 2px; border-radius: var(--radius-pill); background: var(--fill-2); flex: none;
  --lk-indicator-fill: var(--thumb);
}
.segmented .lk-indicator::before { box-shadow: 0 3px 8px rgb(0 0 0 / 0.12), 0 3px 1px rgb(0 0 0 / 0.04); }
.seg {
  position: relative; z-index: 1; min-height: 44px; padding: 0 16px; border: 0; border-radius: var(--radius-pill);
  background: none; color: var(--label); font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.seg[aria-checked="true"] { font-weight: 600; }

.widgets { margin-top: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.widget { background: var(--cell); border-radius: var(--r-group); padding: 14px 16px 16px; display: grid; gap: 2px; justify-items: start; }
.widget .tile { margin-bottom: 10px; }
.widget__num { font: 700 28px/1.15 var(--font-display); }
.widget__label { color: var(--label-2); font-size: 13px; letter-spacing: -0.006em; }

/* Telegram-style message bubble for the rules / welcome preview */
.bubble {
  position: relative; margin: 0 40px 0 6px; padding: 9px 12px 10px; border-radius: 18px 18px 18px 6px;
  background: var(--cell); font-size: 16px; line-height: 1.35; overflow-wrap: anywhere;
}
.bubble blockquote { margin: 4px 0; padding: 2px 0 2px 10px; border-left: 3px solid var(--tint); border-radius: 2px; }
.bubble__link { color: var(--blue-text); }

/* ---------------------------------------------------------------- gate */
.gate { display: grid; justify-items: center; text-align: center; gap: 12px; padding: 32px 24px; margin-top: 8vh; }
.gate__title { font: 700 22px/1.25 var(--font-display); }

/* iOS 26 scroll edge: content fades out under the floating tab bar instead of showing sharp text
 * and colour blobs through it. Paper, not glass. */
.edge-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: calc(var(--z-nav) - 1); pointer-events: none;
  height: calc(var(--tab-space) + 28px);
  background: linear-gradient(to top, var(--color-bg) 45%, color-mix(in oklab, var(--color-bg) 0%, transparent));
}

/* ---------------------------------------------------------------- tab bar (glass) */
.tabbar {
  position: fixed; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: var(--z-nav);
  translate: -50% 0; width: min(calc(100% - 2 * var(--gutter)), 400px);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 4px;
  --lk-indicator-fill: var(--fill-2);
}
.tab {
  position: relative; z-index: 1; display: grid; justify-items: center; align-content: center; gap: 1px;
  min-height: 56px; border: 0; border-radius: var(--radius-pill); background: none; cursor: pointer;
  color: var(--glass-ink, var(--label)); font-size: 10px; font-weight: 600; letter-spacing: 0.01em;
  transition: color var(--dur-hover);
}
.tab svg { font-size: 25px; }
.tab[aria-current="page"] { color: var(--tint-text); }
.tab:focus-visible { outline-offset: -3px; }

/* ---------------------------------------------------------------- bottom sheet (glass) */
.sheet, .actions {
  margin: auto auto 0; padding: 0; border: 0; background: transparent; color: inherit; overflow: visible;
  width: min(100%, 520px); max-width: none; max-height: none;
}
.sheet::backdrop, .actions::backdrop { background: rgb(0 0 0 / 0.36); animation: backdrop-in 250ms ease-out; }
:is(.sheet, .actions)[data-closing]::backdrop { animation: backdrop-out 280ms ease-in forwards; }
/* UIKit sheets come up from below the screen edge on a spring and leave the same way (app.js). */
:is(.sheet, .actions)[open]:not([data-closing]) { animation: sheet-up var(--dur-spring-15) var(--ease-spring-15); }
@keyframes sheet-up { from { translate: 0 100%; } }
@keyframes backdrop-in { from { opacity: 0; } }
@keyframes backdrop-out { to { opacity: 0; } }
:where([data-motion="reduce"]) :is(.sheet, .actions)[open], :where([data-motion="reduce"]) :is(.sheet, .actions)::backdrop { animation: none; }
.sheet__grabber, .sheet__bar { touch-action: none; cursor: grab; }
.sheet__glass {
  display: grid; grid-template-rows: auto auto minmax(0, 1fr);
  max-height: calc(92dvh - env(safe-area-inset-top, 0px)); border-radius: 30px 30px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet__grabber { justify-self: center; width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin-top: 6px; }
.sheet__bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 4px 8px 6px; }
.sheet__title { font-size: 17px; font-weight: 600; text-align: center; }
.sheet__action { justify-self: start; min-height: 44px; padding: 0 10px; border: 0; background: none; color: var(--tint-text); font-size: 17px; cursor: pointer; }
.sheet__action--done { justify-self: end; font-weight: 600; }
.sheet__action:disabled { color: var(--label-3); }
.sheet__body { overflow-y: auto; overscroll-behavior: contain; padding: 4px var(--gutter) 24px; }
.sheet__body .cell-group { background: color-mix(in oklab, var(--cell) 88%, transparent); }

.actions { padding: 0 8px calc(8px + env(safe-area-inset-bottom, 0px)); display: none; gap: 8px; }
.actions[open] { display: grid; }
.actions__glass { border-radius: 26px; overflow: hidden; display: grid; }
.actions__title { color: var(--label-2); font-size: 13px; text-align: center; padding: 14px 16px; }
.actions__btn, .actions__cancel {
  min-height: 56px; border: 0; background: none; font-size: 19px; cursor: pointer; width: 100%;
}
.actions__btn { border-top: 0.5px solid var(--sep); }
.actions__btn--danger { color: var(--red-text); }
.actions__cancel { border-radius: 26px; color: var(--tint-text); font-weight: 600; }

/* ---------------------------------------------------------------- HUD */
.hud {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 10px); z-index: var(--z-toast);
  translate: -50% 0; display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 16px 0 12px; font-size: 15px; font-weight: 600; max-width: calc(100% - 32px);
  color: var(--glass-ink, var(--label));
  transition: translate var(--dur-spring-20) var(--ease-spring-20), opacity var(--dur-enter);
}
@starting-style { .hud { translate: -50% -16px; opacity: 0; } }
.hud[data-leaving] { translate: -50% -16px; opacity: 0; transition: translate 200ms var(--ease-out-quint), opacity 200ms; }
.hud svg { font-size: 18px; color: var(--green); }
.hud[data-kind="error"] svg { color: var(--red); }

@media (min-width: 560px) {
  .widgets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (forced-colors: active) {
  .tab[aria-current="page"] { outline: 2px solid Highlight; }
}
