/* Nocturne — токены дизайн-системы макета. Правится здесь, нигде больше. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --color-bg: #161826;
  --color-surface: #232532;
  --color-text: #e9e9ed;
  --color-accent: #5fbfa5;
  --color-divider: color-mix(in srgb, #e9e9ed 16%, transparent);

  --color-neutral-300: #cfd3e5; --color-neutral-400: #b2b6ca;
  --color-neutral-500: #9397ab; --color-neutral-600: #75798c;
  --color-neutral-700: #595d6c; --color-neutral-800: #3f424d;
  --color-neutral-900: #292b31;

  --color-accent-100: #eefaf6; --color-accent-200: #d3f2e8;
  --color-accent-300: #a9e3d1; --color-accent-600: #4a9d86;
  --color-accent-700: #3a7b69; --color-accent-800: #2c5b4e;
  --color-accent-900: #1e3b33;

  --font: "Inter", system-ui, sans-serif;
  --shadow-sm: 0 0 0 1px #3f424d;
  --shadow-md: 0 0 0 1px #595d6c, 0 6px 18px rgba(0,0,0,.55);
  --tabbar: calc(84px + env(safe-area-inset-bottom));
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

body {
  margin: 0; background: var(--color-bg); color: var(--color-text);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* ── шапка и вкладки ── */
.topbar {
  position: sticky; top: 0; z-index: 30; height: 44px; background: var(--color-bg);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 12px 0 8px; font-size: 15px;
}
.topbar .title { font-weight: 500; white-space: nowrap; }
.topbar button {
  background: none; border: 0; color: var(--color-accent); cursor: pointer;
  display: flex; align-items: center; gap: 2px; padding: 0; font-size: 15px;
}
.topbar .right { justify-self: end; }
.topbar .right.strong { font-weight: 500; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: var(--tabbar); display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 10px 8px calc(22px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-divider); background: var(--color-bg);
}
.tabbar button {
  background: none; border: 0; cursor: pointer; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  color: var(--color-neutral-500); font-size: 10px; letter-spacing: .03em;
}
.tabbar button.on { color: var(--color-accent); }

.screen { padding: 0 16px calc(24px + var(--tabbar)); }
.screen.nested { padding-bottom: 32px; }

/* ── типографика ── */
.kicker { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--color-neutral-500); }
.h-big { font-size: 30px; font-weight: 500; line-height: 1; letter-spacing: -.02em; }
.h-huge { font-size: 48px; font-weight: 500; line-height: 1; letter-spacing: -.03em; }
.h-sec { font-size: 17px; font-weight: 500; letter-spacing: -.01em; }
.muted { color: var(--color-neutral-500); }
.note { font-size: 12px; line-height: 1.55; color: var(--color-neutral-500); text-wrap: pretty; }
.sub { font-size: 14px; color: var(--color-neutral-500); font-weight: 400; letter-spacing: 0; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.sec { padding-top: 26px; }
.sec-sm { padding-top: 14px; }

/* ── растворяющаяся линия ── */
.hair {
  height: 1px; background: linear-gradient(to right, transparent,
    var(--color-divider) 48px, var(--color-divider) calc(100% - 48px), transparent);
}

/* ── карточка-группа ── */
.group {
  background: var(--color-surface); border-radius: 18px; box-shadow: var(--shadow-sm);
  overflow: hidden; margin-top: 8px;
}
.group .item {
  display: grid; align-items: center; gap: 12px; padding: 13px 14px; font-size: 15px;
}
.group .sep { margin: 0 14px; height: 1px; background: var(--color-divider); }
.item-sub { font-size: 12px; color: var(--color-neutral-500); margin-top: 2px; }
.chev { color: var(--color-neutral-600); flex: none; }
.badge {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--color-accent-900); color: var(--color-accent-200);
  font-size: 14px; font-weight: 500;
}
.badge.off { background: none; box-shadow: inset 0 0 0 1px var(--color-neutral-800); color: var(--color-neutral-500); }

