/* MERCY (бывшая Lingua) — стили. Тёмная тема по умолчанию, светлая — :root[data-theme="light"] */

:root {
  color-scheme: dark;
  --bg: #0e1016;
  --bg-nav: #11141b;
  --surface: #161922;
  --surface-2: #1c202b;
  --surface-3: #252a38;
  --border: #262b38;
  --border-strong: #363d50;
  --text: #e8eaf1;
  --muted: #9ca3b6;
  --faint: #6d7488;
  --accent: #8b7cf6;
  --accent-strong: #7564f1;
  --accent-soft: rgba(139, 124, 246, 0.16);
  --on-accent: #ffffff;
  --ok: #3ccf86;
  --warn: #f3b63f;
  --bad: #ff5f6d;
  --de: #f4c021;
  --en: #5b95ff;
  --pl: #ff6377;
  --ru: #a7aec0;
  --g-m: #63a4ff;
  --g-f: #ff74a3;
  --g-n: #45d39a;
  --g-pl: #f3b63f;
  --flame: #ff8a3d;
  --bubble-me: #5a4ad4;
  /* «Тексты»: цвета текста, маркеры и шрифты (в HTML записаны как var(--…), поэтому подстраиваются под тему) */
  --tc-red: #ff6b6b;
  --tc-orange: #ff9f43;
  --tc-yellow: #ffd43b;
  --tc-green: #51cf66;
  --tc-blue: #5c9dff;
  --tc-purple: #b197fc;
  --tc-pink: #f783ac;
  --tc-gray: #9ca3b6;
  --hl-yellow: rgba(255, 212, 0, 0.34);
  --hl-green: rgba(64, 214, 120, 0.3);
  --hl-pink: rgba(247, 100, 170, 0.32);
  --hl-blue: rgba(77, 148, 255, 0.34);
  --hl-orange: rgba(255, 140, 40, 0.34);
  --hl-purple: rgba(150, 110, 255, 0.36);
  --tf-serif: Georgia, "Times New Roman", serif;
  --tf-mono: Consolas, Menlo, "Courier New", monospace;
  --tf-hand: "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  --tf-poster: Impact, "Arial Black", "Avenir Next Condensed", sans-serif;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", ui-monospace, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f9;
  --bg-nav: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f3f4f8;
  --surface-3: #e8eaf1;
  --border: #e3e6ee;
  --border-strong: #cfd4e0;
  --text: #191c25;
  --muted: #5b6275;
  --faint: #8a90a1;
  --accent: #6b5ae6;
  --accent-strong: #5845d8;
  --accent-soft: rgba(107, 90, 230, 0.1);
  --ok: #14975a;
  --warn: #b77900;
  --bad: #d92d43;
  --de: #a77c00;
  --en: #2c6be0;
  --pl: #d4304a;
  --ru: #687083;
  --g-m: #2c6be0;
  --g-f: #d6336c;
  --g-n: #12945e;
  --g-pl: #b07a00;
  --flame: #f06a12;
  --bubble-me: #6b5ae6;
  --tc-red: #d92d43;
  --tc-orange: #d9480f;
  --tc-yellow: #a37b00;
  --tc-green: #1f9d55;
  --tc-blue: #2463d6;
  --tc-purple: #7c4ddb;
  --tc-pink: #c2255c;
  --tc-gray: #6b7280;
  --hl-yellow: rgba(255, 221, 0, 0.55);
  --hl-green: rgba(80, 220, 130, 0.42);
  --hl-pink: rgba(255, 120, 185, 0.4);
  --hl-blue: rgba(110, 170, 255, 0.42);
  --hl-orange: rgba(255, 160, 70, 0.45);
  --hl-purple: rgba(170, 140, 255, 0.42);
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.05), 0 10px 28px rgba(20, 24, 40, 0.08);
}

/* ---------- База ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, h4, h5 { line-height: 1.25; }
kbd {
  font: 600 10.5px/1 var(--font);
  padding: 3px 5px;
  border-radius: 5px;
  border: 1px solid currentColor;
  opacity: 0.65;
}
code { font-family: var(--mono); font-size: 0.9em; }
@media (hover: none) { .btn kbd { display: none; } }
.ico { flex: none; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.center { display: flex; justify-content: center; margin-top: 14px; }
.hint { font-size: 13px; color: var(--muted); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Каркас ---------- */
.app { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }

