:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --line: #e2dfd8;
  --text: #1d1c1a;
  --muted: #6f6b63;
  --accent: #2f5bd3;
  --accent-ink: #ffffff;
  --accent-soft: #e6ecfb;
  --danger: #b3261e;
  --danger-soft: #fbeaea;
  --ok: #1f7a4d;
  --mark: #ffe58f;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.04);
  --spk-0: #2f5bd3; --spk-1: #c2410c; --spk-2: #15803d; --spk-3: #9333ea;
  --spk-4: #0e7490; --spk-5: #be185d; --spk-6: #a16207; --spk-7: #4b5563;
  color-scheme: light;
}

/* Тема: по умолчанию как в системе; выбор «светлая» или «тёмная» ставит data-theme на <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151514;
    --surface: #1e1e1c;
    --surface-2: #272725;
    --line: #34332f;
    --text: #ecebe7;
    --muted: #a19d94;
    --accent: #7f9ef5;
    --accent-ink: #10131c;
    --accent-soft: #232b40;
    --danger: #f2877f;
    --danger-soft: #3a2220;
    --ok: #6fcf97;
    --mark: #6b5a12;
    --shadow: none;
    --spk-0: #7f9ef5; --spk-1: #fb923c; --spk-2: #4ade80; --spk-3: #c084fc;
    --spk-4: #22d3ee; --spk-5: #f472b6; --spk-6: #facc15; --spk-7: #a3a3a3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151514;
  --surface: #1e1e1c;
  --surface-2: #272725;
  --line: #34332f;
  --text: #ecebe7;
  --muted: #a19d94;
  --accent: #7f9ef5;
  --accent-ink: #10131c;
  --accent-soft: #232b40;
  --danger: #f2877f;
  --danger-soft: #3a2220;
  --ok: #6fcf97;
  --mark: #6b5a12;
  --shadow: none;
  --spk-0: #7f9ef5; --spk-1: #fb923c; --spk-2: #4ade80; --spk-3: #c084fc;
  --spk-4: #22d3ee; --spk-5: #f472b6; --spk-6: #facc15; --spk-7: #a3a3a3;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1rem; font-weight: 650; margin-bottom: 0.6rem; }
p { margin: 0.3rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
em.muted { font-style: normal; font-weight: 400; }
[hidden] { display: none !important; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1.1rem;
  padding: 1.1rem 0.9rem; border-right: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 700; font-size: 1.1rem; color: var(--text); padding: 0 0.35rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.38rem 0.55rem; border-radius: 7px; color: var(--text);
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav .count { color: var(--muted); font-size: 0.8rem; }
.nav .muted { padding: 0 0.55rem; }
.nav-head { display: flex; justify-content: space-between; align-items: center; padding: 0 0.55rem 0.3rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.3rem; padding: 0 0.4rem; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.6rem; padding-top: 0.7rem; border-top: 1px solid var(--line); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 0.6rem; align-items: center; padding: 0.7rem 1.75rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topsearch { flex: 1; max-width: 560px; }
.topsearch input { width: 100%; }
.menu-btn { display: none; }
.content { padding: 1.75rem; max-width: 1180px; width: 100%; }

/* ---------- элементы ---------- */
input, select, textarea {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.65rem; min-width: 0;
}
/* Свои выпадающие списки: Safari иначе рисует системные — ниже полей ввода и со своей рамкой. */
select {
  -webkit-appearance: none; appearance: none; line-height: 1.55; cursor: pointer;
  padding-right: 2.2rem; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%238a857c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 7.5l3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 12px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; width: 100%; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 550; padding: 0.5rem 0.95rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-danger-quiet { color: var(--danger); }
.btn-block { width: 100%; }
.icon-btn { font: inherit; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; padding: 0.1rem 0.45rem; font-size: 1.1rem; line-height: 1; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link-btn { font: inherit; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; text-align: left; }
.chip { font: inherit; font-size: 0.8rem; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 99px; padding: 0.15rem 0.55rem; cursor: pointer; }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag { display: inline-block; font-size: 0.8rem; color: var(--muted); background: var(--surface-2); border-radius: 99px; padding: 0.05rem 0.5rem; }
a.tag:hover { color: var(--text); text-decoration: none; }
.tag.on { background: var(--accent-soft); color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.85rem; }
.field > span { font-size: 0.85rem; font-weight: 550; }
.field input, .field select { width: 100%; }
.alert { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 0.6rem 0.8rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.empty { text-align: center; padding: 3.5rem 1rem; border: 1px dashed var(--line); border-radius: var(--radius); display: grid; gap: 0.4rem; justify-items: center; }
.empty .btn { margin-top: 0.8rem; }
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 0.55rem 1rem; border-radius: 8px; transition: opacity 0.18s, transform 0.18s; z-index: 50;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); color: #fff; }

/* ---------- заголовок страницы ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.3rem; flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; flex: 1; }
.head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.inline-form { display: flex; gap: 0.5rem; }
.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1; min-width: 180px; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 230px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.12); padding: 0.3rem;
  display: flex; flex-direction: column;
}
.menu-list a, .menu-list button { font: inherit; text-align: left; border: 0; background: none; color: var(--text); padding: 0.45rem 0.65rem; border-radius: 6px; cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--surface-2); text-decoration: none; }
.menu-list .danger { color: var(--danger); }

/* ---------- список записей ---------- */
.rec-list, .person-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.rec-list li + li, .person-list li + li { border-top: 1px solid var(--line); }
.rec-link, .person-list a { display: flex; gap: 0.9rem; padding: 0.85rem 1.1rem; color: var(--text); align-items: flex-start; }
.rec-link:hover, .person-list a:hover { background: var(--surface-2); text-decoration: none; }
.rec-kind { flex: none; width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); position: relative; }
.rec-kind::after { content: ""; position: absolute; inset: 9px; background: var(--accent); mask: var(--icon) center / contain no-repeat; -webkit-mask: var(--icon) center / contain no-repeat; }
.kind-audio { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 6h1.5v4H2zM5 3h1.5v10H5zM8 5h1.5v6H8zM11 2h1.5v12H11zM14 6h1.5v4H14z'/%3E%3C/svg%3E"); }
.kind-video { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1 3.5h10v9H1zM12 6l3-2v8l-3-2z'/%3E%3C/svg%3E"); }
.rec-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.rec-title { font-weight: 600; }
.rec-meta { color: var(--muted); font-size: 0.85rem; }
.rec-summary { color: var(--muted); font-size: 0.88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 0.15rem; }
.rec-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; flex: none; max-width: 40%; }
.rec-tags { display: flex; gap: 0.25rem; flex-wrap: wrap; justify-content: flex-end; }
.status { font-size: 0.78rem; font-weight: 600; padding: 0.1rem 0.55rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.status-error { background: var(--danger-soft); color: var(--danger); }
.avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.avatar-img { flex: none; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.avatar.sm, .avatar-img.sm { width: 28px; height: 28px; font-size: 0.8rem; }
.avatar.lg, .avatar-img.lg { width: 52px; height: 52px; font-size: 1.2rem; }
.avatar.xl, .avatar-img.xl { width: 104px; height: 104px; font-size: 2.4rem; }

/* ---------- новая запись ---------- */
.new-form { max-width: 760px; }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; margin-bottom: 1.1rem; }
.tab { font: inherit; font-weight: 550; border: 0; background: none; color: var(--muted); padding: 0.4rem 0.9rem; border-radius: 7px; cursor: pointer; }
.tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tab-panel { margin-bottom: 1.2rem; }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 0.35rem;
  min-height: 170px; padding: 1.5rem; border: 2px dashed var(--line); border-radius: var(--radius); cursor: pointer; background: var(--bg);
}
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.has-file { border-style: solid; border-color: var(--accent); }
.drop-title { font-weight: 600; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 0.6rem 0 1rem; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

/* ---------- карточка записи ---------- */
.rec-head { min-width: 0; }
.editable-title { border-radius: 6px; padding: 0 0.25rem; margin-left: -0.25rem; outline: none; overflow-wrap: anywhere; }
.editable-title:hover { background: var(--surface-2); }
.editable-title:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--accent); }
.state-card { display: flex; gap: 0.8rem; align-items: flex-start; background: var(--accent-soft); border-radius: var(--radius); padding: 0.9rem 1.1rem; margin-bottom: 1.2rem; }
.state-card.is-error { background: var(--danger-soft); }
.state-card.is-error p { color: var(--danger); }
.spinner { flex: none; width: 18px; height: 18px; margin-top: 3px; border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.player {
  position: sticky; top: 58px; z-index: 4; display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.55rem 0.8rem; margin-bottom: 1.2rem; box-shadow: var(--shadow);
}
.player audio { flex: 1; min-width: 240px; height: 38px; }
.speed { display: flex; gap: 0.25rem; }
.follow { display: flex; gap: 0.35rem; align-items: center; color: var(--muted); }

.rec-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.5rem; align-items: start; }
.rec-aside { position: sticky; top: 130px; display: flex; flex-direction: column; gap: 1rem; }
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.25rem; box-shadow: var(--shadow); }
.rec-body { display: flex; flex-direction: column; gap: 1.2rem; min-width: 0; }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.block-head h2 { margin: 0; }
.find { max-width: 220px; padding: 0.3rem 0.6rem; }
.summary { font-size: 1.02rem; }
.outline { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.75rem; }
.outline ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }
.outline li li { margin: 0.15rem 0; }
.outline-head { display: flex; gap: 0.5rem; align-items: baseline; }
.ts { font: inherit; font-size: 0.78rem; font-variant-numeric: tabular-nums; color: var(--muted); background: var(--surface-2); border: 0; border-radius: 5px; padding: 0.05rem 0.4rem; cursor: pointer; white-space: nowrap; }
button.ts:hover { color: var(--accent); background: var(--accent-soft); }