/* ── сегментированный переключатель ── */
.seg { display: grid; padding: 3px; border-radius: 999px; background: var(--color-surface); }
.seg.on-bg { background: var(--color-bg); }
.seg button {
  height: 34px; border: 0; border-radius: 999px; cursor: pointer; background: transparent;
  color: var(--color-neutral-500); font-size: 13px;
}
.seg button.on { background: var(--color-accent-900); color: var(--color-accent-100); font-weight: 500; }

/* ── пилюли выбора ── */
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  height: 32px; padding: 0 12px; border-radius: 999px; border: 0; cursor: pointer;
  display: grid; place-items: center; font-size: 13px;
  background: transparent; color: var(--color-neutral-400);
  box-shadow: inset 0 0 0 1px var(--color-neutral-800);
}
.pill.on { background: var(--color-accent-800); color: var(--color-accent-100); font-weight: 500; box-shadow: none; }

/* ── плитки упражнений ── */
/* minmax(0,…) обязателен: с обычным 1fr колонка растягивается под min-content
   содержимого, и плитка вылезает за экран. */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-top: 18px; }
.tile {
  background: var(--color-surface); border-radius: 18px; box-shadow: var(--shadow-sm);
  padding: 14px 12px 12px; display: flex; flex-direction: column; gap: 14px;
}
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile-name { font-size: 13px; font-weight: 500; letter-spacing: .01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-unit { font-size: 11px; color: var(--color-neutral-500); flex: none; }
.ring { display: flex; justify-content: center; }
.ring-outer {
  width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--color-accent) var(--p, 0%), var(--color-neutral-800) 0);
  border: 0; padding: 0; cursor: pointer;
}
.ring-inner {
  width: 92px; height: 92px; border-radius: 50%; background: var(--color-surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-value { font-size: 34px; line-height: 1; font-weight: 500; letter-spacing: -.03em; color: var(--color-text); }
.ring-value.zero { color: var(--color-neutral-500); }
.ring-value.done { color: var(--color-accent-300); }
.ring-sub { font-size: 11px; color: var(--color-neutral-500); margin-top: 5px; letter-spacing: .02em; }
.ring-sub.done { color: var(--color-accent-300); }
.presets { display: grid; grid-template-columns: 32px repeat(3, minmax(0, 1fr)); gap: 5px; }
.presets button {
  height: 38px; border: 0; border-radius: 999px; cursor: pointer;
  display: grid; place-items: center; font-size: 13px; font-weight: 500;
  background: var(--color-accent-900); color: var(--color-accent-200);
  min-width: 0; padding: 0 2px; overflow: hidden;
}
.presets button.minus {
  font-size: 18px; font-weight: 400; background: transparent;
  color: var(--color-neutral-500); box-shadow: inset 0 0 0 1px var(--color-neutral-800);
}

/* ── ленты записей ── */
.log { display: flex; flex-direction: column; }
.log-row { display: grid; grid-template-columns: 44px 1fr auto auto; gap: 12px; align-items: center; padding: 12px 0; font-size: 15px; }
.log-row .t { color: var(--color-neutral-500); font-size: 13px; }
.log-row .d { font-weight: 500; }
.log-row .u { color: var(--color-accent); font-size: 13px; background: none; border: 0; cursor: pointer; padding: 0; }
.day-row { display: grid; grid-template-columns: 8px 1fr auto; gap: 14px; align-items: center; padding: 14px 0; font-size: 15px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-neutral-700); }
.dot.on { background: var(--color-accent); }
.day-val { font-size: 17px; font-weight: 500; letter-spacing: -.01em; }
.day-val span { color: var(--color-neutral-500); font-weight: 400; font-size: 13px; }
.chip-out { font-size: 12px; color: var(--color-neutral-400); padding: 6px 10px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--color-neutral-800); }

