/* Венлафаксин — трекер титрования. Стили под iOS: системный шрифт,
   групповые карточки, безопасные отступы, автотёмная тема. */

:root {
  --blue: #1a66e6;
  --deep-blue: #0a2c7a;
  --sky: #61a3ff;
  --mint: #29ad8c;
  --amber: #ed9e24;
  --danger: #d63d42;

  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #101426;
  --secondary: #6b7185;
  --tertiary: #9aa0b0;
  --separator: rgba(60, 60, 67, 0.14);
  --fill: rgba(120, 120, 128, 0.12);

  --radius: 18px;
  --tabbar-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --card: #161c2e;
    --text: #f2f4f8;
    --secondary: #9aa3b8;
    --tertiary: #6f7891;
    --separator: rgba(255, 255, 255, 0.12);
    --fill: rgba(120, 130, 160, 0.22);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
}

.app { display: block; }

/* ---------- Шапка раздела ---------- */

.screen-head {
  padding: calc(env(safe-area-inset-top) + 18px) 16px 4px;
}
.screen-head .date {
  font-size: 15px;
  color: var(--secondary);
  text-transform: capitalize;
}
.screen-head h1 {
  margin: 2px 0 0;
  font-size: 26px;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
}
.screen-head .sub {
  margin-top: 2px;
  font-size: 14px;
  color: var(--secondary);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px 8px;
}

/* ---------- Карточки ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
}
.card.tight { padding: 0; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.title { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; margin: 0; }
.caption { font-size: 13px; color: var(--secondary); line-height: 1.45; }
.caption b, .caption strong { color: var(--text); font-weight: 600; }
.tiny { font-size: 12px; color: var(--secondary); }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--secondary); }

/* ---------- Главная карточка приёма ---------- */

.hero {
  position: relative;
  border-radius: 24px;
  padding: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--deep-blue) 0%, var(--blue) 55%, var(--sky) 100%);
  box-shadow: 0 10px 24px rgba(26, 102, 230, 0.28);
  overflow: hidden;
}
.hero.done { background: linear-gradient(135deg, #16704f 0%, #29ad8c 100%); box-shadow: 0 10px 24px rgba(41, 173, 140, 0.28); }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hero-slot { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.hero-chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 58%;
}
.hero-time {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 12px 0 4px;
}
.hero-time .t {
  font-size: 54px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
}
.hero-time .rel { font-size: 13px; opacity: 0.85; }
.hero-dose { font-size: 19px; font-weight: 600; }
.hero-note { margin-top: 8px; font-size: 12.5px; opacity: 0.88; line-height: 1.4; }
.hero-actions { margin-top: 14px; display: flex; gap: 10px; }
.hero-actions .btn { flex: 1; }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  background: var(--fill);
  color: var(--text);
  transition: transform 0.08s ease, opacity 0.15s ease;
  cursor: pointer;
}
.btn:active { transform: scale(0.985); opacity: 0.9; }
.btn.white { background: #fff; color: var(--deep-blue); }
.btn.success { background: var(--mint); color: #fff; }
.btn.danger { background: rgba(214, 61, 66, 0.12); color: var(--danger); }
.btn.ghost { background: transparent; color: var(--blue); padding: 10px 6px; font-size: 15px; }
.btn.wide { display: flex; width: 100%; }
.btn svg { width: 18px; height: 18px; flex: 0 0 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:disabled { opacity: 0.5; }

/* ---------- Предупреждение ---------- */

.warn {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: rgba(214, 61, 66, 0.1);
  border: 1px solid rgba(214, 61, 66, 0.28);
}
.warn.amber { background: rgba(237, 158, 36, 0.12); border-color: rgba(237, 158, 36, 0.32); }
.warn svg { width: 22px; height: 22px; flex: 0 0 22px; fill: var(--danger); stroke: none; }
.warn.amber svg { fill: var(--amber); }
.warn .w-title { font-weight: 600; margin-bottom: 3px; }
.warn .w-text { font-size: 13px; color: var(--secondary); line-height: 1.45; }

/* ---------- Прогресс ---------- */

.bar {
  height: 8px;
  border-radius: 99px;
  background: var(--fill);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--blue), var(--sky));
  transition: width 0.35s ease;
}
.bar.mint > i { background: linear-gradient(90deg, var(--mint), #54c9a8); }

.stage-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(26, 102, 230, 0.12);
  color: var(--blue);
  white-space: nowrap;
}

/* ---------- Список приёмов ---------- */

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--separator);
}
.row:first-child { border-top: 0; }
.row .r-main { flex: 1; min-width: 0; }
.row .r-title { font-weight: 600; font-size: 15px; }
.row .r-sub { font-size: 13px; color: var(--secondary); margin-top: 1px; }
.row .r-time { font-variant-numeric: tabular-nums; font-size: 15px; color: var(--secondary); }
.icon-btn {
  appearance: none;
  border: 0;
  background: var(--fill);
  border-radius: 12px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--blue);
  flex: 0 0 38px;
}
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.ok { background: rgba(41, 173, 140, 0.14); color: var(--mint); }
.icon-btn.warn { background: rgba(214, 61, 66, 0.12); color: var(--danger); }