.transcript { display: flex; flex-direction: column; margin-top: 0.6rem; }
.seg { --spk: var(--spk-0); padding: 0.55rem 0.7rem; border-radius: 8px; transition: background 0.15s; }
.seg + .seg { margin-top: 0.25rem; }
.seg.playing { background: var(--accent-soft); }
.seg.flash { animation: flash 2.4s ease-out; }
@keyframes flash { from { background: var(--mark); } }
.seg-meta { display: flex; gap: 0.5rem; align-items: center; }
.seg-speaker { font-weight: 650; font-size: 0.88rem; color: var(--spk); display: inline-flex; align-items: center; gap: 0.35rem; }
.seg-speaker::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--spk); }
.seg-text { margin: 0.15rem 0 0; white-space: pre-wrap; }
.seg-text[contenteditable=plaintext-only], .seg-text[contenteditable=true] { outline: none; background: var(--surface-2); border-radius: 6px; padding: 0.2rem 0.4rem; }
.spk-0 { --spk: var(--spk-0); } .spk-1 { --spk: var(--spk-1); } .spk-2 { --spk: var(--spk-2); } .spk-3 { --spk: var(--spk-3); }
.spk-4 { --spk: var(--spk-4); } .spk-5 { --spk: var(--spk-5); } .spk-6 { --spk: var(--spk-6); } .spk-7 { --spk: var(--spk-7); }

