/* ДЕРЗАЙ — веб-версия. Оформление «Высота».
   Каждая цель — подъём к вершине. Спокойный серебристый фон (в тёмной теме —
   графит), белые «листы» с тонким контуром и мягкой тенью, один цвет-акцент
   на маршрут и главные действия. Шрифт Geologica, цифры — табличные.
   Цвета задаются переменными: шесть цветовых тем × светлый и тёмный режим. */

/* =====================================================================
   Токены: светлый режим (по умолчанию — фиолетовая тема)
   ===================================================================== */
:root,
:root[data-theme="light"] {
  --bg: #EDEEF1;
  --bg-soft: #F4F5F7;          /* «колодцы»: поля ввода, подложка переключателей */
  --card: #FFFFFF;
  --card-hover: #F5F6F8;
  --card-border: rgba(20, 22, 30, .10);
  --card-edge: rgba(20, 22, 30, .07);
  --line: rgba(20, 22, 30, .075);
  --raised: #FFFFFF;           /* выбранный сегмент, плитки поверх колодца */
  --track: #E4E5EA;            /* дорожка прогресса */

  --text: #15161B;
  --text-muted: #5C5F69;
  --text-faint: #737782;

  --accent: #5B41E6;
  --accent-hover: #6A52F0;
  --accent-press: #4B32D2;
  --accent-dark: #3F2BB0;
  --accent-soft: #EEEBFD;
  --accent-ink: #4A31CF;       /* текст и линии акцентом поверх светлого */
  --accent-grad-from: #5B41E6;
  --accent-grad-to: #957EFF;
  --on-accent: #FFFFFF;

  --success: #1D8754;
  --success-soft: #E4F3EB;
  --success-grad-to: #48C083;
  --on-success: #FFFFFF;
  --danger: #D2382B;
  --danger-soft: #FCEBE8;
  --warn: #A5620F;
  --warn-soft: #FBF0DF;
  --white: #FFFFFF;

  --hm0: #E3E4E9;
  --hm1: #D4CDFA;
  --hm2: #A797F5;
  --hm3: #6D55EC;
  --hm4: #4127C6;

  --sheet-shadow: 0 0 0 1px var(--card-edge), 0 1px 2px rgba(18, 20, 30, .04), 0 14px 32px -18px rgba(18, 20, 30, .16);
  --float-shadow: 0 0 0 1px var(--card-edge), 0 2px 6px rgba(18, 20, 30, .05), 0 24px 48px -16px rgba(18, 20, 30, .22);
  --shadow: 0 0 0 1px var(--card-edge), 0 30px 80px -24px rgba(18, 20, 30, .32), 0 2px 8px rgba(18, 20, 30, .06);
  --glass: rgba(237, 238, 241, .78);
  --glass-strong: rgba(255, 255, 255, .82);
  --scrim: rgba(18, 20, 28, .38);
  --ambient: .10;
  /* Тень под цветными кнопками: в светлой теме — оттенок акцента, в тёмной — просто тень */
  --accent-shadow: color-mix(in srgb, var(--accent) 70%, transparent);
  --success-shadow: color-mix(in srgb, var(--success) 70%, transparent);
  color-scheme: light;
}

/* =====================================================================
   Тёмный режим
   ===================================================================== */
:root[data-theme="dark"] {
  --bg: #0B0C10;
  --bg-soft: #121318;
  --card: #16171D;
  --card-hover: #1C1D24;
  --card-border: rgba(255, 255, 255, .10);
  --card-edge: rgba(255, 255, 255, .065);
  --line: rgba(255, 255, 255, .07);
  --raised: #25262E;
  --track: #24252D;

  --text: #F2F3F6;
  --text-muted: #A3A7B1;
  --text-faint: #7E828D;

  --accent: #6E55F5;
  --accent-hover: #6449F0;
  --accent-press: #5E45E6;
  --accent-dark: #4A3A9E;
  --accent-soft: #211D38;
  --accent-ink: #B4A6FF;
  --accent-grad-from: #6E55F5;
  --accent-grad-to: #B2A2FF;
  --on-accent: #FFFFFF;

  --success: #3CCB86;
  --success-soft: #13261C;
  --success-grad-to: #8AE8B8;
  --on-success: #06130C;
  --danger: #FF6B5D;
  --danger-soft: #2C1513;
  --warn: #EDB45A;
  --warn-soft: #2A2112;

  --hm0: #1E1F26;
  --hm1: #2D2760;
  --hm2: #4A3BB4;
  --hm3: #7C66FF;
  --hm4: #C3B7FF;

  --sheet-shadow: 0 0 0 1px var(--card-edge), inset 0 1px 0 rgba(255, 255, 255, .035), 0 18px 40px -22px rgba(0, 0, 0, .7);
  --float-shadow: 0 0 0 1px var(--card-border), inset 0 1px 0 rgba(255, 255, 255, .05), 0 24px 56px -18px rgba(0, 0, 0, .8);
  --shadow: 0 0 0 1px var(--card-border), inset 0 1px 0 rgba(255, 255, 255, .05), 0 40px 90px -24px rgba(0, 0, 0, .85);
  --glass: rgba(11, 12, 16, .74);
  --glass-strong: rgba(28, 29, 36, .82);
  --scrim: rgba(0, 0, 0, .58);
  --ambient: .16;
  --accent-shadow: rgba(0, 0, 0, .6);
  --success-shadow: rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* =====================================================================
   Цветовые темы. Меняется акцент и всё, что от него зависит; фон и
   поверхности общие — так каждая тема выглядит одинаково дорого.
   :not([data-theme="light"]) — чтобы тёмный вариант не перебивал светлый.
   ===================================================================== */

/* Чёрно-белая */
:root[data-palette="mono"][data-theme="light"] {
  --accent: #17181D; --accent-hover: #2B2C33; --accent-press: #0E0F13; --accent-dark: #3A3B43;
  --accent-soft: #E7E8EC; --accent-ink: #17181D;
  --accent-grad-from: #17181D; --accent-grad-to: #6B6E78; --on-accent: #FFFFFF;
  --success: #2A2B31; --success-soft: #E9EAED; --success-grad-to: #6B6E78; --on-success: #FFFFFF;
  --warn: #55575F; --warn-soft: #ECEDF0;
  --hm0: #E3E4E9; --hm1: #C8CAD1; --hm2: #9A9DA7; --hm3: #5E616B; --hm4: #17181D;
}
:root[data-palette="mono"]:not([data-theme="light"]) {
  --accent: #F2F3F6; --accent-hover: #FFFFFF; --accent-press: #D8D9DE; --accent-dark: #3A3B43;
  --accent-soft: #24252C; --accent-ink: #F2F3F6;
  --accent-grad-from: #8D909A; --accent-grad-to: #F2F3F6; --on-accent: #0B0C10;
  --success: #E2E3E7; --success-soft: #202127; --success-grad-to: #FFFFFF; --on-success: #0B0C10;
  --warn: #C7C9CF; --warn-soft: #202127;
  --hm0: #1E1F26; --hm1: #3A3C44; --hm2: #6A6D77; --hm3: #A6A9B2; --hm4: #F2F3F6;
}

/* Океан */
:root[data-palette="ocean"][data-theme="light"] {
  --accent: #1F62D8; --accent-hover: #2D71E6; --accent-press: #1652C0; --accent-dark: #134AA8;
  --accent-soft: #E5EDFC; --accent-ink: #1A56C4;
  --accent-grad-from: #1F62D8; --accent-grad-to: #4CB0F5;
  --hm0: #E3E5EA; --hm1: #C3D6F7; --hm2: #87AFEE; --hm3: #3F7FE6; --hm4: #1648A4;
}
:root[data-palette="ocean"]:not([data-theme="light"]) {
  --accent: #3C79EE; --accent-hover: #578DF4; --accent-press: #2E68D8; --accent-dark: #1D3F80;
  --accent-soft: #14203A; --accent-ink: #8DB8FF;
  --accent-grad-from: #3C79EE; --accent-grad-to: #6CC6FF;
  --hm0: #1E1F26; --hm1: #172F5A; --hm2: #1F4E9E; --hm3: #3C79EE; --hm4: #9CC7FF;
}

/* Лес */
:root[data-palette="forest"][data-theme="light"] {
  --accent: #1D7A4B; --accent-hover: #238A56; --accent-press: #16653D; --accent-dark: #145A36;
  --accent-soft: #E2F2E9; --accent-ink: #186B41;
  --accent-grad-from: #1D7A4B; --accent-grad-to: #4BBE84;
  --success: #0F857A; --success-soft: #E0F3F0; --success-grad-to: #2DCBB6;
  --hm0: #E3E5E8; --hm1: #BFE0CC; --hm2: #82C7A0; --hm3: #2E9A62; --hm4: #145A36;
}
:root[data-palette="forest"]:not([data-theme="light"]) {
  --accent: #23905A; --accent-hover: #2BA568; --accent-press: #1C7C4D; --accent-dark: #1E6B44;
  --accent-soft: #132A1E; --accent-ink: #79D9A6;
  --accent-grad-from: #23905A; --accent-grad-to: #7FE3AE;
  --success: #2DD4BF; --success-soft: #0F2623; --success-grad-to: #99F6E4; --on-success: #04201C;
  --hm0: #1E1F26; --hm1: #163F2A; --hm2: #1E6B44; --hm3: #2FA367; --hm4: #8FE6B6;
}

/* Закат */
:root[data-palette="sunset"][data-theme="light"] {
  --accent: #C24A12; --accent-hover: #D25618; --accent-press: #A63E0E; --accent-dark: #8F360C;
  --accent-soft: #FCEDE3; --accent-ink: #AE420F;
  --accent-grad-from: #C24A12; --accent-grad-to: #F0A23C;
  --hm0: #E6E4E2; --hm1: #F6D2BB; --hm2: #EFA477; --hm3: #D9631F; --hm4: #8F360C;
}
:root[data-palette="sunset"]:not([data-theme="light"]) {
  --accent: #C44E14; --accent-hover: #D65C1E; --accent-press: #AC4310; --accent-dark: #7A3311;
  --accent-soft: #2C1A10; --accent-ink: #FFA86E;
  --accent-grad-from: #C44E14; --accent-grad-to: #F7B04A;
  --hm0: #1E1F26; --hm1: #4A2414; --hm2: #8A3A12; --hm3: #E06A22; --hm4: #FFB37A;
}

/* Роза */
:root[data-palette="rose"][data-theme="light"] {
  --accent: #C42466; --accent-hover: #D12F72; --accent-press: #A81C56; --accent-dark: #86123F;
  --accent-soft: #FBE7EF; --accent-ink: #AF1F5B;
  --accent-grad-from: #C42466; --accent-grad-to: #F06BA3;
  --hm0: #E6E3E6; --hm1: #F6C9DB; --hm2: #EC8DB5; --hm3: #D2387A; --hm4: #86123F;
}
:root[data-palette="rose"]:not([data-theme="light"]) {
  --accent: #CF2E70; --accent-hover: #DC4381; --accent-press: #B52360; --accent-dark: #7E1D45;
  --accent-soft: #2D1421; --accent-ink: #FF8EBD;
  --accent-grad-from: #CF2E70; --accent-grad-to: #FF9AC5;
  --hm0: #1E1F26; --hm1: #4A1830; --hm2: #8E1F4F; --hm3: #E0498A; --hm4: #FFA8CC;
}

/* =====================================================================
   Размеры, шрифт, движение
   ===================================================================== */
:root {
  /* Масштаб интерфейса — из настроек */
  --scale: 1;
  --fs-small: calc(13px * var(--scale));
  --fs-base: calc(15px * var(--scale));
  --fs-title: calc(19px * var(--scale));
  --fs-sub: calc(17px * var(--scale));
  --fs-head: calc(24px * var(--scale));
  --fs-huge: calc(40px * var(--scale));
  --thumb: calc(148px * var(--scale));

  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;

  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --col: 880px;

  --ease: cubic-bezier(.23, 1, .32, 1);          /* сильный ease-out для интерфейса */
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);    /* как шторки в iOS */

  /* Смайлики идут ПОСЛЕ текстовых шрифтов: в эмодзи-шрифтах есть цифры, и
     поставь мы их вперёд — цифры в приложении поехали бы вслед за ними.
     На технике Apple есть Apple Color Emoji, на Windows и Android — наш
     урезанный Noto Color Emoji (16 КБ вместо 692). */
  --font: "Geologica", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif,
          "Apple Color Emoji", "MG Emoji", "Segoe UI Emoji", "Noto Color Emoji";
}

