/* Гайка — оформление в духе Apple: крупные заголовки, скруглённые карточки-виджеты,
   системный шрифт, полупрозрачные панели. Здесь — исходная тема «Апельсин»: чёрный, оранжевый,
   серые, тёмно-фиолетовый. Остальные цветовые темы — в themes.css (собирается из bot/web/themes.py). */

@font-face {
  font-family: "Inter Variable";
  src: url("/static/fonts/inter-cyrillic-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter Variable";
  src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212;
}

:root {
  --bg: #F5F5F7;
  --side: #ECECEF;
  --card: #FFFFFF;
  --fill: #E9E9EC;
  --fill-2: #DEDEDE;
  --sep: rgb(60 60 67 / .13);
  --ink: #171717;
  --ink-2: #4D4D4D;
  --ink-3: #8A8A8E;
  --accent: #F25623;
  --accent-soft: #FDE8DF;
  --on-accent: #FFFFFF;
  --accent-ink: var(--accent);   /* главный цвет, когда им пишут текст (в светлых темах он темнее) */
  --on-second: #FFFFFF;
  --deep: #171717;
  --hero: radial-gradient(115% 150% at 100% 0%, #F25623 0%, rgb(242 86 35 / .5) 26%, rgb(242 86 35 / 0) 58%), #171717;
  --cover-3: #4D4D4D; --cover-4: #DEDEDE; --on-cover-4: #171717;
  --indigo: #261A66;
  --indigo-soft: #E9E6F7;
  --indigo-ink: #3A2A9B;
  --green: #248A3D;
  --green-fill: #34C759;
  --green-soft: #E2F6E7;
  --red: #D70015;
  --bar: rgb(245 245 247 / .78);
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 8px 24px rgb(0 0 0 / .06);
  --r-card: 20px;
  --r-widget: 26px;
  --time: 76px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.4; letter-spacing: -0.011em;
  color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --side: #111112; --card: #1C1C1E; --fill: #2C2C2E; --fill-2: #3A3A3C;
    --sep: rgb(84 84 88 / .55); --ink: #F5F5F7; --ink-2: #B4B4BA; --ink-3: #7C7C82;
    --accent: #FF6A3D; --accent-soft: #3B1D12; --on-accent: #FFFFFF;
    --indigo: #2C217A; --indigo-soft: #221C47; --indigo-ink: #A79CFF;
    --green: #30D158; --green-fill: #30D158; --green-soft: #12301C; --red: #FF453A;
    --bar: rgb(18 18 19 / .76); --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 12px 32px rgb(0 0 0 / .5);
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --side: #111112; --card: #1C1C1E; --fill: #2C2C2E; --fill-2: #3A3A3C;
  --sep: rgb(84 84 88 / .55); --ink: #F5F5F7; --ink-2: #B4B4BA; --ink-3: #7C7C82;
  --accent: #FF6A3D; --accent-soft: #3B1D12; --on-accent: #FFFFFF;
  --indigo: #2C217A; --indigo-soft: #221C47; --indigo-ink: #A79CFF;
  --green: #30D158; --green-fill: #30D158; --green-soft: #12301C; --red: #FF453A;
  --bar: rgb(18 18 19 / .76); --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 12px 32px rgb(0 0 0 / .5);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100dvh; background: var(--bg); }
h1, h2, h3, p, dl { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-ink); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
.boot { padding: 48px 20px; color: var(--ink-2); }

/* ---------- каркас: боковая панель на компьютере, нижняя панель на телефоне ---------- */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100dvh; }
.rail {
  position: sticky; top: 0; height: 100dvh; padding: 22px 12px 16px; display: flex; flex-direction: column; gap: 2px;
  background: var(--side); border-right: 1px solid var(--sep);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 18px; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { fill: var(--on-accent); }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; text-decoration: none;
  color: var(--ink); font-size: 15px; font-weight: 500; border: 0; background: none; width: 100%; text-align: left;
}
.nav-link svg { width: 20px; height: 20px; flex: none; color: var(--accent-ink); }
.nav-link span:first-of-type { flex: 1; }
.nav-link:hover { background: color-mix(in srgb, var(--fill) 70%, transparent); }
.nav-link[aria-current="page"] { background: var(--fill-2); font-weight: 600; }
.count { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; flex: none; }
.rail { overflow-y: auto; }
.rail .spacer { flex: 1; min-height: 12px; }
.new-chat { margin: 0 4px 12px; justify-content: flex-start; padding-left: 14px; }
.rail-title { margin: 18px 10px 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.recent-link { font-weight: 400; font-size: 14.5px; padding-top: 7px; padding-bottom: 7px; }
.recent-link svg { color: var(--ink-3); width: 18px; height: 18px; }
.recent-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.scrim { display: none; }
.who { padding: 10px; font-size: 13px; color: var(--ink-3); }
.who b { display: block; color: var(--ink); font-weight: 600; font-size: 15px; }

.main { padding: 30px clamp(20px, 4vw, 56px) 80px; max-width: 980px; width: 100%; }
.tabbar, .topbar { display: none; }
.only-mobile { display: none !important; }

@media (max-width: 859px) {
  :root { --time: 68px; font-size: 17px; }
  .shell { display: block; }
  /* меню выезжает слева поверх страницы */
  .rail {
    position: fixed; z-index: 30; top: 0; left: 0; bottom: 0; width: min(84vw, 330px); height: 100dvh;
    padding: calc(18px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
    border-right: 0; border-radius: 0 26px 26px 0; background: var(--bg);
    transform: translateX(-104%); visibility: hidden; transition: transform .28s cubic-bezier(.2, .7, .3, 1), visibility 0s .28s;
  }
  .shell.menu-open .rail { transform: none; visibility: visible; box-shadow: 0 0 60px rgb(0 0 0 / .25); transition: transform .28s cubic-bezier(.2, .7, .3, 1); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 29; border: 0; padding: 0; background: rgb(0 0 0 / .32); opacity: 0; pointer-events: none; transition: opacity .28s; }
  .shell.menu-open .scrim { opacity: 1; pointer-events: auto; }
  .rail .nav-link { font-size: 17px; padding: 11px 10px; }
  .rail .recent-link { font-size: 16px; padding: 9px 10px; }
  .only-mobile { display: inline-flex !important; }
  .topbar {
    display: flex; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 5;
    padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
    background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  }
  .topbar .brand { padding: 0; font-size: 16px; margin-right: auto; }
  .topbar button.nav-link { margin-left: -8px; }
  .topbar .brand-mark { width: 26px; height: 26px; }
  .topbar .nav-link { width: auto; padding: 8px; gap: 4px; }
  .topbar .nav-link svg { width: 24px; height: 24px; color: var(--ink); }
  .main { padding: 4px 16px calc(96px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--sep);
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 5px 2px; font-size: 10.5px; font-weight: 500; letter-spacing: 0; color: var(--ink-3); text-decoration: none; }
  .tabbar a[aria-current="page"] { color: var(--accent-ink); }
  .tabbar svg { width: 25px; height: 25px; }
}

/* ---------- крупный заголовок страницы ---------- */
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 14px 16px; flex-wrap: wrap; margin: 0 0 18px; }
.page-head h1 { font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -0.028em; overflow-wrap: anywhere; }
.page-head h1 small { display: block; margin-top: 5px; font-size: 15px; line-height: 1.35; font-weight: 400; letter-spacing: -0.011em; color: var(--ink-2); }
.page-head .aside { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chat-head h1 { font-size: 26px; }
.crumb { display: inline-block; margin: 0 0 6px; font-size: 15px; font-weight: 500; text-decoration: none; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 26px 4px 10px; }
.section-head:first-of-type { margin-top: 0; }
.section-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.022em; }
.weather { font-size: 14px; color: var(--ink-2); max-width: 30ch; text-align: right; }

/* ---------- виджеты страницы «Сегодня» ---------- */
.widgets { display: grid; grid-template-columns: 1.7fr 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.widget { display: flex; flex-direction: column; gap: 2px; min-height: 158px; padding: 18px; border-radius: var(--r-widget); background: var(--card); overflow: hidden; }
.w-label { font-size: 13px; font-weight: 600; opacity: .72; }
.w-big { font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -0.028em; margin-top: 6px; overflow-wrap: anywhere; }
.w-sub { font-size: 15px; opacity: .86; }
.w-foot { margin-top: auto; padding-top: 12px; font-size: 14px; opacity: .86; }
.widget.hero { color: #fff; background: var(--hero); }
.widget.hero .w-big { font-size: 38px; }
.widget.next { color: var(--on-second); background: var(--indigo); }
.widget.ring { align-items: flex-start; }
.ring-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.ring-svg { width: 62px; height: 62px; flex: none; transform: rotate(-90deg); }
.ring-svg circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.ring-svg .track { stroke: var(--fill); }
.ring-svg .value { stroke: var(--accent-ink); }
.ring-num { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.ring-num small { font-size: 15px; font-weight: 500; color: var(--ink-2); letter-spacing: -0.011em; }
@media (max-width: 859px) {
  .widgets { grid-template-columns: 1fr 1fr; gap: 12px; }
  .widget.hero { grid-column: 1 / -1; min-height: 150px; }
  .widget { min-height: 140px; }
}

/* ---------- сгруппированные списки ---------- */
.sheet { position: relative; background: var(--card); border-radius: var(--r-card); overflow: hidden; margin-bottom: 16px; }
.row { position: relative; display: grid; grid-template-columns: var(--time) minmax(0, 1fr); min-height: 48px; align-items: stretch; }
.row:not(:last-child)::after, .chat-row:not(:last-child)::after, .source:not(:last-child)::after, .feed-item:not(:last-child)::after {
  content: ""; position: absolute; left: 16px; right: 0; bottom: 0; height: 1px; background: var(--sep);
}
.row > .in-margin { padding: 15px 0 12px 16px; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; letter-spacing: 0; }
.row > .body { padding: 12px 16px 12px 6px; min-width: 0; }
.row.head { min-height: 0; }
.row.head > .body { padding-top: 18px; padding-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.row.routine > .body { color: var(--ink-2); padding-top: 14px; }
.lesson-name { font-weight: 600; font-size: 17px; letter-spacing: -0.018em; }
.bring { color: var(--ink-2); font-size: 14px; }
.empty { padding: 20px 16px; color: var(--ink-2); font-size: 15px; }
.n { display: inline-block; margin-left: 8px; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--fill); color: var(--ink-2); font-size: 12px; text-align: center; line-height: 20px; }

.item { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 8px; align-items: start; width: 100%; padding: 6px 0; border: 0; background: none; text-align: left; border-radius: 10px; }
.item + .item { margin-top: 2px; }
.mark { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--fill-2); display: grid; place-items: center; margin-top: 1px; color: #fff; font-size: 13px; font-weight: 800; line-height: 1; }
.mark[data-s="done"] { background: var(--green-fill); border-color: var(--green-fill); }
.mark[data-s="in_progress"] { border-color: var(--indigo-ink); background: linear-gradient(90deg, var(--indigo-ink) 50%, transparent 50%); }
.mark[data-s="postponed"] { border-style: dashed; border-color: var(--ink-3); }
.mark[data-s="needs_help"], .mark[data-s="reason_given"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.item-text { display: block; font-size: 16px; overflow-wrap: anywhere; }
.item-text b { font-weight: 600; }
.item:hover .item-text { color: var(--accent-ink); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; letter-spacing: 0; background: var(--indigo-soft); color: var(--indigo-ink); white-space: nowrap; }
.chip.ok { background: var(--green-soft); color: var(--green); }
.chip.warn { background: var(--accent-soft); color: var(--accent-ink); }
.chip.quiet { background: transparent; color: var(--ink-3); padding-left: 0; font-weight: 500; }
.note { display: block; color: var(--ink-2); font-size: 14px; margin-top: 4px; overflow-wrap: anywhere; }

/* ---------- кнопки и поля ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border-radius: 999px; border: 0; background: var(--fill); font-size: 15px; font-weight: 600; min-height: 40px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--fill-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.small { min-height: 34px; padding: 6px 14px; font-size: 14px; }
.btn.ghost { background: none; color: var(--ink-2); }
.btn.danger { color: var(--red); }
.btn[disabled] { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
label.field, div.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
input[type=text], input[type=password], input[type=date], input[type=datetime-local], input[type=time], select, textarea {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid transparent; background: var(--fill); color: var(--ink);
  font-size: 17px; font-weight: 400; min-height: 46px; appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent); }
::placeholder { color: var(--ink-3); }
.form { display: grid; gap: 14px; }
.hint { font-size: 13px; line-height: 1.4; color: var(--ink-3); font-weight: 400; }
.lead { margin: 0 4px 16px; font-size: 15px; }
.error { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); padding: 10px 14px; border-radius: 12px; font-size: 15px; }
.seg, .kids { display: inline-flex; padding: 2px; border-radius: 10px; background: var(--fill); gap: 2px; flex-wrap: wrap; }
.seg button, .kids button { border: 0; background: none; padding: 7px 14px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--ink); }
.seg button[aria-pressed="true"], .kids button[aria-pressed="true"] { background: var(--card); font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0 / .14); }
:root[data-theme="dark"] .seg button[aria-pressed="true"], :root[data-theme="dark"] .kids button[aria-pressed="true"] { background: #636366; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button[aria-pressed="true"], :root:not([data-theme="light"]) .kids button[aria-pressed="true"] { background: #636366; } }
/* переключатель в стиле iOS */
.check { display: flex; gap: 12px; align-items: center; font-size: 16px; color: var(--ink); font-weight: 400; }
.check input { appearance: none; -webkit-appearance: none; flex: none; width: 51px; height: 31px; margin: 0; border-radius: 999px; background: var(--fill-2); position: relative; transition: background .2s; cursor: pointer; }
.check input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgb(0 0 0 / .25); transition: transform .2s; }
.check input:checked { background: var(--green-fill); }
.check input:checked::after { transform: translateX(20px); }
.linklike { border: 0; background: none; padding: 0; color: var(--accent-ink); font-weight: 600; }
.icon-btn { border: 0; background: none; color: var(--ink-3); min-width: 36px; height: 36px; padding: 8px; border-radius: 50%; flex: none; font-size: 20px; line-height: 1; }
.icon-btn svg { width: 20px; height: 20px; display: block; }
.icon-btn:hover { color: var(--accent-ink); background: var(--fill); }
.icon-btn.sure { color: var(--red); font-size: 14px; font-weight: 600; padding: 8px 12px; border-radius: 999px; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { position: relative; }
.days input { position: absolute; opacity: 0; inset: 0; }
.days span { display: grid; place-items: center; min-width: 44px; height: 40px; border-radius: 999px; background: var(--fill); color: var(--ink); font-weight: 500; font-size: 15px; }
.days input:checked + span { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.days input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* ---------- окно: лист снизу на телефоне, карточка по центру на компьютере ---------- */
dialog { border: 0; padding: 0; border-radius: 24px; background: var(--card); color: var(--ink); width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(0 0 0 / .36); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.dlg { position: relative; padding: 24px; display: grid; gap: 16px; }
.dlg h2 { font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -0.022em; padding-right: 40px; }
.dlg .x { position: absolute; top: 18px; right: 18px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--fill); font-size: 19px; line-height: 1; color: var(--ink-2); display: grid; place-items: center; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.more[hidden] { display: none; }
.more { display: grid; gap: 10px; padding: 14px; border-radius: 16px; background: var(--bg); }
@media (max-width: 859px) {
  dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 26px 26px 0 0; max-height: 92dvh; }
  .dlg { padding: 28px 20px calc(22px + env(safe-area-inset-bottom)); }
  .dlg::before { content: ""; position: absolute; top: 8px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: var(--fill-2); }
}

/* ---------- расписание ---------- */
.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.week .sheet { margin: 0; --time: 62px; }
.day-title { position: relative; display: flex; justify-content: space-between; align-items: center; padding: 10px 8px 8px 16px; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.day-title.today { color: var(--accent-ink); }
.day-title button { border: 0; background: none; color: var(--ink-3); width: 36px; height: 36px; padding: 8px; border-radius: 50%; flex: none; }
.day-title button:hover { color: var(--accent-ink); background: var(--fill); }
.day-title button svg { width: 20px; height: 20px; display: block; }
.week .row { min-height: 42px; }
.week .row > .body, .week .row > .in-margin { padding-top: 11px; padding-bottom: 9px; }
.routine-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.routine-title { font-weight: 600; margin-right: 8px; }

/* ---------- проекты: цветные плитки ---------- */
.covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.cover { display: flex; flex-direction: column; gap: 4px; min-height: 176px; padding: 18px; border-radius: var(--r-widget); text-decoration: none; color: #fff; background: var(--cover); }
.cover:hover { filter: brightness(1.06); }
.cover.c0 { --cover: var(--accent); color: var(--on-accent); } .cover.c1 { --cover: var(--indigo); color: var(--on-second); } .cover.c2 { --cover: var(--deep); }
.cover.c3 { --cover: var(--cover-3); } .cover.c4 { --cover: var(--cover-4); color: var(--on-cover-4); }
:root[data-theme="dark"] .cover.c2 { --cover: #2C2C2E; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cover.c2 { --cover: #2C2C2E; } }
.cover-n { order: -1; margin-bottom: auto; font-size: 13px; font-weight: 600; opacity: .8; }
.cover-label { font-weight: 700; font-size: 22px; line-height: 1.12; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.cover-desc { font-size: 13.5px; line-height: 1.35; opacity: .82; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.about { white-space: pre-line; color: var(--ink); }
.chat-row { position: relative; display: flex; align-items: center; padding-right: 8px; }
.chat-main { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 13px 8px 13px 16px; text-decoration: none; color: var(--ink); }
.chat-row:hover { background: color-mix(in srgb, var(--fill) 50%, transparent); }
.chat-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-when { font-size: 13px; color: var(--ink-3); white-space: nowrap; padding-top: 2px; }
.chat-preview { grid-column: 1 / -1; font-size: 14.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 859px) { .covers { grid-template-columns: 1fr 1fr; gap: 12px; } .cover { min-height: 150px; } .cover-label { font-size: 19px; } }

/* ---------- учебники ---------- */
.source { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 8px 12px 16px; }
.source-name { font-weight: 600; text-decoration: none; color: var(--ink); overflow-wrap: anywhere; }
.source-name:hover { color: var(--accent-ink); }
.source-state { display: block; font-size: 14px; color: var(--ink-3); }
.source.ready .source-state { color: var(--green); }
.source.no_text .source-state, .source.error .source-state { color: var(--accent-ink); }

/* ---------- чат ---------- */
.chat { display: grid; gap: 8px; padding: 16px; min-height: 240px; align-content: start; }
.msg { max-width: 82%; padding: 9px 14px; border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.38; }
.msg.me { justify-self: end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; }
.msg.bot { justify-self: start; background: var(--fill); border-bottom-left-radius: 6px; }
.msg.fresh { animation: msg-in .38s cubic-bezier(.2, .7, .3, 1); }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } }
/* помощник думает: гайка поворачивается шаг за шагом и переливается цветами темы */
.thinking { justify-self: start; display: flex; align-items: center; gap: 10px; padding: 4px 4px 6px; }
.nut { width: 32px; height: 32px; flex: none; animation: nut-turn 4.2s cubic-bezier(.65, 0, .35, 1) infinite, nut-glow 1.4s ease-in-out infinite alternate; }
.nut .g1 { stop-color: var(--accent); animation: nut-flow-a 2.4s ease-in-out infinite alternate; }
.nut .g2 { stop-color: var(--accent-ink); }
.nut .g3 { stop-color: var(--indigo); animation: nut-flow-b 2.4s ease-in-out infinite alternate; }
@keyframes nut-turn { 0% { transform: rotate(0); } 16.667% { transform: rotate(60deg); } 33.333% { transform: rotate(120deg); } 50% { transform: rotate(180deg); } 66.667% { transform: rotate(240deg); } 83.333% { transform: rotate(300deg); } 100% { transform: rotate(360deg); } }
@keyframes nut-glow { from { filter: drop-shadow(0 0 2px color-mix(in srgb, var(--accent) 35%, transparent)); } to { filter: drop-shadow(0 0 9px color-mix(in srgb, var(--accent) 85%, transparent)); } }
@keyframes nut-flow-a { to { stop-color: var(--indigo); } }
@keyframes nut-flow-b { to { stop-color: var(--accent); } }
.think-text { font-size: 15px; font-weight: 500; color: transparent; background: linear-gradient(90deg, var(--ink-3) 0%, var(--ink-3) 38%, var(--accent-ink) 50%, var(--ink-3) 62%, var(--ink-3) 100%) 110% 0 / 240% 100%; -webkit-background-clip: text; background-clip: text; animation: think-shine 1.9s linear infinite; }
@keyframes think-shine { to { background-position: -130% 0; } }
@media (prefers-reduced-motion: reduce) {
  .nut, .nut stop, .msg.fresh, .composer .mic[aria-pressed="true"] { animation: none; }
  .think-text { animation: none; background: none; color: var(--ink-3); }
}
.msg a { color: inherit; text-decoration: underline; overflow-wrap: anywhere; }
.msg.bot a { color: var(--accent-ink); }
.msg a.filechip, .msg .files a { text-decoration: none; }
.msg .files { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 4px 0 8px; white-space: normal; }
.msg .files:last-child { margin-bottom: 4px; }
.shot { display: block; height: 170px; width: auto; max-width: 100%; object-fit: cover; border-radius: 12px; background: #fff; }
.used { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--sep); font-size: 13px; color: var(--ink-2); white-space: normal; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; justify-self: start; margin-top: 2px; }
.quick .btn { background: none; box-shadow: inset 0 0 0 1px var(--fill-2); color: var(--accent-ink); }
.quick .btn:hover { background: var(--accent-soft); }
.composer { display: grid; gap: 4px; margin: 4px 12px 12px; padding: 10px 10px 10px 12px; border-radius: 24px; background: var(--fill); }
.composer:focus-within { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }
.composer textarea { min-height: 30px; max-height: 160px; padding: 4px 6px; border: 0; border-radius: 8px; background: none; resize: none; }
.composer textarea:focus { outline: none; }
.composer-row { display: flex; align-items: center; gap: 8px; }
.composer-row .grow { flex: 1; }
.composer .btn.clip { background: var(--card); }
.composer .btn.clip, .composer .btn.send { width: 40px; min-height: 40px; }
.composer .mic[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 22%, transparent); } }
.btn.clip { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
.btn.clip svg { width: 22px; height: 22px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn > span { overflow: hidden; text-overflow: ellipsis; max-width: 20ch; }
/* отправка — круглая плоская кнопка со стрелкой */
.btn.send { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
.btn.send svg { width: 22px; height: 22px; stroke-width: 2.4; }
/* поле на странице «Чаты», с которого разговор начинается сразу */
.composer.ask { margin: 0 0 16px; background: var(--card); padding: 12px 12px 12px 14px; }
.composer.ask textarea { min-height: 34px; }
.composer.ask .btn.clip { background: var(--fill); }
/* выбор проекта для чата */
.picks { display: grid; gap: 2px; max-height: 40dvh; overflow: auto; margin: 0 -8px; }
.pick { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 0; border-radius: 12px; background: none; text-align: left; font-size: 16px; }
.pick svg { width: 20px; height: 20px; flex: none; color: var(--accent-ink); }
.pick span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick:hover { background: var(--fill); }
.pick[aria-pressed="true"] { background: var(--accent-soft); font-weight: 600; }
.pick[aria-pressed="true"]::after { content: "✓"; color: var(--accent-ink); font-weight: 700; }
.pick em { font-style: normal; color: var(--ink-3); font-size: 20px; line-height: 1; }
.pending { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 12px; }
.pending:not(:empty) { padding: 4px 16px 6px; }
.filechip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 11px; border-radius: 999px; background: var(--fill); color: var(--ink); font-size: 14px; font-weight: 500; text-decoration: none; overflow-wrap: anywhere; }
.filechip svg { width: 16px; height: 16px; flex: none; }
.filechip.wait { opacity: .6; }
.filechip button { border: 0; background: none; color: inherit; font-size: 18px; line-height: 1; padding: 0 2px; }
.msg.me .filechip { background: rgb(255 255 255 / .22); color: inherit; }

/* ---------- сообщения помощника, история ---------- */
.feed-item { position: relative; padding: 14px 16px; overflow-wrap: anywhere; }
.feed-item.unread::before { content: ""; position: absolute; left: 5px; top: 20px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-ink); }
.feed-text { white-space: pre-line; font-size: 15.5px; }
.feed-when { display: block; font-size: 13px; color: var(--ink-3); margin-bottom: 4px; }
.feed-item .btn { margin-top: 10px; }
.log-day { padding: 16px 16px 6px; font-size: 13px; font-weight: 600; color: var(--ink-3); }

/* ---------- карточки профиля ---------- */
.card { background: var(--card); border-radius: var(--r-card); padding: 20px; margin-bottom: 16px; display: grid; gap: 12px; }
.card h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.card p { color: var(--ink-2); font-size: 15px; max-width: 62ch; }
.card p b { color: var(--ink); font-weight: 600; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.code { font-size: 22px; font-weight: 700; letter-spacing: .06em; font-variant-numeric: tabular-nums; user-select: all; color: var(--ink) !important; }
.linkbox { font-size: 13.5px !important; overflow-wrap: anywhere; user-select: all; }
.privacy { white-space: pre-line; color: var(--ink); font-size: 15px; }
/* выбор цветовой темы: плитка = три основных цвета темы на её фоне */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.theme-tile { display: grid; gap: 8px; justify-items: center; padding: 14px 6px 10px; border: 0; border-radius: 18px; background: var(--tile); color: var(--tile-ink); font-size: 13.5px; font-weight: 600; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .07); }
.theme-tile .dots { display: flex; }
.theme-tile .dots i { width: 26px; height: 26px; border-radius: 50%; box-shadow: 0 0 0 2px var(--tile); }
.theme-tile .dots i + i { margin-left: -7px; }
.theme-tile[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--tile-ink); }
.theme-tile:active { transform: scale(.97); }
.members { display: grid; }
.member { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--sep); }
.member:first-child { border-top: 0; }

/* ---------- вход ---------- */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth-side { padding: clamp(28px, 6vw, 80px); display: flex; flex-direction: column; justify-content: center; gap: 20px; }
.auth-side h1 { font-size: clamp(38px, 5.2vw, 64px); line-height: 1.02; font-weight: 700; letter-spacing: -0.04em; max-width: 11ch; }
.auth-side > p { font-size: 19px; line-height: 1.4; color: var(--ink-2); max-width: 40ch; }
.auth-form { padding: clamp(20px, 4vw, 48px); display: flex; background: var(--side); }
.auth-page { align-self: center; width: min(420px, 100%); margin: 0 auto; display: grid; gap: 14px; }
.auth-page .card { margin: 0; padding: 22px; }
.auth-page .seg { justify-self: start; }
.phone-row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 10px; max-width: 420px; margin-top: 6px; }
.phone-row .widget { min-height: 124px; padding: 16px; border-radius: 22px; }
.phone-row .widget.hero .w-big { font-size: 28px; }
.phone-row .w-big { font-size: 24px; }
@media (max-width: 859px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: calc(28px + env(safe-area-inset-top)) 20px 8px; gap: 12px; }
  .auth-side > p { font-size: 17px; }
  .phone-row { display: none; }
  .auth-form { padding: 20px 16px 40px; background: none; }
}

#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(8px); background: rgb(40 40 42 / .92); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 15px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100vw - 32px); text-align: center; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
#toast.on { opacity: 1; transform: translateX(-50%); }
@media (min-width: 860px) { #toast { bottom: 28px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- обновление помощника ---------- */
.filepick { display: flex; align-items: center; gap: 12px; min-height: 46px; }
.filepick .hint { overflow-wrap: anywhere; }
.update-last.bad, .update-note.bad { color: var(--red); }
.update-note { font-size: 15px; line-height: 1.4; color: var(--ink-2); }
