@font-face { font-family: "Sofia Sans"; src: url("/fonts/sofia-sans-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: "Sofia Sans"; src: url("/fonts/sofia-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Literata"; src: url("/fonts/literata-cyrillic-opsz-normal.woff2") format("woff2");
  font-weight: 200 900; font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Literata"; src: url("/fonts/literata-latin-opsz-normal.woff2") format("woff2");
  font-weight: 200 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #F3F4F1;          /* варовик — фонът на страницата */
  --surface: #FFFFFF;     /* панели, карти, полета */
  --surface-2: #ECEEEA;   /* страничното меню, сегментирани превключватели */
  --surface-3: #E2E6E0;
  --ink: #14201B;  --ink-2: #3B4842;  --muted: #59665F;      /* muted върху --bg = 5,3:1 */
  --line: #DCE0DA; --line-2: #CBD1CB;
  --acc: #1F4A3E; --acc-ink: #FFFFFF; --acc-soft: #E3ECE7; --acc-line: #B9CCC3;
  --ok: #1F6B45;     --ok-soft: #E4F1E8;
  --warn: #7A5512;   --warn-soft: #F6EEDC;                   /* = охра, тъмна за текст */
  --danger: #A3352B; --danger-soft: #F7E7E4;
  --shadow-sm: 0 1px 2px rgba(20, 32, 27, .06);
  --shadow: 0 1px 3px rgba(20, 32, 27, .06), 0 8px 24px rgba(20, 32, 27, .06);
  --shadow-lg: 0 2px 4px rgba(20, 32, 27, .08), 0 24px 56px rgba(20, 32, 27, .22);
  --radius: 12px; --radius-sm: 8px;
  --font: "Sofia Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-letter: "Literata", Georgia, "Times New Roman", serif;   /* САМО текстовете към клиенти */
  --gold: #B8862B; --gold-ink: #7A5512; --gold-soft: #F6EEDC; --gold-line: #E6D3A6;   /* охрата: „Защо днес“, броячи, „Приключи“ */
  --paper: #FBFBF9;        /* фонът на писмото */
  --side: #ECEEEA;         /* страничното меню */
  --side-w: 280px;
  --night: #14201B;        /* тъмната половина на входа (логото на тъмно) */
  --acc-hover: #173A31;
  --head-bg: #F8F9F6;      /* заглавният ред на таблиците */
  --ctl-h: 40px; --ctl-h-sm: 34px; --ctl-h-lg: 48px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1714; --surface: #16201C; --surface-2: #1C2723; --surface-3: #24302B;
    --ink: #E9EDE8; --ink-2: #C4CCC6; --muted: #93A099; --line: #26322D; --line-2: #33413A;
    --acc: #7FB8A4; --acc-ink: #0F1714; --acc-soft: #1A2E27; --acc-line: #2F5246;
    --ok: #5CC08A; --ok-soft: #12291D; --warn: #E2B85A; --warn-soft: #2A2110; --danger: #F08A7E; --danger-soft: #2E1613;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
    --gold: #D9A441; --gold-ink: #E2B85A; --gold-soft: #2A2110; --gold-line: #4A3A17;
    --paper: #1A2420; --side: #121B18;
    --night: #0B110E; --acc-hover: #95C7B5; --head-bg: #1A2420;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1714; --surface: #16201C; --surface-2: #1C2723; --surface-3: #24302B;
  --ink: #E9EDE8; --ink-2: #C4CCC6; --muted: #93A099; --line: #26322D; --line-2: #33413A;
  --acc: #7FB8A4; --acc-ink: #0F1714; --acc-soft: #1A2E27; --acc-line: #2F5246;
  --ok: #5CC08A; --ok-soft: #12291D; --warn: #E2B85A; --warn-soft: #2A2110; --danger: #F08A7E; --danger-soft: #2E1613;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
  --gold: #D9A441; --gold-ink: #E2B85A; --gold-soft: #2A2110; --gold-line: #4A3A17;
  --paper: #1A2420; --side: #121B18;
  --night: #0B110E; --acc-hover: #95C7B5; --head-bg: #1A2420;
  color-scheme: dark;
}

::selection { background: var(--acc-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
input, textarea { caret-color: var(--acc); }
body { font-variant-numeric: tabular-nums; }   /* телефони, часове, броячи — подравнени */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
       overflow-x: hidden; }
a { color: var(--acc); text-underline-offset: 2px; }
input, select, textarea, button { font: inherit; color: inherit; }
h1, h2, h3 { text-wrap: balance; }
.ico { width: 18px; height: 18px; flex: none; vertical-align: -3px; }   /* <svg class="ico"><use href="/ui-icons.svg#i-copy"/></svg> */
* { scrollbar-color: var(--line-2) transparent; }

.shell { display: flex; min-height: 100vh; }
.shell > .side { position: sticky; top: 0; height: 100vh; overflow-y: auto; width: var(--side-w); flex: none;
        display: flex; flex-direction: column; gap: 3px; padding: 22px 16px 20px;
        background: var(--side); border-right: 1px solid var(--line); }
.shell > .side .brand { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 0 6px 4px; text-decoration: none; }
.shell > .side .brand img { height: 48px; width: auto; display: block; }
.brand img.on-dark, .shell > .side .brand img.on-dark { display: none; }
.shell > .side .brand img.tagline { height: 22px; width: auto; margin-left: 52px; }
.shell > .side .ident { display: grid; gap: 2px; padding: 8px 8px 18px; font-size: 13px; color: var(--muted); }
.shell > .side .ident b { color: var(--ink-2); font-weight: 600; }
.shell > .main { flex: 1; min-width: 0; max-width: none; margin: 0; padding: 40px 56px 64px; align-content: start; }
.shell > .main > :where(:not(dialog, .modal, .toast, .scrim, .drawer)) { max-width: var(--content-w, 1040px); }
.shell > .main > .wrap { max-width: 1040px; display: flex; flex-direction: column; gap: 20px; }
.btn.menu-btn { display: none; }
.side-scrim { display: none; }

.shell > .side .nav { display: flex; flex-direction: column; gap: 3px; padding: 0; background: none; border: 0; }
.shell > .side .nav a { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: var(--radius-sm);
               color: var(--ink-2); font-size: 15px; font-weight: 500; text-decoration: none; }
.shell > .side .nav a:hover { background: var(--surface-3); color: var(--ink); }
.shell > .side .nav a[aria-current="page"] { background: var(--acc); color: var(--acc-ink); font-weight: 600; }
.shell > .side .nav a .soon { margin-left: auto; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-ink); }

.shell > .side .rail { display: flex; flex-direction: column; gap: 1px; margin: 4px 0 8px 20px; padding-left: 8px; border-left: 1px solid var(--line-2); }
.shell > .side .rail a, .shell > .side .rail button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 0 12px 0 14px;
              border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); font-size: 14px; text-align: left;
              text-decoration: none; cursor: pointer; box-shadow: none; }