@font-face {
  font-family: "Derzay Wordmark";
  src: url("../fonts/unbounded-800-derzay.woff2") format("woff2");
  font-weight: 800; font-display: swap;
  /* Только буквы Д Е Р З А Й — файл весит 2 КБ */
  unicode-range: U+410, U+414-415, U+417-419, U+420;
}
@font-face {
  font-family: "MG Emoji";
  src: url("../fonts/emoji-subset.woff2") format("woff2");
  font-display: swap;
}

* { box-sizing: border-box; }

/* Обязательно со !important: правила ниже задают display (например, у
   .modal-host он grid), а правило браузера [hidden]{display:none} — стиль
   пользовательского агента, и любой авторский display его перебивает. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.45;
  letter-spacing: -.003em;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
/* Фон — только у html: свечение ниже лежит под содержимым, но над фоном */
html { background: var(--bg); touch-action: manipulation; scroll-behavior: smooth; overflow-x: hidden; overflow-x: clip; }
body { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; overflow-x: clip; }

/* Мягкое свечение акцентом сверху — единственная «атмосфера» в приложении */
body::before {
  content: ""; position: fixed; z-index: -1; pointer-events: none;
  left: 50%; top: -38vh; width: min(1100px, 160vw); height: 76vh;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, var(--accent), transparent);
  opacity: var(--ambient);
  filter: blur(40px);
}

::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text) 18%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text) 16%, transparent);
  border-radius: 10px; border: 3px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-track { background: transparent; }

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; letter-spacing: inherit; }
input, textarea, select { -webkit-appearance: none; appearance: none; caret-color: var(--accent); }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

svg.ic { display: block; flex: none; }

/* =====================================================================
   Экран загрузки
   ===================================================================== */
.boot {
  position: fixed; inset: 0; z-index: 900;
  background: var(--bg);
  display: grid; place-items: center;
  transition: opacity .32s var(--ease);
}
.boot::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 520px; height: 520px;
  transform: translate(-50%, -58%);
  background: radial-gradient(closest-side, var(--accent), transparent);
  opacity: calc(var(--ambient) * 1.4); filter: blur(30px); pointer-events: none;
}
.boot.hiding { opacity: 0; pointer-events: none; }
.boot-inner { position: relative; text-align: center; }
/* Знак «ДЕРЗАЙ»: фиолетовая плитка с вершиной (icons/logo.svg).
   Цвета фирменные и от выбранной палитры не зависят */
.boot-logo, .brand-logo {
  position: relative; flex: none;
  background: url("../icons/logo.svg") center / contain no-repeat;
}
.boot-logo { width: 60px; height: 60px; margin: 0 auto 18px; }
/* Слово «ДЕРЗАЙ»: шрифт Unbounded, светлое на тёмном и тёмное на светлом */
.boot-title, .brand-name {
  display: flex; align-items: baseline;
  font-family: "Derzay Wordmark", var(--font); font-weight: 800;
  letter-spacing: .02em; color: #f4efe6;
}
:root[data-theme="light"] .boot-title, :root[data-theme="light"] .brand-name { color: #120f1d; }
/* Вершина вместо буквы «А»: на тёмном фоне светло-фиолетовая, на светлом — тёмно-фиолетовая */
.wm-peak { flex: none; width: .85em; height: .74em; margin: 0 .06em 0 .03em; }
.wm-peak-fill { fill: #a78bfa; }
:root[data-theme="light"] .wm-peak-fill { fill: #5b3fd1; }
.boot-title { justify-content: center; font-size: calc(22px * var(--scale)); }
.boot-msg { margin-top: 6px; color: var(--text-muted); font-size: var(--fs-small); }
.boot-bar {
  width: 200px; height: 4px; margin: 22px auto 10px;
  background: var(--track); border-radius: 99px; overflow: hidden;
}
.boot-fill {
  height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-grad-from), var(--accent-grad-to));
  transition: width .2s var(--ease);
}
.boot-pct { font-size: calc(12px * var(--scale)); font-weight: 600; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* =====================================================================
   Шапка и вкладки. Одна «стеклянная» полоса прилипает к верху целиком —
   и шапка, и лента вкладок, поэтому вкладки никогда не уезжают под шапку.
   ===================================================================== */
.shell-top {
  position: sticky; top: 0; z-index: 40;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(1.6) blur(22px);
  backdrop-filter: saturate(1.6) blur(22px);
  box-shadow: 0 1px 0 var(--line);
}
.topbar {
  display: flex; align-items: center; gap: 10px;
  max-width: calc(var(--col) + 64px); margin: 0 auto;
  padding: 10px var(--gutter-r) 6px var(--gutter);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; }
.brand-logo { width: 38px; height: 38px; }
.brand-text { min-width: 0; }
.brand-name {
  font-size: calc(15px * var(--scale));
  white-space: nowrap; line-height: 1.1;
}
.brand-sub { font-size: calc(12px * var(--scale)); color: var(--text-faint); margin-top: 2px; white-space: nowrap; display: none; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* Круглые кнопки в шапке: значок, а на широком экране — ещё и подпись */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; min-width: 38px; padding: 0 10px; border: 0; border-radius: 99px; cursor: pointer;
  background: var(--glass-strong); color: var(--text);
  box-shadow: 0 0 0 1px var(--card-edge), 0 1px 2px rgba(0, 0, 0, .04);
  font-size: var(--fs-small); font-weight: 600; white-space: nowrap;
  transition: background-color .2s ease, transform .16s var(--ease);
}
.icon-btn .btn-label { display: none; }
.icon-btn:active { transform: scale(.94); }
.icon-btn.add { background: var(--text); color: var(--bg); box-shadow: none; }

/* Кнопка профиля: круг с фото или буквой; без входа — плашка «Войти» */
.avatar-btn {
  flex: none; width: 38px; height: 38px; border-radius: 50%; padding: 0; overflow: hidden;
  border: 0; cursor: pointer;
  background: linear-gradient(145deg, var(--accent-grad-from), var(--accent-grad-to));
  color: var(--on-accent); font-weight: 700; font-size: var(--fs-base);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--card-edge), 0 6px 14px -6px var(--accent-shadow);
  transition: transform .16s var(--ease);
}
.avatar-btn:active { transform: scale(.94); }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-btn.signed-out {
  width: auto; height: 38px; border-radius: 99px; padding: 0 16px;
  background: var(--accent); color: var(--on-accent);
  font-size: var(--fs-small); font-weight: 650;
  box-shadow: 0 6px 16px -8px var(--accent-shadow);
}
.avatar-btn.big {
  width: 88px; height: 88px; font-size: 34px;
  box-shadow: 0 0 0 4px var(--card), 0 0 0 5px var(--card-edge), 0 16px 32px -14px var(--accent-shadow);
}
.profile-head { display: flex; align-items: center; gap: 18px; }
.profile-head > div { min-width: 0; overflow-wrap: anywhere; }
.profile-head .row { margin-top: 0; }
.nick-row .input { flex: 1 1 160px; min-width: 0; }

/* Лента вкладок */
.tabstrip {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  max-width: calc(var(--col) + 64px); margin: 0 auto;
  padding: 6px var(--gutter-r) 10px var(--gutter);
  scroll-padding-inline: var(--gutter);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter), #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter), #000 calc(100% - 28px), transparent);
}
.tabstrip::-webkit-scrollbar { display: none; }
/* Заголовок группы «Сферы». В ленте на телефоне — тонкая черта и подпись */
.tab-group {
  flex: none; display: flex; align-items: center; gap: 6px;
  margin: 0 2px 0 6px; padding: 0 6px 0 12px;
  box-shadow: inset 1px 0 0 var(--line);
  font-size: calc(12.5px * var(--scale)); font-weight: 700; color: var(--text);
  white-space: nowrap;
}
.tab-group-count {
  min-width: 20px; padding: 1px 6px; border-radius: 99px; text-align: center;
  font-size: calc(11px * var(--scale)); font-weight: 650; font-variant-numeric: tabular-nums;
  color: var(--text-muted); background: color-mix(in srgb, var(--text) 8%, transparent);
}

/* .tab — и вкладка, и выбор-«таблетка» внутри карточек (сон, фильтры, причины) */
.tab {
  border: 0; cursor: pointer; white-space: nowrap; flex: none;
  padding: 8px 14px; border-radius: 99px;
  background: var(--bg-soft); color: var(--text-muted);
  box-shadow: inset 0 0 0 1px var(--card-edge);
  font-size: var(--fs-small); font-weight: 600; line-height: 1.25;
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease, transform .16s var(--ease);
}
.tab:hover { color: var(--text); background: var(--card-hover); }
.tab:active { transform: scale(.96); }
/* Высота не меняется при выборе — меняется только цвет */
.tab.active { background: var(--accent); color: var(--on-accent); box-shadow: none; }

.tabstrip .tab { background: transparent; box-shadow: none; padding: 8px 14px; }
.tabstrip .tab:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.tabstrip .tab.active {
  background: var(--text); color: var(--bg);
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .45);
}

/* overflow-x: clip — ничего не может вылезти за ширину экрана (на iPhone
   страницу иначе можно было сдвинуть пальцем вбок). touch-action: pan-y —
   горизонтальный жест не двигает страницу, а листает вкладки. */