.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px;
  background: var(--bg-nav);
  border-right: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.2px;
}
.brand img { border-radius: 9px; }
.brand-name { color: var(--accent); font-weight: 900; letter-spacing: 2.5px; font-size: 20px; }
.mobile-top { display: none; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--text); }
.nav-link.active .nav-ico { color: var(--accent); }
.nav-ico { display: inline-flex; width: 20px; height: 20px; }
.nav-badge {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  text-align: center;
}
/* Серия дней — сразу под MERCY */
.nav-streak {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -8px 0 14px;
  padding: 9px 12px;
  border-radius: 13px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--flame) 16%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--flame) 30%, var(--border));
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  transition: border-color 0.15s;
}
.nav-streak:hover { border-color: color-mix(in srgb, var(--flame) 60%, var(--border)); }
.streak-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  color: var(--flame);
  background: color-mix(in srgb, var(--flame) 16%, transparent);
}
.nav-streak:not(.today) .streak-ico { opacity: 0.75; }
.streak-txt { line-height: 1.25; }
.streak-txt b { color: var(--text); font-size: 17px; }
.streak-txt small { display: block; color: var(--faint); font-size: 11.5px; }
.nav-streak.today small { color: color-mix(in srgb, var(--flame) 80%, var(--text)); }
/* ИИ и синхронизация — внизу, над «Настройками» */
.nav-foot { margin-top: auto; padding: 8px 12px 6px; font-size: 13px; }
.nav-foot .hint { font-size: 12px; line-height: 1.5; }
.nav-settings { border-top: 1px solid var(--border); border-radius: 0 0 12px 12px; padding-top: 12px; }
.nav-settings.active { border-radius: 12px; }

.main { padding: 28px clamp(16px, 4vw, 44px) 64px; max-width: 1080px; width: 100%; }

/* Колонка «Мудрость дня» — в пустом месте справа, только на широком экране */
.wisdom { display: none; }
@media (min-width: 1300px) {
  .app { grid-template-columns: 224px minmax(0, 1080px) minmax(300px, 1fr); }
  .wisdom { display: block; padding: 28px clamp(16px, 1.6vw, 40px) 28px 0; }
  .wisdom-sticky { position: sticky; top: 28px; max-width: 380px; }
  .home-quote { display: none; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .nav {
    position: fixed;
    z-index: 40;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: auto;
    flex-direction: row;
    justify-content: space-around;
    gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--border);
  }
  .brand, .nav-foot, .nav-streak, .nav-settings { display: none; }
  .mobile-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
  .mobile-brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; }
  .mobile-streak {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px 3px 8px;
    border-radius: 99px;
    color: var(--flame);
    background: color-mix(in srgb, var(--flame) 14%, transparent);
    font-size: 14px;
  }
  .mobile-streak b { color: var(--text); }
  .mobile-gear { width: 38px; height: 38px; }
  .mobile-brand img { border-radius: 8px; }
  .mobile-brand .brand-name { font-size: 18px; }
  .nav-link { flex: 1; min-width: 0; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 10.5px; border-radius: 10px; }
  .nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-badge { position: absolute; top: 1px; left: 50%; margin-left: 5px; min-width: 18px; padding: 0 5px; font-size: 10.5px; }
  .main {
    padding: 18px 16px 100px;
    padding-top: max(18px, calc(env(safe-area-inset-top) + 8px));
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }
}

