/* Темы: «Овсяное молоко» / «Лаванда» × светлая / тёмная (design.md v0.3) */
:root, [data-theme="oat"][data-mode="light"] {
  --bg:#F5EFE6; --card:#FFFBF5; --soft:#EADBC8; --acc:#C9A88C; --onacc:#3B342E; --ink:#3B342E; --muted:#6B6056; --line:#E7DCCF; --hand:#A07D62;
  --done:#C8A46A; --crisis:#B5644E; --crisis-bg:#F6E4DC; --shadow:0 1px 2px rgba(59,52,46,.05);
}
[data-theme="oat"][data-mode="dark"] { --bg:#1E1A17; --card:#2A2420; --soft:#3A3029; --acc:#C9A88C; --onacc:#1E1A17; --ink:#F2EBE3; --muted:#B8AB9E; --line:#3A322C; --hand:#C9A88C; --done:#D4B47E; --crisis:#E0957F; --crisis-bg:#3A2420; }
[data-theme="lavender"][data-mode="light"] { --bg:#F4EFE8; --card:#FFFCF7; --soft:#E6E0EE; --acc:#A99DC0; --onacc:#36323A; --ink:#36323A; --muted:#675F6C; --line:#E8E1D8; --hand:#8A7CA8; --done:#C8A46A; --crisis:#B5644E; --crisis-bg:#F6E4DC; }
[data-theme="lavender"][data-mode="dark"] { --bg:#1C1A21; --card:#26232D; --soft:#36313F; --acc:#B4A8CC; --onacc:#1C1A21; --ink:#EEEAF2; --muted:#B0AABA; --line:#37323F; --hand:#B4A8CC; --done:#D4B47E; --crisis:#E0957F; --crisis-bg:#3A2420; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.55 Manrope, system-ui, sans-serif; min-height: 100dvh; transition: background .3s; }
h1, h2, h3, .serif { font-family: Lora, Georgia, serif; font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 28px; line-height: 1.2; } h2 { font-size: 21px; } h3 { font-size: 17px; }
.hand { font-family: Caveat, cursive; color: var(--hand); font-size: 22px; line-height: 1.25; }
.muted { color: var(--muted); } .small { font-size: 13.5px; } .center { text-align: center; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }

#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.page { padding: 18px 18px 110px; flex: 1; display: flex; flex-direction: column; gap: 14px; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px; box-shadow: var(--shadow); }
.card.soft { background: var(--soft); border-color: transparent; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }

.btn { border: 0; border-radius: 16px; padding: 13px 18px; background: var(--acc); color: var(--onacc); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .15s, opacity .2s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.big { width: 100%; padding: 17px; font-size: 17px; border-radius: 20px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); font-weight: 600; }
.btn.soft { background: var(--soft); color: var(--ink); font-weight: 600; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 12px; }
.btn.danger { background: transparent; border: 1px solid var(--crisis); color: var(--crisis); }
.icon-btn { border: 0; background: transparent; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--ink); flex: none; }
.icon-btn:active { background: var(--soft); }
.icon-btn svg, .btn svg { width: 22px; height: 22px; }

label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=tel], textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 14px; padding: 12px 14px; font: 16px/1.5 Manrope, sans-serif; outline: none; transition: border-color .2s;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { border-color: var(--acc); }

.choice { display: grid; gap: 10px; }
.choice button { text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 14px 16px; cursor: pointer; }
.choice button.on { border-color: var(--acc); background: var(--soft); }
.choice button b { display: block; } .choice button span { color: var(--muted); font-size: 14px; }
.seg { display: flex; background: var(--soft); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 8px; border-radius: 11px; cursor: pointer; font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--card); box-shadow: var(--shadow); }

/* Вход */
.pin { display: flex; gap: 12px; justify-content: center; }
.pin input { width: 58px; height: 64px; text-align: center; font-size: 26px; font-weight: 700; border-radius: 16px; padding: 0; }
.logo { width: 64px; height: 64px; border-radius: 22px; background: var(--soft); display: grid; place-items: center; margin: 30px auto 6px; }
.logo svg { width: 34px; height: 34px; color: var(--hand); }

/* Нижняя навигация */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
.nav-in { max-width: 640px; width: 100%; display: flex; justify-content: space-around; }
.nav a { text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); padding: 4px 10px; border-radius: 12px; }
.nav a.on { color: var(--ink); } .nav a.on svg { color: var(--hand); }
.nav svg { width: 24px; height: 24px; }