main {
  display: block; overflow-x: clip; touch-action: pan-y;
  max-width: calc(var(--col) + 64px); margin: 0 auto;
  padding: 18px var(--gutter-r) calc(56px + env(safe-area-inset-bottom, 0px)) var(--gutter);
}

/* =====================================================================
   Карточки-листы
   ===================================================================== */
.card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  margin-bottom: 14px;
  box-shadow: var(--sheet-shadow);
  min-width: 0; max-width: 100%;
}
.card-sm { border-radius: var(--r-md); padding: 12px 16px; margin-bottom: 10px; }
.modal .card-sm, .panel-wrap .card-sm { box-shadow: 0 0 0 1px var(--card-edge); }

.section-title {
  font-size: var(--fs-sub); font-weight: 650; letter-spacing: -.012em; line-height: 1.25;
  margin: 4px 0 12px;
}
.muted { color: var(--text-muted); font-size: var(--fs-small); }
.faint { color: var(--text-faint); }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; flex-wrap: wrap; }

/* Заголовок «Обзора»: день недели и дата — с чего начинается утро */
.today-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 4px 16px; }
.today-day {
  font-size: calc(32px * var(--scale)); font-weight: 700; letter-spacing: -.035em; line-height: 1;
}
.today-date { margin-top: 6px; color: var(--text-muted); font-size: var(--fs-small); font-weight: 500; }
.today-count { text-align: right; flex: none; }
.today-count b {
  display: block; font-size: calc(24px * var(--scale)); font-weight: 700; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.today-count span { color: var(--text-muted); font-size: calc(12px * var(--scale)); }

/* =====================================================================
   Кнопки
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; border-radius: 99px; cursor: pointer;
  padding: 10px 17px; min-height: 40px;
  font-weight: 600; font-size: var(--fs-small); line-height: 1.2; letter-spacing: -.003em;
  background: var(--card-hover); color: var(--text);
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease, transform .16s var(--ease), opacity .2s ease;
  white-space: nowrap;
}
.btn:hover { background: color-mix(in srgb, var(--text) 8%, var(--card)); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-primary {
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .16) inset, 0 8px 18px -10px var(--accent-shadow);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }
.btn-ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--card-border); }
.btn-ghost:hover { background: var(--card-hover); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-ghost-danger { background: transparent; color: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-soft); }
.btn-icon { padding: 9px 12px; font-size: var(--fs-base); }
.btn-sm { padding: 6px 13px; min-height: 32px; font-size: calc(12.5px * var(--scale)); }
.btn-ai {
  color: var(--accent-ink);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}
.btn-ai:hover { background: color-mix(in srgb, var(--accent) 16%, var(--card)); }
.btn > svg.ic { margin: 0 -2px; }

/* =====================================================================
   Маршрут подъёма — так здесь выглядит любой прогресс: дорожка, стоянки
   на этапах, пройденная часть цветом и метка «вы здесь»
   ===================================================================== */
.pill {
  position: relative; height: 8px; border-radius: 99px; background: var(--track);
}
.pill-fill {
  position: relative; height: 100%; min-width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-grad-from), var(--accent-grad-to));
}
.pill-camp {
  position: absolute; top: -1px; bottom: -1px; width: 2px; margin-left: -1px;
  background: var(--card); border-radius: 2px; pointer-events: none;
}
.pill-pin {
  position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; background: var(--card);
  box-shadow: inset 0 0 0 2.5px var(--accent), 0 2px 6px rgba(0, 0, 0, .18);
  pointer-events: none;
}
.pill-pin::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--accent); }
.pill.at-start .pill-pin { margin-left: -2px; }
.pill.at-end .pill-pin { margin-left: -14px; }
.pill-ms { height: 6px; }
.pill-ms .pill-fill {
  background: linear-gradient(90deg, var(--success), var(--success-grad-to));
  box-shadow: none;
}
.pill-ms .pill-pin { width: 12px; height: 12px; margin: -6px 0 0 -6px; box-shadow: inset 0 0 0 2px var(--success), 0 1px 4px rgba(0, 0, 0, .16); }
.pill-ms .pill-pin::after { inset: 4px; background: var(--success); }
.pill-ms.at-start .pill-pin { margin-left: -1px; }
.pill-ms.at-end .pill-pin { margin-left: -11px; }

.chip {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--bg-soft); box-shadow: inset 0 0 0 1px var(--card-edge);
  border-radius: var(--r-md); padding: 10px 16px 11px; min-width: 96px;
}
.chip-value {
  color: var(--text); font-weight: 700; font-size: calc(22px * var(--scale));
  letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums;
}
.chip-label { color: var(--text-muted); font-size: calc(12.5px * var(--scale)); white-space: nowrap; }
.chip-amount {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-soft); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--card-edge);
  border-radius: 99px; padding: 5px 12px;
  font-size: var(--fs-small); font-weight: 600; font-variant-numeric: tabular-nums;
}

/* =====================================================================
   Карточка цели
   ===================================================================== */
.goal { display: block; padding: 22px; }
.goal-top { display: flex; gap: 22px; align-items: flex-start; }
.goal-photo {
  width: var(--thumb); height: var(--thumb); flex: none;
  border-radius: 20px;
  object-fit: cover;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 90% at 20% 0%, color-mix(in srgb, var(--accent-grad-to) 55%, transparent), transparent 60%),
    linear-gradient(160deg, var(--accent-grad-from), var(--accent-dark));
  color: var(--on-accent);
  font-size: calc(48px * var(--scale)); font-weight: 700; letter-spacing: -.04em;
  overflow: hidden; max-width: 100%;
  box-shadow: 0 0 0 1px var(--card-edge), 0 14px 30px -18px rgba(0, 0, 0, .45);
}
img.goal-photo { display: block; background: var(--track); }
.goal-body { flex: 1; min-width: 0; }
.goal-body > .row:first-child { gap: 6px 8px; }
.goal-title {
  font-size: var(--fs-title); font-weight: 650; letter-spacing: -.018em; line-height: 1.25;
  overflow-wrap: anywhere; min-width: 0;
}
.goal-body > .row:first-child > .muted { font-weight: 500; }
.badge-done {
  display: inline-block; text-transform: lowercase;
  color: var(--success); background: var(--success-soft);
  font-weight: 650; font-size: calc(12px * var(--scale));
  border-radius: 99px; padding: 3px 10px;
}
.badge-done::first-letter { text-transform: uppercase; }
.goal-percent {
  font-size: var(--fs-huge); font-weight: 700; line-height: 1;
  letter-spacing: -.04em; font-variant-numeric: tabular-nums;
}
.goal-body .row[style*="baseline"] { gap: 4px 12px; }
.goal-body .row[style*="baseline"] .muted { font-variant-numeric: tabular-nums; }
.goal-actions {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding-top: 16px; margin-top: 18px; border-top: 1px solid var(--line);
}
/* Удаление — отдельно от остальных кнопок, чтобы не нажать случайно */
.goal-actions .btn-ghost-danger { margin-left: auto; }

#main.slide-next { animation: cal-next .32s var(--ease); }
#main.slide-prev { animation: cal-prev .32s var(--ease); }

/* =====================================================================
   Этапы и задачи
   ===================================================================== */
.ms-head { display: flex; align-items: baseline; gap: 10px; font-weight: 650; font-size: var(--fs-small); }
.ms-head .ms-count { font-weight: 600; }
.ms-list { margin-top: 4px; }
.ms-row { padding: 0; }
.ms-row > .swipe-front { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
/* Название и подписи под ним. min-width: 0 обязателен: без него длинное
   название не сжимается и выталкивает кнопки за край экрана */
.ms-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ms-main .ms-text { flex: none; overflow-wrap: anywhere; line-height: 1.35; }
.ms-meta { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.ms-meta .ms-count { white-space: nowrap; }
.ms-tools { display: flex; flex: none; gap: 2px; }

/* Отметка: скруглённый квадрат, галочка нарисована линиями — в любом шрифте одинаковая */
.ms-check {
  width: calc(22px * var(--scale)); height: calc(22px * var(--scale)); flex: none;
  border-radius: 7px; border: 0; padding: 0;
  box-shadow: inset 0 0 0 1.75px color-mix(in srgb, var(--text) 26%, transparent);
  background: transparent; cursor: pointer;
  display: grid; place-items: center; position: relative;
  color: transparent; font-size: 0; line-height: 0;
  transition: background-color .2s ease, box-shadow .2s ease, transform .16s var(--ease);
}
.ms-check:hover { box-shadow: inset 0 0 0 1.75px var(--success); }
.ms-check:active { transform: scale(.88); }
.ms-check.on { background: var(--success); box-shadow: 0 3px 8px -3px var(--success-shadow); }
.ms-check.on::after {
  content: ""; position: absolute; left: 50%; top: 46%;
  width: 42%; height: 22%;
  border-left: 2px solid var(--on-success); border-bottom: 2px solid var(--on-success);
  transform: translate(-50%, -50%) rotate(-45deg);
}
span.ms-check { cursor: default; }
.ms-text { flex: 1; min-width: 0; cursor: pointer; font-size: var(--fs-small); }
.ms-row .ms-text { font-size: calc(14.5px * var(--scale)); font-weight: 500; }
.ms-text.done { color: var(--text-faint); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text-faint) 60%, transparent); }
.ms-btn {
  flex: none; width: calc(34px * var(--scale)); height: calc(34px * var(--scale));
  display: inline-grid; place-items: center; padding: 0;
  border: 0; border-radius: 99px; background: transparent; cursor: pointer;
  font-size: calc(15px * var(--scale)); color: var(--text-muted);
  transition: background-color .2s ease, color .2s ease, transform .16s var(--ease);
}
.ms-btn:hover { background: var(--card-hover); color: var(--text); }
.ms-btn:active { transform: scale(.9); }
.ms-btn.danger { color: var(--text-faint); }
.ms-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

.ms-count { font-size: calc(12px * var(--scale)); color: var(--text-faint); font-variant-numeric: tabular-nums; }
.ms-due.late { color: var(--danger); }
.task-row, .task-row > .swipe-front {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 0 2px calc(32px * var(--scale));
}
.task-row.swipe-row { display: block; padding: 0; }
.task-row .ms-text { color: var(--text-muted); }
.task-row .ms-text.done { color: var(--text-faint); }
.task-add { padding-top: 6px; padding-bottom: 8px; }
.ms-check.sm { width: calc(18px * var(--scale)); height: calc(18px * var(--scale)); border-radius: 6px; }
.ms-group { border-radius: 10px; }
.task-list { display: block; }

/* =====================================================================
   Поля ввода
   ===================================================================== */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: var(--fs-small); color: var(--text-muted); font-weight: 550; margin-bottom: 7px; }
