/* DocApp fake door — стили в духе приложения Docmed (TT Hoves, фиолетовый акцент, белые карточки 16pt). */
:root {
  --violet: #4C55E4;
  --violet-light: #EDEEFC;
  --black: #1F1F29;
  --text: #333333;
  --secondary: #9299A2;
  --border: #E6E2DF;
  --bg: #FAF6F3;
  --card: #FFFFFF;
  --chip: #F3EFEC;
  --red: #FF383E;
  --red-light: #FFF3F3;
  --green: #44DB93;
  --blue: #41A4FF;
  --blue-light: #E4F2FF;
  --radius-card: 16px;
  --radius-btn: 10px;
  --shadow: 0 6px 24px rgba(31, 31, 41, 0.06);
  --font: "TT Hoves", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  color: var(--black);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea, select { -webkit-user-select: text; user-select: text; font: inherit; color: inherit; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
a { color: var(--violet); text-decoration: none; }
[hidden] { display: none !important; }

/* --- Каркас экрана --- */
.screen { min-height: 100vh; display: flex; flex-direction: column; animation: enter .22s ease-out; }
.screen.back-anim { animation: enter-back .22s ease-out; }
@keyframes enter { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes enter-back { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }

.nav {
  position: sticky; top: 0; z-index: 10;
  padding: calc(var(--safe-top) + 4px) 8px 4px;
  min-height: calc(var(--safe-top) + 52px);
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  background: rgba(250, 246, 243, 0.94);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.nav-title { text-align: center; font-size: 17px; font-weight: 500; letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 22px; }
.nav-btn:active { background: rgba(31, 31, 41, 0.06); }
.nav-btn svg { width: 24px; height: 24px; stroke: var(--black); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.content { flex: 1; padding: 8px 16px calc(var(--safe-bottom) + 24px); display: flex; flex-direction: column; gap: 12px; }
.content.with-bar { padding-bottom: calc(var(--safe-bottom) + 112px); }

/* --- Типографика --- */
.h1 { font-size: 26px; font-weight: 500; letter-spacing: -0.5px; line-height: 1.2; margin: 0; }
.h2 { font-size: 20px; font-weight: 500; letter-spacing: -0.3px; line-height: 1.25; margin: 0; }
.h3 { font-size: 17px; font-weight: 500; letter-spacing: -0.2px; margin: 0; }
.body { font-size: 15px; color: var(--text); margin: 0; }
.small { font-size: 13px; color: var(--secondary); margin: 0; }
.tiny { font-size: 12px; color: var(--secondary); }
.muted { color: var(--secondary); }

/* --- Карточки --- */
.card { background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card.tap { cursor: pointer; transition: transform .12s; }
.card.tap:active { transform: scale(0.985); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; font-size: 20px; }
.card-icon.sleep { background: var(--violet-light); }
.card-icon.chat { background: var(--blue-light); }
.card-icon.kb { background: #FFF1E0; }
.chevron { width: 20px; height: 20px; stroke: var(--secondary); fill: none; stroke-width: 2; flex: none; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }

.badge { display: inline-block; font-size: 11px; font-weight: 500; padding: 2px 7px; border-radius: 6px; background: var(--violet-light); color: var(--violet); vertical-align: middle; letter-spacing: 0.2px; }
.badge.warn { background: var(--red-light); color: var(--red); }

/* --- Кнопки (как DMButtonStyle) --- */
.btn { height: 45px; padding: 0 16px; border-radius: var(--radius-btn); font-size: 15px; font-weight: 500; width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: opacity .15s, transform .1s; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--violet); color: #fff; }
.btn.secondary { background: var(--violet-light); color: var(--violet); }
.btn.cancel { background: var(--red-light); color: var(--red); }
.btn.ghost { background: transparent; color: var(--violet); height: 40px; }
.btn.small { height: 35px; font-size: 14px; width: auto; }
.btn:disabled { opacity: .3; pointer-events: none; }
.btn .spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { color: var(--secondary); font-size: 14px; padding: 10px 0; text-align: center; width: 100%; }
.link-btn.violet { color: var(--violet); }

/* --- Шапка обзора --- */
.hero { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 4px; }
.child-switch { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); font-size: 14px; font-weight: 500; }
.child-switch svg { width: 16px; height: 16px; stroke: var(--secondary); fill: none; stroke-width: 2; }
.informer { background: var(--blue-light); border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text); }
.informer button { color: var(--secondary); font-size: 18px; line-height: 1; padding: 0 2px; }

/* --- Нижняя плашка тарифов --- */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px 16px calc(var(--safe-bottom) + 12px); background: rgba(255,255,255,.96); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 -4px 24px rgba(31,31,41,.06); display: flex; align-items: center; gap: 12px; }
.bar .grow { font-size: 13px; color: var(--text); line-height: 1.3; }
.bar .grow b { color: var(--black); font-weight: 500; font-size: 15px; }
.bar .btn { width: auto; flex: none; padding: 0 18px; }

/* --- Чипы, сегменты --- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); font-size: 14px; color: var(--text); white-space: nowrap; }
.chip.active { background: var(--violet); color: #fff; }
.chip.wrap { white-space: normal; text-align: left; flex: 1 1 auto; }
.chips-col { display: flex; flex-direction: column; gap: 8px; }
.segment { display: grid; grid-template-columns: 1fr 1fr; background: var(--chip); border-radius: 12px; padding: 3px; }
.segment button { height: 36px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--secondary); }
.segment button.active { background: var(--card); color: var(--black); box-shadow: 0 1px 4px rgba(31,31,41,.08); }

/* --- Списки --- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--chip); }
.list-item:first-child { border-top: 0; padding-top: 2px; }
.list-item .title { font-size: 15px; color: var(--black); }
.article-item { cursor: pointer; }
.topic-dot { width: 8px; height: 8px; border-radius: 4px; flex: none; }
.topic-sleep { background: var(--violet); }
.topic-food { background: #FF9811; }
.topic-development { background: var(--green); }
.topic-daily { background: var(--blue); }

/* --- Дневник --- */
.stat { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.stat .value { font-size: 26px; font-weight: 500; letter-spacing: -0.5px; }
.delta { font-size: 13px; padding: 3px 8px; border-radius: 8px; background: var(--chip); color: var(--text); }
.chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 120px; padding-top: 6px; }
.chart .col { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart .bar-v { width: 100%; max-width: 28px; border-radius: 6px 6px 3px 3px; background: var(--violet-light); min-height: 3px; }
.chart .col.today .bar-v { background: var(--violet); }
.chart .val { font-size: 10px; color: var(--secondary); height: 14px; }
.chart .day { font-size: 11px; color: var(--secondary); }
.chart .col.today .day { color: var(--black); font-weight: 500; }
.entry { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--chip); font-size: 14px; }
.entry:first-child { border-top: 0; }
.timer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--violet-light); color: var(--violet); font-weight: 500; }

/* --- Оценка 1–5 --- */
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale button { height: 44px; border-radius: 12px; background: var(--chip); font-size: 17px; font-weight: 500; color: var(--text); }
.scale button.active { background: var(--violet); color: #fff; }
.scale-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--secondary); }
.option { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--chip); font-size: 15px; color: var(--text); text-align: left; width: 100%; }
.option .radio { width: 20px; height: 20px; border-radius: 10px; border: 2px solid var(--border); flex: none; display: grid; place-items: center; }
.option.active { background: var(--violet-light); color: var(--black); }
.option.active .radio { border-color: var(--violet); }
.option.active .radio::after { content: ""; width: 10px; height: 10px; border-radius: 5px; background: var(--violet); }
.checkbox { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 12px; background: var(--chip); font-size: 15px; width: 100%; text-align: left; }
.checkbox .box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border); flex: none; display: grid; place-items: center; background: #fff; }
.checkbox.on .box { background: var(--violet); border-color: var(--violet); }
.checkbox.on .box::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.done-note { display: flex; gap: 8px; align-items: center; padding: 12px 14px; border-radius: 12px; background: #E8FAF1; color: #1E7A4F; font-size: 14px; }

/* --- Тарифы --- */
.plan { background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 8px; border: 2px solid transparent; text-align: left; width: 100%; transition: border-color .15s; }
.plan.active { border-color: var(--violet); }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.plan-title { font-size: 17px; font-weight: 500; }
.plan-price { font-size: 20px; font-weight: 500; white-space: nowrap; }
.plan-line { display: grid; grid-template-columns: 86px 1fr; gap: 8px; font-size: 14px; color: var(--text); }
.plan-line span:first-child { color: var(--secondary); }
.plan-delta { font-size: 13px; color: var(--violet); background: var(--violet-light); border-radius: 8px; padding: 6px 10px; }
.plan-situation { font-size: 13px; color: var(--secondary); }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0 calc(var(--safe-bottom) + 8px); background: linear-gradient(to top, var(--bg) 75%, rgba(250,246,243,0)); display: flex; flex-direction: column; gap: 4px; }