/* ── календарь ── */
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-week { font-size: 11px; color: var(--color-neutral-600); text-align: center; letter-spacing: .04em; padding-top: 12px; }
.cal-grid { padding-top: 8px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 10px; border: 0; padding: 0; background: transparent;
  display: grid; place-items: center; font-size: 13px; font-weight: 500; color: var(--color-neutral-700);
}
.cal-cell.has { cursor: pointer; }
.cal-cell.open { box-shadow: inset 0 0 0 1px var(--color-neutral-800); color: var(--color-neutral-400); }
.cal-cell.closed { background: var(--color-accent-800); color: var(--color-accent-100); }
.cal-cell.today { box-shadow: inset 0 0 0 1.5px var(--color-accent); color: var(--color-text); }
.legend { display: flex; gap: 16px; font-size: 11px; color: var(--color-neutral-500); padding-top: 14px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: block; }
.legend i.closed { background: var(--color-accent-800); }
.legend i.open { box-shadow: inset 0 0 0 1px var(--color-neutral-700); }
.legend i.today { box-shadow: inset 0 0 0 1.5px var(--color-accent); }

/* ── столбики ── */
.bars { height: 128px; position: relative; display: flex; align-items: flex-end; gap: 3px; margin-top: 22px; }
.bars .goal {
  position: absolute; left: 0; right: 0; height: 1px;
  background: linear-gradient(to right, transparent, var(--color-accent) 24px,
              var(--color-accent) calc(100% - 24px), transparent);
}
.bars .goal-label { position: absolute; right: 0; font-size: 10px; letter-spacing: .04em; color: var(--color-accent-300); }
.bars i { flex: 1; background: var(--color-neutral-800); border-radius: 2px 2px 0 0; display: block; min-height: 1px; }
.bars i.ok { background: var(--color-accent-700); }
.bars i.now { box-shadow: inset 0 0 0 1px var(--color-accent); }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--color-neutral-600); padding-top: 8px; }

.stat3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 26px; }
.stat {
  background: var(--color-surface); border-radius: 16px; box-shadow: var(--shadow-sm); padding: 14px 12px;
}
.stat-label { font-size: 11px; color: var(--color-neutral-500); margin-bottom: 8px; letter-spacing: .02em; }
.stat-value { font-size: 26px; font-weight: 500; line-height: 1; letter-spacing: -.02em; }
.stat-value span { font-size: 12px; color: var(--color-neutral-500); font-weight: 400; letter-spacing: 0; }

/* ── ступени норм ── */
.steps-chart { height: 96px; display: flex; align-items: flex-end; margin-top: 22px; }
.steps-chart div { border-top: 2px solid var(--color-accent-700); background: linear-gradient(var(--color-accent-900), transparent); }
.steps-chart div.now { border-top-color: var(--color-accent); }
.steps-chart div.plan { border-top-style: dashed; border-top-color: var(--color-accent-600); }

/* ── формы ── */
.field { display: flex; flex-direction: column; gap: 8px; }
.input {
  width: 100%; height: 48px; border-radius: 14px; padding: 0 14px;
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-divider); font-size: 17px; font-weight: 500;
}
.input.plain { font-size: 15px; font-weight: 400; }
.input:focus-visible { border-color: var(--color-accent); }
input.input[type=number] { -moz-appearance: textfield; }
input.input::-webkit-outer-spin-button, input.input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.btn {
  height: 48px; border-radius: 14px; border: 1px solid transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 500; background: transparent; color: var(--color-text);
  padding: 0 16px;
}
.btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.btn-primary:active { background: color-mix(in srgb, var(--color-accent) 20%, transparent); }
.btn-block { width: 100%; }
.link { background: none; border: 0; color: var(--color-accent); cursor: pointer; font-size: 13px; padding: 0; }

/* ── переключатели ── */
.switch { width: 46px; height: 28px; border-radius: 14px; border: 0; padding: 0; position: relative; cursor: pointer; background: var(--color-neutral-800); flex: none; }
.switch.on { background: var(--color-accent-800); box-shadow: inset 0 0 0 1px var(--color-accent); }
.switch i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--color-neutral-600); transition: left .18s, background .18s; }
.switch.on i { left: 21px; background: var(--color-accent-200); }
.switch.sm { width: 42px; height: 26px; }
.switch.sm i { width: 20px; height: 20px; }
.switch.sm.on i { left: 19px; }

