/* «Выпили таблетки?» — мини-приложение Telegram.
   Цвета берутся из темы Telegram (переменные --tg-theme-*), запасные — для
   открытия в обычном браузере. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f1f2f6);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #111317);
  --hint: var(--tg-theme-hint-color, #8b919b);
  --accent: var(--tg-theme-button-color, #3390ec);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #2f80ed);
  /* Запасные цвета для старых WebView без color-mix (iOS ниже 16.2),
     новые — в блоке @supports ниже. */
  --sep: rgba(139, 145, 155, .22);
  --soft: rgba(51, 144, 236, .12);
  --ok: #22b062;
  --ok-soft: rgba(34, 176, 98, .14);
  --warn: #e8930c;
  --warn-soft: rgba(245, 165, 36, .16);
  --bad: #e5484d;
  --bad-soft: rgba(229, 72, 77, .13);
  /* Свойство с var() внутри color-mix запасной цвет не оставляет: старый
     WebView считает его верным и делает пустым. Поэтому смеси — только токенами. */
  --due-border: rgba(232, 147, 12, .55);
  --missed-border: rgba(229, 72, 77, .35);
  --cal-full: #22b062;
  --cal-part: #e8930c;
  --cal-none: #e5484d;
  --fab-shadow: rgba(51, 144, 236, .45);
  --bar-bg: var(--card);
  --head-bg: var(--bg);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 10px rgba(16, 24, 40, .05);
  --safe-b: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
  --tabbar-h: 64px;
}
@supports (color: color-mix(in srgb, red, blue)) {
  :root {
    --sep: color-mix(in srgb, var(--hint) 22%, transparent);
    --soft: color-mix(in srgb, var(--accent) 12%, var(--card));
    --ok-soft: color-mix(in srgb, #22b062 14%, var(--card));
    --warn-soft: color-mix(in srgb, #f5a524 16%, var(--card));
    --bad-soft: color-mix(in srgb, #e5484d 13%, var(--card));
    --due-border: color-mix(in srgb, var(--warn) 55%, transparent);
    --missed-border: color-mix(in srgb, var(--bad) 35%, transparent);
    --cal-full: color-mix(in srgb, var(--ok) 80%, transparent);
    --cal-part: color-mix(in srgb, var(--warn) 75%, transparent);
    --cal-none: color-mix(in srgb, var(--bad) 70%, transparent);
    --fab-shadow: color-mix(in srgb, var(--accent) 45%, transparent);
    --bar-bg: color-mix(in srgb, var(--card) 88%, transparent);
    --head-bg: color-mix(in srgb, var(--bg) 92%, transparent);
  }
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #0f1115; --card: #1a1d23; --text: #eef0f3; --hint: #8b919b;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
[x-cloak] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); }
h1, h2 { margin: 0; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
#app.locked .content { overflow: hidden; }

/* ---------- каркас ---------- */
.content { padding: 4px 16px calc(var(--tabbar-h) + var(--safe-b) + 88px); max-width: 640px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; padding: 14px 4px 14px; }
.page-head h1 { font-size: 28px; font-weight: 750; letter-spacing: -.02em; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.date-title { font-size: 24px !important; font-weight: 700; text-transform: none; }
.date-title::first-letter { text-transform: uppercase; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.group-title { font-size: 13px; font-weight: 600; color: var(--hint); text-transform: uppercase; letter-spacing: .05em; margin: 22px 6px 8px; }
.center-fill { min-height: 80vh; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.center-pad { padding: 40px; display: flex; justify-content: center; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--sep); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border-radius: 14px; font-weight: 600; font-size: 15px; transition: transform .12s, opacity .12s, background .2s; user-select: none; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.secondary { background: var(--soft); color: var(--accent); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger-soft { background: var(--bad-soft); color: var(--bad); }
.btn.ghost-danger { background: transparent; color: var(--bad); }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn.take { min-height: 38px; padding: 0 16px; background: var(--accent); color: var(--accent-text); border-radius: 12px; font-size: 14px; }
.btn.take.soft { background: var(--soft); color: var(--accent); }
.link { color: var(--link); font-weight: 500; padding: 8px 4px; }
.link.strong { font-weight: 700; }
.back-link { display: inline-flex; align-items: center; gap: 2px; }
.back-link .bi { width: 20px; height: 20px; margin-left: -4px; }
.link.danger { color: var(--bad); }
.link.add { display: block; padding: 12px 2px 6px; }
.icon-btn { width: 32px; height: 32px; border-radius: 50%; color: var(--hint); background: var(--bg); font-size: 13px; flex: none; }
.chip-btn { padding: 7px 12px; border-radius: 999px; background: var(--bg); font-size: 13px; font-weight: 500; }
.chip-btn.on { background: var(--accent); color: var(--accent-text); }

/* ---------- «Сегодня» ---------- */
.hero { display: flex; align-items: center; gap: 18px; padding: 18px; margin-bottom: 8px; }
.ring { position: relative; width: 104px; height: 104px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; }
.ring-bg { stroke: var(--sep); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.2, .8, .2, 1), stroke .3s; }
.ring.done .ring-fg { stroke: var(--ok); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
.ring-text b { font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.ring-text span { font-size: 12px; color: var(--hint); }
.hero-side { min-width: 0; }
.hero-title { font-size: 17px; font-weight: 650; margin-bottom: 10px; }
.hero-stats { display: flex; gap: 18px; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-size: 20px; font-weight: 750; letter-spacing: -.02em; }
.stat-lbl { font-size: 12px; color: var(--hint); }

.slot { margin-top: 18px; }
.slot-head { display: flex; align-items: center; gap: 10px; margin: 0 4px 8px; }
.slot-time { font-size: 17px; font-weight: 750; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.slot-time.small { font-size: 13px; font-weight: 600; color: var(--hint); text-transform: uppercase; letter-spacing: .05em; }
.slot-line { flex: 1; height: 1px; background: var(--sep); }
.slot-badge { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.slot-badge.ok { color: var(--ok); background: var(--ok-soft); }
.slot-take { font-size: 13px; font-weight: 600; color: var(--accent); background: var(--soft); padding: 5px 11px; border-radius: 999px; }

.dose, .med { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 12px; margin-bottom: 8px; cursor: pointer;
  border: 1.5px solid transparent; transition: border-color .2s, background .2s, opacity .2s; }
.dose-icon { width: 48px; height: 48px; flex: none; border-radius: 14px; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.dose-main { flex: 1; min-width: 0; }
.dose-name { font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dose-sub { font-size: 13px; color: var(--hint); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dose-side { flex: none; }
.dose.s-due { border-color: var(--due-border); background: var(--warn-soft); }
.dose.s-taken .dose-name { color: var(--hint); }
.dose.s-taken .dose-icon, .dose.s-skipped .dose-icon { opacity: .55; }
.dose.s-missed { border-color: var(--missed-border); }
.chip { display: inline-flex; align-items: center; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip.ok { color: var(--ok); background: var(--ok-soft); }
.chip.warn { color: var(--warn); background: var(--warn-soft); }
.chip.bad { color: var(--bad); background: var(--bad-soft); }
.chip.ghost { color: var(--hint); background: var(--bg); }
.chip.muted-chip { color: var(--hint); background: var(--bg); text-decoration: line-through; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.chips:empty { display: none; }

.empty { text-align: center; padding: 30px 22px 24px; }
.empty-art { display: flex; justify-content: center; margin-bottom: 10px; }
.empty h2 { font-size: 19px; margin-bottom: 6px; }
.empty p { margin: 0 0 18px; }
.empty-day { text-align: center; padding: 40px 10px; }

/* ---------- «Лекарства» ---------- */
.med.st-paused { opacity: .75; }
.med.st-finished { opacity: .6; }
.chev { color: var(--hint); font-size: 24px; flex: none; padding-left: 4px; }

/* ---------- «История» ---------- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-card { padding: 14px 10px; text-align: center; }
.cal { padding: 14px 12px 12px; margin-top: 8px; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head span { text-align: center; font-size: 11px; color: var(--hint); font-weight: 600; }
.cal-grid { margin-top: 6px; }
.cal-day { aspect-ratio: 1; border-radius: 10px; font-size: 13px; font-weight: 600; background: var(--bg); color: var(--hint); font-variant-numeric: tabular-nums; }
.cal-day.pad { background: transparent; }
.cal-day.full { background: var(--cal-full); color: #fff; }
.cal-day.part { background: var(--cal-part); color: #fff; }
.cal-day.none { background: var(--cal-none); color: #fff; }
.cal-day.future { opacity: .45; }
.cal-day.sel { outline: 2.5px solid var(--text); outline-offset: 1px; }
.legend { display: flex; gap: 14px; justify-content: center; margin-top: 12px; font-size: 12px; color: var(--hint); }
.lg { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.lg.full { background: var(--ok); } .lg.part { background: var(--warn); } .lg.none { background: var(--bad); }
.list { padding: 4px 0; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; }
.list-row + .list-row { border-top: 1px solid var(--sep); }
.list-empty { padding: 16px; text-align: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); }
.list-time { font-variant-numeric: tabular-nums; font-weight: 600; width: 44px; flex: none; }
.list-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-st { font-size: 13px; font-weight: 600; flex: none; }
.t-taken { color: var(--ok); } .t-missed { color: var(--bad); } .t-skipped, .t-pending { color: var(--hint); }

/* ---------- формы ---------- */
.form { padding: 14px; }
.field { margin-top: 14px; }
.field:first-child { margin-top: 0; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--hint); margin-bottom: 8px; }
.field.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field.inline > label { margin: 0; font-size: 15px; font-weight: 500; color: var(--text); }
.hint { font-size: 13px; color: var(--hint); margin: 10px 2px 0; }
.hint.top { margin-top: 0; }
.hint.small { font-size: 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; background: var(--bg); padding: 4px; border-radius: 13px; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 1 auto; min-height: 44px; padding: 8px 7px; border-radius: 10px; font-size: 14px; font-weight: 550; color: var(--text); white-space: nowrap; transition: background .2s; }
.seg button.on { background: var(--card); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); color: var(--accent); font-weight: 650; }
.seg.wrap { flex-wrap: wrap; }
.seg.big button { flex: 1 1 0; min-width: 0; padding: 11px 8px; white-space: normal; line-height: 1.2; }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 12px 0 2px; cursor: pointer; }
.toggle-row + .toggle-row { border-top: 1px solid var(--sep); margin-top: 10px; }
.toggle-row span { flex: 1; display: flex; flex-direction: column; }
.toggle-row small { color: var(--hint); font-size: 13px; margin-top: 2px; }
.toggle-row input { display: none; }
.toggle-row i { width: 50px; height: 30px; border-radius: 999px; background: var(--sep); position: relative; flex: none; transition: background .2s; }
.toggle-row i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.toggle-row input:checked + i { background: var(--ok); }
.toggle-row input:checked + i::after { transform: translateX(20px); }
input[type=time], input[type=date], .num-input, .select { background: var(--bg); border: 0; border-radius: 11px; padding: 9px 12px; font-size: 16px; min-height: 40px; outline: none; }
.select { width: 100%; margin-top: 12px; appearance: none; }
.select.small { width: auto; margin: 0; }
.num-input { width: 96px; }
.time-input { font-variant-numeric: tabular-nums; font-weight: 600; }
.time-input.small, .num-input { font-size: 15px; }
.name-input { width: 100%; border: 0; outline: none; background: transparent; font-size: 20px; font-weight: 650; padding: 4px 2px 12px; border-bottom: 1px solid var(--sep); margin-bottom: 14px; }
.name-input::placeholder { color: var(--hint); font-weight: 500; }
.note { width: 100%; border: 0; outline: none; background: transparent; resize: none; font-size: 15px; }
.stepper { display: inline-flex; align-items: center; background: var(--bg); border-radius: 11px; overflow: hidden; }
.stepper button { width: 44px; height: 44px; font-size: 20px; color: var(--accent); }
.stepper span { min-width: 34px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.unit { color: var(--hint); font-size: 14px; }
.time-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.time-row + .time-row { border-top: 1px solid var(--sep); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.every { padding-top: 12px; border-top: 1px solid var(--sep); }
.forms, .shapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.form-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 2px 8px; border-radius: 13px; background: var(--bg); font-size: 12px; font-weight: 550; border: 1.5px solid transparent; }
.form-btn.on { border-color: var(--accent); background: var(--soft); color: var(--accent); }
.colors { display: flex; flex-wrap: wrap; gap: 10px; }
.color { width: 32px; height: 32px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25), inset 0 0 0 1px rgba(0, 0, 0, .14); transition: transform .15s; }
.color.on { transform: scale(1.12); box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--text); }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 12px; }
.weekdays button { min-height: 44px; border-radius: 12px; background: var(--bg); font-weight: 650; font-size: 13px; }
.weekdays button.on { background: var(--accent); color: var(--accent-text); }
.person { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--sep); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--soft); color: var(--accent); font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.person-name { flex: 1; font-weight: 600; }
.sub-title { font-size: 13px; color: var(--hint); font-weight: 600; margin: 16px 0 2px; }
.invite input { width: 100%; margin-top: 10px; background: var(--bg); border: 0; border-radius: 11px; padding: 10px 12px; font-size: 13px; }
.footer-note { text-align: center; color: var(--hint); font-size: 13px; margin: 26px 10px 0; }
.footer-note a { color: var(--link); text-decoration: none; }

/* ---------- кнопка «+» и вкладки ---------- */
.fab { position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); width: 58px; height: 58px; border-radius: 20px;
  background: var(--accent); color: var(--accent-text); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px var(--fab-shadow); z-index: 20; transition: transform .15s; }
.fab:active { transform: scale(.93); }
.fab svg { width: 26px; height: 26px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; padding: 6px 8px var(--safe-b);
  background: var(--bar-bg); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--sep); }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 8px; color: var(--hint); position: relative; }
.tabbar button.on { color: var(--accent); }
.tab-ico svg { width: 25px; height: 25px; display: block; }
.tab-lbl { font-size: 11px; font-weight: 600; }
.badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; }

/* ---------- редактор ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; }
.overlay.top { z-index: 50; }
.editor { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; }
.editor-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; background: var(--card); border-bottom: 1px solid var(--sep); flex: none; }
.editor-head b { font-size: 16px; }
.editor-body { flex: 1; overflow-y: auto; scrollbar-width: none; padding: 0 16px calc(28px + var(--safe-b)); max-width: 640px; width: 100%; margin: 0 auto; -webkit-overflow-scrolling: touch; }
.ed-preview { display: flex; justify-content: center; padding: 18px 0 14px; }
.ed-preview > div { width: 88px; height: 88px; border-radius: 26px; background: var(--card); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; }
.ed-actions { margin-top: 24px; }
.save-btn { margin-top: 18px; min-height: 52px; font-size: 16px; }
.slide-in { animation: slideUp .28s cubic-bezier(.2, .8, .2, 1); }
.slide-out { animation: slideDown .2s ease-in forwards; }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideDown { to { transform: translateY(40px); opacity: 0; } }

/* ---------- нижний лист ---------- */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--card); border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(18px + var(--safe-b)); max-width: 640px; margin: 0 auto; box-shadow: 0 -8px 30px rgba(0, 0, 0, .18); }
.sheet-in { animation: sheetUp .26s cubic-bezier(.2, .8, .2, 1); }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--sep); margin: 0 auto 14px; }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.sheet-head b { font-size: 17px; }
.sheet-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.sheet-actions { margin-top: 6px; }
.row-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 8px; margin-top: 10px; }
.row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 8px; }
.take-at { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--sep); }
.take-at label { flex: none; }