.speakers { display: flex; flex-direction: column; gap: 0.9rem; }
.speaker { display: flex; flex-direction: column; gap: 0.35rem; }
.speaker-top { display: flex; align-items: center; gap: 0.45rem; }
.speaker-label { font-weight: 600; font-size: 0.88rem; flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--spk); }
.speaker input, .speaker select { width: 100%; }

/* ---------- поиск ---------- */
.search-form { margin-bottom: 1.4rem; }
.search-form > input { width: 100%; font-size: 1.08rem; padding: 0.7rem 0.9rem; margin-bottom: 0.6rem; }
.search-form .filters { margin-bottom: 0.4rem; }
.results { display: flex; flex-direction: column; gap: 1rem; }
.result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.result h2 a { color: var(--text); }
.hit { display: flex; gap: 0.7rem; align-items: baseline; color: var(--text); padding: 0.5rem 0.6rem; margin: 0 -0.6rem; border-radius: 8px; }
.hit:hover { background: var(--surface-2); text-decoration: none; }
.hit-text { font-size: 0.93rem; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.answer { background: var(--accent-soft); border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1.4rem; }
.answer .ref { font-weight: 600; font-size: 0.85em; }
.answer-refs { margin: 0.8rem 0 0; padding-left: 1.4rem; font-size: 0.88rem; }

/* ---------- вход ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 2rem; box-shadow: var(--shadow); }
.login-card .brand { padding: 0; margin-bottom: 0.2rem; font-size: 1.3rem; }
.login-card > .muted { margin-bottom: 1.3rem; }
.login-card .brand { margin-bottom: 1rem; }
.auth-title { font-size: 1.3rem; margin-bottom: 0.4rem; }
.auth-links { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.note { background: var(--accent-soft); border-radius: 8px; padding: 0.6rem 0.8rem; margin-bottom: 1rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.login-card .btn { margin-top: 0.4rem; }

/* ---------- узкие экраны ---------- */
@media (max-width: 1000px) {
  .rec-grid { grid-template-columns: 1fr; }
  .rec-aside { position: static; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 20; width: 270px; transform: translateX(-100%); transition: transform 0.2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / 0.2); }
  .menu-btn { display: block; }
  .topbar { padding: 0.6rem 1rem; }
  .content { padding: 1.1rem 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .rec-link { flex-wrap: wrap; }
  .rec-side { max-width: none; align-items: flex-start; width: 100%; padding-left: 48px; }
  .rec-tags { justify-content: flex-start; }
  .player { top: 54px; }
  .block { padding: 1rem; }
  .inline-form { width: 100%; }
  .inline-form input { flex: 1; }
}

/* ---------- иконки, свёрнутая панель, тема ---------- */
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.collapse-btn { padding: 0.35rem; display: grid; place-items: center; }
.icon-btn .ico { width: 18px; height: 18px; }
.nav a { justify-content: flex-start; gap: 0.6rem; }
.nav a .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a .ico { color: var(--muted); }
.nav a.on .ico { color: var(--accent); }
.new-btn { gap: 0.5rem; }
.badge { display: inline-block; min-width: 1.3em; padding: 0 0.4em; border-radius: 99px; background: var(--danger); color: #fff; font-size: 0.75rem; font-weight: 700; text-align: center; }
.nav a .count:not(:empty) { font-variant-numeric: tabular-nums; }
.theme-switch { display: flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.theme-switch button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem; font: inherit; font-size: 0.78rem; border: 0; background: none; color: var(--muted); padding: 0.3rem 0.2rem; border-radius: 7px; cursor: pointer; }
.theme-switch button .ico { width: 15px; height: 15px; }
.theme-switch button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.me-row { display: flex; align-items: center; gap: 0.3rem; }
.me { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.55rem; padding: 0.3rem 0.4rem; border-radius: 8px; color: var(--text); }
.me:hover, .me.on { background: var(--surface-2); text-decoration: none; }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }

@media (min-width: 761px) {
  .shell { transition: grid-template-columns 0.18s ease; }
  :root[data-sidebar="collapsed"] .shell { grid-template-columns: 64px 1fr; }
  :root[data-sidebar="collapsed"] .side { padding-left: 0.55rem; padding-right: 0.55rem; overflow-x: hidden; }
  :root[data-sidebar="collapsed"] .side .label,
  :root[data-sidebar="collapsed"] .side .count,
  :root[data-sidebar="collapsed"] .tags-group { display: none; }
  :root[data-sidebar="collapsed"] .side-top { flex-direction: column; }
  :root[data-sidebar="collapsed"] .brand { padding: 0; }
  :root[data-sidebar="collapsed"] .nav a, :root[data-sidebar="collapsed"] .new-btn { justify-content: center; padding-left: 0; padding-right: 0; }
  :root[data-sidebar="collapsed"] .nav-head { justify-content: center; padding: 0 0 0.3rem; }
  :root[data-sidebar="collapsed"] .theme-switch { flex-direction: column; }
  :root[data-sidebar="collapsed"] .me-row { justify-content: center; }
  :root[data-sidebar="collapsed"] .me { flex: none; padding: 0.2rem; }
}
@media (prefers-reduced-motion: reduce) { .shell { transition: none; } }

/* ---------- кабинет ---------- */
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.2rem; align-items: start; }
.avatar-edit { display: flex; gap: 1.1rem; align-items: center; margin-bottom: 1.2rem; }
.avatar-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.avatar-actions .muted { width: 100%; }
.usage-big { font-size: 1.6rem; font-weight: 650; margin: 0.2rem 0 0.6rem; }
.usage-big .muted { font-size: 1rem; font-weight: 400; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-bottom: 0.5rem; }
.meter > div { height: 100%; background: var(--accent); border-radius: inherit; }
.meter.is-high > div { background: var(--danger); }
.meter.sm { height: 5px; width: 120px; margin: 0; }
.pw-hint { color: var(--muted); margin: -0.5rem 0 0.85rem; }
.pw-hint.is-bad { color: var(--danger); }
.pw-hint.is-good { color: var(--ok); }