/* ---------- Фон приложения (Настройки → Оформление → Фон) ---------- */
.app-bg { display: none; }
.has-bg .app-bg {
  display: block;
  position: fixed;
  inset: 0;
  z-index: -1;
  background: #05060a var(--app-bg) center / cover no-repeat;
}
.has-bg .app-bg::after { content: ""; position: absolute; inset: 0; background: rgba(4, 5, 10, var(--bg-dim, 0.35)); }
.has-bg body { background: #05060a; }
/* поверх картинки — полупрозрачные панели с размытием, чтобы фон было видно, а текст читался */
.has-bg .nav { background: color-mix(in srgb, var(--bg-nav) 70%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.has-bg .card, .has-bg .qa, .has-bg .note, .has-bg .tx-card, .has-bg .threads, .has-bg .nav-foot, .has-bg .capture-card {
  background-color: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.has-bg .banner { backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.has-bg .page-head h1, .has-bg .page-head .sub, .has-bg .tx-section-title { text-shadow: 0 1px 12px rgba(0, 0, 0, 0.55); }
:root[data-theme="light"].has-bg .page-head h1 { color: #fff; }
:root[data-theme="light"].has-bg .page-head .sub, :root[data-theme="light"].has-bg .tx-section-title { color: rgba(255, 255, 255, 0.85); }
.bg-head { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 10px; }
.bg-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.bg-tile {
  position: relative;
  aspect-ratio: 16 / 10;
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface-2) center / cover no-repeat;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.bg-tile:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.bg-tile.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.bg-tile.none { background: repeating-linear-gradient(45deg, var(--surface-2) 0 10px, var(--surface-3) 10px 20px); }
.bg-tile span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 8px 6px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}
.bg-tile.none span { background: none; color: var(--muted); }
.bg-tile i { position: absolute; top: 6px; right: 6px; display: inline-flex; padding: 3px; border-radius: 50%; background: var(--accent); color: var(--on-accent); }

/* ---------- Заголовки страниц ---------- */
.page-head { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -0.3px; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); }
@media (max-width: 860px) { .page-head h1 { font-size: 24px; } }

/* ---------- Карточки-блоки ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 14px; }
.card h2 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card h2 .ico { color: var(--accent); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.grid > .card { margin: 0; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, opacity 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--bad) 50%, transparent); color: var(--bad); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 13px; border-radius: 9px; gap: 6px; }
.btn.lg { min-height: 46px; padding: 10px 20px; font-size: 15px; }
.btn.full { width: 100%; }
.btn kbd { margin-left: 2px; }
.file-btn { position: relative; overflow: hidden; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.speaking { color: var(--accent); background: var(--accent-soft); }
.icon-btn.txt { width: auto; padding: 0 7px; font-size: 11.5px; font-weight: 700; }

.send-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.send-btn:hover { background: var(--accent-strong); }
.send-btn:active { transform: scale(0.96); }
.send-btn.stop { background: var(--surface-3); color: var(--text); }

/* ---------- Поля ---------- */
.input, .textarea, .select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.textarea { resize: vertical; min-height: 44px; line-height: 1.5; }
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3b6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.select option { background: var(--surface); color: var(--text); }
.input.sm, .select.sm { width: auto; min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 9px; }
.select.sm { padding-right: 28px; background-position: right 9px center; }
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--accent); }
input[type="range"] { width: 100%; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span, .label { font-size: 13px; color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--muted); cursor: pointer; }

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex: none;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(18px); }

/* ---------- Значки языков, переключатели, чипы ---------- */
.lb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 30px;
  height: 22px;
  padding: 0 6px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.lb-de { color: var(--de); background: color-mix(in srgb, var(--de) 16%, transparent); }
.lb-en { color: var(--en); background: color-mix(in srgb, var(--en) 16%, transparent); }
.lb-pl { color: var(--pl); background: color-mix(in srgb, var(--pl) 16%, transparent); }
.lb-ru { color: var(--ru); background: color-mix(in srgb, var(--ru) 16%, transparent); }

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
:root[data-theme="light"] .seg button.on { box-shadow: 0 1px 3px rgba(20, 24, 40, 0.12); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--faint); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip .lb { height: 18px; min-width: 24px; font-size: 10.5px; }
.chip.lang { padding: 4px 6px; opacity: 0.55; }
.chip.lang.on { opacity: 1; }

.banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
}
.banner-ico {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}
.notice {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
}
.notice p { margin: 6px 0 10px; }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); }
.notice.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); background: color-mix(in srgb, var(--bad) 7%, var(--surface)); }
.card.notice { padding: 16px 18px; }

.spin {
  display: inline-block;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  height: 16px;
  border-radius: 8px;
  margin: 10px 0;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
.skeleton.short { width: 55%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Главная ---------- */
.flame-box {
  display: inline-flex;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  align-items: center;
  justify-content: center;
  color: var(--flame);
  background: color-mix(in srgb, var(--flame) 15%, transparent);
  flex: none;
}
.big-num { font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.week { display: flex; justify-content: space-between; gap: 6px; margin: 16px 0 10px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 1; font-size: 11.5px; color: var(--faint); }
.wd i { width: 100%; max-width: 30px; height: 8px; border-radius: 99px; background: var(--surface-3); }
.wd.on i { background: linear-gradient(90deg, var(--flame), #ffb547); }
.wd.today span { color: var(--text); font-weight: 700; }
.due-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.due-row:last-child { border-bottom: 0; }
.due-row b { font-size: 18px; min-width: 26px; text-align: right; }
.due-list { margin-bottom: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.stat b { display: block; font-size: 22px; line-height: 1.2; }
.stat span { font-size: 12.5px; color: var(--muted); }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 14px; }
.qa {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  transition: border-color 0.15s;
}
.qa:hover { border-color: var(--accent); }
.qa small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.qa-ico {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}

/* ---------- Тексты для зубрёжки ---------- */
.cat-interview { --cat: var(--accent); }
.cat-meeting { --cat: var(--ok); }
.cat-terms { --cat: var(--en); }
.cat-event { --cat: var(--flame); }
.cat-other { --cat: var(--muted); }
.tx-cat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 99px;
  color: var(--cat, var(--muted));
  background: color-mix(in srgb, var(--cat, var(--muted)) 15%, transparent);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.tx-when {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.tx-when.soon, .tx-when.today { color: var(--flame); background: color-mix(in srgb, var(--flame) 16%, transparent); }
.tx-when.today { animation: pulse 1.8s ease-in-out infinite; }
.tx-when.past { opacity: 0.65; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--flame) 18%, transparent); } }
.tx-section-title { display: flex; align-items: center; gap: 8px; margin: 22px 2px 10px; color: var(--faint); font-size: 12px; font-weight: 800; letter-spacing: 0.7px; text-transform: uppercase; }
.tx-section-title .ico { color: var(--accent); }
.tx-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.tx-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 186px;
  padding: 17px 16px 13px;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(170deg, color-mix(in srgb, var(--cat) 10%, var(--surface)), var(--surface) 58%);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.tx-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--cat); opacity: 0.9; }
.tx-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--cat) 55%, var(--border)); box-shadow: var(--shadow); }
.tx-card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tx-pin { display: inline-flex; color: var(--accent); }
.tx-card h3 { margin: 0; font-size: 16.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tx-preview { flex: 1; margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.tx-card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--faint); font-size: 12px; }
.tx-card-foot .lb { height: 19px; min-width: 26px; font-size: 10.5px; }
.tx-reads { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; color: var(--ok); font-weight: 700; }