/* ── прочее ── */
.avatar { width: 54px; height: 54px; border-radius: 50%; background: var(--color-accent-900); color: var(--color-accent-200); display: grid; place-items: center; font-size: 17px; font-weight: 500; letter-spacing: .02em; flex: none; }
.radio { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 1px var(--color-neutral-800); }
.radio.on { box-shadow: inset 0 0 0 1.5px var(--color-accent); }
.radio i { width: 10px; height: 10px; border-radius: 50%; background: transparent; display: block; }
.radio.on i { background: var(--color-accent); }
.bubble { padding: 12px 14px; border-radius: 18px 18px 18px 4px; background: var(--color-surface); font-size: 14px; line-height: 1.5; text-wrap: pretty; margin-top: 8px; }
.hint-card { padding: 12px 14px; border-radius: 14px; background: var(--color-accent-900); display: flex; gap: 10px; align-items: flex-start; }
.hint-card .d { width: 6px; height: 6px; border-radius: 50%; background: var(--color-accent); margin-top: 6px; flex: none; }
.streak { display: flex; align-items: baseline; gap: 5px; padding-bottom: 2px; }
.streak b { font-size: 24px; line-height: 1; font-weight: 500; color: var(--color-accent-300); letter-spacing: -.02em; }
.streak span { font-size: 11px; color: var(--color-neutral-500); }