/* ---------- администратор ---------- */
.faces { display: flex; gap: 0.9rem; overflow-x: auto; padding: 0.2rem 0 1rem; margin-bottom: 0.4rem; }
.face { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; width: 96px; flex: none; color: var(--text); font-size: 0.78rem; text-align: center; }
.face:hover { text-decoration: none; }
.face span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.face.status-blocked, .face.status-rejected { opacity: 0.45; }
a.tab { text-decoration: none; display: inline-flex; align-items: center; gap: 0.35rem; }
.apply-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.apply { display: flex; flex-direction: column; gap: 1rem; }
.apply-who { display: flex; gap: 0.9rem; align-items: center; }
.apply-act .field { margin-bottom: 0.6rem; }
.row-actions { display: flex; gap: 0.5rem; }
.user-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.user-row { display: flex; gap: 0.9rem; align-items: center; padding: 0.8rem 1.1rem; scroll-margin-top: 80px; }
.user-row + .user-row { border-top: 1px solid var(--line); }
.user-row:target { background: var(--accent-soft); }
.user-main { flex: 1; min-width: 0; }
.user-name { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.user-usage { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.25rem; }
.user-ctl { display: flex; gap: 0.5rem; align-items: center; flex: none; }
.user-ctl > * { height: 38px; }
.limit-group { display: flex; align-items: center; width: 212px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding-right: 0.7rem; cursor: text; }
.limit-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.limit-group input { flex: 1; min-width: 0; width: 100%; height: 100%; border: 0; background: none; box-shadow: none; padding: 0 0.4rem 0 0.7rem; text-align: right; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.limit-group input:focus { box-shadow: none; }
.limit-group input::-webkit-inner-spin-button, .limit-group input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.limit-group input:placeholder-shown { text-align: left; }
.limit-unit { flex: none; color: var(--muted); font-size: 0.85rem; white-space: nowrap; width: 7.4em; }
.limit-unit:empty { display: none; }
.user-ctl select { width: 168px; height: 38px; padding: 0 2.2rem 0 0.7rem; }
.user-ctl .menu > summary { height: 38px; width: 44px; padding: 0; }
@media (max-width: 760px) {
  .user-row { flex-wrap: wrap; }
  .user-ctl { width: 100%; padding-left: 50px; }
  .user-ctl { flex-wrap: wrap; height: auto; }
  .limit-group { width: 100%; }
  .user-ctl select { flex: 1; width: auto; min-width: 0; }
  .user-usage { flex-wrap: wrap; }
  .avatar-edit { flex-direction: column; align-items: flex-start; }
}