.tx-empty { text-align: center; padding: 34px 22px 30px; }
.tx-empty-art { font-size: 54px; line-height: 1; margin-bottom: 10px; }
.tx-empty h2 { justify-content: center; font-size: 20px; }
.tx-empty > .hint { max-width: 520px; margin: 0 auto 20px; font-size: 14px; }
.tx-ideas { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); max-width: 680px; margin: 0 auto 22px; }
.tx-idea {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed color-mix(in srgb, var(--cat) 50%, var(--border));
  background: color-mix(in srgb, var(--cat) 7%, transparent);
  color: var(--text);
  text-align: left;
  text-decoration: none;
  transition: background 0.15s, transform 0.15s;
}
.tx-idea:hover { background: color-mix(in srgb, var(--cat) 14%, transparent); transform: translateY(-1px); }
.tx-idea span { font-size: 22px; }
.tx-idea small { color: var(--muted); font-size: 12px; }

.tx-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.tx-bar .icon-btn.on { color: var(--accent); background: var(--accent-soft); }
.tx-saved { margin-left: 6px; }
/* overflow: clip (а не hidden), чтобы панель оформления могла «прилипать» к верху экрана */
.tx-paper { position: relative; padding: 26px clamp(18px, 4vw, 44px) 24px; border-top: 4px solid var(--cat); overflow: hidden; overflow: clip; }
.tx-paper::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 140px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--cat) 9%, transparent), transparent);
  pointer-events: none;
}
.tx-paper > * { position: relative; z-index: 1; }
.tx-title { margin: 12px 0 6px; font-size: clamp(24px, 3vw, 31px); line-height: 1.2; letter-spacing: -0.3px; }
.tx-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.tx-meta b { color: var(--text); }
.tx-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 18px 0 6px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.tx-tools .seg button { padding: 4px 11px; font-weight: 800; }
.tx-cram-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 13.5px;
}
.tx-body { max-width: 74ch; margin-top: 18px; line-height: 1.75; word-break: break-word; }
.tx-body > p.hint { margin: 0; }
.tx-chunk { margin: 0 -8px 0.85em; padding: 2px 8px; border-radius: 9px; transition: filter 0.25s, background 0.2s, opacity 0.25s; }
.tx-chunk.reading { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.tx-body.cram .tx-chunk:not(.shown) { filter: blur(7px); opacity: 0.8; cursor: pointer; user-select: none; -webkit-user-select: none; }
.tx-body.cram .tx-chunk:not(.shown):hover { filter: blur(5px); background: var(--surface-2); }
.tx-body.cram .tx-chunk.shown { cursor: pointer; background: color-mix(in srgb, var(--ok) 8%, transparent); }
/* Оформленный текст — одинаково в чтении и в редакторе */
.tx-chunk p, .tx-rich p { margin: 0; }
.tx-chunk ul, .tx-chunk ol, .tx-rich ul, .tx-rich ol { margin: 0.15em 0; padding-left: 1.4em; }
.tx-chunk [style*="--hl-"], .tx-rich [style*="--hl-"] { padding: 0.05em 0.12em; border-radius: 0.28em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.tx-chunk [style*="--tf-hand"], .tx-rich [style*="--tf-hand"] { line-height: 1.5; }

/* Редактор с оформлением */
.tx-rich-wrap { position: relative; margin-top: 12px; }
.rt-bar {
  position: sticky;
  top: 8px;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 92%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}
.rt-group { display: flex; align-items: center; gap: 1px; padding-right: 4px; margin-right: 1px; border-right: 1px solid var(--border); }
.rt-group:last-child { border-right: 0; padding-right: 0; }
.rt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 32px;
  height: 32px;
  padding: 0 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.rt-btn:hover, .rt-btn.open { background: var(--surface-3); color: var(--text); }
.rt-btn.on { background: var(--accent-soft); color: var(--accent); }
.rt-btn b, .rt-btn i, .rt-btn u, .rt-btn s { font-size: 15px; }
.rt-split { padding-right: 3px; border-radius: 8px 0 0 8px; }
.rt-caret { min-width: 20px; padding: 0 3px; border-radius: 0 8px 8px 0; }
.rt-a, .rt-marker { position: relative; display: inline-flex; flex-direction: column; align-items: center; line-height: 1; font-weight: 800; font-size: 16px; }
.rt-a { font-family: Georgia, serif; padding-bottom: 5px; }
.rt-a i, .rt-marker i { position: absolute; left: -2px; right: -2px; bottom: -1px; height: 4px; border-radius: 2px; }
.rt-marker { padding-bottom: 5px; }
.rt-marker i { height: 5px; bottom: -2px; }
.rt-lbl { font-size: 13px; }
.rt-menu {
  position: absolute;
  z-index: 30;
  min-width: 190px;
  max-width: calc(100vw - 32px);
  padding: 8px;
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  animation: rise 0.14s ease-out;
}
.rt-menu-title { padding: 4px 8px 6px; color: var(--faint); font-size: 11px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; }
.rt-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.rt-item:hover { background: var(--surface-2); }
.rt-item .ico { color: var(--muted); }
.rt-swatches { display: grid; grid-template-columns: repeat(4, 34px); gap: 8px; padding: 4px 6px 8px; }
.rt-swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; transition: transform 0.12s; }
.rt-swatch.mark { border-radius: 9px; }
.rt-swatch:hover { transform: scale(1.1); }
.rt-swatch.on { box-shadow: 0 0 0 2px var(--accent); }
.tx-rich {
  position: relative;
  min-height: 46vh;
  padding: 16px 2px 14px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.7;
  outline: none;
  word-break: break-word;
  -webkit-user-modify: read-write;
}
.tx-rich.is-empty::before {
  content: attr(data-placeholder);
  position: absolute;
  top: 16px;
  left: 2px;
  right: 2px;
  color: var(--faint);
  white-space: pre-line;
  pointer-events: none;
}
@media (max-width: 860px) {
  .rt-lbl { display: none; }
  /* на телефоне — одна строка, листается пальцем вбок */
  .rt-bar { top: max(6px, env(safe-area-inset-top)); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .rt-bar::-webkit-scrollbar { display: none; }
  .rt-group { flex: none; }
}
.tx-done { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--border); }

.tx-edit { padding-top: 22px; }
.tx-title-input {
  width: 100%;
  padding: 4px 0 8px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: clamp(22px, 2.6vw, 28px);
  font-weight: 800;
  outline: none;
}
.tx-title-input::placeholder { color: var(--faint); font-weight: 600; }
.tx-title-input:focus { border-bottom-color: var(--accent); }
.tx-edit-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 14px 0 6px; }
.tx-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.tx-date { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 600; }
.tx-date .input { width: auto; color-scheme: inherit; }
.tx-textarea {
  display: block;
  width: 100%;
  min-height: 46vh;
  margin-top: 12px;
  padding: 14px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  line-height: 1.7;
  resize: none;
  outline: none;
}
.tx-textarea::placeholder { color: var(--faint); }
.tx-edit-foot { padding-top: 10px; border-top: 1px solid var(--border); }
.tx-soon { color: var(--text); text-decoration: none; background: linear-gradient(135deg, color-mix(in srgb, var(--cat) 20%, var(--surface)), var(--surface)); border-color: color-mix(in srgb, var(--cat) 45%, var(--border)); }
.tx-soon .banner-ico { font-size: 22px; background: color-mix(in srgb, var(--cat) 16%, transparent); }
@media (max-width: 860px) {
  .tx-paper { padding: 20px 16px 18px; }
  .tx-date { margin-left: 0; }
  .tx-done .hint { font-size: 12.5px; }
  .tx-bar .tx-saved { display: none; }
}