/* ── шторка ── */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; }
.sheet-back { position: absolute; inset: 0; background: color-mix(in srgb, #0f1019 72%, transparent); animation: fade .18s; }
@keyframes fade { from { opacity: 0 } }
.sheet {
  position: relative; width: 100%; background: var(--color-surface);
  border-radius: 24px 24px 0 0; box-shadow: var(--shadow-md);
  padding: 10px 16px calc(34px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 22px;
  animation: rise .24s cubic-bezier(.2,.7,.3,1); max-height: 92vh; overflow-y: auto;
}
@keyframes rise { from { transform: translateY(100%) } }
.grab { width: 36px; height: 4px; border-radius: 2px; background: var(--color-neutral-700); margin: 0 auto; flex: none; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 28px; padding: 8px 0; }
.stepper button {
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer; font-size: 24px;
  background: transparent; color: var(--color-neutral-300); box-shadow: inset 0 0 0 1px var(--color-neutral-800);
}
.stepper button.plus { background: var(--color-accent-900); color: var(--color-accent-200); box-shadow: none; }
.stepper .num {
  font-size: 72px; line-height: 1; font-weight: 500; letter-spacing: -.04em;
  min-width: 110px; text-align: center; background: none; border: 0; color: inherit; padding: 0;
}
.quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.quick button {
  height: 36px; border-radius: 999px; border: 0; cursor: pointer; font-size: 13px;
  background: transparent; color: var(--color-neutral-400); box-shadow: inset 0 0 0 1px var(--color-neutral-800);
}
.quick button.on { background: var(--color-accent-800); color: var(--color-accent-100); font-weight: 500; box-shadow: none; }

/* ── служебное ── */
.boot { display: grid; place-items: center; min-height: 80vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--color-neutral-800); border-top-color: var(--color-accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.boot-error { padding: 24px; text-align: center; color: var(--color-neutral-400); max-width: 320px; }
.toast {
  position: fixed; left: 50%; bottom: calc(16px + var(--tabbar)); transform: translateX(-50%);
  z-index: 80; background: var(--color-surface); box-shadow: var(--shadow-md);
  padding: 11px 18px; border-radius: 999px; font-size: 14px; max-width: 90vw; text-align: center;
  animation: pop .2s cubic-bezier(.2,.7,.3,1);
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px) } }
.empty { color: var(--color-neutral-500); font-size: 13px; padding: 20px 0; text-align: center; }

/* ── справа налево (иврит) ── */
[dir="rtl"] .switch i { left: auto; right: 3px; }
[dir="rtl"] .switch.on i { left: auto; right: 21px; }
[dir="rtl"] .switch.sm.on i { right: 19px; }
[dir="rtl"] .topbar button svg { transform: scaleX(-1); }
[dir="rtl"] .chev { transform: scaleX(-1); }
[dir="rtl"] .bubble { border-radius: 18px 18px 4px 18px; }
[dir="rtl"] .log-row, [dir="rtl"] .day-row, [dir="rtl"] .item { direction: rtl; }
/* Числа со знаком не должны переворачиваться в RTL: «+10», а не «10+». */
[dir="rtl"] .presets button,
[dir="rtl"] .quick button,
[dir="rtl"] .log-row .d,
[dir="rtl"] .day-val,
[dir="rtl"] .ring-value,
[dir="rtl"] .stepper .num,
[dir="rtl"] .log-row .t { direction: ltr; unicode-bidi: isolate; }
/* Отклик на нажатие: без него кнопка кажется неотзывчивой. */
.presets button { transition: transform .09s cubic-bezier(.2,.7,.3,1), background .18s; }
.presets button:active { transform: scale(.9); }
/* Вспышка после нажатия — единственный отклик, поэтому её видно и после отрыва пальца. */
.presets button.tap { animation: tap .26s cubic-bezier(.2,.7,.3,1); }
@keyframes tap {
  0%   { background: var(--color-accent); color: var(--color-accent-900); transform: scale(.9); }
  55%  { background: var(--color-accent-800); color: var(--color-accent-100); transform: scale(1.04); }
  100% { transform: scale(1); }
}
/* Кнопки режима правки в списке упражнений. */
.icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 10px; padding: 0; cursor: pointer;
  background: color-mix(in srgb, var(--color-text) 6%, transparent);
  display: grid; place-items: center; transition: transform .09s, opacity .15s;
}
.icon-btn:active { transform: scale(.9); }
.icon-btn:disabled { opacity: .3; cursor: default; }

/* Ничто не должно расширять страницу по горизонтали. */
html, body { max-width: 100%; overflow-x: hidden; }
.tile, .tile-head, .presets { min-width: 0; }

/* ── строка приёма ── */
.dose {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
  padding: 13px 14px; font-size: 15px;
}
.dose-time { font-size: 15px; font-weight: 500; color: var(--color-neutral-400); font-variant-numeric: tabular-nums; }
.dose-time.done { color: var(--color-accent-300); }
.dose-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dose-sub { font-size: 12px; color: var(--color-neutral-500); margin-top: 2px; }
.dose.taken .dose-name { color: var(--color-neutral-400); }
.check {
  width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; flex: none;
  background: transparent; box-shadow: inset 0 0 0 1.5px var(--color-neutral-700);
  display: grid; place-items: center; transition: transform .09s, background .18s, box-shadow .18s;
}
.check:active { transform: scale(.88); }
.check.on { background: var(--color-accent); box-shadow: none; }
.check.skip { box-shadow: inset 0 0 0 1.5px var(--color-neutral-800); background: var(--color-neutral-900); }
.check svg { display: none; }
.check.on svg, .check.skip svg { display: block; }

/* ── кольцо дня ── */
.today-ring { display: flex; align-items: center; gap: 16px; padding-top: 14px; }
.ring-lg { width: 84px; height: 84px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--color-accent) var(--p, 0%), var(--color-neutral-800) 0); }
.ring-lg > div { width: 72px; height: 72px; border-radius: 50%; background: var(--color-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-lg b { font-size: 24px; font-weight: 500; letter-spacing: -.02em; line-height: 1; }
.ring-lg span { font-size: 11px; color: var(--color-neutral-500); margin-top: 3px; }

/* ── предупреждение об остатке ── */
.warn { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px;
  background: color-mix(in srgb, #e5a23b 16%, transparent); margin-top: 12px; }
.warn .d { width: 6px; height: 6px; border-radius: 50%; background: #e5a23b; margin-top: 6px; flex: none; }
.warn div { font-size: 13px; color: #f0c98a; text-wrap: pretty; }

/* ── чипы времени в форме ── */
.times { display: flex; gap: 6px; flex-wrap: wrap; }
.time-chip { height: 34px; padding: 0 12px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--color-accent-900); color: var(--color-accent-200); font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; }
.time-chip .x { opacity: .6; }
.time-add { background: transparent; color: var(--color-neutral-400);
  box-shadow: inset 0 0 0 1px var(--color-neutral-800); }