/* --- Чат --- */
.notice { display: flex; flex-direction: column; gap: 10px; background: #FFF6E5; border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--text); }
.composer { display: flex; gap: 8px; align-items: flex-end; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 8px; }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; min-height: 40px; max-height: 140px; padding: 9px 8px; font-size: 15px; background: transparent; }
.composer .btn { width: auto; height: 40px; }
.bubble { align-self: flex-end; max-width: 85%; background: var(--violet); color: #fff; padding: 10px 14px; border-radius: 18px 18px 4px 18px; font-size: 15px; white-space: pre-wrap; word-break: break-word; -webkit-user-select: text; user-select: text; }
.bubble-meta { align-self: flex-end; font-size: 12px; color: var(--red); display: flex; gap: 4px; align-items: center; }
.system-msg { background: var(--card); border-radius: 16px; padding: 14px; font-size: 14px; color: var(--text); box-shadow: var(--shadow); }

/* --- Шторка, поля --- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(31,31,41,.35); z-index: 50; animation: fade .2s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 16px calc(var(--safe-bottom) + 16px); max-height: 92vh; overflow-y: auto; animation: up .24s ease-out; display: flex; flex-direction: column; gap: 12px; }
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--border); align-self: center; margin-bottom: 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--secondary); }
.field input, .field select { height: 48px; border-radius: 12px; border: 1px solid var(--border); background: #fff; padding: 0 14px; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none; }
.field input:focus, .field select:focus { border-color: var(--violet); }
.error { color: var(--red); font-size: 13px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--safe-bottom) + 24px); z-index: 60; background: var(--black); color: #fff; border-radius: 12px; padding: 12px 16px; font-size: 14px; text-align: center; animation: up .2s; }

.center-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 32px 24px; }
.center-state .emoji { font-size: 48px; }
.loader { width: 28px; height: 28px; border: 3px solid var(--violet-light); border-top-color: var(--violet); border-radius: 50%; animation: spin .8s linear infinite; }
.hide-btn { color: var(--secondary); font-size: 14px; padding: 12px 0 4px; text-align: center; width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