/* ---------- подтверждение и сообщения ---------- */
.confirm-wrap { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .4); display: flex; align-items: center; justify-content: center; padding: 24px; }
.confirm { background: var(--card); border-radius: 20px; padding: 20px; width: 100%; max-width: 340px; text-align: center; }
.confirm b { font-size: 17px; }
.confirm p { color: var(--hint); margin: 8px 0 18px; }
.confirm-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px); transform: translate(-50%, 20px); z-index: 90;
  background: rgba(20, 22, 26, .92); color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 550;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); }

/* ---------- открыто не из Telegram ---------- */
.outside { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 12px; }
.outside h1 { font-size: 26px; }
.outside p { color: var(--hint); max-width: 300px; margin: 0 0 8px; }
.outside .btn { text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- шапка с профилем ---------- */
.topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 10px; padding: 10px 16px 8px;
  background: var(--head-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); max-width: 640px; margin: 0 auto; }
.who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; position: relative; padding: 4px 6px 4px 0; border-radius: 14px; }
.who-text { min-width: 0; display: flex; flex-direction: column; }
.who-text b { font-size: 18px; font-weight: 750; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text small { font-size: 12.5px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-chev { color: var(--hint); width: 18px; height: 18px; display: inline-flex; }
.who-chev svg { width: 100%; height: 100%; }
.dot-badge { position: absolute; left: 32px; top: 2px; width: 11px; height: 11px; border-radius: 50%; background: var(--bad); border: 2px solid var(--bg); }
.avatar.big { width: 42px; height: 42px; font-size: 22px; }
.icon-round { width: 42px; height: 42px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); color: var(--hint); display: flex; align-items: center; justify-content: center; flex: none; }
.icon-round svg { width: 22px; height: 22px; }
.banner { display: flex; gap: 10px; align-items: flex-start; margin: 4px 16px 0; padding: 11px 14px; border-radius: 14px; background: var(--soft); color: var(--text); font-size: 13.5px; max-width: 608px; }
.banner.warn { background: var(--warn-soft); }
.banner svg { width: 18px; height: 18px; color: var(--accent); flex: none; margin-top: 1px; }
@media (min-width: 672px) { .banner { margin-left: auto; margin-right: auto; } }

/* ---------- полоса недели ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 6px 0 12px; }
.wday { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }
.wday.today { background: var(--accent); color: var(--accent-text); }
.wd-name { font-size: 11px; font-weight: 600; opacity: .75; }
.wd-num { font-size: 16px; font-weight: 750; font-variant-numeric: tabular-nums; }
.wd-dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.wday.full .wd-dot { background: var(--ok); }
.wday.part .wd-dot { background: var(--warn); }
.wday.none .wd-dot { background: var(--bad); }
.wday.today .wd-dot { background: var(--accent-text); opacity: .9; }
.wday.today.none-planned .wd-dot { opacity: 0; }

/* ---------- картинки ---------- */
.art { display: block; border-radius: 22px; object-fit: cover; }
.art-hero { width: 180px; height: 180px; margin: 0 auto 14px; }
.art-mid { width: 140px; height: 140px; margin: 0 auto 12px; }
.art-small { width: 64px; height: 64px; border-radius: 16px; flex: none; }
.art-small.center { margin: 10px auto; width: 96px; height: 96px; }
.art-wide { width: 100%; aspect-ratio: 4 / 3; height: auto; margin-bottom: 12px; border-radius: 16px; }
.welcome { padding: 22px 18px 18px; text-align: center; }
.welcome h2 { font-size: 20px; margin-bottom: 10px; }
.perks { list-style: none; padding: 0; margin: 0 0 14px; text-align: left; }
.perks li { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--sep); font-size: 15px; }
.perk-ico { width: 34px; height: 34px; border-radius: 11px; background: var(--soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.perk-ico svg { width: 19px; height: 19px; }
.perks li:last-child { border-bottom: 0; }
.celebrate { display: flex; align-items: center; gap: 14px; padding: 12px 14px; margin-bottom: 6px; background: var(--ok-soft); }
.celebrate p { margin: 2px 0 0; }
.family-hero { padding: 14px; }
.family-hero p { margin: 0; color: var(--hint); font-size: 14px; }

/* ---------- лекарства ---------- */
.dose-sub.wrap { white-space: normal; }
.stockbar { height: 5px; border-radius: 3px; background: var(--sep); margin-top: 8px; overflow: hidden; }
.stockbar i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.stockbar i.low { background: var(--bad); }
.slot-part { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 650; color: var(--hint); }
.slot-part .bi { width: 16px; height: 16px; }
.note-view { display: flex; gap: 8px; align-items: flex-start; background: var(--bg); border-radius: 12px; padding: 10px 12px; margin: 8px 0 4px; font-size: 14px; }
.note-view .bi { color: var(--hint); margin-top: 1px; }

/* ---------- семья ---------- */
.person-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.person-row + .person-row { border-top: 1px solid var(--sep); }
.person-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; }
.person-main small { color: var(--hint); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-pick { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 4px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--bg); border: 1.5px solid transparent; }
.pick.on { border-color: var(--accent); background: var(--soft); }
.emojis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 12px 0; }
.emojis button { padding: 6px 0; border-radius: 16px; background: var(--bg); border: 2px solid transparent; display: grid; place-items: center; }
.emojis button svg { width: 46px; height: 46px; display: block; }
.emojis button.on { border-color: var(--accent); background: var(--soft); }
.row-2.tight { grid-template-columns: 1fr 1fr; margin-top: 14px; }