.input, textarea.input, select.input {
  width: 100%; min-height: 44px; padding: 11px 14px;
  background: var(--bg-soft); color: var(--text);
  border: 0; border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--card-border);
  transition: box-shadow .2s ease, background-color .2s ease;
}
.input::placeholder { color: var(--text-faint); }
.input:hover { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 22%, transparent); }
.input:focus { background: var(--card); box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
.input:focus-visible { outline: none; }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.45; }
select.input {
  cursor: pointer; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
input[type="date"].input, input[type="time"].input { font-variant-numeric: tabular-nums; }
input[type="search"].input::-webkit-search-cancel-button { -webkit-appearance: none; }
.input-inline { width: auto; min-width: 180px; flex: 1 1 180px; }

/* =====================================================================
   Обзор: уровень и достижения
   ===================================================================== */
.level-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.level-num {
  font-size: calc(32px * var(--scale)); font-weight: 700; letter-spacing: -.035em; line-height: 1;
  color: var(--text);
}
.ach-grid {
  display: grid; gap: 14px 8px;
  grid-template-columns: repeat(auto-fill, minmax(calc(92px * var(--scale)), 1fr));
  margin-top: 4px;
}
.ach {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 2px 2px 0; text-align: center; color: var(--text-faint);
}
/* Медаль: круг с эмодзи. Открытые — в цветной оправе, закрытые — бледные */
.ach-icon {
  width: calc(58px * var(--scale)); height: calc(58px * var(--scale)); border-radius: 50%;
  display: grid; place-items: center; line-height: 1;
  font-size: calc(26px * var(--scale));
  background: var(--bg-soft);
  box-shadow: inset 0 0 0 1px var(--card-edge);
}
.ach.on { color: var(--text); }
.ach.on .ach-icon {
  background:
    radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--card) 70%, transparent), transparent 60%),
    var(--accent-soft);
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent),
    0 8px 18px -10px var(--accent-shadow);
}
/* Цветной смайлик не подчиняется color, поэтому «ещё не открыто» — обесцвечиванием */
.ach:not(.on) .ach-icon { filter: grayscale(1); opacity: .45; }
.ach.on .ach-icon { filter: none; }
.ach-title { font-size: calc(11.5px * var(--scale)); font-weight: 600; line-height: 1.25; }

/* =====================================================================
   Календарь
   ===================================================================== */
/* Ширина колонок — minmax(0, 1fr): у простого 1fr нижняя граница равна
   ширине содержимого, и на iPhone сетка вылезала вправо. Высота ячеек задана
   явно, без aspect-ratio: Safari считал квадратные кнопки в сетке неверно. */
.cal-card {
  background: var(--card); border-radius: var(--r-xl);
  padding: 16px 14px 14px; overflow: hidden;
  box-shadow: var(--sheet-shadow);
  touch-action: pan-y;   /* вертикально листает страница, горизонтальный свайп — наш */
}
.cal-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.cal-month { text-align: center; min-width: 0; }
.cal-month-name { font-size: calc(22px * var(--scale)); font-weight: 700; letter-spacing: -.025em; line-height: 1.1; }
.cal-year { font-size: var(--fs-small); color: var(--text-faint); font-variant-numeric: tabular-nums; margin-top: 2px; }
.cal-nav {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0;
  background: var(--bg-soft); color: var(--text); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--card-edge);
  display: grid; place-items: center;
  transition: background-color .2s ease, transform .16s var(--ease);
}
.cal-nav:hover { background: var(--card-hover); }
.cal-nav:active { transform: scale(.92); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-grid.slide-next { animation: cal-next .3s var(--ease); }
.cal-grid.slide-prev { animation: cal-prev .3s var(--ease); }
@keyframes cal-next { from { opacity: 0; transform: translateX(24px); } }
@keyframes cal-prev { from { opacity: 0; transform: translateX(-24px); } }
.cal-head {
  text-align: center; padding: 2px 0 8px;
  font-size: calc(11.5px * var(--scale)); font-weight: 600; color: var(--text-faint);
}
.cal-head.weekend { color: var(--accent-ink); opacity: .85; }
.cal-day {
  min-width: 0; width: 100%; height: clamp(42px, 11vw, 58px); padding: 0; margin: 0;
  border: 0; border-radius: 14px; cursor: pointer;
  background: transparent; color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: var(--fs-base); position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .2s ease, color .2s ease, transform .16s var(--ease);
}
.cal-num { font-weight: 550; font-variant-numeric: tabular-nums; line-height: 1; }
.cal-day.weekend { color: var(--accent-ink); }
.cal-day.past { color: var(--text-faint); }
.cal-day:hover { background: var(--card-hover); }
.cal-day:active { transform: scale(.92); }
/* padding: 0 обязателен: у общего класса .empty (пустой экран) свой отступ */
.cal-day.empty { cursor: default; padding: 0; }
.cal-day.empty::before { content: none; }
.cal-day.empty:hover { background: transparent; }
.cal-day.today { color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-day.today .cal-num { font-weight: 750; }
.cal-day.selected {
  background: linear-gradient(150deg, var(--accent-grad-from), color-mix(in srgb, var(--accent-grad-to) 70%, var(--accent-grad-from)));
  color: var(--on-accent);
  box-shadow: 0 10px 20px -10px var(--accent-shadow);
}
.cal-day.selected .cal-num { font-weight: 750; }
.cal-day.selected .dot { box-shadow: 0 0 0 1.5px var(--on-accent); }
/* Точки не участвуют в раскладке: иначе пустой ряд точек сдвигал число вверх */
.cal-dots {
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  display: flex; gap: 3px; height: 5px;
}
.cal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.cal-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: calc(12px * var(--scale)); color: var(--text-muted); }
.cal-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.cal-today-btn { color: var(--accent-ink); }
.cal-add { display: flex; gap: 8px; margin-top: 16px; }
.cal-add .input { flex: 1; min-width: 0; }
.cal-day-head { display: flex; align-items: center; gap: 14px; margin: 24px 4px 14px; }
.cal-day-big {
  flex: none; width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center;
  background: var(--card); color: var(--text); box-shadow: var(--sheet-shadow);
  font-size: calc(24px * var(--scale)); font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
}
.cal-day-week { font-size: var(--fs-sub); font-weight: 650; letter-spacing: -.01em; }
.dot { width: 5px; height: 5px; border-radius: 50%; flex: none; }
.dot-deadline { background: var(--danger); }
.dot-event { background: var(--success); }
.dot-work { background: var(--accent); }

/* =====================================================================
   Панели (календарь, настройки, профиль, гайды)
   ===================================================================== */
.panel-host {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  overflow-y: auto; overscroll-behavior: contain;
  animation: panel-in .34s var(--ease-drawer);
}
@keyframes panel-in { from { opacity: 0; transform: translateY(18px); } }
/* env(safe-area-inset-*) — отступы от «чёлки», полоски «домой» и скруглённых
   углов iPhone. Без них заголовок панели уходил под часы, а низ — под полоску. */
.panel-wrap {
  max-width: calc(var(--col) + 64px); margin: 0 auto; min-height: 100%;
  padding: 0 var(--gutter-r) calc(56px + env(safe-area-inset-bottom, 0px)) var(--gutter);
  background: var(--bg);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 0 calc(-1 * var(--gutter-r)) 16px calc(-1 * var(--gutter));
  /* Заголовок с «Закрыть» прилипает к верху — закрыть панель можно с любого места */
  position: sticky; top: 0; z-index: 3;
  padding: calc(12px + env(safe-area-inset-top, 0px)) var(--gutter-r) 12px var(--gutter);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(1.6) blur(22px);
  backdrop-filter: saturate(1.6) blur(22px);
  box-shadow: 0 1px 0 var(--line);
}
.panel-title { font-size: calc(22px * var(--scale)); font-weight: 700; letter-spacing: -.028em; }
.panel-close { width: 38px; padding: 0; }

/* =====================================================================
   Модальные окна. На телефоне — шторка снизу, как в iOS
   ===================================================================== */
.modal-host {
  position: fixed; inset: 0; z-index: 80;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto; overscroll-behavior: contain;
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  background: var(--card);
  border-radius: var(--r-xl);
  /* Двойная оправа: полупрозрачное кольцо вокруг окна */
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--card) 38%, transparent), 0 0 0 7px var(--card-edge), var(--shadow);
  width: min(560px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; overscroll-behavior: contain;
  padding: 24px 24px 22px;
  animation: modal-in .3s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.modal-title { font-size: calc(20px * var(--scale)); font-weight: 700; letter-spacing: -.024em; line-height: 1.2; margin-bottom: 16px; padding-right: 8px; overflow-wrap: anywhere; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }

.preview-box {
  width: 100%; max-width: 260px; aspect-ratio: 1;
  border-radius: 20px;
  display: grid; place-items: center; overflow: hidden;
  background: var(--bg-soft); color: var(--text-faint); font-size: var(--fs-small);
  box-shadow: inset 0 0 0 1.5px var(--card-border);
  text-align: center; padding: 14px;
}
.preview-box:has(img) { padding: 0; box-shadow: 0 0 0 1px var(--card-edge); }
.preview-box img { width: 100%; height: 100%; object-fit: cover; }
.preview-box.cropping { display: block; aspect-ratio: auto; max-width: 320px; padding: 0; background: none; box-shadow: none; overflow: visible; }

/* Рамка выбора части картинки */
.crop { width: 100%; max-width: 320px; }
.crop-view {
  position: relative; width: 100%; aspect-ratio: 1; overflow: hidden;
  border-radius: 20px; background: var(--bg-soft);
  box-shadow: 0 0 0 1px var(--card-edge);
  touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
}
.crop-view.dragging { cursor: grabbing; }
.crop-view:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.crop-img {
  position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0;
  pointer-events: none; -webkit-user-drag: none;
  opacity: 0; transition: opacity .2s ease;
}
.crop.ready .crop-img { opacity: 1; }
/* Сетка «на трети», пока двигаете, — чтобы проще было поставить главное по центру */
.crop-frame {
  position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background:
    linear-gradient(90deg, transparent calc(33.33% - .5px), rgba(255, 255, 255, .55) calc(33.33% - .5px) calc(33.33% + .5px), transparent calc(33.33% + .5px) calc(66.66% - .5px), rgba(255, 255, 255, .55) calc(66.66% - .5px) calc(66.66% + .5px), transparent calc(66.66% + .5px)),
    linear-gradient(180deg, transparent calc(33.33% - .5px), rgba(255, 255, 255, .55) calc(33.33% - .5px) calc(33.33% + .5px), transparent calc(33.33% + .5px) calc(66.66% - .5px), rgba(255, 255, 255, .55) calc(66.66% - .5px) calc(66.66% + .5px), transparent calc(66.66% + .5px));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
  opacity: 0; transition: opacity .2s ease;
}
.crop-view.dragging .crop-frame { opacity: 1; }
/* Фото профиля: круг, всё за кругом затемнено */
.crop-view.round .crop-frame {
  inset: 0; border-radius: 50%; background: none;
  box-shadow: 0 0 0 999px rgba(10, 12, 18, .5), inset 0 0 0 1.5px rgba(255, 255, 255, .6);
  opacity: 1;
}
.crop-controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--text-muted); }
.crop-zoom {
  flex: 1; min-width: 0; height: 28px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.crop-zoom::-webkit-slider-runnable-track { height: 4px; border-radius: 99px; background: var(--track); }
.crop-zoom::-moz-range-track { height: 4px; border-radius: 99px; background: var(--track); }
.crop-zoom::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%;
  background: var(--card); box-shadow: inset 0 0 0 2.5px var(--accent), 0 2px 6px rgba(0, 0, 0, .2);
}
.crop-zoom::-moz-range-thumb {
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: var(--card); box-shadow: inset 0 0 0 2.5px var(--accent), 0 2px 6px rgba(0, 0, 0, .2);
}
.crop-zoom:focus-visible { outline-offset: 4px; border-radius: 99px; }
.crop-help { margin-top: 8px; }
.modal .crop { margin: 0 auto; }