/* ---------- Мудрость дня ---------- */
.home-quote { margin-top: 14px; }
.wisdom-card {
  position: relative;
  overflow: hidden;
  padding: 20px 20px 14px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 15%, var(--surface)), var(--surface) 62%);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
}
.wisdom-card::after {
  content: "\201D";
  position: absolute;
  top: -22px;
  right: 12px;
  font: 150px/1 Georgia, "Times New Roman", serif;
  color: var(--accent);
  opacity: 0.09;
  pointer-events: none;
}
.wisdom-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.wisdom-top .hint { font-size: 12px; }
.wisdom-label { display: inline-flex; align-items: center; gap: 7px; color: var(--accent); font-size: 11.5px; font-weight: 800; letter-spacing: 1.3px; text-transform: uppercase; }
.wisdom-en { position: relative; margin: 0 0 12px; color: var(--text); font: italic 500 19px/1.45 Georgia, "Times New Roman", serif; }
.wisdom-en::before { content: "\201C"; }
.wisdom-en::after { content: "\201D"; }
.wisdom-ru { margin: 0 0 14px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.wisdom-by { padding-top: 12px; border-top: 1px solid var(--border); font-size: 14px; }
.wisdom-src { margin-top: 3px; color: var(--faint); font-size: 12px; }
.wisdom-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 2px; margin-top: 10px; }
.wisdom-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; flex-basis: 100%; }
.wisdom-nav .btn { min-width: 0; padding: 4px 6px; gap: 4px; font-size: 12.5px; }
.wisdom-card.compact .wisdom-en { font-size: 17.5px; }
@media (max-width: 860px) { .wisdom-card.compact { padding: 16px 16px 12px; } }