/* ---------- мастер ---------- */
.head-gap { width: 56px; }
.progress { height: 3px; background: var(--sep); flex: none; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.step-head { padding: 20px 4px 6px; }
.step-no { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.step-head h2 { font-size: 24px; letter-spacing: -.02em; margin: 4px 0 4px; }
.step-head p { margin: 0 0 6px; font-size: 14px; }
.choice-list { display: flex; flex-direction: column; gap: 6px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 14px; background: var(--bg); border: 1.5px solid transparent; text-align: left; }
.choice.on { border-color: var(--accent); background: var(--soft); }
.choice-ico { width: 38px; height: 38px; border-radius: 12px; background: var(--soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.choice-ico svg { width: 21px; height: 21px; }
.choice.on .choice-ico { background: var(--accent); color: var(--accent-text); }
.choice b { display: block; font-size: 15px; }
.choice small { color: var(--hint); font-size: 12.5px; }
.wizard-nav { margin-top: 20px; }
.btn.ghost { background: transparent; color: var(--hint); }
.settings-for { color: var(--hint); font-size: 14px; margin: 16px 4px 0; }

/* ---------- крупный текст ---------- */
html.big body { font-size: 17px; }
html.big .dose-name { font-size: 19px; }
html.big .dose-sub, html.big .hint, html.big .who-text small { font-size: 15px; }
html.big .btn { font-size: 17px; min-height: 50px; }
html.big .btn.take { min-height: 46px; font-size: 16px; }
html.big .slot-time { font-size: 20px; }
html.big .chip { font-size: 14px; }
html.big .seg button { font-size: 16px; }
/* ---------- доступность и длинные имена (аудит 14.10.2026) ---------- */
body { overflow-wrap: anywhere; }
html:has(#app.locked) { overflow: hidden; }
.slot-take, .btn.take, .btn.small, .link, .chip-btn { min-height: 44px; }
.slot-take { display: inline-flex; align-items: center; padding: 0 14px; }
.chip-btn { display: inline-flex; align-items: center; }
.icon-btn, .color { position: relative; }
.icon-btn::after, .color::after { content: ""; position: absolute; inset: -6px; }
.person-name, .person-main b, .sheet-head b, .sheet-title, .confirm b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.person-name, .person-main b { white-space: nowrap; }
.sheet { max-height: 88vh; overflow-y: auto; overscroll-behavior: contain; }
.bad-text { color: var(--bad); }
.empty-day a { color: var(--link); }
html.big .slot-take, html.big .link, html.big .chip-btn { font-size: 16px; }

/* Значки внутри текста и кнопок: линейные, цвета текста. */
.bi { display: inline-flex; width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.bi svg { width: 100%; height: 100%; display: block; }
.slot-badge { display: inline-flex; align-items: center; }
.chip .bi, .slot-badge .bi { width: 14px; height: 14px; margin-right: 4px; }
.empty-day .bi { color: var(--ok); margin-right: 4px; }
.hint .bi { vertical-align: -4px; }
.icon-btn svg { width: 15px; height: 15px; }
.toast { display: flex; align-items: center; gap: 8px; }
.toast .bi { width: 18px; height: 18px; }
.avatar svg { width: 100%; height: 100%; display: block; }
.av { border-radius: 50%; overflow: hidden; }
html.big .bi { width: 21px; height: 21px; }
.share-card { display: flex; align-items: center; gap: 12px; padding: 14px; margin-top: 16px; }
.share-text { flex: 1; min-width: 0; }
.share-text b { display: block; font-size: 15px; }
.share-text small { display: block; color: var(--hint); font-size: 12.5px; margin-top: 2px; }
/* Поле с крестиком «очистить» справа. */
.input-wrap { position: relative; }
.input-wrap .name-input { padding-right: 44px; }
.clear-btn { position: absolute; right: 2px; top: 4px; width: 32px; height: 32px; border-radius: 50%; background: var(--bg); color: var(--hint);
  display: grid; place-items: center; }
.clear-btn svg { width: 14px; height: 14px; }
.clear-btn::after { content: ""; position: absolute; inset: -6px; }
/* Полоса дней: будущие дни и выбранный день. */
.wday.future { background: var(--bg); box-shadow: none; }
.wday.sel { box-shadow: 0 0 0 2px var(--accent); }
.day-view { margin-bottom: 12px; }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 2px 8px; }
.day-head b { font-size: 17px; }
.day-wait { display: grid; place-items: center; padding: 30px 0; }
.day-row { align-items: center; }
.day-ico { display: inline-flex; flex: none; }
.day-row .list-name { flex: 1; min-width: 0; white-space: normal; }
.day-row .list-name b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.day-row .list-name small { display: block; color: var(--hint); font-size: 13px; }
.day-row .chip { flex: none; }
/* Поля в карточке формы не слипаются: между соседними блоками воздух. */
.form > * + *:not(.field) { margin-top: 14px; }
.form > div > .field:first-child { margin-top: 0; }

/* Выбранные дни недели — с галочкой в углу. */
.weekdays button { position: relative; }
.wd-check { position: absolute; top: 3px; right: 3px; width: 15px; height: 15px; border-radius: 50%; background: var(--accent-text);
  color: var(--accent); display: grid; place-items: center; }
.wd-check svg { width: 10px; height: 10px; stroke-width: 3.2; }

/* Вкладки шагов при правке лекарства. */
.step-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; padding: 12px 0 2px; }
.step-tabs::-webkit-scrollbar { display: none; }
.step-tabs button { min-height: 44px; padding: 4px 2px; border-radius: 12px; background: var(--card); color: var(--text);
  font-size: 12.5px; font-weight: 600; line-height: 1.15; box-shadow: var(--shadow); }
.step-tabs button.on { background: var(--accent); color: var(--accent-text); }