/* =====================================================================
   Уведомления
   ===================================================================== */
.toast-host {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 100;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  --toast-accent: var(--accent);
  position: relative;
  background: var(--glass-strong);
  -webkit-backdrop-filter: saturate(1.6) blur(20px);
  backdrop-filter: saturate(1.6) blur(20px);
  border-radius: 18px; padding: 12px 18px 12px 34px; box-shadow: var(--float-shadow);
  max-width: 340px; animation: toast-in .36s var(--ease);
}
.toast::before {
  content: ""; position: absolute; left: 15px; top: 18px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--toast-accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--toast-accent) 20%, transparent);
}
.toast.leaving { animation: toast-out .26s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(.98); } }
.toast-line { font-size: var(--fs-small); color: var(--text-muted); }
.toast-line:first-child { font-weight: 650; color: var(--text); }

/* Пустой экран: знак-«вы здесь» над подписью */
.empty { text-align: center; padding: 56px 20px; }
.empty::before {
  content: ""; display: block; width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0 7px, transparent 7.5px);
  box-shadow: inset 0 0 0 2.5px color-mix(in srgb, var(--accent) 45%, transparent);
}
.empty-title { font-size: var(--fs-sub); font-weight: 650; letter-spacing: -.01em; }

.hidden { display: none !important; }

/* =====================================================================
   Перетаскивание
   ===================================================================== */
.drag-handle {
  flex: none; width: calc(18px * var(--scale)); height: calc(28px * var(--scale));
  border: 0; border-radius: 7px; padding: calc(6px * var(--scale)) 3px;
  background-color: transparent;
  background-image: radial-gradient(circle, var(--text-faint) 1.3px, transparent 1.7px);
  background-size: 6px 6px; background-origin: content-box; background-clip: content-box;
  cursor: grab; opacity: .7;
  /* Без этого палец на телефоне прокручивал бы страницу вместо перетаскивания */
  touch-action: none;
}
.drag-handle:hover { opacity: 1; background-color: var(--card-hover); }
.drag-handle:active { cursor: grabbing; }
.drag-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; opacity: 1; }
.drag-spacer { flex: none; width: calc(18px * var(--scale)); }
.dragging {
  position: relative; z-index: 5;
  background: var(--card); border-radius: 14px; box-shadow: var(--float-shadow);
}
body.sorting, body.sorting * { user-select: none; cursor: grabbing !important; }

/* Порядок сфер в настройках */
.sort-list { display: grid; gap: 6px; margin-top: 14px; }
.sort-row {
  display: flex; align-items: center; gap: 12px; padding: 7px 8px 7px 8px;
  border-radius: 14px; background: var(--bg-soft); box-shadow: inset 0 0 0 1px var(--card-edge);
}
.sort-row.dragging { background: var(--card); box-shadow: var(--float-shadow); }
.sort-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }

/* =====================================================================
   План на сегодня и неделю
   ===================================================================== */
.plan-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-top: 1px solid var(--line);
}
.plan-row.swipe-row { display: block; padding: 0; border-radius: 0; }
.plan-row > .swipe-front { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.plan-card .row-between + .plan-row { margin-top: 12px; }
.plan-row.done .plan-title { color: var(--text-faint); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text-faint) 60%, transparent); }
.plan-row.warn .plan-sub { color: var(--warn); }
.plan-text { flex: 1; min-width: 0; }
.plan-title { font-weight: 550; overflow-wrap: anywhere; line-height: 1.35; }
.plan-sub {
  display: block; border: 0; padding: 0; margin-top: 2px; background: none;
  color: var(--text-muted); font-size: var(--fs-small); text-align: left; cursor: pointer;
}
.plan-sub:hover { color: var(--accent-ink); }
.plan-plus { min-width: calc(30px * var(--scale)); min-height: calc(30px * var(--scale)); padding: 0 9px; }
.plan-icon { width: calc(22px * var(--scale)); text-align: center; flex: none; }
.plan-empty { margin-top: 10px; line-height: 1.55; max-width: 60ch; }
.plan-remove { width: calc(32px * var(--scale)); height: calc(32px * var(--scale)); color: var(--text-faint); }
.plan-remove:hover { color: var(--danger); background: var(--danger-soft); }
.plan-dot::before {
  content: ""; display: block; width: 8px; height: 8px; margin: 0 auto;
  border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--text-faint);
}

/* «Беру в работу» — круглая кнопка с треугольником */
.plan-focus { display: inline-grid; place-items: center; color: var(--accent-ink); background: var(--accent-soft); }
.plan-focus:hover { background: color-mix(in srgb, var(--accent) 18%, var(--card)); color: var(--accent-ink); }
/* Треугольник рисуем сами: знак ▶ на Windows превращается в синюю плитку-эмодзи */
.plan-focus::before {
  content: ""; display: block; margin-left: 3px;
  border-left: calc(9px * var(--scale)) solid currentColor;
  border-top: calc(5.5px * var(--scale)) solid transparent;
  border-bottom: calc(5.5px * var(--scale)) solid transparent;
  border-radius: 1px;
}
.plan-time {
  flex: none; white-space: nowrap; font-size: calc(12.5px * var(--scale)); color: var(--text-muted);
  background: var(--bg-soft); box-shadow: inset 0 0 0 1px var(--card-edge); border-radius: 99px;
  padding: 2px 10px; font-variant-numeric: tabular-nums;
}
.plan-row.focusing .plan-time { color: var(--accent-ink); background: var(--accent-soft); box-shadow: none; }
.plan-row.focusing .plan-title::after {
  content: "в работе"; display: inline-block; white-space: nowrap; margin-left: 8px; padding: 1px 8px; border-radius: 99px; vertical-align: 2px;
  font-size: calc(11px * var(--scale)); font-weight: 650; color: var(--on-accent); background: var(--accent);
}
.plan-sub.static { cursor: default; }
.plan-sub.static:hover { color: var(--text-muted); }
.plan-total { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: var(--fs-small); }

.plan-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 7px; }
.plan-when {
  border: 0; cursor: pointer; font: inherit; font-size: calc(12.5px * var(--scale)); font-weight: 650;
  color: var(--accent-ink); background: var(--accent-soft); border-radius: 99px; padding: 3px 10px;
  font-variant-numeric: tabular-nums;
}
span.plan-when { cursor: default; }
.plan-clock { display: inline-grid; place-items: center; color: var(--text-faint); }
.plan-clock.set { color: var(--accent-ink); }
.plan-clock:hover { color: var(--accent-ink); }
.plan-min { font-weight: 750; color: var(--accent-ink); }
.plan-min:hover { background: var(--accent-soft); }
.plan-dlg-title { font-weight: 650; margin: 18px 0 8px; }
.time-range { display: flex; align-items: center; gap: 10px; }
.time-range .input { flex: 1; min-width: 0; }
.plan-dlg .row .input { flex: 1; min-width: 0; }