.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--secondary);
  white-space: nowrap;
}
.pill.taken { background: rgba(41, 173, 140, 0.14); color: var(--mint); }
.pill.missed { background: rgba(214, 61, 66, 0.12); color: var(--danger); }
.pill.pending { background: rgba(237, 158, 36, 0.14); color: var(--amber); }

/* ---------- Этапы ---------- */

.stage {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-top: 1px solid var(--separator);
}
.stage:first-child { border-top: 0; }
.stage.current { background: rgba(26, 102, 230, 0.07); }
.stage.past { opacity: 0.72; }
.stage-num {
  width: 24px; height: 24px; flex: 0 0 24px;
  border-radius: 999px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: rgba(26, 102, 230, 0.12);
  color: var(--blue);
  margin-top: 1px;
}
.stage.past .stage-num { background: rgba(41, 173, 140, 0.16); color: var(--mint); }
.stage-body { flex: 1; min-width: 0; }
.stage-days { font-size: 15px; font-weight: 600; }
.stage-title { font-size: 13px; color: var(--secondary); margin-top: 1px; }
.stage-dose { font-size: 13px; color: var(--secondary); margin-top: 4px; line-height: 1.4; }
.stage-mg { font-size: 13px; font-weight: 700; color: var(--blue); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- История ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  background: var(--card);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.stat .l { font-size: 11.5px; color: var(--secondary); margin-top: 2px; }
.stat.good .v { color: var(--mint); }
.stat.bad .v { color: var(--danger); }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 92px; margin-top: 4px; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar-fill { width: 100%; border-radius: 6px; background: transparent; position: relative; flex: 1; overflow: hidden; display: flex; align-items: flex-end; }
.bars .bar-fill > i { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 6px; background: linear-gradient(180deg, var(--sky), var(--blue)); min-height: 0; }
.bars .bar-fill.empty > i { background: var(--separator); }
.bars .bar-lbl { font-size: 10.5px; color: var(--tertiary); text-transform: lowercase; }

.month-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 14px 0 4px; margin-top: 2px;
  border-top: 1px solid var(--separator);
}
.month-head.first { border-top: 0; padding-top: 2px; margin-top: 0; }
.month-head .m-name { font-size: 13px; font-weight: 600; text-transform: capitalize; letter-spacing: 0.2px; }
.month-head .m-stat { font-size: 12px; color: var(--secondary); font-variant-numeric: tabular-nums; }

.history-day { padding: 12px 0; border-top: 1px solid var(--separator); }
.history-day:first-child { border-top: 0; }
.hd-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hd-date { font-size: 14px; font-weight: 600; text-transform: capitalize; }
.hd-day { font-size: 12px; color: var(--tertiary); font-variant-numeric: tabular-nums; }
.hd-items { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }

/* ---------- Настройки ---------- */

.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--separator); }
.field:first-child { border-top: 0; }
.field .f-main { flex: 1; min-width: 0; }
.field .f-label { font-size: 15px; font-weight: 500; }
.field .f-note { font-size: 12.5px; color: var(--secondary); margin-top: 2px; line-height: 1.4; }
.field input[type="time"], .field input[type="date"], .field input[type="password"], .field input[type="text"] {
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--fill);
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 108px;
  text-align: center;
}
.field input::-webkit-calendar-picker-indicator { opacity: 0.55; }

.section-title {
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--tertiary);
  padding: 18px 16px 6px;
}

/* ---------- Таббар ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 84%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--separator);
  z-index: 50;
}
.tab {
  appearance: none;
  border: 0;
  background: none;
  color: var(--tertiary);
  font: inherit;
  font-size: 10.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  padding: 6px 2px 4px;
  cursor: pointer;
}
.tab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab[data-tab="today"] svg { fill: currentColor; stroke: none; }
.tab[aria-current="page"] { color: var(--blue); }
.tab:active { opacity: 0.6; }

/* ---------- Тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  background: rgba(28, 32, 46, 0.94);
  color: #fff;
  font-size: 14px;
  padding: 11px 16px;
  border-radius: 14px;
  max-width: calc(100% - 40px);
  z-index: 90;
  animation: toast-in 0.18s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Прочее ---------- */

.hero-card-about {
  border-radius: 24px;
  padding: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--deep-blue) 0%, var(--blue) 55%, var(--sky) 100%);
}
.hero-card-about h2 { margin: 6px 0 4px; font-size: 26px; letter-spacing: -0.5px; }
.hero-card-about p { margin: 0; font-size: 13.5px; opacity: 0.92; line-height: 1.45; }
.facts { display: flex; gap: 18px; margin-top: 14px; }
.fact .fv { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fact .fl { font-size: 11px; opacity: 0.8; }

.li { display: flex; gap: 9px; margin-top: 9px; }
.li::before { content: ""; width: 5px; height: 5px; border-radius: 99px; background: rgba(26, 102, 230, 0.55); margin-top: 8px; flex: 0 0 5px; }
.li span { font-size: 13px; color: var(--secondary); line-height: 1.45; }

.disclaimer { padding: 4px 4px 10px; }
.disclaimer b { display: block; font-size: 12px; color: var(--secondary); margin-bottom: 4px; }
.disclaimer span { font-size: 11.5px; color: var(--tertiary); line-height: 1.45; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--fill);
  padding: 1px 5px;
  border-radius: 5px;
}
