/* Стетоскоп QSTiUM. Цвета — те же пять тем, что в приложении: тему ставит stethoscope-theme.js
   на <html data-theme>. --ink — цвет «чернил» схемы и графиков в виде r, g, b для rgba(). */
:root, :root[data-theme="dark-mode"] {
	color-scheme: dark;
	--bg: #1d2025;
	--bg-glow: #2a2f3a;
	--glass: rgba(33, 36, 44, 0.8);
	--glass-solid: #21242c;
	--line: rgba(255, 255, 255, 0.1);
	--text: #e0e0e0;
	--heading: #f1f1f1;
	--muted: #aaaaaa;
	--ink: 255, 255, 255;
	--bar: rgba(29, 32, 37, 0.88);
	--island: rgba(33, 36, 44, 0.86);
	--well: rgba(0, 0, 0, 0.22);
	--panel-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
	--float-shadow: 0 0.6em 1.6em rgba(0, 0, 0, 0.35);
	--heart: #ff8b8b;
	--heart-ink: #1a0b0b;
	--lung: #58a6ff;
	--lung-ink: #0d1117;
	--gut: #f0b46a;
	--gut-ink: #1f1406;
	--ok: #7ee0a8;
	--bad: #ff9c8f;
	--warn-text: #ffd9a8;
	--warn-bg: rgba(255, 170, 60, 0.12);
}
:root[data-theme="oled-mode"] {
	--bg: #000000;
	--bg-glow: #000000;
	--glass: rgba(10, 10, 10, 0.92);
	--glass-solid: #0a0a0a;
	--line: rgba(255, 255, 255, 0.13);
	--text: #e0e0e0;
	--heading: #ffffff;
	--muted: #b5b5b5;
	--bar: rgba(0, 0, 0, 0.9);
	--island: rgba(10, 10, 10, 0.92);
	--well: #000000;
	--panel-shadow: none;
	--float-shadow: 0 0 0 1px #1a1a1a;
	--lung: #8cc8ff;
	--lung-ink: #08131f;
}
:root[data-theme="synthwave-mode"] {
	--bg: #0f172a;
	--bg-glow: #172554;
	--glass: rgba(30, 41, 59, 0.74);
	--glass-solid: #1e293b;
	--line: #334155;
	--text: #e2e8f0;
	--heading: #38bdf8;
	--muted: #94a3b8;
	--ink: 226, 232, 240;
	--bar: rgba(15, 23, 42, 0.88);
	--island: rgba(30, 41, 59, 0.86);
	--well: rgba(15, 23, 42, 0.6);
	--heart: #f472b6;
	--heart-ink: #0f172a;
	--lung: #2dd4bf;
	--lung-ink: #0f172a;
	--gut: #fbbf24;
	--gut-ink: #0f172a;
	--ok: #6ee7b7;
	--bad: #f87171;
}
:root[data-theme="light"] {
	color-scheme: light;
	--bg: #eaeaea;
	--bg-glow: #f8f8f8;
	--glass: rgba(255, 255, 255, 0.86);
	--glass-solid: #ffffff;
	--line: rgba(0, 0, 0, 0.12);
	--text: #333333;
	--heading: #2c3e50;
	--muted: #666666;
	--ink: 44, 62, 80;
	--bar: rgba(234, 234, 234, 0.9);
	--island: rgba(255, 255, 255, 0.9);
	--well: rgba(0, 0, 0, 0.05);
	--panel-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
	--float-shadow: 0 0.5em 1.4em rgba(0, 0, 0, 0.14);
	--heart: #c0392b;
	--heart-ink: #ffffff;
	--lung: #1f6fb2;
	--lung-ink: #ffffff;
	--gut: #9a5b0f;
	--gut-ink: #ffffff;
	--ok: #1e7e45;
	--bad: #b3261e;
	--warn-text: #7a4a00;
	--warn-bg: rgba(255, 170, 60, 0.2);
}
:root[data-theme="claude-mode"] {
	color-scheme: light;
	--bg: #f2ede8;
	--bg-glow: #faf7f3;
	--glass: rgba(251, 248, 244, 0.88);
	--glass-solid: #fbf8f4;
	--line: rgba(90, 80, 70, 0.18);
	--text: #4a443e;
	--heading: #3d352f;
	--muted: #6b6155;
	--ink: 74, 68, 62;
	--bar: rgba(242, 237, 232, 0.9);
	--island: rgba(251, 248, 244, 0.92);
	--well: rgba(90, 80, 70, 0.07);
	--panel-shadow: 0 1px 3px rgba(90, 80, 70, 0.1);
	--float-shadow: 0 0.5em 1.4em rgba(90, 80, 70, 0.16);
	--heart: #a8473f;
	--heart-ink: #ffffff;
	--lung: #4a6f8f;
	--lung-ink: #ffffff;
	--gut: #8a5a22;
	--gut-ink: #ffffff;
	--ok: #275c33;
	--bad: #8b454d;
	--warn-text: #6e4a12;
	--warn-bg: rgba(200, 150, 70, 0.16);
}
:root { --gutter: max(1em, env(safe-area-inset-left)); }
body { --accent: var(--heart); --accent-ink: var(--heart-ink); }
body.organ-lung { --accent: var(--lung); --accent-ink: var(--lung-ink); }
body.organ-gut { --accent: var(--gut); --accent-ink: var(--gut-ink); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; min-height: 100dvh; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: radial-gradient(120% 60% at 50% 0%, var(--bg-glow) 0%, var(--bg) 60%) fixed; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.glass { border: 1px solid var(--line); border-radius: 1.1em; background: var(--glass); -webkit-backdrop-filter: blur(14px) saturate(130%); backdrop-filter: blur(14px) saturate(130%); box-shadow: var(--panel-shadow); }
.round { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 2.75em; height: 2.75em; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.round--flat { border: none; background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.btn { min-height: 2.75em; padding: 0.4em 1.2em; border: none; border-radius: 1.4em; font-weight: 600; color: var(--accent-ink); background: var(--accent); }

/* Слева место под кнопку «назад» приложения, она лежит поверх окна */
#homeLink { position: fixed; z-index: 21; top: max(0.75em, env(safe-area-inset-top)); left: var(--gutter); color: inherit; }
#top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 0.6em; padding: max(0.75em, env(safe-area-inset-top)) var(--gutter) 0.5em calc(var(--gutter) + 3.4em); background: var(--bar); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
#title { flex: 1; margin: 0; font-size: 1.2em; font-weight: 700; color: var(--heading); }

#main { max-width: 34em; margin: 0 auto; padding: 0 var(--gutter) calc(6.5em + env(safe-area-inset-bottom)); }
#main section { display: flex; flex-direction: column; gap: 0.75em; }

/* Схема груди */
#torsoWrap { position: relative; }
#torso { display: block; width: 100%; max-height: 38dvh; margin: 0 auto; touch-action: manipulation; }
#torso .body { fill: rgba(var(--ink), 0.05); stroke: rgba(var(--ink), 0.28); stroke-width: 1.5; }
#torso .bone { fill: none; stroke: rgba(var(--ink), 0.22); stroke-width: 1.3; stroke-linecap: round; }
#torso .rib { fill: none; stroke: rgba(var(--ink), 0.09); stroke-width: 1; }
#torso .organ { fill: var(--accent); opacity: 0.12; }
#torso .pt { cursor: pointer; }
#torso .pt circle.hit { fill: transparent; }
#torso .pt circle.ring { fill: none; stroke: none; }
#torso .pt circle.dot { fill: rgba(var(--ink), 0.18); stroke: rgba(var(--ink), 0.35); stroke-width: 1.2; transition: r 0.2s, fill 0.2s; }
#torso .pt.has circle.dot { fill: var(--accent); stroke: #fff; opacity: 0.9; }
#torso .pt.on circle.dot { fill: #fff; stroke: var(--accent); stroke-width: 3; }
#torso .pt.on circle.ring { fill: none; stroke: var(--accent); stroke-width: 2; animation: волна 1.6s ease-out infinite; transform-box: fill-box; transform-origin: center; }
#torso .pt:not(.has) { pointer-events: none; }
@keyframes волна { from { transform: scale(0.6); opacity: 0.9; } to { transform: scale(2.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #torso .pt.on circle.ring { animation: none; } }
/* Во время звука волну запускает скрипт на каждом ударе, равномерная пульсация выключена */
#torso.playing .pt.on circle.ring { animation: none; opacity: 0; }
#torso .pt.on circle.dot { transform-box: fill-box; transform-origin: center; }
#pointHint { margin: 0.2em 0 0; text-align: center; font-size: 0.8em; }
#pointHint:empty { display: none; }

/* Проигрыватель */
#player { padding: 0.8em 0.9em; }
.player__head { display: flex; align-items: center; gap: 0.7em; }
.player__names { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.player__names strong { font-size: 1.05em; line-height: 1.25; }
.player__names span { font-size: 0.82em; }
.play { position: relative; flex: none; width: 3.2em; height: 3.2em; border: none; border-radius: 50%; color: var(--accent-ink); background: var(--accent); }
.play::before { content: ""; position: absolute; left: 50%; top: 50%; width: 0; height: 0; margin: -0.6em 0 0 -0.35em; border-style: solid; border-width: 0.6em 0 0.6em 1em; border-color: transparent transparent transparent currentColor; }
.play[aria-pressed="true"]::before { width: 0.95em; height: 1.1em; margin: -0.55em 0 0 -0.475em; border: none; background: linear-gradient(90deg, currentColor 0 35%, transparent 35% 65%, currentColor 65%); }
.play--big { width: 4.4em; height: 4.4em; margin: 0.4em auto; display: block; }
.play:disabled { opacity: 0.4; }
#wave, #quizWave { display: block; width: 100%; height: 4em; margin: 0.6em 0 0.5em; cursor: pointer; touch-action: pan-y; border-radius: 0.4em; }
#wave:focus-visible, #quizWave:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Отметки на волне: чип с названием звука под бегунком, место под него оставлено заранее */
.wave-wrap { position: relative; }
.wave-wrap.has-marks { padding-bottom: 2em; }
.wave-chip { position: absolute; bottom: 0.1em; left: 0; max-width: 100%; padding: 0.25em 0.75em; border-radius: 1em; font-size: 0.8em; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--accent-ink); background: var(--accent); opacity: 0; transform: translate(-50%, -0.3em); transition: opacity 0.35s ease, transform 0.35s ease; pointer-events: none; }
.wave-chip.on { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .wave-chip, .wave-chip.on { transform: translate(-50%, 0); } }
.player__row { display: flex; align-items: center; gap: 0.6em; flex-wrap: wrap; }
.seg { display: inline-flex; flex: 1 1 auto; padding: 0.2em; border: 1px solid var(--line); border-radius: 1.2em; background: var(--well); }
.seg button { flex: 1; min-height: 2.4em; padding: 0.2em 0.6em; border: none; border-radius: 1em; font-size: 0.82em; color: var(--muted); background: transparent; white-space: nowrap; }
.seg button[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); font-weight: 600; }
.vol { display: flex; align-items: center; gap: 0.4em; flex: 0 1 9em; color: var(--muted); }
.vol input { width: 100%; accent-color: var(--accent); }
/* Шумоподавление: переключатель рядом с громкостью */
.toggle { display: inline-flex; align-items: center; gap: 0.45em; min-height: 2.4em; padding: 0.2em 0.85em; border: 1px solid var(--line); border-radius: 1.2em; font-size: 0.82em; white-space: nowrap; color: var(--muted); background: var(--well); }
.toggle .icon { width: 1.1em; height: 1.1em; }
.toggle[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: transparent; font-weight: 600; }
#pointLabel { margin: 0.55em 0 0; font-size: 0.85em; }

#about { padding: 0.8em 0.9em; }
#about p { margin: 0; }
#about p + p { margin-top: 0.55em; }

/* Выбор звука: ряд категорий + список строк */
#soundPick { padding: 0.55em 0.45em 0.45em; }
.cats { position: relative; display: flex; gap: 0.35em; overflow-x: auto; padding: 0 0.15em 0.55em; scrollbar-width: thin; scrollbar-color: rgba(var(--ink), 0.25) transparent; }
/* Правый край гаснет, только пока ряд можно листать дальше (класс ставит скрипт) */
.cats.more { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 2em), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 2em), transparent); }
.cats button { flex: none; display: inline-flex; align-items: center; gap: 0.4em; min-height: 2.3em; padding: 0.2em 0.8em; border: 1px solid var(--line); border-radius: 1.2em; font-size: 0.84em; white-space: nowrap; color: var(--muted); background: transparent; }
.cats button[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: transparent; font-weight: 600; }
.cats__n { font-size: 0.85em; font-variant-numeric: tabular-nums; opacity: 0.7; }
#soundList { display: flex; flex-direction: column; padding-top: 0.35em; border-top: 1px solid var(--line); }
.snd { display: flex; align-items: center; gap: 0.65em; width: 100%; min-height: 2.9em; padding: 0.45em 0.6em; border: none; border-radius: 0.8em; text-align: left; background: transparent; }
.snd + .snd { margin-top: 0.1em; }
.snd:hover { background: rgba(var(--ink), 0.05); }
.snd:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.snd__dot { flex: none; width: 0.55em; height: 0.55em; border-radius: 50%; background: rgba(var(--ink), 0.2); transition: background 0.2s, box-shadow 0.2s; }
.snd__name { flex: 1; min-width: 0; font-size: 0.93em; line-height: 1.3; }
.snd__tag { flex: none; padding: 0.1em 0.55em; border: 1px solid var(--line); border-radius: 0.8em; font-size: 0.72em; color: var(--muted); }
.snd__tag--live { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.snd[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.snd[aria-pressed="true"] .snd__name { font-weight: 600; color: var(--heading); }
.snd[aria-pressed="true"] .snd__dot { background: var(--accent); box-shadow: 0 0 0 0.25em color-mix(in srgb, var(--accent) 28%, transparent); }
/* Дыхание: чипы типов */
.chips { display: flex; flex-wrap: wrap; gap: 0.45em; }
.chip { min-height: 2.6em; padding: 0.35em 0.9em; border: 1px solid var(--line); border-radius: 1.3em; font-size: 0.9em; text-align: left; background: var(--glass); }
.chip[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: transparent; font-weight: 600; }

/* Дыхание */
#breathStage { position: relative; padding: 0.8em; }
#breathChest { display: block; width: 100%; height: 11em; }
#breathGraph { display: block; width: 100%; height: 6em; margin-top: 0.4em; }
#breathRate { margin: 0.3em 0 0; text-align: center; font-size: 0.85em; }
#breath article { padding: 0.8em 0.9em; }
#breath article p { margin: 0.4em 0 0; }

/* Тест */
#quizCard { padding: 1em 0.9em; text-align: center; }
#quizQuestion { margin: 0; color: var(--muted); }
#quizOptions { display: grid; gap: 0.45em; margin-top: 0.4em; }
#quizOptions button { min-height: 3em; padding: 0.4em 0.9em; border: 1px solid var(--line); border-radius: 0.9em; text-align: left; background: rgba(var(--ink), 0.04); }
#quizOptions button.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, transparent); }
#quizOptions button.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
#quizOptions button:disabled { cursor: default; }
#quizResult { margin-top: 0.8em; text-align: left; }
#quizVerdict { margin: 0; font-weight: 700; }
#quizExplain { margin: 0.4em 0 0.8em; }
#quizResult .btn { width: 100%; }
#quizScore { margin: 0; text-align: center; font-size: 0.9em; }

/* Нижний остров вкладок */
#tabs { position: fixed; z-index: 25; left: 50%; bottom: max(0.9em, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 0.2em; max-width: calc(100% - 2em); padding: 0.3em; border: 1px solid var(--line); border-radius: 1.6em; background: var(--island); -webkit-backdrop-filter: blur(16px) saturate(140%); backdrop-filter: blur(16px) saturate(140%); box-shadow: var(--float-shadow); }
#tabs button { min-height: 2.6em; padding: 0.3em 0.8em; border: none; border-radius: 1.3em; font-size: 0.9em; color: var(--muted); background: transparent; white-space: nowrap; }
#tabs button[aria-selected="true"] { color: var(--accent-ink); background: var(--accent); font-weight: 600; }

/* Лист «Источники» */
#shade { position: fixed; inset: 0; z-index: 29; background: rgba(0, 0, 0, 0.45); }
.sheet { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; max-width: 40em; max-height: 80dvh; margin: 0 auto; padding: 1em max(1em, env(safe-area-inset-right)) max(1.2em, env(safe-area-inset-bottom)) max(1em, env(safe-area-inset-left)); overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-bottom: none; border-radius: 1.2em 1.2em 0 0; background: var(--glass-solid); }
.sheet h2 { margin: 0 2.5em 0.5em 0; font-size: 1.2em; }
.sheet h3 { margin: 1em 0 0.3em; font-size: 0.95em; }
.sheet p, .sheet li { overflow-wrap: anywhere; }
.sheet ul { margin: 0; padding-left: 1.1em; }
.sheet li { margin: 0.3em 0; font-size: 0.9em; }
.sheet__close { position: absolute; top: 0.45em; right: 0.45em; }
.warn { margin: 0 0 0.6em; padding: 0.6em 0.8em; border-radius: 0.8em; color: var(--warn-text); background: var(--warn-bg); }

@media (min-width: 700px) {
	#listen:not([hidden]) { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
	#torsoWrap { grid-row: span 3; position: sticky; top: 4em; }
	#torso { max-height: 70dvh; }
	#main { max-width: 60em; }
}