.week-day { padding: 12px 0; border-top: 1px solid var(--line); }
.week-card .row-between + .week-day { margin-top: 12px; }
.week-head { display: flex; align-items: center; gap: 10px; }
.week-name { font-weight: 650; white-space: nowrap; }
.week-day.today .week-name { color: var(--accent-ink); }
.week-info { flex: 1; min-width: 0; }
.week-items { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.summary-items { margin-top: 12px; }
/* Фиксированная колонка времени: строки меняют вид, но сетка не ломается */
.week-item {
  display: flex; align-items: baseline; gap: 12px; width: 100%; text-align: left;
  border: 0; background: none; color: var(--text); cursor: pointer; font: inherit;
  padding: 8px 10px; border-radius: 12px;
  transition: background-color .2s ease;
}
.week-item:hover { background: var(--card-hover); }
.week-item.done .week-text { color: var(--text-faint); text-decoration: line-through; }
.week-time {
  flex: none; font-size: var(--fs-small); font-weight: 650; color: var(--accent-ink);
  font-variant-numeric: tabular-nums; min-width: 6.4em;
}
.week-text { min-width: 0; overflow-wrap: anywhere; }
/* Первый открытый шаг дня — главный на экране */
.summary-items .week-item:first-child { padding-top: 10px; padding-bottom: 10px; background: var(--bg-soft); box-shadow: inset 0 0 0 1px var(--card-edge); }
.summary-items .week-item:first-child .week-text { font-weight: 650; font-size: calc(16px * var(--scale)); letter-spacing: -.01em; }

/* Факт против плана */
.plan-fact {
  font-size: calc(12.5px * var(--scale)); font-weight: 600; border-radius: 99px; padding: 2px 10px;
  background: var(--bg-soft); box-shadow: inset 0 0 0 1px var(--card-edge); color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.plan-fact.ontime { color: var(--success); background: var(--success-soft); box-shadow: none; }
.plan-fact.late { color: var(--warn); background: var(--warn-soft); box-shadow: none; }
.plan-fact.missed, .plan-fact.skipped { color: var(--text-faint); }

.free-box { padding: 16px; margin-bottom: 4px; border-radius: 18px; background: var(--bg-soft); box-shadow: inset 0 0 0 1px var(--card-edge); }
.free-box > .input { width: 100%; background: var(--card); }
.free-box .time-range .input { background: var(--card); }
.free-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.free-line .time-range { flex: 1 1 220px; }
.check-line { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; margin-top: 12px; }
.free-line .check-line { margin-top: 0; }
.check-line input { appearance: auto; -webkit-appearance: checkbox; width: 19px; height: 19px; margin: 0; accent-color: var(--accent); flex: none; }

.rt-row {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  background: none; border: 0; border-top: 1px solid var(--line); padding: 13px 8px; border-radius: 0;
  transition: background-color .2s ease;
}
.rt-row:hover { background: var(--card-hover); }
.rt-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.plan-card .row-between + .rt-row { margin-top: 12px; }
.rt-row .row-between { flex-wrap: wrap; gap: 4px 12px; }
.rt-row .plan-title { font-variant-numeric: tabular-nums; }
.rt-dots { display: flex; gap: 5px; margin-top: 9px; flex-wrap: wrap; }
.rt-dot { width: 16px; height: 16px; border-radius: 5px; background: var(--track); }
.rt-dot.ontime { background: var(--success); }
.rt-dot.late { background: var(--warn); }
.rt-dot.skipped { background: transparent; box-shadow: inset 0 0 0 1px var(--card-border); }
.rt-history { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.rt-hrow { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; font-size: var(--fs-small); }

/* Окно выбора пунктов для плана */
.pick-list { margin-top: 12px; max-height: min(52vh, 520px); overflow-y: auto; margin-inline: -6px; padding-inline: 6px; }
.pick-sphere {
  position: sticky; top: 0; z-index: 1; background: var(--card);
  padding: 14px 4px 6px; font-size: calc(12.5px * var(--scale)); font-weight: 650;
  color: var(--text-muted);
}
.pick-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 0; background: none; cursor: pointer; border-radius: 12px;
  padding: 9px 10px; color: var(--text);
  transition: background-color .2s ease;
}
.pick-row:hover { background: var(--card-hover); }
.pick-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pick-row.lvl2 { padding-left: calc(10px + 20px * var(--scale)); }
.pick-row.lvl3 { padding-left: calc(10px + 40px * var(--scale)); }
.pick-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pick-title { overflow-wrap: anywhere; }
.pick-row.lvl1 .pick-title { font-weight: 600; }
.pick-row.lvl3 .pick-title { font-size: var(--fs-small); }
.pick-sub { font-size: calc(12px * var(--scale)); color: var(--text-faint); }
.pick-state {
  flex: none; min-width: calc(30px * var(--scale)); text-align: center;
  font-weight: 650; color: var(--accent-ink); font-size: var(--fs-small);
}
.pick-row.in .pick-state { color: var(--success); }
.pick-row.in { background: var(--accent-soft); }

/* =====================================================================
   Типы целей, привычки, срок и ставка
   ===================================================================== */
.type-badge {
  font-size: calc(12px * var(--scale)); font-weight: 600;
  color: var(--text-muted); background: var(--bg-soft);
  box-shadow: inset 0 0 0 1px var(--card-edge);
  border-radius: 99px; padding: 2px 10px;
}

/* Привычка: семь дней недели. Ровно семь колонок — дни всегда в одну строку */
.week-dots {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px; margin-top: 14px; max-width: calc(340px * var(--scale));
}
.wd {
  min-width: 0; padding: 7px 0 8px;
  border: 0; border-radius: 13px;
  background: var(--bg-soft); color: var(--text-muted); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--card-edge);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: background-color .2s ease, box-shadow .2s ease, color .2s ease, transform .16s var(--ease);
}
.wd:hover:not(:disabled) { box-shadow: inset 0 0 0 1.5px var(--success); }
.wd:active:not(:disabled) { transform: scale(.93); }
.wd:disabled { opacity: .38; cursor: default; }
.wd.today { box-shadow: inset 0 0 0 1.5px var(--text); color: var(--text); }
.wd.done { background: var(--success); color: var(--on-success); box-shadow: 0 6px 12px -8px var(--success-shadow); }
.wd-name { font-size: calc(11px * var(--scale)); font-weight: 600; }
.wd-mark { font-size: calc(13px * var(--scale)); line-height: 1; min-height: 1em; font-weight: 700; }
.wd.min .wd-mark { font-weight: 800; }
.wd.done.min { background: var(--success-soft); color: var(--success); box-shadow: inset 0 0 0 1.5px var(--success); }

/* Предупреждение держит свой цвет, пока его не решат */
.goal-warn {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 16px; padding: 11px 14px; border-radius: 14px;
  font-size: var(--fs-small); line-height: 1.45; font-weight: 500;
}
.goal-warn.behind { background: var(--warn-soft); color: var(--warn); }
.goal-warn.overdue { background: var(--danger-soft); color: var(--danger); }
.deadline-warn { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 45%, transparent), var(--sheet-shadow); }

.stake {
  display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: baseline;
  margin-top: 12px; padding: 10px 14px; border-radius: 14px;
  font-size: var(--fs-small); background: var(--bg-soft);
  box-shadow: inset 0 0 0 1px var(--card-edge);
}
.stake-label { font-weight: 650; color: var(--accent-ink); }
.stake-kept { background: var(--success-soft); box-shadow: none; }
.stake-kept .stake-label { color: var(--success); }
.stake-burned { background: var(--danger-soft); box-shadow: none; }
.stake-burned .stake-label { color: var(--danger); }

/* Сегментный переключатель: подложка-колодец и «поднятая» выбранная часть */
.seg {
  display: inline-flex; gap: 2px; padding: 3px; flex-wrap: wrap;
  background: var(--bg-soft); box-shadow: inset 0 0 0 1px var(--card-edge); border-radius: 14px;
}
.seg-btn {
  border: 0; border-radius: 11px; cursor: pointer; padding: 8px 15px;
  background: transparent; color: var(--text-muted);
  font-size: var(--fs-small); font-weight: 600;
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--raised); color: var(--text); box-shadow: 0 0 0 1px var(--card-edge), 0 3px 8px -2px rgba(0, 0, 0, .14); }
.seg-btn:focus-visible, .wd:focus-visible, .plan-sub:focus-visible, .review-row:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.type-hint { margin-top: 9px; }
.field-help { display: block; margin-top: 7px; font-size: calc(12px * var(--scale)); color: var(--text-faint); line-height: 1.45; }
.period-label { font-weight: 650; font-variant-numeric: tabular-nums; }

/* =====================================================================
   Итоги
   ===================================================================== */
.insights { margin: 0; padding-left: 20px; display: grid; gap: 8px; line-height: 1.55; }
.insights li::marker { color: var(--accent); }

.review-row {
  display: flex; gap: 12px; align-items: flex-start; width: 100%;
  border: 0; background: none; cursor: pointer; text-align: left; color: var(--text);
  padding: 11px 8px; border-radius: 12px; border-top: 1px solid var(--line);
  transition: background-color .2s ease;
}
.review-row:hover { background: var(--card-hover); }
.review-row.warn .review-title { color: var(--warn); }
.review-icon { width: 22px; text-align: center; flex: none; }
.review-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.review-title { font-weight: 600; overflow-wrap: anywhere; }
.review-more { padding: 10px 8px 2px 42px; border-top: 1px solid var(--line); }

/* Графики. Все краски — из переменных темы */
.chart-box { margin-top: 14px; overflow-x: auto; scrollbar-width: none; }
.chart-box::-webkit-scrollbar { display: none; }
.chart { display: block; width: 100%; height: auto; }
.chart-label { fill: var(--text-faint); font-size: 10px; font-family: inherit; }
.radar-box { max-width: 560px; margin-inline: auto; }
.heatmap-box .chart { min-width: 520px; }
.heatmap-foot { display: flex; justify-content: flex-end; margin-top: 8px; }
.heatmap-legend { width: 160px; overflow: visible; }

.hm.l0 { fill: var(--hm0); }
.hm.l1 { fill: var(--hm1); }
.hm.l2 { fill: var(--hm2); }
.hm.l3 { fill: var(--hm3); }
.hm.l4 { fill: var(--hm4); }

.radar-ring { fill: none; stroke: var(--line); stroke-width: 1; }
.radar-ring.outer { stroke: var(--card-border); }
.radar-axis { stroke: var(--line); stroke-width: 1; }
.radar-shape { fill: var(--accent); fill-opacity: .2; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.radar-dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.radar-dot.weak { fill: var(--warn); }
.radar-label { fill: var(--text-muted); font-size: 11.5px; font-weight: 600; font-family: inherit; }
.radar-label.weak { fill: var(--warn); }
.radar-score { fill: var(--text-faint); font-size: 10.5px; font-family: inherit; font-variant-numeric: tabular-nums; }
.bar-track { fill: var(--hm0); }
.bar-fill { fill: var(--accent); }
.bar-fill.weak { fill: var(--warn); }

.chart.line .grid { stroke: var(--line); stroke-width: 1; }
.chart.line .target-line { stroke: var(--success); stroke-width: 1.5; stroke-dasharray: 5 5; }
.chart.line .target-label { fill: var(--success); }
.chart.line .line-path { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart.line .end-dot { fill: var(--accent); stroke: var(--card); stroke-width: 3; }
.area-stop-top { stop-color: var(--accent); stop-opacity: .28; }
.area-stop-bottom { stop-color: var(--accent); stop-opacity: 0; }

/* =====================================================================
   Панель таймера «Беру в работу»
   ===================================================================== */
.focus-bar {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50;
  width: min(560px, calc(100vw - 24px)); overflow: hidden;
  background: var(--glass-strong);
  -webkit-backdrop-filter: saturate(1.6) blur(24px);
  backdrop-filter: saturate(1.6) blur(24px);
  border-radius: 24px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent), var(--float-shadow);
  animation: focus-in .4s var(--ease);
}
@keyframes focus-in { from { opacity: 0; transform: translate(-50%, 18px); } }
.focus-bar.rest { box-shadow: 0 0 0 1px color-mix(in srgb, var(--success) 40%, transparent), var(--float-shadow); }
.focus-progress { height: 3px; background: var(--track); }
.focus-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-grad-from), var(--accent-grad-to)); transition: width 1s linear; }
.focus-bar.rest .focus-progress-fill { background: linear-gradient(90deg, var(--success), var(--success-grad-to)); }
.focus-main { display: flex; align-items: center; gap: 14px; padding: 14px 18px 6px; }
.focus-info { flex: 1; min-width: 0; }
.focus-phase { font-size: calc(12.5px * var(--scale)); font-weight: 650; color: var(--accent-ink); }
.focus-bar.rest .focus-phase { color: var(--success); }
.focus-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.focus-clock { font-size: calc(32px * var(--scale)); font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1; }
.focus-hint { padding: 0 18px; font-size: var(--fs-small); color: var(--text-muted); }
.focus-hint:empty { display: none; }
.focus-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 18px 16px; }
.focus-total { margin-left: auto; font-size: var(--fs-small); color: var(--text-faint); font-variant-numeric: tabular-nums; }
body.has-focus #main { padding-bottom: calc(170px * var(--scale)); }
body.has-focus .toast-host { bottom: calc(180px * var(--scale)); }
.focus-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0 12px; }
.focus-summary .chip { min-width: 0; }

/* Настройки таймера */
.focus-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; max-width: 420px; }
.focus-settings .field { margin: 0; }

/* =====================================================================
   Гайды
   ===================================================================== */