/* ---------- Строки на разных языках ---------- */
.line { display: flex; align-items: flex-start; gap: 10px; padding: 3px 0; }
.line .lb { margin-top: 2px; }
.line .txt { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; font-size: 15.5px; }
.line .icon-btn { width: 28px; height: 28px; margin-top: -2px; }
.line.sm .txt { font-size: 14px; }
mark { background: color-mix(in srgb, var(--warn) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- Переводчик ---------- */
.tr-input { padding: 14px 16px; transition: border-color 0.15s; }
.tr-input:focus-within { border-color: var(--accent); }
.tr-input .textarea {
  font-size: 19px;
  min-height: 96px;
  max-height: 340px;
  border: 0;
  background: transparent;
  padding: 10px 2px;
  box-shadow: none;
  resize: none;
}
.tr-top { margin-bottom: 4px; }
.tr-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.tr-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0 10px; color: var(--muted); font-size: 13px; }
.tr-results { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.tr-card { margin: 0 !important; border-top: 3px solid var(--c, var(--border)); }
.tr-card.de { --c: var(--de); }
.tr-card.en { --c: var(--en); }
.tr-card.pl { --c: var(--pl); }
.tr-card.ru { --c: var(--ru); }
.tr-head { display: flex; align-items: center; gap: 6px; margin: -4px 0 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.tr-text { font-size: 19px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.tr-alt { margin-top: 8px; color: var(--muted); font-size: 14px; }
.tr-alt span { color: var(--text); }
.tr-note { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px; color: var(--muted); }
.words { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.word {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 6px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, opacity 0.15s;
}
.word:hover { border-color: var(--accent); }
.word .ico { color: var(--faint); }
.word.added { opacity: 0.5; cursor: default; }
.g { font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 99px; }
.g-m { color: var(--g-m); background: color-mix(in srgb, var(--g-m) 16%, transparent); }
.g-f { color: var(--g-f); background: color-mix(in srgb, var(--g-f) 16%, transparent); }
.g-n { color: var(--g-n); background: color-mix(in srgb, var(--g-n) 16%, transparent); }
.g-pl { color: var(--g-pl); background: color-mix(in srgb, var(--g-pl) 16%, transparent); }
.hist-list { display: grid; gap: 4px; }
.hist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.hist-item:hover { background: var(--surface-2); }
.hist-item .ellipsis { flex: 1; }

/* ---------- Блокнот ---------- */
.capture-card { padding: 8px 10px 8px 14px; transition: border-color 0.15s; }
.capture-card:focus-within { border-color: var(--accent); }
.capture { display: flex; gap: 10px; align-items: flex-end; }
.capture .textarea {
  border: 0;
  background: transparent;
  box-shadow: none;
  min-height: 44px;
  max-height: 260px;
  resize: none;
  padding: 10px 2px;
  font-size: 15.5px;
}
.cap-foot { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 2px 2px 4px; }
.cap-preview { display: flex; flex-wrap: wrap; gap: 6px; }
.cap-preview .chip { cursor: default; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0 12px; }
.search { position: relative; flex: 1 1 240px; display: block; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search .input { padding-left: 38px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.bulk { margin-bottom: 12px; }
.notes-list { display: grid; gap: 10px; }
.note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px 9px;
}
.note-comment {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
}
.note-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px dashed var(--border);
  color: var(--faint);
  font-size: 12.5px;
}
.note-foot .icon-btn { width: 30px; height: 30px; }
.tag { border: 0; background: none; padding: 0; color: var(--accent); font-size: 12.5px; cursor: pointer; }
.tag:hover { text-decoration: underline; }
.lvl-pill { padding: 1px 7px; border-radius: 99px; background: var(--surface-2); font-size: 11.5px; color: var(--muted); }
.btn.missing { color: var(--warn); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 42px; line-height: 1; margin-bottom: 10px; }
.empty h2 { justify-content: center; color: var(--text); }

/* ---------- Карточки (повторение) ---------- */
.review-langs { display: grid; gap: 8px; margin-bottom: 14px; }
.rl {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
}
.rl.on { border-color: var(--accent); background: var(--accent-soft); }
.rl b { font-size: 17px; }
.flash { max-width: 700px; margin: 0 auto; }
.fc-top { margin-bottom: 10px; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-bottom: 14px; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width 0.3s; }
.fc { padding: 22px 24px 24px; }
.fc-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.fc-prompt { display: flex; gap: 12px; align-items: flex-start; font-size: 22px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.fc-ask { margin: 18px 0 10px; color: var(--muted); }
.fc-answer { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.fc-answer .row { align-items: flex-start; flex-wrap: nowrap; }
.ans-text { font-size: 21px; line-height: 1.4; word-break: break-word; }
.verdict { margin-top: 10px; font-weight: 600; font-size: 14px; }
.verdict.ok { color: var(--ok); }
.verdict.mid { color: var(--warn); }
.verdict.bad { color: var(--bad); }
.w-ok { color: var(--ok); }
.w-near { color: var(--warn); text-decoration: underline wavy; text-underline-offset: 4px; }
.w-miss { color: var(--bad); text-decoration: underline; text-underline-offset: 4px; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 20px; }
.grade {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 11px 6px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.grade small { font-weight: 500; color: var(--muted); font-size: 12px; }
.grade kbd { position: absolute; top: 6px; right: 7px; font-size: 9.5px; padding: 2px 4px; }
.grade.g0:hover { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface-2)); }
.grade.g1:hover { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface-2)); }
.grade.g2:hover { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface-2)); }
.grade.g3:hover { border-color: var(--en); background: color-mix(in srgb, var(--en) 10%, var(--surface-2)); }
.levels { display: inline-flex; gap: 3px; }
.levels i { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); }
.levels i.on { background: var(--accent); }
.new-pill { padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; }
.done-card { text-align: center; padding: 36px 24px; }
.done-card .big { font-size: 52px; line-height: 1; }
.done-card .row { justify-content: center; margin-top: 18px; }
ul.clean { margin: 0 0 10px; padding-left: 20px; display: grid; gap: 4px; }
@media (max-width: 520px) {
  .grades { grid-template-columns: repeat(2, 1fr); }
  .fc { padding: 18px 16px 20px; }
  .fc-prompt { font-size: 19px; }
  .ans-text { font-size: 18px; }
}

/* ---------- Репетитор ---------- */
.tutor-head .seg button .name { display: inline; }
.tutor-wrap {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 14px;
  height: calc(100vh - 176px);
  min-height: 440px;
}
.tutor {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

/* Список чатов: на ПК — колонка слева, на телефоне — выезжает по кнопке «Чаты» */
.threads {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.threads-head { display: flex; align-items: center; gap: 6px; padding: 2px 4px 0; }
.threads-head .hint { font-size: 12.5px; }
.threads-close { display: none; }
.threads-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 0 6px 4px; }
.th-group { padding: 12px 10px 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--faint); }
.th { display: flex; align-items: center; border-radius: 10px; transition: background 0.15s; }
.th:hover { background: var(--surface-2); }
.th.on { background: var(--accent-soft); }
.th-open {
  flex: 1;
  min-width: 0;
  display: flex;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.th:hover .th-open, .th.on .th-open { color: var(--text); }
.th.on .th-open { font-weight: 600; }
.th-acts { display: none; padding-right: 3px; }
.th:hover .th-acts, .th:focus-within .th-acts { display: flex; }
.th-acts .icon-btn { width: 26px; height: 26px; }
@media (hover: none) { .th.on .th-acts { display: flex; } }
.th-empty { margin: 0; padding: 10px 8px; }
.threads-backdrop { display: none; }
.chat-top { display: flex; align-items: center; gap: 2px; min-height: 50px; padding: 7px 10px 7px 18px; border-bottom: 1px solid var(--border); }
.chat-title { flex: 1; min-width: 0; font-weight: 700; font-size: 14.5px; }
.chat-top .icon-btn { width: 30px; height: 30px; }
.chat-top .side-btn, .chat-top .new-btn { display: none; }
.side-btn b { min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface-3); color: var(--text); font-size: 11.5px; line-height: 18px; }
.side-btn b:empty { display: none; }
@media (max-width: 1023px) {
  .tutor-wrap { grid-template-columns: minmax(0, 1fr); }
  .threads {
    position: fixed;
    z-index: 90;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 86vw);
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    border-radius: 0 18px 18px 0;
    border-left: 0;
    box-shadow: var(--shadow);
    transform: translateX(-104%);
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0.22s;
  }
  .side-open .threads { transform: none; visibility: visible; }
  .threads-close { display: inline-flex; }
  .side-open .threads-backdrop { display: block; position: fixed; inset: 0; z-index: 85; background: rgba(6, 8, 14, 0.55); animation: fade 0.15s ease-out; }
  .chat-top { padding-left: 6px; }
  .chat-top .side-btn, .chat-top .new-btn { display: inline-flex; }
  .chat-title { padding-left: 4px; }
  .th-acts { display: flex; }
}
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: min(82%, 720px); padding: 10px 14px; border-radius: 16px; line-height: 1.55; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--bubble-me); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.msg.error { align-self: flex-start; border: 1px solid color-mix(in srgb, var(--bad) 50%, var(--border)); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.msg-actions { display: flex; gap: 2px; margin: 6px -6px -4px; opacity: 0; transition: opacity 0.15s; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: 1; } }
.msg-actions .icon-btn { width: 30px; height: 30px; }
.tutor-intro { margin: auto; max-width: 460px; text-align: center; color: var(--muted); padding: 20px 6px; }
.tutor-intro .big { font-size: 44px; line-height: 1; margin-bottom: 8px; }
.tutor-intro h2 { justify-content: center; color: var(--text); font-size: 19px; margin-bottom: 8px; }
.quick { display: flex; gap: 6px; padding: 10px 14px 0; overflow-x: auto; scrollbar-width: none; border-top: 1px solid var(--border); }
.quick::-webkit-scrollbar { display: none; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px 14px; }
.composer .textarea { max-height: 200px; resize: none; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@media (max-width: 860px) {
  .tutor-wrap { height: calc(100vh - 222px); height: calc(100dvh - 222px); min-height: 380px; }
  .tutor-head .sub { display: none; }
  .msg { max-width: 92%; }
}
@media (max-width: 600px) { .tutor-head .seg button .name { display: none; } }

/* Markdown в ответах ИИ */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 8px; }
.md h3, .md h4, .md h5 { margin: 12px 0 6px; font-size: 15.5px; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md strong { font-weight: 700; color: var(--text); }
.md code { padding: 1px 5px; border-radius: 5px; background: var(--surface-3); font-size: 13px; }
.md pre { margin: 6px 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-3); overflow-x: auto; }
.md pre code { padding: 0; background: none; }
.md blockquote { margin: 6px 0 10px; padding: 2px 12px; border-left: 3px solid var(--accent); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.table-wrap { overflow-x: auto; margin: 6px 0 10px; }
.md table { border-collapse: collapse; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border-strong); padding: 5px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-3); }