.shell > .side .rail a:hover, .shell > .side .rail button:hover { background: var(--surface-3); color: var(--ink); }
.shell > .side .rail .ico { width: 16px; height: 16px; color: var(--muted); }
.shell > .side .rail .n { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--gold-ink); }

.shell > .side .foot { margin-top: auto; display: flex; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 6px;
                      padding-top: 18px; border-top: 0; justify-content: flex-start; }
.shell > .side .foot > .btn { justify-content: flex-start; width: 100%; }
.shell > .side .foot > .btn.ghost { color: var(--ink-2); }
.shell > .side .me { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 8px 0; margin-top: 8px;
                     border-top: 1px solid var(--line-2); min-height: 48px; }
.shell > .side .me .who { display: block; min-width: 0; flex: 1 1 0; }   /* името на профила до „Изход“ (Николай, 29.10) */
.shell > .side .me .who b { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell > .side .me .who span { font-size: 13px; color: var(--muted); }
.shell > .side .me .avatar { display: none; }
.shell > .side .me .btn { margin-left: auto; border-color: var(--line-2); background: var(--surface); }
.shell > .side .me select { order: 3; width: 100%; height: var(--ctl-h-sm); padding: 0 8px; border: 1px solid var(--line-2);
                            border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; }

@media (max-width: 900px) {
  .shell > .side { position: fixed; z-index: 40; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease-out;
                   box-shadow: var(--shadow-lg); visibility: hidden; }
  .shell > .side.open { transform: none; visibility: visible; }
  .shell > .main { padding: 16px 16px 96px; }
  .btn.menu-btn { display: inline-flex; margin: 0 0 12px -4px; }
  .side-scrim.on { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(20, 32, 27, .45); }
  .shell > .side .nav a, .shell > .side .rail button { min-height: 44px; }
}

.page-head { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px 24px; }
.page-head .date { font-size: 14px; color: var(--muted); }
.page-head h1 { margin: 4px 0 0; font-size: 36px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.page-head .sub { font-size: 15px; color: var(--muted); margin-top: 4px; }
.page-head > .btn, .page-head > .actions { margin-left: auto; }
.kpis { margin-left: auto; display: flex; gap: 28px; }
.kpi { display: flex; flex-direction: column; align-items: flex-end; }
.kpi b { font-size: 26px; font-weight: 700; line-height: 1.15; } .kpi span { font-size: 13px; color: var(--muted); }
.kpi.gold b { color: var(--gold-ink); }
@media (max-width: 640px) { .page-head h1 { font-size: 28px; } .kpis { gap: 18px; } .kpi b { font-size: 22px; } }

.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: var(--ctl-h);
       padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
       font-size: 14px; font-weight: 500; line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
       transition: background-color .15s ease-out, border-color .15s ease-out, color .15s ease-out; }
.btn:hover { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible, .field:focus-visible, .chip:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }
.btn.primary:hover { background: var(--acc-hover); border-color: var(--acc-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover, .btn.quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.gold { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold-ink); font-weight: 600; }   /* „Приключи“, „Добави телефон“ */
.btn.sm { min-height: var(--ctl-h-sm); padding: 0 10px; font-size: 13px; }
.btn.lg { min-height: var(--ctl-h-lg); padding: 0 18px; font-size: 15px; }
.btn .ico { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions.tools { gap: 6px; padding-top: 12px; border-top: 1px dashed var(--line-2); }      /* лентата в разговора */
@media (max-width: 900px) { .btn { min-height: 44px; } .btn.sm { min-height: 40px; } }

.field { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
         background: var(--surface); color: var(--ink); font-size: 15px; }
.field::placeholder { color: var(--muted); }
textarea.field { min-height: 90px; padding: 11px 12px; resize: vertical; line-height: 1.5; }
label.label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
label.label .opt { font-weight: 400; color: var(--muted); }
label.lbl { display: block; font-size: 14px; font-weight: 600; color: var(--ink); margin: 16px 0 6px; }
label.lbl .opt { color: var(--muted); font-weight: 400; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
div.search { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 0 16px; background: var(--surface);
          border: 1px solid var(--line-2); border-radius: 10px; color: var(--muted); }
div.search:focus-within { border-color: var(--acc); outline: 2px solid var(--acc); outline-offset: 1px; }
div.search input { flex: 1; min-width: 0; height: 48px; border: 0; outline: 0; padding: 0; background: transparent; color: var(--ink); font-size: 16px; }
div.search input::placeholder { color: var(--muted); }

.logo-box { margin-top: 8px; min-height: 40px; display: flex; align-items: center; }
.logo-box img { max-height: 90px; max-width: 260px; object-fit: contain; background: #fff; border: 1px solid var(--line);
                border-radius: 8px; padding: 6px; }
.pw-wrap { position: relative; display: block; }
.pw-wrap > input { width: 100%; padding-right: 44px; }
.pw-wrap > input::-ms-reveal { display: none; }   /* Edge слага и свое оченце до нашето */
.pw-wrap .pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px;
                   margin: 0; padding: 0; display: grid; place-items: center; border: 0; border-radius: 8px;
                   background: transparent; color: var(--muted); cursor: pointer; }
.pw-wrap .pw-eye:hover { color: var(--ink); background: var(--surface-2); }
.pw-wrap .pw-eye:focus-visible { outline: 2px solid var(--acc); outline-offset: 0; }

details.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
details.panel > summary { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 0 20px; cursor: pointer; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary > .ico { color: var(--acc); }
details.panel > summary .t { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
details.panel > summary .c { font-size: 14px; color: var(--muted); }
details.panel > summary .chev { margin-left: auto; color: var(--muted); transition: transform .15s ease-out; }
details.panel[open] > summary .chev { transform: rotate(180deg); }
details.panel > .body { padding: 0 20px 20px; border-top: 1px solid var(--line); }
details.panel .item { display: flex; flex-direction: column; gap: 14px; padding: 22px 0; border-bottom: 1px solid var(--line); }
details.panel .item:last-child { border-bottom: 0; }
details.panel .who { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
details.panel .who b { font-size: 17px; font-weight: 700; } details.panel .who span { font-size: 14px; color: var(--muted); }
.why-today { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.45; color: var(--gold-ink); }
.why-today .ico { width: 16px; height: 16px; margin-top: 2px; }

.letter { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 18px 22px; max-width: 66ch;
          font: 17px/1.62 var(--font-letter); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
textarea.letter { display: block; width: 100%; min-height: 150px; resize: vertical; }
.hold { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm);
        background: var(--danger-soft); color: var(--danger); font-size: 14px; line-height: 1.45; }
.nudge { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 10px; background: var(--acc-soft); font-size: 14px; }
.nudge .actions { margin-left: auto; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
         background: var(--surface-2); color: var(--ink-2); border: 0; white-space: nowrap; line-height: 1.4; }
.badge.acc { background: var(--acc-soft); color: var(--acc); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.gold, .badge.warn { background: var(--gold-soft); color: var(--gold-ink); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.callout { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; line-height: 1.45; border: 1px solid var(--line); background: var(--surface-2); }
.callout.warn { background: var(--gold-soft); border-color: transparent; color: var(--ink); }
.callout.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); font-weight: 500; }
.callout.ok { background: var(--ok-soft); border-color: transparent; }
.callout.acc { background: var(--acc-soft); border-color: var(--acc-line); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 8px); background: var(--ink); color: var(--bg);
         padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity .2s ease-out, transform .2s ease-out;
         pointer-events: none; z-index: 60; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.seg { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: var(--surface-2); }
.seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2);
              font-size: 14px; font-weight: 500; cursor: pointer; box-shadow: none; }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600;
              box-shadow: 0 1px 2px rgba(20, 32, 27, .12); }
.ag-theme-quartz { --ag-font-family: var(--font); --ag-font-size: 14px; --ag-foreground-color: var(--ink-2); --ag-text-color: var(--ink-2);
  --ag-header-foreground-color: var(--muted); --ag-header-background-color: var(--head-bg); --ag-background-color: var(--surface);
  --ag-odd-row-background-color: var(--surface); --ag-row-hover-color: var(--surface-2); --ag-selected-row-background-color: var(--acc-soft);
  --ag-border-color: var(--line); --ag-row-border-color: var(--line); --ag-wrapper-border-radius: var(--radius);
  --ag-row-height: 58px; --ag-header-height: 44px; --ag-active-color: var(--acc); --ag-input-focus-border-color: var(--acc);
  --ag-checkbox-checked-color: var(--acc); --ag-range-selection-border-color: var(--acc); }

.login { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.login .brandside { background: var(--night); display: grid; place-items: center; padding: 48px; }
.login .brandside img { width: min(460px, 80%); height: auto; }
.login .formside { display: grid; place-items: center; padding: 48px; }
.login .formside > * { width: min(400px, 100%); }
.login form { display: flex; flex-direction: column; gap: 18px; }
.login h1 { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -.02em; }
.login .sub { color: var(--muted); font-size: 15px; margin-top: -10px; }
@media (max-width: 900px) { .login { grid-template-columns: 1fr; min-height: 0; } .login .brandside { padding: 32px 24px; }
  .login .brandside img { width: 220px; } .login .formside { padding: 32px 20px 48px; } }

.app-ver { margin: 24px auto 12px; text-align: center; color: var(--muted); font-size: 12px; }
.shell ~ .app-ver { margin-left: calc(var(--side-w) + 56px); text-align: left; }
@media (max-width: 900px) { .shell ~ .app-ver { margin-left: 16px; } }

.sheet { border: 0; border-radius: 14px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg); padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.sheet::backdrop { background: rgba(20, 32, 27, .55); }
.sheet .in { padding: 28px; display: grid; gap: 18px; overflow: auto; max-height: calc(100vh - 48px); }
.sheet h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.sheet .ver { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 4px; }
.sheet ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 8px; line-height: 1.5; font-size: 15px; }
.sheet .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.sheet .kinds { display: flex; gap: 8px; }
.sheet .item { border-top: 1px solid var(--line); padding-top: 10px; font-size: 14px; display: grid; gap: 4px; }
.sheet .item .t { white-space: pre-wrap; }
.sheet .item .a { color: var(--muted); }
@media (max-width: 640px) { .sheet .in { padding: 22px 18px; } }
.fab-row { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; gap: 8px; }
.fab-row .btn { box-shadow: var(--shadow); }
@media print { .fab-row, .shell > .side, .menu-btn { display: none; } }
.sheet.chat { width: min(680px, calc(100vw - 24px)); }
.chat .log { display: grid; gap: 10px; max-height: 55vh; min-height: 2.2em; overflow: auto; padding-right: 4px; }
.chat .log > .hint { margin: 0; }   /* празният: без min-height и с отстъпа на .hint се свиваше и превърташе надолу — режеше надписа (20.10) */
.chat .m { padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; line-height: 1.5; font-size: 15px; }
.chat .m.user { background: var(--acc-soft); justify-self: end; max-width: 85%; }
.chat .m.ai { background: var(--surface-2); max-width: 92%; }
.chat .act { border: 1px dashed var(--line-2); border-radius: 10px; padding: 8px 10px; margin-top: 8px; font-size: 14px; display: grid; gap: 6px; }
.chat .act .row { justify-content: flex-start; }
.chat textarea { min-height: 70px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 600;
          font-size: 13px; background: var(--acc-soft); color: var(--acc); border: 1px solid var(--acc-line); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
.shell > .side .nav .grp { display: flex; align-items: center; gap: 2px; }
.shell > .side .nav .grp > a { flex: 1; min-width: 0; }
.shell > .side .nav .fold { appearance: none; flex: none; display: grid; place-items: center; width: 32px; height: 32px; border: 0;
  border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.shell > .side .nav .fold:hover { background: var(--surface-3); color: var(--ink); }
.shell > .side .nav .fold .ico { width: 16px; height: 16px; transition: transform .15s ease-out; }
.shell > .side .nav .fold[aria-expanded="false"] .ico { transform: rotate(-90deg); }
.shell > .side .rail a[aria-current="page"] { background: var(--surface-3); color: var(--ink); font-weight: 600; }
.shell > .side .rail a .ico { width: 16px; height: 16px; color: var(--muted); }

@view-transition { navigation: auto; }
.shell > .side { view-transition-name: appside; }
.theme-switch { view-transition-name: themeswitch; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .14s; }
::view-transition-old(appside), ::view-transition-old(themeswitch) { display: none; }
::view-transition-new(appside), ::view-transition-new(themeswitch) { animation: none; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }

.theme-switch { position: absolute; top: 10px; right: 16px; z-index: 30; display: flex; gap: 2px; padding: 3px; border-radius: 9px;
                background: var(--surface-2); border: 1px solid var(--line); }
.theme-switch button { appearance: none; display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 0 9px; border: 0;
                       border-radius: 6px; background: transparent; color: var(--muted); font: 500 12px/1 var(--font); cursor: pointer; }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(20, 32, 27, .12); }
.theme-switch .ico { width: 14px; height: 14px; }
@media (max-width: 900px) { .theme-switch { top: 18px; right: 12px; } .theme-switch button { min-height: 32px; padding: 0 8px; } }
@media print { .theme-switch { display: none; } }

@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .shell > .side .brand img.on-light { display: none; }
  :root:not([data-theme="light"]) .shell > .side .brand img.on-dark { display: block; } }
:root[data-theme="dark"] .shell > .side .brand img.on-light { display: none; }
:root[data-theme="dark"] .shell > .side .brand img.on-dark { display: block; }