.guides-intro { margin: -2px 4px 18px; line-height: 1.55; max-width: 68ch; }
.guide { padding: 0; overflow: hidden; }
.guide > summary {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px; cursor: pointer; list-style: none;
}
.guide > summary::-webkit-details-marker { display: none; }
.guide > summary::after {
  content: ""; flex: none; width: 8px; height: 8px; margin-right: 6px;
  border-right: 2px solid var(--text-faint); border-bottom: 2px solid var(--text-faint);
  transform: rotate(45deg); transition: transform .3s var(--ease);
}
.guide[open] > summary::after { transform: rotate(-135deg); }
.guide > summary:hover .guide-title { color: var(--accent-ink); }
.guide > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-lg); }
.guide-icon {
  font-size: calc(24px * var(--scale)); flex: none; line-height: 1;
  width: calc(48px * var(--scale)); height: calc(48px * var(--scale)); border-radius: 15px;
  display: grid; place-items: center; background: var(--bg-soft); box-shadow: inset 0 0 0 1px var(--card-edge);
}
.guide-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.guide-title { font-weight: 650; font-size: var(--fs-sub); letter-spacing: -.012em; transition: color .2s ease; }
.guide-gist { font-size: var(--fs-small); }
.guide-body { padding: 0 20px 22px calc(20px + 16px + 48px * var(--scale)); line-height: 1.65; max-width: 80ch; }
.guide-body p { margin: 0 0 12px; }
.guide-apply { margin: 16px 0; padding: 14px 18px; border-radius: 16px; background: var(--accent-soft); }
.guide-apply-title { font-weight: 650; color: var(--accent-ink); margin-bottom: 6px; }
.guide-apply ul { margin: 0; padding-left: 20px; }
.guide-apply li + li { margin-top: 4px; }
.guide-cite { font-size: var(--fs-small); color: var(--text-muted); overflow-wrap: anywhere; }
.guide-cite + .guide-cite { margin-top: 6px; }

/* =====================================================================
   Самочувствие, минимум, прогноз, письма, причины срывов, связи
   ===================================================================== */
.checkin-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 14px; }
.checkin-label { min-width: 7em; color: var(--text-muted); font-size: var(--fs-small); font-weight: 600; }
.checkin-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.mood-btn {
  width: calc(44px * var(--scale)); height: calc(44px * var(--scale)); border-radius: 15px; cursor: pointer; padding: 0;
  font-size: calc(22px * var(--scale)); line-height: 1; border: 0;
  background: var(--bg-soft); box-shadow: inset 0 0 0 1px var(--card-edge);
  filter: grayscale(.7); opacity: .7;
  transition: transform .2s var(--ease), opacity .2s ease, filter .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.mood-btn:hover { opacity: 1; filter: none; }
.mood-btn:active { transform: scale(.9); }
.mood-btn.on {
  opacity: 1; filter: none; background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent), 0 8px 16px -10px var(--accent-shadow);
  transform: scale(1.06);
}

.goal-why { margin-top: 6px; font-size: var(--fs-small); color: var(--text-muted); }
.why-quote {
  margin-bottom: 16px; padding: 12px 16px; border-radius: 16px; background: var(--accent-soft);
  color: var(--text); font-size: var(--fs-small); line-height: 1.5;
}
.forecast { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 6px; font-size: var(--fs-small); font-weight: 600; }
.forecast.late > span:first-child { color: var(--warn); }

.letter-line { margin-top: 8px; font-size: var(--fs-small); color: var(--text-muted); }
.link-btn { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-ink); cursor: pointer; font-weight: 600; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.letter-box {
  margin-top: 16px; padding: 18px 20px; border-radius: 20px; text-align: left;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(135deg, var(--accent-grad-from), var(--accent-grad-to)) border-box;
  border: 1.5px solid transparent;
}
.letter-title { font-weight: 700; color: var(--accent-ink); }
.letter-text { margin-top: 10px; white-space: pre-wrap; line-height: 1.65; }

.reason-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.reason-chips .tab { font-size: var(--fs-small); padding: 7px 12px; }
.miss-list { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; max-height: 56vh; overflow-y: auto; }
.miss-item { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.miss-head { font-size: var(--fs-sub); font-weight: 650; letter-spacing: -.01em; margin: 12px 0 10px; }
.miss-row { display: grid; grid-template-columns: minmax(8em, auto) 1fr auto; align-items: center; gap: 12px; margin-top: 9px; }
.miss-bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.miss-bar > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-grad-from), var(--accent-grad-to)); }
.miss-count { font-variant-numeric: tabular-nums; }
.link-row { padding: 11px 0; border-top: 1px solid var(--line); line-height: 1.5; }
.card .row-between + .link-row { margin-top: 10px; }

/* Выбор цветовой темы в настройках */
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(160px * var(--scale)), 1fr)); gap: 8px; }
.palette-btn {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; text-align: left;
  font: inherit; color: var(--text); background: var(--bg-soft);
  border: 0; box-shadow: inset 0 0 0 1px var(--card-edge); border-radius: 14px;
  transition: box-shadow .2s ease, background-color .2s ease;
}
.palette-btn:hover { box-shadow: inset 0 0 0 1px var(--card-border); }
.palette-btn.active { box-shadow: inset 0 0 0 2px var(--accent); background: var(--card); font-weight: 650; }
.palette-btn > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.palette-swatch {
  flex: none; width: calc(26px * var(--scale)); height: calc(26px * var(--scale)); border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .4);
}

/* ИИ-разбивка цели на шаги */
.ai-body { min-width: min(460px, 100%); }
.ai-steps { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.ai-step {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px;
  background: var(--bg-soft); box-shadow: inset 0 0 0 1px var(--card-edge); cursor: pointer;
  transition: box-shadow .2s ease;
}
.ai-step:hover { box-shadow: inset 0 0 0 1px var(--card-border); }
.ai-step input { appearance: auto; -webkit-appearance: checkbox; flex: none; width: 19px; height: 19px; margin: 0; accent-color: var(--accent); }
.ai-step-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ai-note { display: flex; gap: 12px; align-items: flex-start; line-height: 1.55; }
.ai-note-icon { font-size: 1.4em; line-height: 1.1; }
.ai-loading { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 22px 0 8px; text-align: center; color: var(--text-muted); }
.ai-spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--track); border-top-color: var(--accent);
  animation: ai-spin .9s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* =====================================================================
   Свайп по этапу или задаче: влево — открываются кнопки
   ===================================================================== */
.swipe-row { position: relative; overflow: hidden; border-radius: 14px; }
.swipe-front {
  position: relative; z-index: 1; background: var(--card);
  touch-action: pan-y;   /* вертикально прокручивает браузер, горизонталь — наша */
  transition: transform .34s var(--ease-drawer);
}
.swipe-actions {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 0;
  display: none; align-items: stretch;
}
.swipe-row:not(.revealed) .swipe-actions { visibility: hidden; }
.swipe-btn {
  border: 0; cursor: pointer; min-width: 68px; padding: 0 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: var(--raised); color: var(--text);
  font-size: calc(11px * var(--scale)); font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.swipe-btn.accent { background: var(--accent); color: var(--on-accent); }
.swipe-btn.danger { background: var(--danger); color: var(--white); }
.swipe-icon { font-size: calc(16px * var(--scale)); line-height: 1; display: grid; place-items: center; }
.swipe-hint { display: none; margin: 4px 0 6px; font-size: calc(12px * var(--scale)); color: var(--text-faint); }
.dragging .swipe-front { background: transparent; }

/* =====================================================================
   Телефон
   ===================================================================== */
@media (max-width: 640px) {
  :root { --thumb: calc(84px * var(--scale)); }
  .card { padding: 18px; border-radius: 20px; }
  .goal { padding: 18px; }
  .goal-top { gap: 14px; }
  .goal-photo { border-radius: 18px; font-size: calc(32px * var(--scale)); }
  /* Квадрат с картинкой — рядом с названием, всё остальное — под ними на всю
     ширину. В квадрате ровно та часть, которую выбрали при добавлении */
  .goal-top { display: grid; grid-template-columns: var(--thumb) minmax(0, 1fr); gap: 0 14px; align-items: start; }
  .goal-top > .goal-photo { grid-row: 1; grid-column: 1; }
  .goal-body { display: contents; }
  .goal-body > * { grid-column: 1 / -1; }
  .goal-body > .row:first-child { grid-column: 2; grid-row: 1; align-self: center; min-height: var(--thumb); align-content: center; }
  .goal-actions { gap: 8px; }
  .goal-actions .btn { flex: 1 1 auto; }
  .goal-actions .btn-primary { flex-basis: 100%; }
  .goal-actions .btn-ghost-danger { flex: 0 1 auto; }
  .today-day { font-size: calc(28px * var(--scale)); }
  .chip { min-width: 0; flex: 1 1 auto; padding: 10px 14px; }
  .row:has(> .chip) { flex: 1 1 100%; }
  .toast-host { left: 12px; right: 12px; align-items: stretch; }
  .toast { max-width: none; }
  .week-dots { gap: 5px; }
  .task-row, .task-row > .swipe-front { padding-left: calc(22px * var(--scale)); }
  .task-row.swipe-row { padding-left: 0; }
  .seg { width: 100%; flex-wrap: nowrap; }
  .seg-btn { flex: 1 1 auto; padding: 8px 6px; min-width: 0; }
  .week-time { min-width: 0; }
  .focus-bar { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .focus-clock { font-size: calc(26px * var(--scale)); }
  .guide > summary { padding: 16px; gap: 14px; }
  .guide-body { padding: 0 16px 18px; }
  .cal-card { padding: 14px 10px 12px; border-radius: 24px; }
  .miss-row { grid-template-columns: minmax(6.5em, auto) 1fr auto; gap: 10px; }

  /* Окна — шторкой снизу: так их удобно держать одной рукой */
  .modal-host { place-items: end center; padding: calc(24px + env(safe-area-inset-top, 0px)) 0 0; }
  .modal {
    width: 100%; max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px));
    border-radius: 28px 28px 0 0;
    padding: 26px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    box-shadow: var(--shadow);
    animation: sheet-in .42s var(--ease-drawer);
  }
  .modal::before {
    content: ""; display: block; width: 38px; height: 5px; border-radius: 99px;
    background: color-mix(in srgb, var(--text) 18%, transparent);
    margin: -12px auto 16px;
  }
  .modal-actions .btn { flex: 1 1 auto; min-height: 46px; }
  /* iOS увеличивает страницу, если шрифт поля меньше 16px */
  .input, textarea.input, select.input { font-size: max(16px, var(--fs-base)); }
}
@keyframes sheet-in { from { transform: translateY(100%); } }

/* На телефоне в шапке остаётся только знак: слово «ДЕРЗАЙ» не влезает
   рядом с пятью кнопками */
@media (max-width: 479px) {
  .brand-text { display: none; }
  .topbar-actions { gap: 6px; }
}

/* =====================================================================
   Планшет и компьютер
   ===================================================================== */