/* Главная */
.hello { padding-top: 8px; }
.task { border-left: 4px solid var(--acc); }
.task.done { border-left-color: var(--done); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; background: var(--soft); color: var(--ink); border-radius: 99px; padding: 3px 10px; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }

/* Сессия */
.session { padding: 0; gap: 0; }
.s-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.s-head .who { flex: 1; min-width: 0; }
.s-head .who b { font-family: Lora, serif; font-size: 17px; }
.dots { display: flex; gap: 3px; margin-top: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--acc); } .dots i.extra { background: var(--done); }
.feed { flex: 1; padding: 16px 14px 200px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; padding: 12px 15px; border-radius: 20px; white-space: pre-wrap; word-wrap: break-word; animation: fade .3s ease; }
.msg.psy { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; align-self: flex-start; }
.msg.me { background: var(--soft); border-bottom-right-radius: 6px; align-self: flex-end; }
.msg .tools { display: flex; gap: 4px; margin: 6px -6px -6px; }
.msg .tools .icon-btn { width: 34px; height: 34px; color: var(--muted); }
.msg .tools .icon-btn svg { width: 19px; height: 19px; }
.chip-note { align-self: center; font-size: 13px; color: var(--muted); background: var(--soft); border-radius: 99px; padding: 4px 12px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

.composer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
.composer-in { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.chips button.on { background: var(--acc); border-color: var(--acc); color: var(--onacc); font-weight: 600; }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.input-row textarea { min-height: 48px; max-height: 40dvh; border-radius: 22px; padding: 12px 16px; resize: none; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; flex: none; background: var(--acc); color: var(--onacc); }
.round.soft { background: var(--soft); color: var(--ink); }
.round.rec { background: var(--crisis); color: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--crisis) 50%, transparent); } 70% { box-shadow: 0 0 0 12px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.round svg { width: 22px; height: 22px; }
.counter { font-size: 12px; color: var(--muted); text-align: right; }

/* Окно-упражнение */
.flow { border: 1.5px solid var(--acc); border-radius: 22px; background: var(--card); padding: 16px; align-self: stretch; animation: fade .35s ease; }
.flow .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.flow .progress { display: flex; gap: 4px; margin: 10px 0 14px; }
.flow .progress i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.flow .progress i.on { background: var(--acc); }
.flow .prompt { font-family: Lora, serif; font-size: 18px; line-height: 1.4; margin-bottom: 10px; }
.flow .prefill { font-family: Caveat, cursive; font-size: 22px; color: var(--hand); margin-bottom: 8px; }
.flow.closed { border-style: dashed; border-color: var(--line); padding: 10px 14px; font-size: 14px; color: var(--muted); }
.scale-val { font-size: 34px; font-weight: 700; font-family: Lora, serif; text-align: center; }
input[type=range] { width: 100%; accent-color: var(--acc); height: 32px; }
.breath { display: grid; place-items: center; padding: 10px 0 4px; }
.breath .ball { width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--card), var(--acc)); display: grid; place-items: center; transform: scale(.6); transition-property: transform; transition-timing-function: ease-in-out; }
.breath .phase { font-weight: 700; color: var(--onacc); }

/* Карточки */
.crisis { background: var(--crisis-bg); border: 1px solid var(--crisis); color: var(--ink); border-radius: 20px; padding: 16px; align-self: stretch; }
.crisis h3 { color: var(--crisis); }
.crisis a.tel { display: block; padding: 10px 12px; margin-top: 8px; background: var(--card); border-radius: 12px; text-decoration: none; font-weight: 600; }
.insight .hand { font-size: 26px; }
.voice-card { display: flex; align-items: center; gap: 12px; }
.voice-card .round { width: 42px; height: 42px; }

/* Нижний лист */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: bgin .25s ease; }
@keyframes bgin { from { opacity: 0; } }
.sheet { background: var(--bg); width: 100%; max-width: 640px; border-radius: 26px 26px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow-y: auto; animation: up .3s ease; display: flex; flex-direction: column; gap: 14px; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.scale5 { display: flex; gap: 8px; }
.scale5 button { flex: 1; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 0; font-size: 20px; cursor: pointer; }
.scale5 button.on { background: var(--acc); border-color: var(--acc); }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: 14px; z-index: 40; max-width: 90vw; animation: fade .25s ease; }
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--line); border-top-color: var(--acc); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
table.mini { width: 100%; border-collapse: collapse; font-size: 14px; }
table.mini td, table.mini th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; }
details summary { cursor: pointer; font-weight: 600; }