/* ---------- Настройки ---------- */
.steps { margin: 12px 0 14px; padding-left: 22px; display: grid; gap: 6px; }
.key-row { display: flex; gap: 8px; flex-wrap: wrap; }
.key-row .input { flex: 1 1 260px; width: auto; }
.key-status { margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.key-status.ok { color: var(--ok); }
.key-status.bad { color: var(--bad); }
.set-row { display: flex; align-items: center; gap: 10px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.set-row:last-child { border-bottom: 0; }
.set-row > .grow { min-width: 96px; }
.set-row .select:not(.sm) { flex: 1 1 160px; width: auto; min-width: 0; max-width: 100%; }
.prov-body { margin-top: 14px; }
.danger-zone { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }

/* ---------- Окна и уведомления ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(6, 8, 14, 0.62);
  backdrop-filter: blur(3px);
  animation: fade 0.15s ease-out;
}
.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: rise 0.18s ease-out;
}
.modal.wide { width: min(840px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 6px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 10px 18px; overflow-y: auto; }
.modal-body p { margin: 0 0 10px; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 18px 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.toasts {
  position: fixed;
  z-index: 200;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}
@media (max-width: 860px) { .toasts { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: none; } }
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: rise 0.2s ease-out;
  transition: opacity 0.25s, transform 0.25s;
}
.toast.ok { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.toast.error { border-color: color-mix(in srgb, var(--bad) 60%, var(--border)); }
.toast.out { opacity: 0; transform: translateY(6px); }
.toast-btn { margin-left: auto; border: 0; background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; white-space: nowrap; }

/* Импорт */
.imp-tools { margin: 14px 0 8px; gap: 8px 12px; }
.imp-list { max-height: 46vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; }
.imp-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.imp-item:last-child { border-bottom: 0; }
.imp-item.dup { opacity: 0.55; }
.imp-item input { margin-top: 4px; }
.imp-foot { margin-top: 12px; gap: 12px; }

/* iPhone увеличивает страницу, если шрифт в поле меньше 16px — не даём ему это делать.
   Правило стоит в конце файла, чтобы перекрыть размеры шрифта выше. */
@media (pointer: coarse) {
  .input, .textarea, .select, .input.sm, .select.sm, .capture .textarea, .composer .textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ===== Polly · музыка для учёбы (кнопка 🎧 и мини-плеер) ===== */
.music { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.music-fab { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: inherit; font-size: 22px; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.music.playing .music-fab { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent), 0 6px 20px rgba(0,0,0,.35); }
.music-panel { display: none; width: min(320px, calc(100vw - 36px)); padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.music.open .music-panel { display: block; }
.music-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.music-frame { border-radius: 10px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.music-frame:empty { display: none; }
.music-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.music-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.music .hint { margin: 6px 0 0; font-size: 12px; }
/* плеер свёрнут, но музыка играет: держим iframe в странице, только прячем */
.music:not(.open) .music-panel { display: block; position: absolute; width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; opacity: 0; pointer-events: none; }
@media (max-width: 860px) { .music { right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); } }