@media (min-width: 641px) {
  .topbar { padding-top: 12px; }
  .icon-btn .btn-label { display: inline; }
  .icon-btn { padding: 0 14px 0 12px; }
  .goal-percent { font-size: calc(44px * var(--scale)); }
  main { padding-top: 22px; }
}
@media (min-width: 900px) {
  .brand-sub { display: block; }
}

/* Широкий экран: вкладки — боковой колонкой, как оглавление */
@media (min-width: 1100px) {
  :root { --side: 236px; --frame: 1240px; }
  .topbar, .tabstrip { max-width: none; }
  .topbar {
    padding-left: max(28px, calc((100vw - var(--frame)) / 2));
    padding-right: max(28px, calc((100vw - var(--frame)) / 2));
  }
  .shell-top { -webkit-backdrop-filter: none; backdrop-filter: none; background: transparent; box-shadow: none; }
  .topbar {
    background: var(--glass);
    -webkit-backdrop-filter: saturate(1.6) blur(22px);
    backdrop-filter: saturate(1.6) blur(22px);
    box-shadow: 0 1px 0 var(--line);
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-bottom: 12px;
  }
  .shell-top { padding-top: 0; }
  .tabstrip {
    position: fixed; top: 74px; bottom: 0;
    left: max(28px, calc((100vw - var(--frame)) / 2));
    width: var(--side);
    flex-direction: column; gap: 2px; overflow-x: hidden; overflow-y: auto;
    padding: 22px 0 24px; margin: 0;
    -webkit-mask-image: none; mask-image: none;
  }
  .tabstrip .tab {
    text-align: left; padding: 10px 14px; border-radius: 12px; font-size: calc(14px * var(--scale));
    color: var(--text-muted); overflow: hidden; text-overflow: ellipsis;
  }
  .tabstrip .tab.active {
    background: var(--card); color: var(--text);
    box-shadow: var(--sheet-shadow);
  }
  /* Боковая колонка: «Сферы» — заголовок раздела, сферы под ним с отступом
     и точкой, как пункты списка; у выбранной точка цветная */
  .tab-group {
    justify-content: space-between;
    margin: 18px 0 6px; padding: 18px 14px 4px;
    box-shadow: inset 0 1px 0 var(--line);
    font-size: calc(15px * var(--scale)); letter-spacing: -.01em;
  }
  .tab-group ~ .tab { margin-left: 10px; padding-left: 14px; }
  .tab-group ~ .tab::before {
    content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 11px; vertical-align: 2px;
    border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--text-faint);
  }
  .tab-group ~ .tab.active::before { background: var(--accent); box-shadow: none; }
  main, .panel-wrap { max-width: none; }
  main {
    margin-left: calc(max(28px, (100vw - var(--frame)) / 2) + var(--side) + 40px);
    margin-right: auto;
    width: min(var(--col), calc(100vw - (max(28px, (100vw - var(--frame)) / 2) + var(--side) + 40px) - 28px));
    padding: 26px 0 72px;
  }

  /* Панели — шторкой справа поверх затемнения */
  .panel-host {
    background: var(--scrim);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    display: flex; justify-content: flex-end;
    animation: fade-in .24s ease;
  }
  .panel-wrap {
    width: min(680px, 100%); flex: none; min-height: 100%; height: max-content;
    margin: 0 0 0 auto; padding: 0 32px 56px;
    box-shadow: var(--shadow);
  }
  .panel-wrap.entering { animation: drawer-in .42s var(--ease-drawer); }
  .panel-head { margin: 0 -32px 18px; padding: 18px 32px 14px; }
}
@keyframes drawer-in { from { transform: translateX(48px); opacity: .4; } }

/* =====================================================================
   Телефон и планшет: панель разделов внизу (Обзор, Планы, Сферы, Итоги).
   Лента вверху показывает только сферы — и только в разделе «Сферы».
   ===================================================================== */
.bottombar, .section-seg { display: none; }
@media (max-width: 1099px) {
  .bottombar {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px;
    position: fixed; z-index: 45;
    left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px));
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    max-width: 520px; margin: 0 auto; padding: 6px;
    border-radius: 26px;
    background: var(--glass-strong);
    -webkit-backdrop-filter: saturate(1.8) blur(24px);
    backdrop-filter: saturate(1.8) blur(24px);
    box-shadow: var(--float-shadow);
    transition: transform .34s var(--ease-drawer), opacity .2s ease;
  }
  .bb-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 52px; padding: 6px 4px 5px; border: 0; border-radius: 20px; cursor: pointer;
    background: transparent; color: var(--text-muted);
    font-size: calc(11px * var(--scale)); font-weight: 650; letter-spacing: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .2s ease, color .2s ease, transform .16s var(--ease);
  }
  .bb-item:active { transform: scale(.92); }
  .bb-item.active { color: var(--accent-ink); background: var(--accent-soft); }
  /* Пока печатаете в поле, панель уезжает вниз, чтобы не висеть над клавиатурой */
  body:has(#main input:focus, #main textarea:focus) .bottombar { transform: translateY(160%); opacity: 0; pointer-events: none; }

  main { padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }
  .toast-host { bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
  .focus-bar { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  body.has-focus #main { padding-bottom: calc(260px * var(--scale)); }
  body.has-focus .toast-host { bottom: calc(250px * var(--scale)); }

  .tabstrip .tab-fixed, .tabstrip .tab-group { display: none; }
  body:not([data-section="spheres"]) .tabstrip { display: none; }
  body:not([data-section="spheres"]) .topbar { padding-bottom: 10px; }

  /* Переключатель разделов внутри «Итогов» — как вкладки (чёрная «таблетка»),
     чтобы не путать его с «Неделя / Месяц» ниже */
  .section-seg {
    display: flex; width: 100%; flex-wrap: nowrap; gap: 4px; margin: 0 0 18px; padding: 0;
    background: transparent; box-shadow: none;
  }
  .section-seg .seg-btn {
    flex: 1 1 0; min-width: 0; padding: 10px 6px; border-radius: 99px;
    font-size: calc(14px * var(--scale)); font-weight: 650;
  }
  .section-seg .seg-btn.active { background: var(--text); color: var(--bg); box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .45); }
}

/* =====================================================================
   Карточка цели на телефоне: шапку заливает размытая копия картинки цели,
   поверх — крупный квадрат с той частью картинки, что выбрали при
   добавлении; справа тип цели над названием
   ===================================================================== */
@media (max-width: 640px) {
  :root { --thumb: calc(124px * var(--scale)); }
  .goal { position: relative; overflow: hidden; }
  .goal::before {
    content: ""; position: absolute; left: 0; right: 0; top: 0; height: 190px; z-index: 0; pointer-events: none;
    background: var(--photo, linear-gradient(160deg, var(--accent-grad-from), var(--accent-dark))) center / cover no-repeat;
    filter: blur(26px) saturate(1.35); transform: scale(1.35); transform-origin: 50% 0; opacity: .6;
  }
  /* Размытый слой после увеличения уходит ниже — плавно гасим его до цвета карточки */
  .goal::after {
    content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
    background: linear-gradient(180deg, transparent 50px, var(--card) 240px);
  }
  .goal > * { position: relative; z-index: 1; }
  .goal-top > .goal-photo {
    border-radius: 24px; font-size: calc(44px * var(--scale));
    box-shadow: 0 18px 34px -16px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .14);
  }
  .goal-body > .row:first-child {
    flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; flex-wrap: nowrap;
  }
  .goal-body > .row:first-child > .type-badge,
  .goal-body > .row:first-child > .badge-done { order: -1; }
  .goal-body > .row:first-child > .type-badge {
    background: color-mix(in srgb, var(--card) 70%, transparent); box-shadow: none; color: var(--text);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  }
  .goal-body > .row:first-child > .goal-title { font-size: calc(20px * var(--scale)); line-height: 1.2; }
  .goal-body > .row:first-child + * { margin-top: 14px; }
}

/* =====================================================================
   Сенсорный экран: кнопки строк прячутся под строку и открываются свайпом
   ===================================================================== */
@media (hover: none) and (pointer: coarse) {
  .swipe-actions { display: flex; }
  .swipe-row .ms-tools, .swipe-row .plan-remove { display: none; }
  .plan-row > .swipe-front { gap: 10px; }
  .swipe-hint { display: block; }
  .ms-row > .swipe-front { padding: 8px 4px 8px 0; }
  .task-row > .swipe-front { padding-top: 6px; padding-bottom: 6px; }
  .ms-check { width: calc(25px * var(--scale)); height: calc(25px * var(--scale)); border-radius: 8px; }
  .ms-check.sm { width: calc(21px * var(--scale)); height: calc(21px * var(--scale)); border-radius: 7px; }
}

/* На iPhone после касания :hover «залипает» — на сенсорных экранах
   подсветку наведения убираем, остаются только выбранные состояния */
@media (hover: none) {
  .tab:hover:not(.active), .btn-ghost:hover, .ms-btn:hover, .seg-btn:hover:not(.active),
  .cal-day:hover:not(.selected), .pick-row:hover:not(.in), .review-row:hover,
  .week-item:hover, .rt-row:hover, .ai-step:hover, .plan-remove:hover, .plan-min:hover,
  .cal-nav:hover, .drag-handle:hover {
    background-color: transparent;
  }
  .tab:hover:not(.active) { background-color: var(--bg-soft); }
  .tabstrip .tab:hover:not(.active) { background-color: transparent; }
  .summary-items .week-item:first-child:hover { background-color: var(--bg-soft); }
  .cal-nav:hover { background-color: var(--bg-soft); }
  .plan-focus:hover { background-color: var(--accent-soft); }
  .btn:hover:not(.btn-ghost):not(.btn-primary):not(.btn-danger):not(.btn-ai):not(.btn-ghost-danger) { background: var(--card-hover); }
  .btn-primary:hover { background: var(--accent); }
  .btn-ai:hover { background: var(--accent-soft); }
  .btn-ghost-danger:hover { background: transparent; }
  .tab:hover:not(.active), .seg-btn:hover:not(.active) { color: var(--text-muted); }
  .ms-btn:hover { color: var(--text-muted); }
  .ms-btn.danger:hover, .plan-remove:hover { color: var(--text-faint); }
  .mood-btn:hover:not(.on) { opacity: .7; filter: grayscale(.7); }
  .wd:hover:not(:disabled):not(.today) { box-shadow: inset 0 0 0 1px var(--card-edge); }
  .wd.done:hover { box-shadow: none; }
  .ms-check:hover:not(.on) { box-shadow: inset 0 0 0 1.75px color-mix(in srgb, var(--text) 26%, transparent); }
}

/* Меньше движения — оставляем смену прозрачности, убираем сдвиги */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
  .panel-host, .panel-wrap, .modal, .toast, .focus-bar, #main.slide-next, #main.slide-prev,
  .cal-grid.slide-next, .cal-grid.slide-prev { animation: fade-in .2s ease !important; }
  .focus-bar { animation: none !important; }
  .ai-spinner { animation-duration: 3s; }
}
