/* ====== основа ====== */
:root {
  --bg: #08070f;
  --panel: #12101f;
  --panel-2: #171426;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #ece9f7;
  --dim: #9d97ba;
  --dim-2: #6d6789;
  --accent: #8b9cff;
  --accent-rgb: 139, 156, 255;
  /* Холод: осадок от грубости. Тёплый красный, не тревожный - это не ошибка,
     а «мне неприятно», поэтому цвет ближе к закату, чем к светофору. */
  --cold: #e2797f;
  --radius: 20px;
  --font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Inter",
    Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* `hidden` must beat any `display` rule: otherwise an invisible overlay keeps
   swallowing clicks (this is what froze the whole page after adding the card). */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(900px 620px at 12% -12%, rgba(var(--accent-rgb), 0.13), transparent 62%),
    radial-gradient(760px 520px at 88% -6%, rgba(255, 143, 171, 0.08), transparent 60%),
    radial-gradient(1100px 780px at 50% 122%, rgba(107, 168, 255, 0.09), transparent 62%),
    linear-gradient(180deg, #0a0813, #06050b 72%);
  background-attachment: fixed;
  transition: background 0.9s ease;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

::selection { background: rgba(var(--accent-rgb), 0.35); }

/* ====== каркас ====== */
.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  padding: 0 clamp(14px, 2.4vw, 34px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 68px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.16), 0 0 18px rgba(var(--accent-rgb), 0.8);
  transition: background 0.6s, box-shadow 0.6s;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-size: 17px; font-weight: 650; letter-spacing: 0.01em; }
.brand-sub {
  font-size: 11.5px; color: var(--dim-2); letter-spacing: 0.06em;
  text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--dim);
  border: 1px solid transparent;
  transition: 0.18s;
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); border-color: var(--line); }
.icon-btn:active { transform: scale(0.95); }

.layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: clamp(16px, 2.2vw, 34px);
  min-height: 0;
  padding: clamp(14px, 2vh, 26px) 0 18px;
}

/* ====== сцена с «лицом» ====== */
.avatar-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-height: 0;
  min-width: 0;
  padding: clamp(10px, 4vh, 44px) 8px 8px;
  position: relative;
}

.face {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: auto 0;
  min-width: 0;
}

.avatar-pane::after {
  content: "";
  position: absolute;
  inset: 6% 0 6% 100%;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--line), transparent);
}

.orb-shell {
  position: relative;
  width: min(258px, 62vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-bottom: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.orb-shell:active { transform: scale(0.985); }
.orb-shell:focus-visible { outline: 2px solid rgba(var(--accent-rgb), 0.6); outline-offset: 6px; border-radius: 50%; }

.orb-halo {
  position: absolute;
  inset: -26%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.34), transparent 64%);
  filter: blur(30px);
  opacity: 0.5;
  transition: background 0.9s, opacity 0.5s;
  animation: breathe 7.5s ease-in-out infinite;
}

.orb-ring {
  position: absolute;
  inset: -7%;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    transparent 0 58%,
    rgba(var(--accent-rgb), 0.55) 76%,
    rgba(var(--accent-rgb), 0.05) 86% 100%
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1.5px));
  animation: spin 18s linear infinite;
  opacity: 0.85;
  transition: background 0.9s;
}

.orb {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(circle at 50% 58%, #191634, #0a0814 58%, #050409 100%);
  box-shadow:
    0 0 100px -20px rgba(var(--accent-rgb), 0.6),
    inset 0 0 70px rgba(var(--accent-rgb), 0.16),
    inset 0 0 0 1px rgba(var(--accent-rgb), 0.22),
    inset 0 -34px 64px rgba(0, 0, 0, 0.8),
    inset 0 18px 40px rgba(255, 255, 255, 0.05);
  transition: box-shadow 0.9s, transform 0.25s;
  animation: float 10s ease-in-out infinite;
  will-change: transform;
}

/* «туманность» внутри сферы — два пятна акцента, медленно дышат */
.orb::before {
  content: "";
  position: absolute;
  inset: -18%;
  background:
    radial-gradient(closest-side at 67% 33%, rgba(var(--accent-rgb), 0.9), transparent 72%),
    radial-gradient(closest-side at 31% 69%, rgba(var(--accent-rgb), 0.5), transparent 74%),
    radial-gradient(closest-side at 52% 50%, rgba(255, 255, 255, 0.22), transparent 56%);
  filter: blur(16px);
  opacity: 0.95;
  transition: background 0.9s;
  animation: swirl 19s ease-in-out infinite alternate;
}

/* блик стекла */
.orb::after {
  content: "";
  position: absolute;
  inset: 9% 19% 56% 13%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.55), transparent 72%);
  filter: blur(13px);
  opacity: 0.5;
}

.orb-shine {
  position: absolute;
  inset: 62% 26% 12% 30%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(var(--accent-rgb), 0.5), transparent 74%);
  filter: blur(16px);
  opacity: 0.7;
}

.avatar-pane.speaking .orb { animation: pulse 0.85s ease-in-out infinite; }
.avatar-pane.speaking .orb-halo { opacity: 1; }
.avatar-pane.speaking .orb-ring { animation-duration: 5s; }

.rings { position: absolute; inset: 0; pointer-events: none; }
.rings i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  opacity: 0;
}
.avatar-pane.speaking .rings i { animation: ping 2.1s cubic-bezier(0.2, 0.6, 0.3, 1) infinite; }
.avatar-pane.speaking .rings i:nth-child(2) { animation-delay: 0.7s; }
.avatar-pane.speaking .rings i:nth-child(3) { animation-delay: 1.4s; }

.face-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--dim);
  transition: color 0.3s;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5ad38a;
  box-shadow: 0 0 9px rgba(90, 211, 138, 0.85);
  transition: background 0.3s, box-shadow 0.3s;
}

.face-status[data-state="typing"] .status-dot {
  background: rgba(var(--accent-rgb), 1);
  box-shadow: 0 0 9px rgba(var(--accent-rgb), 0.9);
  animation: blink 1s ease-in-out infinite;
}
.face-status[data-state="speaking"] .status-dot {
  background: rgba(var(--accent-rgb), 1);
  box-shadow: 0 0 11px rgba(var(--accent-rgb), 0.95);
}
.face-status[data-state="error"] .status-dot {
  background: #ff6b6b;
  box-shadow: 0 0 9px rgba(255, 107, 107, 0.8);
}

.face-status[data-state="asleep"] { color: #9aa7d8; }
.face-status[data-state="asleep"] .status-dot {
  background: #8f9ad6;
  box-shadow: 0 0 10px rgba(143, 154, 214, 0.8);
  animation: blink 3.2s ease-in-out infinite;
}
.face-status[data-state="stream"] { color: #e2a8c9; }
.face-status[data-state="stream"] .status-dot {
  background: #ff7ab8;
  box-shadow: 0 0 10px rgba(255, 122, 184, 0.8);
}

.face-meta {
  margin: 2px 0 0;
  font-size: 11.5px;
  line-height: 1.75;
  color: #635d80;
  text-align: center;
  min-height: 1.7em;
}
.face-meta b { color: var(--dim); font-weight: 500; }

.emotion-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  background: rgba(var(--accent-rgb), 0.09);
  color: color-mix(in srgb, var(--accent) 55%, white);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  transition: 0.6s;
}
.emotion-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  transition: 0.6s;
}

.caption {
  margin: 0;
  min-height: 2.9em;
  max-width: 100%;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
  color: var(--dim);
  font-style: italic;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  transition: opacity 0.3s;
}

.levels {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  opacity: 0;
  transition: opacity 0.4s;
}
.avatar-pane.speaking .levels { opacity: 1; }
.levels i {
  width: 3px; height: 6px;
  border-radius: 3px;
  background: var(--accent);
  opacity: 0.75;
}
.avatar-pane.speaking .levels i { animation: level 0.9s ease-in-out infinite; }
.levels i:nth-child(1) { animation-delay: 0.00s; }
.levels i:nth-child(2) { animation-delay: 0.12s; }
.levels i:nth-child(3) { animation-delay: 0.24s; }
.levels i:nth-child(4) { animation-delay: 0.36s; }
.levels i:nth-child(5) { animation-delay: 0.06s; }
.levels i:nth-child(6) { animation-delay: 0.18s; }
.levels i:nth-child(7) { animation-delay: 0.30s; }
.levels i:nth-child(8) { animation-delay: 0.42s; }
.levels i:nth-child(9) { animation-delay: 0.54s; }

.pane-foot { margin-top: 0; padding-bottom: 6px; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--dim-2);
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: 0.2s;
}
.ghost-btn:hover { color: var(--text); border-color: var(--line); background: rgba(255, 255, 255, 0.04); }
.ghost-btn.off { color: var(--dim-2); opacity: 0.7; }

/* ====== чат ====== */
.chat-pane {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 10px;
  min-height: 0;
  min-width: 0;
}

.chat {
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 6px 12px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.chat::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 8px; }
.chat::-webkit-scrollbar-track { background: transparent; }

.msg {
  position: relative;
  max-width: min(660px, 88%);
  padding: 11px 16px;
  border-radius: 18px;
  font-size: 15.2px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: pop 0.26s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.msg.me {
  align-self: flex-end;
  background: linear-gradient(180deg, rgba(74, 63, 184, 0.95), rgba(56, 46, 148, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom-right-radius: 6px;
  box-shadow: 0 10px 26px -18px rgba(74, 63, 184, 0.9);
}

.msg.mia {
  align-self: flex-start;
  background: linear-gradient(180deg, rgba(26, 24, 48, 0.92), rgba(19, 17, 34, 0.92));
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-bottom-left-radius: 6px;
  box-shadow: 0 14px 34px -24px #000;
  backdrop-filter: blur(6px);
  transition: border-color 0.6s;
}

.msg.mia.error {
  border-left-color: #ff6b6b;
  color: #ffc9c9;
  font-size: 14px;
}

.msg.typing { padding: 14px 18px; }
.dots { display: inline-flex; gap: 5px; align-items: center; height: 8px; }
.dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); opacity: 0.35;
  animation: dot 1.15s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: 0.16s; }
.dots i:nth-child(3) { animation-delay: 0.32s; }

.chat-empty {
  margin: auto;
  text-align: center;
  max-width: 460px;
  padding: 10px;
  animation: fade 0.5s both;
}
.chat-empty h2 {
  font-size: 19px; font-weight: 600; margin: 0 0 6px;
  letter-spacing: 0.01em;
}
.chat-empty p { margin: 0 0 18px; color: var(--dim); font-size: 13.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  font-size: 13px;
  color: var(--dim);
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 14px;
  border-radius: 999px;
  transition: 0.18s;
}
.chip:hover { color: var(--text); border-color: rgba(var(--accent-rgb), 0.5); background: rgba(var(--accent-rgb), 0.1); }

/* ====== ввод ====== */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 10px;
  border-radius: 22px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(23, 20, 38, 0.94), rgba(16, 14, 28, 0.94));
  box-shadow: 0 22px 50px -34px #000, inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer:focus-within {
  border-color: rgba(var(--accent-rgb), 0.45);
  box-shadow: 0 22px 50px -34px #000, 0 0 0 3px rgba(var(--accent-rgb), 0.09);
}

.field { flex: 1; min-width: 0; display: flex; }

#input {
  width: 100%;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  padding: 9px 4px;
  max-height: 148px;
  font-size: 15px;
  line-height: 1.45;
}
#input::placeholder { color: var(--dim-2); }

.mic-btn, .send-btn {
  width: 42px; height: 42px;
  flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 14px;
  color: var(--dim);
  transition: 0.18s;
  position: relative;
}
.mic-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.send-btn {
  color: #0b0a14;
  background: var(--accent);
  box-shadow: 0 8px 24px -12px rgba(var(--accent-rgb), 0.9);
}
.send-btn:hover { filter: brightness(1.08); }
.send-btn:disabled { opacity: 0.35; cursor: default; filter: none; box-shadow: none; }

.mic-btn.recording {
  color: #ff8fab;
  background: rgba(255, 107, 107, 0.14);
  box-shadow: 0 0 0 calc(1px + var(--rms, 0) * 14px) rgba(255, 107, 107, 0.10);
  transition: box-shadow 0.08s linear;
}
.mic-btn.recording::after {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 16px;
  border: 1px solid rgba(255, 107, 107, 0.5);
  animation: ping 1.4s ease-out infinite;
}
.mic-btn.busy { opacity: 0.5; pointer-events: none; }

/* Микрофон открыт постоянно: не «запись», а «я тебя слышу». Тихое свечение,
   чтобы было видно, что микрофон живой, но не пугало красной лампой. */
.mic-btn.live {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.10);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.35);
}
.mic-btn.live::after {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 16px;
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  animation: ping 2.8s ease-out infinite;
}
/* Человек говорит: кольцо повторяет громкость голоса. */
.mic-btn.hearing {
  color: #fff;
  background: rgba(var(--accent-rgb), 0.26);
  box-shadow: 0 0 0 calc(1px + var(--rms, 0) * 12px) rgba(var(--accent-rgb), 0.14);
  transition: box-shadow 0.08s linear, background 0.2s;
}
.mic-btn.hearing::after {
  border-color: rgba(var(--accent-rgb), 0.6);
  animation: none;
}

.mic-timer {
  position: absolute;
  bottom: -2px;
  font-size: 9px;
  color: #ff8fab;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 0.2s;
}
.mic-btn.recording .mic-timer { opacity: 1; }

.hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--dim-2);
  padding-bottom: 2px;
  transition: color 0.2s;
}
.hint.live { color: rgba(var(--accent-rgb), 0.85); }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 13.5px;
  cursor: pointer;
  transition: 0.18s;
}
.check:hover { background: rgba(255, 255, 255, 0.05); }
.check input {
  width: 16px; height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
kbd {
  font-family: inherit;
  font-size: 10.5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--dim);
}

/* ====== доступы ====== */
.access-form { display: grid; gap: 10px; }
.access-scopes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  max-height: 220px;
  overflow: auto;
  padding: 2px;
}
.access-scopes label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--dim);
  cursor: pointer;
}
.access-scopes input { accent-color: var(--accent); }
.access-error { min-height: 16px; margin: 0; color: var(--cold); font-size: 12px; }
.access-token {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: 12px;
  background: rgba(var(--accent-rgb), 0.07);
}
.access-token code {
  display: block;
  overflow-wrap: anywhere;
  color: color-mix(in srgb, var(--accent) 65%, white);
  font-size: 12px;
}
.access-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.access-row {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}
.access-row-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.access-row-name { font-weight: 600; }
.access-row-meta { color: var(--dim-2); font-size: 11.5px; }
.access-row-scopes { color: var(--dim); font-size: 11.5px; overflow-wrap: anywhere; }
.access-revoke { justify-self: start; padding: 2px 8px; font-size: 11px; }

/* ====== вход по токену ====== */
.auth-gate {
  position: fixed; inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(620px 420px at 50% 18%, rgba(var(--accent-rgb), 0.16), transparent 70%),
    rgba(5, 4, 10, 0.84);
  backdrop-filter: blur(10px);
}
.auth-card {
  width: min(380px, 100%);
  display: grid;
  gap: 12px;
  padding: 26px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #161327, #0d0b18);
  box-shadow: 0 30px 90px -40px #000, 0 0 0 1px rgba(var(--accent-rgb), 0.06);
}
.auth-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.3);
}
.auth-card h2 { margin: 0; font-size: 21px; font-weight: 650; }
.auth-note { margin: 0; color: var(--dim); font-size: 13px; line-height: 1.5; }
.auth-note code {
  font-size: 12px;
  color: color-mix(in srgb, var(--accent) 60%, white);
  background: rgba(var(--accent-rgb), 0.1);
  border-radius: 5px;
  padding: 1px 5px;
}
.auth-go { justify-self: start; padding: 8px 18px; }
.auth-error { min-height: 18px; margin: 0; color: var(--cold); font-size: 12px; }

/* ====== шторка памяти ====== */
.scrim {
  position: fixed; inset: 0;
  background: rgba(4, 3, 9, 0.6);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 20;
}
.scrim.show { opacity: 1; }

.drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100dvh;
  width: min(400px, 92vw);
  background: linear-gradient(180deg, #131120, #0c0a15);
  border-left: 1px solid var(--line-2);
  box-shadow: -30px 0 80px -40px #000;
  transform: translateX(103%);
  transition: transform 0.3s cubic-bezier(0.3, 0.8, 0.3, 1);
  z-index: 21;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: none; }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 14px 22px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.drawer-title { display: flex; flex-direction: column; gap: 2px; }
.drawer-sub { margin: 0; font-size: 10.5px; color: var(--dim-2); }

/* ====== модули ======
   Раньше переключатель был списком слов: по нему не видно ни что за вкладкой,
   ни что происходит в ней сейчас. Теперь это шесть плиток — иконка, имя и
   живая строчка состояния, а у каждого модуля свой цвет, чтобы место в шторке
   читалось с одного взгляда. */
.modules {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.022), transparent);
}
.module {
  --mod: 139, 156, 255;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 2px;
  padding: 7px 8px 8px;
  border-radius: 13px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.02);
  color: var(--dim);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
}
/* Цветное пятно в углу — оно и подсвечивает активный модуль, и мягко красит
   карточку на наведении, не забивая текст. */
.module::after {
  content: '';
  position: absolute;
  top: -34px; right: -30px;
  width: 78px; height: 78px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(var(--mod), 0.22), transparent 72%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.module:hover { border-color: rgba(var(--mod), 0.32); background: rgba(255, 255, 255, 0.045); }
.module:hover::after { opacity: 0.7; }
.module:active { transform: scale(0.985); }
.module:focus-visible { outline: none; border-color: rgba(var(--mod), 0.6); }
.module-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.module-ico {
  display: grid;
  place-items: center;
  width: 20px; height: 20px;
  border-radius: 7px;
  color: rgb(var(--mod));
  background: rgba(var(--mod), 0.13);
  box-shadow: inset 0 0 0 1px rgba(var(--mod), 0.16);
}
.module-ico svg { display: block; }
.module-dot {
  flex: none;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #3a3648;
  transition: background 0.25s, box-shadow 0.25s;
}
.module-dot[data-state="on"] { background: #63e6a4; box-shadow: 0 0 7px rgba(99, 230, 164, 0.85); }
.module-dot[data-state="warn"] { background: #f0b45f; box-shadow: 0 0 7px rgba(240, 180, 95, 0.85); }
.module-name {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.module-sub {
  font-size: 9.5px;
  line-height: 1.25;
  color: var(--dim-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.module[aria-selected="true"] {
  border-color: rgba(var(--mod), 0.5);
  background:
    radial-gradient(120% 130% at 100% 0%, rgba(var(--mod), 0.17), transparent 68%),
    rgba(var(--mod), 0.07);
  box-shadow: 0 12px 28px -24px rgba(var(--mod), 0.95);
}
.module[aria-selected="true"]::after { opacity: 1; }
.module[aria-selected="true"] .module-ico {
  color: color-mix(in srgb, rgb(var(--mod)) 68%, white);
  background: rgba(var(--mod), 0.2);
}
.module[aria-selected="true"] .module-sub { color: rgba(var(--mod), 0.9); }

/* Свой цвет у каждого модуля — он же цвет его иконки и подсветки. */
.module[data-mod="memory"]   { --mod: 167, 139, 250; }
.module[data-mod="mind"]     { --mod: 96, 196, 255; }
.module[data-mod="feelings"] { --mod: 255, 138, 182; }
.module[data-mod="live"]     { --mod: 110, 226, 176; }
.module[data-mod="telegram"] { --mod: 110, 168, 255; }
.module[data-mod="general"]  { --mod: 178, 170, 204; }

/* Фраза-подзаголовок панели: одной строкой — зачем этот модуль нужен. */
.pane-lead {
  margin: 16px 0 -6px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
  opacity: 0.7;
}

/* Панель — такая же колонка, как тело шторки: тот же шаг между секциями. */
.tab-pane {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.drawer-body {
  overflow-y: auto;
  padding: 8px 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.drawer-sec h3 {
  margin: 18px 0 10px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim-2);
  font-weight: 600;
}

.text-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  outline: none;
  font-size: 14px;
  transition: 0.18s;
}
.text-input:focus { border-color: rgba(var(--accent-rgb), 0.5); background-color: rgba(255, 255, 255, 0.05); }
.text-input::placeholder { color: var(--dim-2); }

/* Выпадающий список — родной виджет браузера, и он рисует всплывающее меню
   по своей схеме. Без color-scheme: dark список получается белым, а текст
   наследует светлый цвет темы — белое по белому. */
select.text-input {
  color-scheme: dark;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%238a93a8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}
select.text-input option { background-color: #131826; color: var(--text); }

/* Свой выпадающий список. Родное меню <select> в Windows рисует система:
   светлый фон, а цвет текста берётся из страницы — и на тёмной теме пункты
   выходят белым по белому. Настоящий <select> остаётся в разметке невидимым
   (из него читают значение), а меню рисуем сами. */
.dd-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  text-align: left;
  padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%238a93a8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px 7px;
}
.dd-btn[aria-expanded="true"] { border-color: rgba(var(--accent-rgb), 0.45); }
.dd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-menu {
  position: fixed;
  z-index: 90;
  padding: 5px;
  border-radius: 13px;
  background: #10131d;
  border: 1px solid var(--line-2);
  box-shadow: 0 20px 50px -18px rgba(0, 0, 0, 0.92), 0 2px 10px rgba(0, 0, 0, 0.5);
  max-height: 264px;
  overflow-y: auto;
  animation: fade 0.14s both;
}
.dd-item {
  display: block;
  width: 100%;
  padding: 8px 11px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.dd-item:hover { background: rgba(255, 255, 255, 0.06); }
.dd-item:focus-visible { outline: none; background: rgba(255, 255, 255, 0.09); }
.dd-item[aria-selected="true"] { background: rgba(var(--accent-rgb), 0.18); color: #fff; }

.note { margin: 8px 0 0; font-size: 11.5px; color: var(--dim-2); line-height: 1.4; }
/* Осадок от грубости: строка про отношения краснеет, когда человек в минусе.
   Цвет приглушённый - это не тревога, а признание, что близко к сердцу. */
.note.cold { color: var(--cold); }
.note.cold .link-btn { color: var(--cold); }
/* Сноска под полями api_id: мельче и тише самого пояснения. */
.note.note-dim { margin-top: 6px; font-size: 11px; opacity: 0.85; }
.note .link-btn { margin: 0 1px; font-size: inherit; color: var(--accent); text-decoration: underline dotted; }
/* Длинные подсказки свёрнуты: в шторке их много, и столбец серого текста
   утомляет глаза. Хвост лежит в .note-rest и открывается по «ещё». */
.note-rest { color: inherit; }
.note-more {
  margin: 0 0 0 4px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 11px;
  color: rgba(var(--accent-rgb), 0.8);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.note-more:hover { color: var(--text); }
.note-more:focus-visible { outline: none; color: var(--text); }

.facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.facts li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 10px 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  font-size: 13px;
  animation: fade 0.3s both;
}
.facts .k { color: var(--dim-2); flex-shrink: 0; }
.facts .v { flex: 1; overflow-wrap: anywhere; }
.facts .x {
  color: var(--dim-2);
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  flex-shrink: 0;
}
.facts .x:hover { color: #ff9b9b; background: rgba(255, 107, 107, 0.1); }
.facts .empty { color: var(--dim-2); font-size: 12.5px; border: 1px dashed var(--line-2); background: none; }

.fact-form { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 6px; margin-top: 10px; }
.mini-btn {
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  background: rgba(var(--accent-rgb), 0.12);
  color: color-mix(in srgb, var(--accent) 60%, white);
  font-size: 12.5px;
  transition: 0.18s;
}
.mini-btn:hover { background: rgba(var(--accent-rgb), 0.22); }

/* архив заметок */
.archive-head { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-bottom: 10px; }
.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.notes li.note-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  font-size: 13px;
  animation: fade 0.3s both;
}
/* Крестик «убрать строку» стоит в углу, а не отдельной строкой под текстом:
   иначе он растягивается на всю карточку и съедает пол-экрана. */
.notes li.note-item > .x {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 7px;
  color: var(--dim-2);
  font-size: 13px;
  line-height: 1;
}
.notes li.note-item > .x:hover {
  color: #ff9b9b;
  background: rgba(255, 107, 107, 0.12);
}
/* Строка «в факты / забыть» в архивной карточке — внизу, не под крестиком. */
.notes li.note-item .note-tools { padding-right: 24px; }
/* Если крестик есть, справа оставляем место: иначе он наезжает на возраст. */
.notes li.note-item:has(> .x) { padding-right: 34px; }
.notes .note-head { display: flex; align-items: center; gap: 7px; min-width: 0; }
.notes .note-head b { font-weight: 600; overflow-wrap: anywhere; }
.notes .note-kind {
  flex-shrink: 0;
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--dim-2);
  background: rgba(255, 255, 255, 0.06);
}
.notes .note-kind.preference { color: #ffd166; background: rgba(255, 209, 102, 0.12); }
.notes .note-kind.event { color: #8b9cff; background: rgba(139, 156, 255, 0.12); }
.notes .note-kind.feeling { color: #ff8fab; background: rgba(255, 143, 171, 0.12); }
.notes .note-meta { margin-left: auto; font-size: 11px; color: var(--dim-2); flex-shrink: 0; }
.notes p { margin: 0; color: var(--text); line-height: 1.45; overflow-wrap: anywhere; }
/* чьи заметки: полки людей прямо в архиве */
.note-people { position: relative; display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.note-chip {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--dim-2);
  background: rgba(255, 255, 255, 0.02);
  transition: 0.16s;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-chip:hover { color: var(--text); border-color: rgba(var(--accent-rgb), 0.35); }
.note-chip.on { color: #0d0b14; background: var(--accent); border-color: transparent; font-weight: 600; }
.note-person {
  flex-shrink: 0;
  max-width: 36%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 99px;
  color: color-mix(in srgb, var(--accent) 70%, white);
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  transition: 0.16s;
}
.note-person:hover { background: rgba(var(--accent-rgb), 0.2); }
/* Знакомых может быть сколько угодно: если рисовать чип на каждого, фильтр
   архива уползает вниз на несколько экранов. Поэтому один чип-меню. */
.note-chip-more { max-width: 190px; }
.note-chip-more::after {
  content: "▾";
  margin-left: 4px;
  font-size: 9px;
  opacity: 0.65;
}
.note-people-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  width: min(280px, 100%);
  max-height: 258px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: #16141f;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.note-people-search { margin: 6px 6px 4px; }
.note-people-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 6px 6px;
  overflow-y: auto;
}
.note-people-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s;
}
.note-people-row:hover,
.note-people-row:focus-visible { background: rgba(var(--accent-rgb), 0.12); outline: none; }
.note-people-row[aria-checked="true"] { background: rgba(var(--accent-rgb), 0.17); font-weight: 600; }
.note-people-row-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Логины второй строкой: у тёзок имя одинаковое, различает их только это. */
.note-people-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.note-people-row-sub {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 400;
  color: var(--dim-2);
}
.note-people-row-num { flex-shrink: 0; font-size: 10.5px; font-weight: 500; color: var(--dim-2); }
.note-people-empty { margin: 4px 10px 10px; font-size: 12px; color: var(--dim-2); }
/* Заметка пришла из телеграма: тихая метка, чтобы архив не путал её с веб-чатом. */
.notes .note-source {
  flex-shrink: 0;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 99px;
  color: #7fd7ff;
  background: rgba(80, 190, 255, 0.1);
  border: 1px solid rgba(80, 190, 255, 0.22);
}
.notes .note-tools { display: flex; gap: 12px; align-items: center; }
.notes .note-vis {
  font-size: 10.5px;
  color: var(--dim);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 1px 4px;
  max-width: 120px;
}
.notes .note-vis:focus { outline: none; border-color: rgba(var(--accent-rgb), 0.5); }
.notes .empty {
  color: var(--dim-2);
  font-size: 12.5px;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px dashed var(--line-2);
  background: none;
}
.link-btn { font-size: 11.5px; color: var(--dim-2); padding: 1px 2px; border-radius: 6px; transition: 0.15s; }
.link-btn:hover { color: var(--accent); }


.stats { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.stats dt { color: var(--dim-2); }
.stats dd { margin: 0; color: var(--text); }

.danger-btn {
  width: 100%;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid rgba(255, 107, 107, 0.3);
  background: rgba(255, 107, 107, 0.08);
  color: #ff9b9b;
  font-size: 13.5px;
  transition: 0.18s;
}
.danger-btn:hover { background: rgba(255, 107, 107, 0.16); }

/* ====== карта памяти ====== */
.row-inline { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; margin-bottom: 10px; }

.brain {
  position: fixed;
  inset: 0;
  z-index: 60;
  opacity: 0;
  transition: opacity 0.32s ease;
  background:
    radial-gradient(1100px 760px at 16% -8%, rgba(var(--accent-rgb), 0.16), transparent 62%),
    radial-gradient(900px 640px at 88% 108%, rgba(167, 139, 250, 0.12), transparent 60%),
    linear-gradient(180deg, #0a0814, #06050b 72%);
}
.brain[hidden] { display: none; }
.brain.open { opacity: 1; }

.brain-aurora {
  position: absolute;
  inset: -12%;
  pointer-events: none;
  background:
    radial-gradient(620px 460px at 32% 42%, rgba(var(--accent-rgb), 0.12), transparent 70%),
    radial-gradient(540px 420px at 68% 62%, rgba(255, 143, 171, 0.07), transparent 72%);
  filter: blur(18px);
  animation: aurora 22s ease-in-out infinite alternate;
}
@keyframes aurora {
  from { transform: translate(-1.5%, -1%) scale(1); }
  to { transform: translate(1.5%, 1.5%) scale(1.06); }
}

.brain-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
.brain-canvas.grabbing { cursor: grabbing; }
.brain-canvas.hot { cursor: pointer; }

.brain-head {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px 0;
  pointer-events: none;
}
.brain-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brain-orb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.9), transparent 38%),
    radial-gradient(circle at 50% 58%, rgba(var(--accent-rgb), 0.95), rgba(167, 139, 250, 0.5) 58%, transparent 72%);
  box-shadow: 0 0 28px rgba(var(--accent-rgb), 0.6), inset 0 0 14px rgba(255, 255, 255, 0.3);
  animation: brainBeat 4.5s ease-in-out infinite;
}
@keyframes brainBeat {
  0%, 100% { box-shadow: 0 0 22px rgba(var(--accent-rgb), 0.45), inset 0 0 12px rgba(255, 255, 255, 0.25); }
  50% { box-shadow: 0 0 40px rgba(var(--accent-rgb), 0.8), inset 0 0 16px rgba(255, 255, 255, 0.38); }
}
.brain-title-text { min-width: 0; }
.brain-title-text h2 { margin: 0; font-size: 16.5px; font-weight: 600; letter-spacing: 0.01em; }
.brain-title-text p { margin: 4px 0 0; font-size: 11.5px; color: var(--dim-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.brain-tools { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.brain-search {
  width: 190px;
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: rgba(10, 9, 18, 0.65);
  outline: none;
  font-size: 13px;
  transition: 0.18s;
}
.brain-search:focus { border-color: rgba(var(--accent-rgb), 0.55); background: rgba(10, 9, 18, 0.9); }
.brain-search::placeholder { color: var(--dim-2); }
.brain-tools .mini-btn { height: 38px; }

/* чистильщик: список того, что не о ней и не о знакомых. Карточка поверх
   карты, но внутри неё: Esc и клик по фону закрывают только его. */
.cleaner {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 84px 20px 28px;
  background: rgba(4, 3, 9, 0.62);
  backdrop-filter: blur(6px);
}
.cleaner[hidden] { display: none; }
.cleaner-card {
  width: min(720px, 100%);
  max-height: calc(100% - 20px);
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(22, 19, 38, 0.97), rgba(10, 9, 18, 0.98));
  box-shadow: 0 40px 120px -40px #000;
  overflow: hidden;
}
.cleaner-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line-2);
}
.cleaner-title h3 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: 0.01em; }
.cleaner-title p { margin: 5px 0 0; font-size: 12px; color: var(--dim-2); line-height: 1.45; }
.cleaner-body {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 22px 18px;
}
.cleaner-wait, .cleaner-empty {
  margin: 28px 4px;
  font-size: 13px;
  color: var(--dim);
  text-align: center;
}
.cleaner-group { margin: 16px 0 22px; }
.cleaner-group-head { display: flex; align-items: baseline; gap: 8px; }
.cleaner-group-title { margin: 0; font-size: 12px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: #c9c2ff; }
.cleaner-group-count {
  font-size: 11px;
  color: var(--dim-2);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  padding: 1px 8px;
}
.cleaner-group-note { margin: 6px 0 10px; font-size: 11.8px; line-height: 1.5; color: var(--dim-2); }
.cleaner-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  margin: 2px 0;
  border-radius: 12px;
  cursor: pointer;
  transition: 0.14s;
}
.cleaner-row:hover { background: rgba(255, 255, 255, 0.045); }
.cleaner-row input { margin: 3px 0 0; accent-color: rgb(var(--accent-rgb)); }
.cleaner-row-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.cleaner-row-key { font-size: 13px; font-weight: 600; color: #f0edff; }
.cleaner-row-value { flex-basis: 100%; font-size: 12.5px; line-height: 1.5; color: var(--dim); overflow-wrap: anywhere; }
.cleaner-row-why { flex-basis: 100%; font-size: 11px; color: var(--dim-2); }
.cleaner-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line-2);
}
.cleaner-count { font-size: 12px; color: var(--dim-2); }
.cleaner-actions { display: flex; gap: 8px; }
.cleaner-go {
  border-color: rgba(255, 143, 171, 0.4) !important;
  color: #ffc2d1 !important;
  background: rgba(255, 143, 171, 0.12) !important;
}
.cleaner-go:hover { background: rgba(255, 143, 171, 0.2) !important; }
.cleaner-go:disabled { opacity: 0.45; cursor: default; }
@media (max-width: 700px) {
  .cleaner { padding: 76px 10px 16px; }
  .cleaner-head, .cleaner-body, .cleaner-foot { padding-left: 14px; padding-right: 14px; }
  .cleaner-foot { flex-direction: column; align-items: stretch; }
  .cleaner-actions { justify-content: flex-end; }
}

.brain-panel {
  position: absolute;
  z-index: 3;
  top: 84px;
  right: 20px;
  bottom: auto;
  max-height: calc(100% - 108px);
  width: min(360px, 32vw);
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(20, 17, 35, 0.9), rgba(10, 9, 18, 0.94));
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 90px -50px #000;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.bp-empty-title { margin: 6px 0 8px; font-size: 14.5px; font-weight: 600; }
.bp-empty .note { margin-top: 0; font-size: 12.5px; line-height: 1.5; }
.bp-head { display: flex; align-items: center; gap: 8px; }
.bp-kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 7px;
  color: var(--dim);
  background: rgba(255, 255, 255, 0.06);
}
.bp-kind.fact { color: #aab6ff; background: rgba(139, 156, 255, 0.14); }
.bp-kind.event { color: #8cc4ff; background: rgba(107, 168, 255, 0.14); }
.bp-kind.preference { color: #ffd98a; background: rgba(255, 209, 102, 0.14); }
.bp-kind.feeling { color: #ffa9c0; background: rgba(255, 143, 171, 0.14); }
.bp-close { margin-left: auto; }
.bp-key { margin: 12px 0 8px; font-size: 19px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.bp-value { margin: 0 0 12px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.bp-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.bp-tag {
  font-size: 11px;
  color: var(--dim);
  border: 1px solid var(--line-2);
  padding: 2px 9px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.02);
}
.bp-stats { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 16px 0 0; font-size: 12.5px; }
.bp-stats dt { color: var(--dim-2); }
.bp-stats dd { margin: 0; }
.bp-links-title {
  margin: 18px 0 8px;
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim-2);
  font-weight: 600;
}
.bp-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bp-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
  transition: 0.16s;
}
.bp-link:hover { border-color: rgba(var(--accent-rgb), 0.4); background: rgba(var(--accent-rgb), 0.1); }
.bp-link-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.bp-link-key { font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-link-kind { margin-left: auto; font-size: 10.5px; color: var(--dim-2); flex-shrink: 0; }
.bp-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.bp-actions .mini-btn { height: 32px; }
.bp-note { margin: 14px 0 0; font-size: 11.5px; color: var(--dim-2); line-height: 1.45; }
.bp-person {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid rgba(var(--accent-rgb), 0.24);
  background: rgba(var(--accent-rgb), 0.08);
  color: color-mix(in srgb, var(--accent) 70%, white);
  font-size: 11.5px;
  transition: 0.16s;
}
.bp-person:hover { background: rgba(var(--accent-rgb), 0.16); }

.brain-legend {
  position: absolute;
  z-index: 3;
  left: 22px;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(10, 9, 18, 0.66);
  backdrop-filter: blur(8px);
  font-size: 11.5px;
  color: var(--dim);
}
.brain-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.brain-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.brain-hint {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--dim-2);
  pointer-events: none;
  white-space: nowrap;
}

.brain-blank {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  pointer-events: none;
  padding: 0 24px;
}
.brain-blank[hidden] { display: none; }
.brain-blank-title { margin: 0; font-size: 18px; font-weight: 600; }
.brain-blank-text { margin: 0; max-width: 320px; font-size: 13px; color: var(--dim-2); line-height: 1.5; }

@media (max-width: 1080px) {
  .brain-panel { width: min(320px, 34vw); }
  .brain-tools .mini-btn { display: none; }
}

@media (max-width: 900px) {
  .brain-head { padding: 14px 14px 0; gap: 10px; }
  .brain-title-text p { display: none; }
  .brain-orb { width: 32px; height: 32px; }
  .brain-tools { gap: 6px; }
  .brain-search { width: 148px; height: 36px; }
  .brain-tools .mini-btn { display: none; }
  .brain-panel {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: 44%;
    padding: 14px 16px;
    border-radius: 18px;
  }
  .brain-panel.empty { max-height: 116px; }
  .brain-hint, .brain-legend { display: none; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: #1c1930;
  border: 1px solid var(--line-2);
  color: var(--text);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 20px 50px -20px #000;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
  z-index: 40;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ====== анимации ====== */
@keyframes breathe {
  0%, 100% { transform: scale(0.94); opacity: 0.45; }
  50% { transform: scale(1.06); opacity: 0.7; }
}
@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.012); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 90px -14px rgba(var(--accent-rgb), 0.6), inset 0 -22px 46px rgba(0, 0, 0, 0.6); }
  50% { transform: scale(1.045); box-shadow: 0 0 130px -8px rgba(var(--accent-rgb), 0.95), inset 0 -22px 46px rgba(0, 0, 0, 0.6); }
}
@keyframes ping {
  0% { transform: scale(1); opacity: 0.65; }
  100% { transform: scale(1.65); opacity: 0; }
}
@keyframes level {
  0%, 100% { height: 5px; opacity: 0.45; }
  50% { height: 22px; opacity: 1; }
}
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dot {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
@keyframes swirl {
  0% { transform: rotate(-6deg) scale(1); }
  50% { transform: rotate(5deg) scale(1.07); }
  100% { transform: rotate(-3deg) scale(1.02); }
}

/* ====== мобильный ====== */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
    padding: 12px 0 12px;
  }
  .avatar-pane {
    padding: 0 4px;
    min-height: 0;
    width: 100%;
  }
  .avatar-pane::after { display: none; }
  .face {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin: 0;
    width: 100%;
    flex: 1;
  }
  .orb-shell { width: 58px; margin-bottom: 0; }
  .orb-halo { inset: -14%; filter: blur(10px); }
  .caption, .levels, .pane-foot, .face-status, .face-meta { display: none; }
  .emotion-pill { margin-left: auto; flex-shrink: 0; }
  .msg { max-width: 100%; }
  .hint { display: none; }
}

@media (max-width: 560px) {
  .app { padding: 0 12px; }
  .topbar { height: 58px; }
  .orb-shell { width: 46px; }
  #input { font-size: 15.5px; }
}

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

/* «↑ вспомнила» — тихая строка перед ответом */
.msg.recall {
  align-self: flex-start;
  max-width: min(78%, 620px);
  font-size: 12px;
  line-height: 1.4;
  color: var(--dim-2);
  background: none;
  border: 1px dashed var(--line-2);
  padding: 5px 10px;
  border-radius: 10px;
  animation: fade 0.3s both;
}
/* «промолчала» - она прочитала и решила не отвечать: не ошибка и не пузырь */
.msg.silent {
  align-self: flex-start;
  max-width: min(78%, 620px);
  font-size: 12px;
  font-style: italic;
  line-height: 1.4;
  color: var(--dim-2);
  background: none;
  border: none;
  padding: 2px 10px;
  animation: fade 0.3s both;
}

/* сон: «она спит» - это состояние, а не молчание и не ошибка */
.msg.silent.asleep {
  color: var(--dim-1, var(--dim-2));
  font-style: italic;
}

/* Значки под ответом: палец вниз и палец вверх. Тихие, но всегда рядом -
   правка нужна сразу, пока человек помнит, чего он ждал от ответа. */
.msg-review {
  align-self: flex-start;
  display: flex;
  gap: 2px;
  margin: -6px 0 6px 4px;
  animation: fade 0.3s both;
}
.review-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--dim-2);
  background: none;
  border: 1px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s, color 0.15s, background 0.15s, border-color 0.15s;
}
.review-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.msg-review:hover .review-btn { opacity: 0.9; }
.review-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.review-dislike:hover { color: #dfa0a0; }
.review-like:hover { color: #9ed6a6; }
.review-btn:disabled { cursor: default; }
.review-btn:focus-visible { outline: 2px solid var(--line-2); outline-offset: 2px; }
.msg-review.sending .review-btn { opacity: 0.5; }
/* после оценки выбранный значок остаётся ярким, второй только угадывается */
.msg-review.done .review-btn { opacity: 0.28; }
.msg-review.done .review-btn[aria-pressed="true"] { opacity: 1; }
.msg-review.done .review-like[aria-pressed="true"] {
  color: #8fd6a0;
  background: rgba(143, 214, 160, 0.12);
}
.msg-review.done .review-dislike[aria-pressed="true"] {
  color: #e0a3a3;
  background: rgba(224, 163, 163, 0.12);
}

/* «Учёба» в шторке: кнопки и цифры корпуса */
.study-row { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }

/* Примеры учёбы: тот же материал, что уйдёт в обучение, но глазами - промпт,
   вход, ответ и правка. Счётчик в шторке говорит «сколько», этот экран - «что». */
.study {
  position: fixed;
  inset: 0;
  z-index: 62;
  display: flex;
  flex-direction: column;
  padding: 18px clamp(12px, 3vw, 40px) 22px;
  background: radial-gradient(110% 80% at 50% -10%, #161320 0%, #0b0a12 55%, #060509 100%);
  opacity: 0;
  transition: opacity 0.24s ease;
}
.study.open { opacity: 1; }
.study-head {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(1040px, 100%);
  margin: 0 auto;
}
.study-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.study-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 11px;
  border: 1px solid rgba(var(--accent-rgb), 0.34);
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
  font-size: 19px;
}
.study-title-text { min-width: 0; }
.study-title-text h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: 0.01em; }
.study-title-text p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--dim-2);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.study-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.study-search {
  width: 220px;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.study-search::placeholder { color: var(--dim-2); }
.study-search:focus { border-color: rgba(var(--accent-rgb), 0.5); background: rgba(255, 255, 255, 0.06); }
.study-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: min(1040px, 100%);
  margin: 12px auto 0;
}
.study-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.03);
  color: var(--dim);
  font-size: 12px;
  transition: 0.16s;
}
.study-chip:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.study-chip b { font-weight: 600; font-size: 11px; color: var(--dim-2); }
.study-chip[aria-pressed="true"] { color: #0d0b14; background: var(--accent); border-color: transparent; }
.study-chip[aria-pressed="true"] b { color: rgba(13, 11, 20, 0.66); }
.study-list {
  width: min(1040px, 100%);
  margin: 12px auto 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
  scrollbar-width: thin;
}
.study-card {
  padding: 12px 14px 10px;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(23, 20, 38, 0.92), rgba(17, 15, 28, 0.92));
}
.study-card.is-fixed {
  border-color: rgba(var(--accent-rgb), 0.32);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.08);
}
.study-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.study-when { margin-right: 2px; font-size: 11.5px; color: var(--dim-2); }
.study-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--dim);
}
.study-tag.dim { color: var(--dim-2); background: transparent; }
.study-tag.fix { color: #ffd9a8; background: rgba(255, 170, 80, 0.13); border-color: rgba(255, 170, 80, 0.3); }
.study-tag.good { color: #9ce6c3; background: rgba(90, 220, 160, 0.1); border-color: rgba(90, 220, 160, 0.28); }
.study-prompt { margin-top: 9px; }
.study-prompt summary {
  cursor: pointer;
  list-style: none;
  font-size: 11.5px;
  color: var(--dim-2);
}
.study-prompt summary::-webkit-details-marker { display: none; }
.study-prompt summary::before { content: "▸ "; }
.study-prompt[open] summary::before { content: "▾ "; }
.study-prompt pre {
  margin: 7px 0 0;
  padding: 10px 12px;
  max-height: 260px;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.32);
  color: var(--dim);
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.study-prompt-empty { margin: 8px 0 0; font-size: 11.5px; color: var(--dim-2); }
.study-bubble { display: flex; flex-direction: column; gap: 3px; margin-top: 9px; }
.study-bubble b {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim-2);
}
.study-bubble p { margin: 0; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.study-bubble.in p { color: var(--dim); }
.study-bubble.out p { color: var(--text); }
.study-bubble.fix {
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid rgba(255, 170, 80, 0.28);
  background: rgba(255, 170, 80, 0.07);
}
.study-bubble.fix b { color: #ffd9a8; }
.study-bubble.fix em { margin-top: 2px; font-style: normal; font-size: 11.5px; color: var(--dim); }
.study-meta { margin-top: 8px; font-size: 10.5px; letter-spacing: 0.03em; color: var(--dim-2); }
.study-more {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(1040px, 100%);
  margin: 12px auto 0;
}
.study-more-note { font-size: 11.5px; color: var(--dim-2); }
.study-hint { margin: 10px auto 0; font-size: 11px; letter-spacing: 0.04em; color: var(--dim-2); }
.study-empty {
  padding: 22px;
  border: 1px dashed var(--line-2);
  border-radius: 16px;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: var(--dim-2);
}

/* Переключатель «примеры / переписки»: один экран, два разных разбора. */
.study-modes {
  display: flex;
  gap: 6px;
  width: min(1040px, 100%);
  margin: 12px auto 0;
}
.study-mode {
  height: 28px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.03);
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.02em;
  transition: 0.16s;
}
.study-mode:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.study-mode[aria-selected="true"] {
  color: #0d0b14;
  background: var(--accent);
  border-color: transparent;
  font-weight: 600;
}

/* Полоса материала: сколько пар уже есть и из чего они собраны. Счётчики
   раньше жили в шторке; теперь окно отдельное, а кнопки «Обновить» и «Собрать
   корпус» стоят рядом с тем, что они считают. */
.study-material {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(1040px, 100%);
  margin: 10px auto 0;
  padding: 8px 12px 8px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.055);
  background: rgba(255, 255, 255, 0.022);
}
.study-material-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 14px;
  flex: 1;
  min-width: 0;
}
.study-material-count {
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 0.02em;
}
.study-kinds {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.study-kinds li {
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--dim-2);
}
.study-material-btns { display: flex; gap: 6px; flex-shrink: 0; }
.study-material .mini-btn { height: 30px; padding: 0 11px; font-size: 12px; }

/* Оба режима занимают остаток высоты: список примеров и лента переписки
   листаются внутри, а не тянут за собой весь экран. */
.study-examples {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.study-examples[hidden],
.study-chats[hidden] { display: none; }
.study-chats {
  display: flex;
  gap: 14px;
  width: min(1040px, 100%);
  margin: 12px auto 0;
  flex: 1;
  min-height: 0;
}
.study-chats-list {
  width: 260px;
  flex-shrink: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
  scrollbar-width: thin;
}
.study-chat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.025);
  color: var(--dim);
  text-align: left;
  transition: 0.16s;
}
.study-chat:hover { color: var(--text); background: rgba(255, 255, 255, 0.055); }
.study-chat.on {
  border-color: rgba(var(--accent-rgb), 0.42);
  background: rgba(var(--accent-rgb), 0.1);
}
.study-chat b { font-size: 13px; font-weight: 600; color: var(--text); }
.study-chat span { font-size: 10.5px; color: var(--dim-2); letter-spacing: 0.02em; }
.study-chat em { font-style: normal; font-size: 10.5px; color: var(--dim-2); }
.study-thread-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
}
.study-thread-head {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--dim);
}
.study-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 16px;
  scrollbar-width: thin;
}
/* Реплики в ленте: его слева, её справа - как в переписке, а не как в логе. */
.study-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 14px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.035);
}
.study-msg.in { align-self: flex-start; }
.study-msg.out {
  align-self: flex-end;
  border-color: rgba(var(--accent-rgb), 0.24);
  background: rgba(var(--accent-rgb), 0.07);
}
.study-msg-head { display: flex; align-items: center; gap: 8px; }
.study-msg-head b { font-size: 11px; font-weight: 600; color: var(--dim); }
.study-msg-head span { font-size: 10px; color: var(--dim-2); }
.study-msg-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
}
.study-msg-text.silent { color: var(--dim-2); font-style: italic; }

/* Оценка внутри разбора: те же тихие значки, что в чате, но рядом с ними
   может раскрыться форма правки - здесь человек разбирает не спеша. */
.study-rate { margin-top: 4px; }
.study-rate .msg-review { margin: 0; }
.study-rate-why {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  align-self: center;
  font-size: 10.5px;
  color: var(--dim-2);
}
.study-fix {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 170, 80, 0.26);
  background: rgba(255, 170, 80, 0.05);
}
.study-fix-text,
.study-fix-why {
  width: 100%;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  line-height: 1.45;
  resize: vertical;
  outline: none;
}
.study-fix-text:focus,
.study-fix-why:focus { border-color: rgba(var(--accent-rgb), 0.5); }
.study-fix-actions { display: flex; gap: 6px; }

@media (max-width: 760px) {
  .study-chats { flex-direction: column; }
  .study-chats-list {
    width: 100%;
    max-height: 30vh;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .study-chat { min-width: 180px; }
  /* Полоса материала на узком окне переносится: кнопки не должны выдавливать
     счётчик за край. */
  .study-material { flex-wrap: wrap; }
  .study-material-btns { margin-left: auto; }
}

/* люди: карточки знакомых в шторке и модалка карточки */
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.people li.person-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  font-size: 13px;
  cursor: pointer;
  transition: 0.18s;
}
.people li.person-row:hover,
.people li.person-row:focus-visible {
  background: rgba(var(--accent-rgb), 0.07);
  border-color: rgba(var(--accent-rgb), 0.3);
  outline: none;
}
.people .avatar-dot,
.person-dot {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--accent) 72%, white);
  background: radial-gradient(circle at 35% 30%, rgba(var(--accent-rgb), 0.5), rgba(var(--accent-rgb), 0.1) 72%);
  border: 1px solid rgba(var(--accent-rgb), 0.32);
}
.people .avatar-dot[data-kind="owner"],
.person-dot[data-kind="owner"] {
  color: #0d0b14;
  background: radial-gradient(circle at 35% 30%, #fff, var(--accent) 78%);
  border-color: transparent;
}
.people .avatar-dot[data-kind="guest"],
.person-dot[data-kind="guest"] {
  color: var(--dim-2);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--line-2);
}
.people .person-line { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.people .person-line b { font-weight: 600; overflow-wrap: anywhere; }
.people .person-line small { color: var(--dim-2); font-size: 11.5px; overflow-wrap: anywhere; }
.people .person-line .twin-chip {
  margin-left: 3px;
  padding: 1px 5px;
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--dim-2);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  vertical-align: 1px;
}
.people .empty {
  color: var(--dim-2);
  font-size: 12.5px;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px dashed var(--line-2);
}

/* Сводка вместо списка: сами папки живут в досье. Сотня знакомых не должна
   растягивать вкладку «Память» на несколько экранов скролла. */
.people-brief {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}
.people-brief-head { display: flex; align-items: baseline; gap: 6px; }
.people-brief-num { font-size: 20px; font-weight: 700; line-height: 1; color: var(--text); }
.people-brief-label { font-size: 12.5px; color: var(--dim); }
.people-brief-line { margin: 0; font-size: 11.5px; color: var(--dim-2); overflow-wrap: anywhere; }
.people-brief-empty { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--dim-2); }
.people-actions { margin-top: 8px; }

/* Сводка вместо списка: сам список знакомых живёт в досье (папки на столе).
   Сотня человек не должна растягивать вкладку «Память» на несколько экранов. */
.people-brief {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}
.people-brief-head { display: flex; align-items: baseline; gap: 6px; }
.people-brief-num { font-size: 20px; font-weight: 700; line-height: 1; color: var(--text); }
.people-brief-label { font-size: 12.5px; color: var(--dim); }
.people-brief-line { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--dim-2); overflow-wrap: anywhere; }
.people-brief-empty { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--dim-2); }
.people-actions { margin-top: 8px; }

.person {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 3, 9, 0.66);
  backdrop-filter: blur(9px);
  opacity: 0;
  transition: opacity 0.2s;
}
.person[hidden] { display: none; }
.person[hidden] { display: none; }
.person.show { opacity: 1; }
.person-card {
  width: min(540px, 100%);
  max-height: 86vh;
  overflow: auto;
  padding: 18px 20px 22px;
  border-radius: 20px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(23, 21, 36, 0.97), rgba(12, 11, 20, 0.97));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  transform: translateY(10px) scale(0.99);
  transition: transform 0.24s;
}
.person.show .person-card { transform: none; }
.person-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.person-head h2 { margin: 0; flex: 1; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.person-body { display: flex; flex-direction: column; gap: 10px; }
.person-body h3 {
  margin: 6px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim-2);
}
.identities { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.identities li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 10px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.identities li.empty {
  color: var(--dim-2);
  font-size: 12.5px;
  border: 1px dashed var(--line-2);
  background: none;
}
.identities .x { margin-left: auto; }
.person .x,
.identities .x {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--dim-2);
  font-size: 11px;
  transition: 0.15s;
}
.person .x:hover,
.identities .x:hover { color: #ff9b9b; background: rgba(255, 107, 107, 0.12); }
.person .danger-btn { margin-top: 4px; }

/* ---------- телеграм: настройка и очередь ---------- */
/* Строка статуса: «бот · чат · в очереди N». Жёлтым — когда настроено не до
   конца, чтобы «почему не пишет» было видно без чтения логов. */
#tg-status { margin: 2px 0 8px; }
#tg-status.warn { color: #ffd166; }

.tg-outbox { gap: 5px; margin-bottom: 2px; }
.tg-outbox li.note-item {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  padding-right: 34px;
}
.tg-outbox .tg-text { flex: 1 1 100%; color: var(--text); overflow-wrap: anywhere; }
.tg-outbox .note-meta { margin-left: 0; }
.tg-outbox .tg-error { flex: 1 1 100%; font-size: 11px; color: #ff8fab; overflow-wrap: anywhere; }
.tg-outbox li.tg-sent { opacity: 0.6; }
.tg-outbox li.tg-failed { border-color: rgba(255, 107, 129, 0.35); }
.tg-outbox .mini-btn { padding: 2px 8px; font-size: 11px; }

/* ---------- телеграм: входящие ---------- */
/* Журнал входящих: кто написал и что она ответила. Строки те же, что у
   очереди, но ответ уходит на вторую строку со стрелкой и акцентом — иначе
   при быстром ответе непонятно, где письмо, а где её реплика. */
.tg-inbox { margin-top: 12px; display: grid; gap: 8px; }
.tg-inbox .check { padding: 8px 10px; font-size: 12.5px; }
.tg-inbox .check:has(input:disabled) { opacity: 0.55; }
.tg-inbox .check input:disabled { cursor: default; }
#tg-inbox-meta { margin: 0; font-size: 12px; }

.tg-inbox-list { gap: 5px; max-height: 210px; overflow-y: auto; }
.tg-inbox-list:empty { display: none; }
.tg-inbox-list li.note-item {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
}
.tg-inbox-list .tg-text { flex: 1 1 100%; color: var(--text); overflow-wrap: anywhere; }
.tg-inbox-list .note-meta { margin-left: 0; }
.tg-inbox-list .tg-reply {
  flex: 1 1 100%;
  font-size: 11.5px;
  color: rgba(var(--accent-rgb), 0.85);
  overflow-wrap: anywhere;
}
.tg-inbox-list .tg-error { flex: 1 1 100%; font-size: 11px; color: #ff8fab; overflow-wrap: anywhere; }
.tg-inbox-list li.tg-ignored { opacity: 0.6; }
.tg-inbox-list li.tg-failed { border-color: rgba(255, 107, 129, 0.35); }
/* «Ждёт ответа» - не ошибка, а срок: подпись серая, без тревожного красного. */
.tg-inbox-list li.tg-waiting .tg-error { color: var(--dim-2); }
.tg-inbox-list li.tg-waiting { opacity: 0.85; }

/* ---------- зрение: экран ---------- */
/* Миниатюра последнего кадра: видно, что она правда смотрела и на какой
   монитор — если снимок не тот, это заметно сразу, без чтения логов. */
.screen-shot {
  margin: 8px 0 2px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  background: rgba(0, 0, 0, 0.35);
}
.screen-shot img { display: block; width: 100%; height: auto; }
#screen-status.warn { color: #ffd166; }
#screen-what {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
  opacity: 0.9;
}

/* ---------- зрение: экран ---------- */
/* Миниатюра последнего кадра: доказательство, что она правда смотрела, и
   способ заметить, что снят не тот монитор. */
.screen-shot {
  margin: 8px 0 2px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  background: rgba(0, 0, 0, 0.35);
}
.screen-shot img { display: block; width: 100%; height: auto; }
#screen-status.warn { color: #ffd166; }
#screen-what {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
  opacity: 0.9;
}

/* ---------- зрение: экран ---------- */
/* Миниатюра последнего кадра — доказательство, что она правда смотрела, и
   способ заметить, что снимок не тот (например, не тот монитор). */
.screen-shot {
  margin: 8px 0 2px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  background: rgba(0, 0, 0, 0.35);
}
.screen-shot img { display: block; width: 100%; height: auto; }
#screen-status { margin: 2px 0 0; }
#screen-status.warn { color: #ffd166; }
#screen-what {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
  opacity: 0.9;
}
.screen-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.screen-row .text-input { width: auto; max-width: 78px; text-align: center; }
.screen-row .mini-btn { margin-left: auto; }

/* Цель съёмки: режим, поля области, список окон. Поля области — четыре
   числа в один ряд: так видно, что это прямоугольник, а не четыре настройки. */
.screen-target { margin: 10px 0 8px; }
.screen-target .row-inline { margin-bottom: 8px; }
.screen-region {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}
.screen-region .text-input { padding: 8px 6px; text-align: center; }
#screen-region-hint { margin: 0; }
#screen-target-note { margin: 0; }


/* Кнопки «Найти чат» и «Проверить связь» — ровно пополам, а не первая на всю строку. */
.row-inline:has(#tg-find) { grid-template-columns: 1fr 1fr; }

/* ====== телеграм: переключатель «бот / свой аккаунт» ====== */
/* Две кнопки в общей плашке: видно, что это один выбор из двух, а не две
   разные команды. Активная залита акцентом — тем же, что и голосовые кнопки. */
.tg-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 10px 0 12px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
}
.tg-mode {
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--dim-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.tg-mode:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.tg-mode.on {
  background: var(--accent);
  color: #0d0b14;
  font-weight: 600;
}

/* Поля входа стоят столбиком: без отступа они слипаются в одну серую массу. */
#tg-acc-login > .text-input { margin-bottom: 8px; }
#tg-account-pane > .note:first-child { margin: 0 0 10px; }
#tg-acc-me { margin: 0 0 8px; color: var(--dim-2); }

.danger-mini {
  border-color: rgba(255, 107, 129, 0.35);
  background: rgba(255, 107, 129, 0.1);
  color: #ff9b9b;
}
.danger-mini:hover { background: rgba(255, 107, 129, 0.2); }

/* --- твич --- */
/* Чат стрима — это поток: держим его в рамке с прокруткой, иначе шторка
   уезжает вниз от чужих сообщений. */
.twitch-chat {
  max-height: 190px;
  overflow-y: auto;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.twitch-chat:empty { display: none; }
.twitch-chat .note-item {
  align-items: baseline;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.35;
}
.twitch-chat .note-item b { flex: 0 0 auto; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.twitch-chat .note-item span { color: var(--dim); overflow-wrap: anywhere; }
.twitch-chat .empty { opacity: 0.7; }
/* Кнопка «посмотреть сейчас» стоит в ряду одна: рядом с длинной подсказкой
   grid рвал высоту строки, и текст налезал на кнопку. Подсказка — отдельным
   абзацем ниже. */
.twitch-look-row { grid-template-columns: 1fr; margin-bottom: 6px; }
.twitch-look-row .mini-btn { height: 38px; width: 100%; }
/* «качество · раз в N секунд» — одной строкой. В grid на две колонки эти четыре
   элемента съезжали в 2x2, и «раз в» висело справа от списка качеств. */
.twitch-timing { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.twitch-timing .text-input { width: auto; }
.twitch-timing .note { margin: 0; }
.twitch-hear-row { margin-bottom: 6px; }
.twitch-hear-row .mini-btn { white-space: nowrap; }
#twitch-lang { width: 132px; max-width: 132px; }
#twitch-heard { color: #cfd6ff; }
/* Вход в чат: токен и две кнопки в один ряд. Обычный row-inline на две колонки
   выдавил бы «Выйти» на новую строку, оставив пустоту. */
.twitch-login-row { grid-template-columns: minmax(0, 1fr) auto auto; }
/* Отчёт «сказала в чат»: что ушло и что не ушло. Не больше пяти строк —
   это подсказка, а не журнал. */
.twitch-sent {
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.twitch-sent:empty { display: none; }
.twitch-sent .note-item { font-size: 12.5px; line-height: 1.35; }
.twitch-sent .note-item.bad { color: #ffb3b3; }
#twitch-quality { width: 96px; max-width: 96px; }
#twitch-interval { width: 78px; max-width: 78px; }
#twitch-login-status.warn { color: #ffd166; }
#twitch-token-life { margin-top: 4px; }
#twitch-token-life.warn { color: #ffd166; opacity: 1; }
#twitch-frame-wrap img { width: 100%; border-radius: 12px; display: block; }

/* --- она сама: чувства, решение и дневник опыта --- */
#mind-status.warn { color: #ffd166; opacity: 1; }
.mind-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.mind-row .text-input { width: 74px; max-width: 74px; }
.mind-row .mini-btn { margin-left: auto; }
/* Характер: три ползунка. Значение дублируется числом — на глаз по полоске
   не понять, насколько она смелая. */
.mind-range-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0 2px;
  font-size: 12.5px;
  color: var(--dim);
}
.mind-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: 4px 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  accent-color: var(--accent);
  cursor: pointer;
}
.mind-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.18);
}
.mind-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
}
/* Характер: три ползунка. Родной range красим accent-color — иначе в тёмной
   теме он остаётся белым и выбивается из шторки. */
.mind-range-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin: 10px 0 2px;
  font-size: 12.5px;
  color: var(--dim);
}
.mind-range-label:first-of-type { margin-top: 4px; }
.mind-range {
  width: 100%;
  margin: 0 0 2px;
  accent-color: var(--accent);
  cursor: pointer;
}
.mind-range:disabled { opacity: 0.45; cursor: default; }
.mind-feelings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}
.mind-feel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--dim);
}
.mind-feel-head b { color: var(--text); font-weight: 500; }
.mind-bar {
  height: 6px;
  margin-top: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.mind-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.55), var(--accent));
}
.mind-feel-mood .mind-bar i { background: linear-gradient(90deg, #7ac7ff, #8b9cff); }
.mind-feel-urge .mind-bar i { background: linear-gradient(90deg, #ffb86b, #ff7a7a); }
.mind-feel-lonely .mind-bar i { background: linear-gradient(90deg, #9be7c4, #6fd3ff); }
.mind-feel-hurt .mind-bar i { background: linear-gradient(90deg, #ff9b9b, #ff6b6b); }

/* Мораль: вина и принципы. Полоска вины как у чувств, но своя. */
.morality-guilt { margin: 10px 0 6px; }
.morality-guilt .mind-bar i { background: linear-gradient(90deg, #ffd27a, #ff7a7a); }
/* Ползунок гибкости: как полоска вины, но красит не состояние, а решение. */
.morality-flex { margin: 12px 0 8px; }
.morality-flex input[type="range"] {
  width: 100%;
  margin: 2px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.morality-flex-ends {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 1px;
  font-size: 11px;
  color: var(--dim-2);
}
.morality-principles { margin: 10px 0 8px; }
.morality-principles summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--dim);
}
.morality-principles .notes { margin-top: 6px; }
.morality-principles .note-item { font-size: 12.5px; }

/* Живость: кто её задел и насколько сильно. */
.mind-relations {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}
.mind-rel {
  padding: 7px 9px;
  border-radius: 9px;
  font-size: 12px;
  color: var(--dim);
  background: rgba(255, 255, 255, 0.04);
}
.mind-rel b { color: var(--text); font-weight: 500; }
.mind-rel-closed {
  color: #ffc9c9;
  background: rgba(255, 107, 107, 0.10);
}
.mind-rel-empty {
  color: var(--dim-2);
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.10);
}
#mind-episodes .mind-when { color: var(--dim-2); font-size: 11px; }
#mind-episodes .mind-kind {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim-2);
}
.mini-btn.mind-forget { margin-top: 10px; color: #ff9b9b; }
.mini-btn.mind-forget:hover { background: rgba(255, 107, 107, 0.12); }

/* Сны: что она записала в журнал и что ей приснилось. Воспоминание выделено
   полоской, чтобы его не путали с очередной строкой наблюдений. */
#dream-observations .mind-when { color: var(--dim-2); font-size: 11px; }
#dream-observations .mind-kind {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim-2);
}
#dream-observations li.note-item span:last-child { color: var(--text); overflow-wrap: anywhere; }
.note.dream-last {
  margin-top: 8px;
  padding: 9px 11px;
  border-left: 2px solid rgba(167, 139, 250, 0.45);
  background: rgba(167, 139, 250, 0.08);
  color: var(--text);
  font-style: italic;
  line-height: 1.45;
}

/* Кнопка сна — во всю строку: у правого края шторки её подрезало. */
#btn-dream-wake { width: 100%; height: 34px; }

/* ==================== досье: стол с папками ==================== */
/* Отдельный оверлей, не шторка: кнопка «Досье» в топбаре открывает стол.
   Папки - крафт с 3D-створкой, внутри - бумажный лист дела.
   Смотреть здесь, менять - в карточке человека (z-index 60 выше досье). */

.dossier-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 11px 0 9px;
  border-radius: 10px;
  border: 1px solid rgba(216, 180, 131, 0.22);
  background: rgba(216, 180, 131, 0.07);
  color: #e8d9bd;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.dossier-btn:hover { background: rgba(216, 180, 131, 0.14); border-color: rgba(216, 180, 131, 0.4); }
.dossier-btn:active { transform: translateY(1px); }
.dossier-btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.dossier-btn-count {
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #d8b483;
  color: #1c1408;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0;
}

.dossier {
  --dossier-type: "Courier New", "Cascadia Mono", "Consolas", monospace;
  position: fixed;
  inset: 0;
  z-index: 58;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text);
  background: radial-gradient(120% 90% at 50% -10%, #17131f 0%, #0b0a12 52%, #060509 100%);
  opacity: 0;
  transition: opacity 0.34s ease;
}
.dossier.open { opacity: 1; }
.dossier::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 220px rgba(0, 0, 0, 0.78);
}
.dossier-room {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1000px 560px at 50% -6%, rgba(216, 180, 131, 0.13), transparent 62%),
    radial-gradient(820px 520px at 86% 106%, rgba(139, 156, 255, 0.08), transparent 62%),
    radial-gradient(620px 420px at 6% 94%, rgba(216, 180, 131, 0.05), transparent 62%);
}

.dossier-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px 0;
}
.dossier-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dossier-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid rgba(216, 180, 131, 0.4);
  background: rgba(216, 180, 131, 0.1);
  color: #e3cba3;
  font-family: var(--dossier-type);
  font-size: 20px;
  font-weight: 700;
  transform: rotate(-3deg);
}
.dossier-title-text { min-width: 0; }
.dossier-title-text h2 {
  margin: 0;
  font-family: var(--dossier-type);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.dossier-title-text p {
  margin: 3px 0 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--dim-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dossier-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.dossier-search {
  width: 200px;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(216, 180, 131, 0.18);
  background: rgba(9, 8, 14, 0.62);
  color: var(--text);
  font-family: var(--dossier-type);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.dossier-search::placeholder { color: rgba(216, 200, 170, 0.36); }
.dossier-search:focus { border-color: rgba(216, 180, 131, 0.5); background: rgba(9, 8, 14, 0.85); }
.dossier-tools .icon-btn { color: #d9c8ab; }

/* Дело можно завести и руками: не всякий знакомый успел где-то написать,
   а знать о нём Мия уже может. Кнопка живёт в шапке, форма - под стопками. */
.dossier-new-btn {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(216, 180, 131, 0.28);
  background: rgba(216, 180, 131, 0.08);
  color: #e3cba3;
  font-family: var(--dossier-type);
  font-size: 12px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.dossier-new-btn:hover,
.dossier-new-btn[aria-expanded="true"] {
  color: #f3e7cf;
  border-color: rgba(216, 180, 131, 0.5);
  background: rgba(216, 180, 131, 0.16);
}
.dossier-new {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 22px 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(216, 180, 131, 0.26);
  background: rgba(9, 8, 14, 0.74);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
}
.dossier-new[hidden] { display: none; }
.dossier-new-field {
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(216, 180, 131, 0.2);
  background: rgba(9, 8, 14, 0.66);
  color: var(--text);
  font-family: var(--dossier-type);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.16s ease;
}
.dossier-new-field::placeholder { color: rgba(216, 200, 170, 0.36); }
.dossier-new-field:focus { border-color: rgba(216, 180, 131, 0.5); }
.dossier-new-name { flex: 1 1 150px; min-width: 0; }
.dossier-new-handle { flex: 1 1 170px; min-width: 0; }
.dossier-new select.dossier-new-field { flex: 0 0 auto; cursor: pointer; }
.dossier-new-ok,
.dossier-new-cancel {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(216, 180, 131, 0.3);
  background: rgba(216, 180, 131, 0.12);
  color: #f3e7cf;
  font-family: var(--dossier-type);
  font-size: 12px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.dossier-new-ok:hover { background: rgba(216, 180, 131, 0.2); }
.dossier-new-cancel {
  border-color: rgba(216, 180, 131, 0.16);
  background: none;
  color: rgba(216, 200, 170, 0.66);
}
.dossier-new-cancel:hover { color: #e8d9bd; border-color: rgba(216, 180, 131, 0.4); }
.dossier-new-err {
  flex: 1 0 100%;
  margin: 0;
  font-family: var(--dossier-type);
  font-size: 11.5px;
  color: #e08f8f;
}
.dossier-new-err[hidden] { display: none; }
/* Подсказка до отправки: такое имя уже есть. Не запрет - тёзки бывают
   настоящие, - но видно, что заводится второе дело, а не дописывается первое. */
.dossier-new-hint {
  flex: 1 0 100%;
  margin: 0;
  font-family: var(--dossier-type);
  font-size: 11.5px;
  line-height: 1.45;
  color: #e2c28a;
}
.dossier-new-hint[hidden] { display: none; }
.dossier-blank-new {
  align-self: center;
  margin-top: 10px;
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid rgba(216, 180, 131, 0.3);
  background: rgba(216, 180, 131, 0.1);
  color: #f3e7cf;
  font-family: var(--dossier-type);
  font-size: 12px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.dossier-blank-new:hover { background: rgba(216, 180, 131, 0.2); border-color: rgba(216, 180, 131, 0.5); }

/* Стопки по типу знакомства: бумажные ярлыки под шапкой досье. Дело не в
   красоте - без них случайные зрители из чата лежат вперемешку с друзьями. */
.dossier-filters {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 22px 0;
}
.dossier-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(216, 180, 131, 0.18);
  border-radius: 7px;
  background: rgba(9, 8, 14, 0.5);
  color: rgba(216, 200, 170, 0.66);
  font-family: var(--dossier-type);
  font-size: 11px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.dossier-chip:hover { color: #e8d9bd; border-color: rgba(216, 180, 131, 0.4); }
.dossier-chip[aria-pressed="true"] {
  color: #f3e7cf;
  border-color: rgba(216, 180, 131, 0.55);
  background: rgba(216, 180, 131, 0.16);
}
.dossier-chip-num {
  font-size: 10px;
  font-weight: 700;
  color: rgba(216, 180, 131, 0.72);
}
.dossier-chip[aria-pressed="true"] .dossier-chip-num { color: #f0dfc0; }
.dossier-chip.empty { opacity: 0.45; }
.dossier-chip.empty[aria-pressed="true"] { opacity: 0.72; }
.dossier-chip:focus-visible { outline: 2px solid rgba(216, 180, 131, 0.55); outline-offset: 2px; }

.dossier-scene {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 34px 30px 86px;
  perspective: 1500px;
  perspective-origin: 50% 38%;
  scrollbar-width: thin;
  scrollbar-color: rgba(216, 180, 131, 0.22) transparent;
}
.dossier-scene::-webkit-scrollbar { width: 9px; }
.dossier-scene::-webkit-scrollbar-thumb { background: rgba(216, 180, 131, 0.2); border-radius: 9px; }
.dossier-scene::-webkit-scrollbar-track { background: transparent; }

.dossier-desk {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 52px 30px;
  max-width: 1180px;
  margin: 0 auto;
  transform-style: preserve-3d;
  transform: rotateX(var(--tx, 0deg)) rotateY(var(--ty, 0deg));
  transition: transform 0.35s ease-out;
}

.dossier-blank {
  position: absolute;
  left: 50%;
  top: 52%;
  z-index: 3;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 48px));
  padding: 22px 24px;
  text-align: center;
  border: 1px dashed rgba(216, 180, 131, 0.3);
  border-radius: 6px;
  background: rgba(10, 8, 15, 0.6);
}
.dossier-blank-title {
  margin: 0;
  font-family: var(--dossier-type);
  font-size: 15px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #e0cba6;
}
.dossier-blank-text { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--dim-2); }

.dossier-hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 2;
  margin: 0;
  transform: translateX(-50%);
  font-family: var(--dossier-type);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.28);
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- папка ---------- */

.dfolder {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1.5;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  z-index: 1;
  perspective: 900px;
  animation: dfolder-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 26ms);
}
.dfolder:hover, .dfolder:focus-visible { z-index: 2; }
.dfolder:focus-visible { outline: 2px solid rgba(216, 180, 131, 0.65); outline-offset: 4px; border-radius: 6px; }
.dfolder.chosen { z-index: 6; }
.dfolder.gone { display: none; }

@keyframes dfolder-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.dfolder-3d {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateZ(var(--tilt, 0deg)) rotateX(7deg) translateZ(var(--z, 0px));
  transition: transform 0.32s ease;
}
.dfolder:hover .dfolder-3d {
  transform: rotateZ(0deg) rotateX(0deg) translateY(-5px) translateZ(6px);
}
.dfolder.chosen .dfolder-3d {
  transform: rotateZ(0deg) rotateX(2deg) translateY(-8px) translateZ(12px);
}

.dfolder-back {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: 2px 7px 7px 7px;
  background: linear-gradient(180deg, #b7905e, #8f6b3c);
  box-shadow:
    0 26px 30px -18px rgba(0, 0, 0, 0.9),
    0 8px 14px -10px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px rgba(48, 33, 14, 0.4),
    inset 0 0 26px rgba(70, 48, 20, 0.28);
}
.dfolder-back-line { height: 1px; background: rgba(56, 38, 16, 0.22); }
.dfolder-back-line:nth-child(2) { width: 62%; }
.dfolder-back-line:nth-child(3) { width: 78%; }

.dfolder-papers { position: absolute; inset: 11px 12px 9px 12px; }
.dfolder-paper {
  position: absolute;
  inset: 0;
  border-radius: 1px;
  background: linear-gradient(180deg, #f6ecd7, #e8d9ba);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  background-image: repeating-linear-gradient(
    180deg,
    transparent 0 10px,
    rgba(96, 102, 128, 0.28) 10px 11px
  );
  background-size: 62% 100%;
  background-position: 14px 14px;
  background-repeat: no-repeat;
}
.dfolder-paper.paper-1 { transform: rotate(-1.4deg) translateY(-2px); }
.dfolder-paper.paper-2 { transform: rotate(1.1deg) translateY(1px); opacity: 0.92; }

.dfolder-tab {
  position: absolute;
  left: 9px;
  top: -19px;
  height: 22px;
  max-width: 72%;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 5px 8px 0 0;
  background: linear-gradient(180deg, #cfae7f, #b18856);
  box-shadow: inset 0 0 0 1px rgba(48, 33, 14, 0.32);
  transform: translateZ(2px);
}
.dfolder-tab-text {
  font-family: var(--dossier-type);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #33250f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dfolder-flap {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform 0.62s cubic-bezier(0.3, 0.9, 0.25, 1);
}
.dfolder.unsealed .dfolder-flap { transform: rotateY(-166deg); }

.dfolder-cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  padding: 12px 13px 11px;
  overflow: hidden;
  border-radius: 2px 7px 7px 7px;
  background:
    linear-gradient(105deg, rgba(255, 255, 255, 0.16), transparent 42%),
    linear-gradient(180deg, #d9b787, #bd9161 62%, #ab7f4d);
  box-shadow:
    inset 0 0 0 1px rgba(48, 33, 14, 0.34),
    inset 0 0 30px rgba(70, 48, 20, 0.18);
  backface-visibility: hidden;
}
.dfolder-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0 2px,
    transparent 2px 5px
  );
  opacity: 0.5;
}
.dfolder[data-kind="owner"] .dfolder-cover {
  background:
    linear-gradient(105deg, rgba(255, 255, 255, 0.18), transparent 44%),
    linear-gradient(180deg, #e2c294, #c69b68 62%, #b08451);
}

.dfolder-cover-back {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 7px 2px 2px 7px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 2px, transparent 2px 5px),
    linear-gradient(180deg, #c6a273, #a97f4c);
  box-shadow: inset 0 0 0 1px rgba(48, 33, 14, 0.34);
  transform: rotateY(180deg);
  backface-visibility: hidden;
}
.dfolder-back-text {
  font-family: var(--dossier-type);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(52, 36, 14, 0.55);
  transform: rotate(-90deg);
}

.dfolder-stamp {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 7px;
  border: 1.5px solid rgba(150, 44, 38, 0.5);
  border-radius: 2px;
  font-family: var(--dossier-type);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(150, 44, 38, 0.72);
  transform: rotate(-7deg);
}
.dfolder-kind {
  position: absolute;
  top: 10px;
  left: 11px;
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px solid rgba(52, 38, 16, 0.3);
  font-family: var(--dossier-type);
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(52, 38, 16, 0.7);
  background: rgba(255, 250, 240, 0.18);
}
.dfolder-kind.kind-owner { border-color: rgba(150, 44, 38, 0.45); color: rgba(122, 34, 28, 0.85); }
.dfolder-kind.kind-guest { border-color: rgba(48, 62, 104, 0.4); color: rgba(46, 62, 104, 0.8); }
.dfolder-kind.kind-chat { border-color: rgba(52, 38, 16, 0.22); color: rgba(56, 40, 16, 0.55); }

/* Тёзка: на столе есть ещё папка с таким же именем. Вторая, пунктирная
   печать под штампом: имя общее, а дело своё - смотри номер. */
.dfolder-twin {
  position: absolute;
  top: 31px;
  right: 10px;
  padding: 1px 6px;
  border: 1px dashed rgba(150, 44, 38, 0.5);
  border-radius: 2px;
  font-family: var(--dossier-type);
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(122, 34, 28, 0.8);
  background: rgba(255, 250, 240, 0.22);
  transform: rotate(-2deg);
}

.dfolder-label { position: relative; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dfolder-no {
  font-family: var(--dossier-type);
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(56, 40, 16, 0.62);
}
.dfolder-name {
  font-family: var(--dossier-type);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.15;
  color: #2b1f10;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dfolder-meta {
  margin-top: 2px;
  font-size: 9.5px;
  line-height: 1.3;
  color: rgba(56, 40, 16, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- лист дела ---------- */

.dossier-shade {
  position: fixed;
  inset: 0;
  z-index: 7;
  background: radial-gradient(80% 70% at 50% 46%, rgba(4, 3, 8, 0.5), rgba(4, 3, 8, 0.82));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.dossier-shade.show { opacity: 1; }

.dossier-sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 8;
  width: min(680px, calc(100vw - 32px));
  max-height: min(84vh, 820px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 28px 20px 32px;
  border-radius: 2px;
  color: #2c2114;
  font-family: var(--dossier-type);
  background:
    radial-gradient(140% 90% at 8% 0%, rgba(126, 96, 47, 0.16), transparent 58%),
    radial-gradient(120% 80% at 96% 104%, rgba(126, 96, 47, 0.14), transparent 60%),
    linear-gradient(180deg, #f7eeda, #ecdfc6 70%, #e6d7bb);
  box-shadow:
    0 50px 110px -40px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(80, 60, 32, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  opacity: 0;
  transform: translate(-50%, -50%) translateY(18px) scale(0.985);
  transition: opacity 0.3s ease, transform 0.52s cubic-bezier(0.2, 0.9, 0.3, 1);
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 94, 52, 0.4) transparent;
}
.dossier-sheet::-webkit-scrollbar { width: 8px; }
.dossier-sheet::-webkit-scrollbar-thumb { background: rgba(120, 94, 52, 0.35); border-radius: 8px; }
.dossier-sheet.show { opacity: 1; transform: translate(-50%, -50%) translateY(0) scale(1); }
.dossier-sheet.from-folder {
  opacity: 0;
  transform: translate(-50%, -50%) translate(var(--dx, 0px), var(--dy, 0px)) perspective(700px) rotateX(14deg) scale(0.22);
  transition: none;
}

.dsheet-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.dsheet-no {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #7a6242;
}
.dsheet-stamp {
  border: 2px solid rgba(170, 52, 46, 0.5);
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(170, 52, 46, 0.78);
  transform: rotate(-4deg);
}
.dsheet-x {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: auto;
  flex-shrink: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #7a6242;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.dsheet-x:hover { background: rgba(90, 70, 40, 0.12); color: #2c2114; }

.dsheet-body { display: flex; align-items: flex-start; gap: 22px; }
.dsheet-photo { flex: 0 0 116px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dsheet-face {
  position: relative;
  display: grid;
  place-items: center;
  width: 112px;
  height: 130px;
  font-size: 36px;
  font-weight: 700;
  color: #5f4a2c;
  background: linear-gradient(160deg, #dfd1b4, #c6b28d 70%, #b9a37c);
  box-shadow:
    inset 0 0 0 1px rgba(80, 60, 32, 0.35),
    inset 0 0 40px rgba(90, 60, 20, 0.2),
    0 10px 18px -14px rgba(0, 0, 0, 0.7);
}
.dsheet-face::before,
.dsheet-face::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border: 0 solid rgba(120, 95, 55, 0.55);
}
.dsheet-face::before { left: 6px; top: 6px; border-left-width: 1px; border-top-width: 1px; }
.dsheet-face::after { right: 6px; bottom: 6px; border-right-width: 1px; border-bottom-width: 1px; }
.dsheet-photo-note {
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8a7450;
  text-align: center;
}

.dsheet-main { flex: 1; min-width: 0; }
.dsheet-name {
  margin: 0 0 5px;
  font-size: 27px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.dsheet-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 13px; }
.dsheet-tag {
  padding: 3px 7px;
  border: 1px solid rgba(90, 70, 40, 0.34);
  border-radius: 3px;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6f5a3a;
}
.dsheet-tag-twin { border-color: rgba(150, 44, 38, 0.45); color: #8a2f26; }
/* В деле: кто ещё носит это имя. Ссылка ведёт в соседнее дело - номер и
   логин и есть различие между тёзками. */
.dsheet-twins { margin: 0 0 11px; font-size: 11.5px; line-height: 1.5; color: #6b563a; }
.dsheet-twins-label {
  font-family: var(--dossier-type);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8a7450;
}
.dsheet-twin-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: #8a2f26;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}
.dsheet-twin-link:hover { color: #b03a2e; }
.dsheet-fields { display: flex; flex-direction: column; gap: 7px; margin: 0; }
.dsheet-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.dsheet-key-label {
  font-family: var(--dossier-type);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8a7450;
}
.dsheet-value {
  margin: 0;
  font-family: var(--font, inherit);
  font-size: 13px;
  line-height: 1.45;
  color: #2c2114;
  overflow-wrap: anywhere;
}
/* Осадок от грубости на листе дела: та же тёплая краснота, что и в карточке.
   На бумаге она темнее - светлый тон на бежевом не читается. */
.dsheet-value.cold { color: #a2434a; }
/* Осадок в деле: та же бумага, но чернила краснее - «мне неприятно» должно
   бросаться в глаза при чтении папки, а не прятаться в сером. */
.dsheet-value.cold { color: #9c3b3b; }
/* Холод на листе дела: чернила не чёрные, а выцветшие рыжие - «здесь что-то
   не так», но всё ещё пометка, а не ошибка. */
.dsheet-value.cold { color: #a03b33; }

.dsheet-notes { margin-top: 18px; padding-top: 12px; border-top: 1px dashed rgba(90, 70, 40, 0.34); }
.dsheet-h3 {
  margin: 0 0 8px;
  font-family: var(--dossier-type);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #7a6242;
}
.dsheet-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dsheet-note {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 8px;
  padding-left: 12px;
  font-size: 13px;
  line-height: 1.4;
}
.dsheet-note::before { content: "·"; position: absolute; left: 2px; color: #a08a63; font-weight: 700; }
.dsheet-note-empty { color: #8a7450; font-style: italic; }
.dsheet-kind {
  padding: 1px 5px;
  border: 1px solid rgba(90, 70, 40, 0.34);
  border-radius: 2px;
  font-family: var(--dossier-type);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #7a6242;
}
.dsheet-kind.kind-routine { border-color: rgba(120, 90, 40, 0.5); color: #6b5124; }
.dsheet-kind.kind-gender,
.dsheet-kind.kind-alias { border-color: rgba(90, 100, 140, 0.42); color: #4a5a80; }
.dsheet-note-key { font-weight: 700; color: #2c2114; }
.dsheet-note-value { color: #3a2d1c; overflow-wrap: anywhere; }

.dsheet-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px dashed rgba(90, 70, 40, 0.34);
}
.dsheet-count { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: #8a7450; }
.dsheet-btn {
  height: 34px;
  margin-left: auto;
  padding: 0 14px;
  border-radius: 4px;
  border: 1px solid rgba(60, 45, 25, 0.48);
  background: rgba(60, 45, 25, 0.08);
  color: #2c2114;
  font-family: var(--dossier-type);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease;
}
.dsheet-btn:hover { background: rgba(60, 45, 25, 0.16); }
.dsheet-btn:active { transform: translateY(1px); }

@media (max-width: 1080px) {
  .dossier-scene { padding: 30px 22px 80px; }
  .dossier-desk { gap: 48px 24px; }
}

@media (max-width: 900px) {
  .dossier-search { width: 150px; }
  .dossier-filters { padding: 10px 16px 0; }
  .dossier-desk { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); }
}

@media (max-width: 640px) {
  .dossier-head { gap: 10px; padding: 12px 14px 0; }
  .dossier-mark { width: 36px; height: 36px; font-size: 17px; }
  .dossier-title-text h2 { font-size: 16px; }
  .dossier-title-text p { display: none; }
  .dossier-search { width: 138px; height: 34px; font-size: 11.5px; }
  /* ярлыки не переносятся на вторую строку, а листаются пальцем */
  .dossier-filters {
    padding: 10px 14px 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .dossier-filters::-webkit-scrollbar { display: none; }
  .dossier-btn { padding: 0 9px 0 8px; }
  .dossier-btn-label { display: none; }
  .dossier-scene { padding: 26px 14px 70px; }
  .dossier-desk { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 42px 16px; }
  .dfolder-name { font-size: 13px; }
  .dfolder-meta { font-size: 8.5px; }
  .dfolder-tab-text { font-size: 9.5px; }
  .dossier-hint { display: none; }
  .dossier-sheet { padding: 16px 16px 16px 18px; max-height: 88vh; }
  .dsheet-body { flex-direction: column; gap: 14px; }
  .dsheet-photo { flex-direction: row; align-items: center; gap: 12px; }
  .dsheet-face { width: 62px; height: 72px; font-size: 23px; }
  .dsheet-name { font-size: 22px; }
  .dsheet-row { grid-template-columns: 1fr; gap: 2px; }
}

/* юмор и сарказм: не ползунки, а слова - «сдержанная», «живая», «дурашливая».
   Тумблер и ряд кнопок-режимов: видно сразу, какой у неё голос сейчас. */
.wit-modes { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 6px; }
.wit-mode {
  font: inherit;
  font-size: 12.5px;
  padding: 6px 11px;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--dim-2);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: 0.16s;
}
.wit-mode:hover { color: var(--text); border-color: rgba(var(--accent-rgb), 0.45); }
.wit-mode[aria-checked="true"] {
  color: var(--text);
  border-color: rgba(var(--accent-rgb), 0.7);
  background: rgba(var(--accent-rgb), 0.16);
}
.wit-jokes { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.wit-jokes li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.45;
}
.wit-jokes li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.wit-jokes li .x {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 7px;
  color: var(--dim-2);
  font-size: 13px;
  line-height: 1;
}
.wit-jokes li .x:hover { color: #ff9b9b; background: rgba(255, 107, 107, 0.12); }

/* ==================== банк данных ====================
   Хранилище её опыта: слева ячейки наблюдений, в центре сейф со снами,
   справа полки заметок. Сцена рисуется в canvas, здесь - только рама
   окна, панель записи и мелочи, которые дешевле сделать в CSS. */
.bank-btn {
  border-color: rgba(139, 156, 255, 0.24);
  background: rgba(139, 156, 255, 0.08);
  color: #dfe3ff;
}
.bank-btn:hover { background: rgba(139, 156, 255, 0.16); border-color: rgba(139, 156, 255, 0.45); }

/* Кнопка карты памяти в шапке, рядом с банком и досье. Сиреневая, чтобы
   не сливалась с золотым досье и голубым банком. Счётчик - число заметок
   на карте, его пишет graph.js. */
.brain-btn {
  border-color: rgba(167, 139, 250, 0.26);
  background: rgba(167, 139, 250, 0.09);
  color: #e7ddff;
}
.brain-btn:hover { background: rgba(167, 139, 250, 0.17); border-color: rgba(167, 139, 250, 0.48); }
.brain-btn .dossier-btn-count { background: #a78bfa; color: #171021; }

/* Кнопка учёбы в шапке: зелёная, чтобы не путалась с золотым досье, голубым
   банком и сиреневой картой. Раньше экран жил в шторке, теперь это такое же
   отдельное окно, как остальные. */
.study-btn {
  border-color: rgba(126, 214, 178, 0.26);
  background: rgba(126, 214, 178, 0.08);
  color: #d8f5e8;
}
.study-btn:hover { background: rgba(126, 214, 178, 0.16); border-color: rgba(126, 214, 178, 0.46); }

.bank {
  position: fixed;
  inset: 0;
  z-index: 62;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
  background:
    radial-gradient(1200px 820px at 50% 44%, rgba(90, 110, 200, 0.1), transparent 66%),
    linear-gradient(180deg, #05060c, #04050a 70%);
}
.bank[hidden] { display: none; }
.bank.open { opacity: 1; }

.bank-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  z-index: 0;
  cursor: grab;
}
.bank-canvas.grabbing { cursor: grabbing; }
.bank-canvas.hot { cursor: pointer; }

/* Туман по краям: медленные пятна, которые не дают раме выглядеть плоско.
   Те же цвета, что у спрайтов в canvas, поэтому небо и туман сливаются. */
.bank-haze {
  position: absolute;
  top: -14%;
  bottom: -14%;
  width: 30%;
  z-index: 1;
  pointer-events: none;
  opacity: 0.88;
  filter: blur(40px);
}
.bank-haze-l {
  left: -12%;
  background: radial-gradient(closest-side at 42% 46%, rgba(96, 116, 210, 0.4), rgba(70, 84, 170, 0.1) 58%, transparent 78%);
  animation: hazeDriftL 21s ease-in-out infinite alternate;
}
.bank-haze-r {
  right: -12%;
  background: radial-gradient(closest-side at 58% 54%, rgba(126, 112, 220, 0.36), rgba(80, 74, 170, 0.09) 58%, transparent 78%);
  animation: hazeDriftR 26s ease-in-out infinite alternate;
}
@keyframes hazeDriftL {
  from { transform: translate3d(-2%, 1.5%, 0) scale(1.02); opacity: 0.58; }
  to { transform: translate3d(3%, -2%, 0) scale(1.12); opacity: 0.82; }
}
@keyframes hazeDriftR {
  from { transform: translate3d(2%, -1.5%, 0) scale(1.06); opacity: 0.62; }
  to { transform: translate3d(-3%, 2%, 0) scale(1.14); opacity: 0.86; }
}
@media (prefers-reduced-motion: reduce) {
  .bank-haze { animation: none; }
}

.bank-head {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px 0;
  pointer-events: none;
}
.bank-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.bank-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid rgba(160, 176, 255, 0.3);
  background: linear-gradient(160deg, rgba(160, 176, 255, 0.2), rgba(120, 130, 220, 0.05));
  color: #e3e6ff;
  box-shadow: 0 0 22px rgba(130, 146, 255, 0.22), inset 0 0 12px rgba(190, 200, 255, 0.12);
}
.bank-title-text { min-width: 0; }
.bank-title-text h2 { margin: 0; font-size: 16.5px; font-weight: 600; letter-spacing: 0.01em; }
.bank-title-text p { margin: 4px 0 0; font-size: 11.5px; color: var(--dim-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bank-tools { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.bank-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--line-2);
  background: rgba(10, 9, 18, 0.6);
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
}
.bank-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(160, 176, 255, 0.6);
  box-shadow: 0 0 8px rgba(160, 176, 255, 0.7);
}
.bank-chip.busy { color: #cfe0ff; border-color: rgba(140, 180, 255, 0.4); }
.bank-chip.busy::before { background: #8fc2ff; animation: bankPulse 1.4s ease-in-out infinite; }
.bank-chip.sleep { color: #ffe1b3; border-color: rgba(255, 210, 150, 0.32); }
.bank-chip.sleep::before { background: #ffcf8a; box-shadow: 0 0 10px rgba(255, 207, 138, 0.7); }
@keyframes bankPulse {
  0%, 100% { opacity: 0.45; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Листание снов: ячеек двенадцать, снов со временем больше. */
.bank-pager {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 30px;
  padding: 0 3px;
  border-radius: 99px;
  border: 1px solid var(--line-2);
  background: rgba(10, 9, 18, 0.6);
}
.bank-pager[hidden] { display: none; }
.bank-arrow {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.bank-arrow:hover:not(:disabled) { background: rgba(160, 176, 255, 0.16); color: #eef0ff; }
.bank-arrow:disabled { opacity: 0.28; cursor: default; }
.bank-page {
  min-width: 42px;
  text-align: center;
  font-size: 11.5px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.bank-panel {
  position: absolute;
  z-index: 3;
  top: 84px;
  right: 20px;
  box-sizing: border-box;
  max-height: calc(100% - 108px);
  width: min(372px, 33vw);
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(18, 18, 34, 0.9), rgba(8, 9, 17, 0.95));
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 90px -50px #000;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.bk-head { display: flex; align-items: center; gap: 8px; }
.bk-close { margin-left: auto; }
.bk-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 7px;
  color: var(--dim);
  background: rgba(255, 255, 255, 0.06);
}
.bk-chip[data-tone="dream"] { color: #ffe6b8; background: rgba(255, 226, 170, 0.14); }
.bk-chip[data-tone="wait"] { color: #ffc46b; background: rgba(255, 196, 107, 0.14); }
.bk-chip[data-tone="done"] { color: #a8b6ef; background: rgba(112, 134, 200, 0.16); }
.bk-chip[data-tone="note"] { color: #c9beff; background: rgba(169, 155, 255, 0.14); }
.bk-chip[data-tone="cold"] { color: #b9c8ff; background: rgba(140, 170, 255, 0.14); }

.bk-title { margin: 12px 0 8px; font-size: 18px; font-weight: 650; line-height: 1.28; overflow-wrap: anywhere; }
.bk-text { margin: 0 0 12px; font-size: 13.5px; line-height: 1.55; color: #e9ebf7; white-space: pre-wrap; overflow-wrap: anywhere; }
.bk-pair { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.bk-note-key { font-size: 18px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.bk-note-value { font-size: 13.5px; line-height: 1.55; color: #e9ebf7; overflow-wrap: anywhere; }
.bk-facts { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 14px 0 0; font-size: 12.5px; }
.bk-facts dt { color: var(--dim-2); }
.bk-facts dd { margin: 0; overflow-wrap: anywhere; }
.bk-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.bk-tag {
  font-size: 11px;
  color: var(--dim);
  border: 1px solid var(--line-2);
  padding: 2px 9px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.02);
}
.bk-hint { margin: 14px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--dim-2); }

/* Разбор сна: панель справа повторяет то, что вскрыто в сцене, но словами
   и целиком - сцену можно вертеть, а читать в ней мелко. */
.bk-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 16px 0 6px;
}
.bk-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}
.bk-stats b { font-size: 18px; font-weight: 650; color: #f2effc; }
.bk-stats span { font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--dim-2); }

.bk-sec-h {
  margin: 18px 0 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 220, 170, 0.52);
}

.bk-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bk-li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.045);
  background: rgba(255, 255, 255, 0.018);
  font-size: 12.5px;
  line-height: 1.45;
}
.bk-li-empty { color: var(--dim-2); font-size: 12px; }
.bk-li-meta { font-size: 10.5px; color: var(--dim-2); white-space: nowrap; }
.bk-li-text { flex: 1 1 100%; color: #e6e3f4; overflow-wrap: anywhere; }
.bk-li .bk-li-meta + .bk-li-text { flex-basis: auto; }
.bk-kind {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
  color: #dad3ff;
  background: rgba(185, 170, 255, 0.14);
  white-space: nowrap;
}
.bk-kind[data-kind="fact"] { color: #bfe6ff; background: rgba(143, 208, 255, 0.12); }
.bk-kind[data-kind="event"] { color: #ffcde8; background: rgba(255, 179, 217, 0.12); }
.bk-kind[data-kind="preference"] { color: #ffe4b0; background: rgba(255, 217, 138, 0.12); }
.bk-kind[data-kind="feeling"] { color: #d6ccff; background: rgba(185, 170, 255, 0.14); }

.bk-feel { display: flex; align-items: center; gap: 12px; margin: 0 0 4px; font-size: 13px; color: #e9e5f8; }
.bk-feel > span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.bk-mood {
  position: relative;
  flex: 0 0 96px;
  height: 4px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(120, 150, 240, 0.55), rgba(180, 180, 210, 0.3), rgba(255, 205, 140, 0.6));
}
.bk-mood i {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: #fff1d4;
  box-shadow: 0 0 8px rgba(255, 240, 210, 0.8);
}

.bk-open {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.bk-open:hover {
  background: rgba(255, 220, 170, 0.07);
  border-color: rgba(255, 220, 170, 0.28);
}
/* Прогулка в списке - не кнопка: её не вскрыть, это просто запись. */
.bk-open.bk-static { cursor: default; }
.bk-open.bk-static:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.05);
}
.bk-open .bk-row-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.45;
  color: #e6e3f4;
}
.bk-row-time { font-size: 10.5px; color: rgba(255, 220, 170, 0.62); }

body.bank-view { overflow: hidden; }

.bank-legend {
  position: absolute;
  z-index: 3;
  left: 22px;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 9, 17, 0.66);
  backdrop-filter: blur(8px);
  font-size: 11.5px;
  color: var(--dim);
}
.bank-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.bank-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.bank-dot[data-tone="wait"] { background: #ffc46b; box-shadow: 0 0 8px rgba(255, 196, 107, 0.55); }
.bank-dot[data-tone="done"] { background: #7086c8; }
.bank-dot[data-tone="dream"] { background: #ffdca8; box-shadow: 0 0 8px rgba(255, 220, 168, 0.55); }
.bank-dot[data-tone="open"] { background: #fff0cf; box-shadow: 0 0 10px rgba(255, 240, 207, 0.75); }
.bank-dot[data-tone="ghost"] { background: transparent; border: 1px dashed rgba(120, 132, 170, 0.55); }
.bank-dot[data-tone="note"] { background: #a99bff; }

.bank-hint {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--dim-2);
  pointer-events: none;
  white-space: nowrap;
}

.bank-blank {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  pointer-events: none;
  padding: 0 24px;
}
.bank-blank[hidden] { display: none; }
.bank-blank-title { margin: 0; font-size: 18px; font-weight: 600; }
.bank-blank-text { margin: 0; max-width: 340px; font-size: 13px; color: var(--dim-2); line-height: 1.5; }

@media (max-width: 1080px) {
  .bank-panel { width: min(330px, 36vw); }
  .bank-legend { gap: 10px; font-size: 10.5px; padding: 8px 11px; }
}

@media (max-width: 900px) {
  .bank-head { padding: 14px 14px 0; gap: 10px; }
  .bank-title-text p { display: none; }
  .bank-mark { width: 34px; height: 34px; }
  .bank-chip { display: none; }
  .bank-panel {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 44vh;
  }
  .bank-legend { display: none; }
  .bank-hint { display: none; }
}

/* Карта промпта: третий тихий значок под ответом и панель «почему так». */
.trace-mask { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(4, 3, 10, 0.62); backdrop-filter: blur(3px); }
.trace-panel { width: min(720px, 100%); max-height: min(82vh, 900px); overflow: auto; padding: 18px 20px 20px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55); }
.trace-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.trace-title { font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.trace-sub { font-size: 12px; color: var(--dim-2); }
.trace-close { margin-left: auto; width: 30px; height: 30px; border-radius: 50%; border: 1px solid transparent; background: none; color: var(--dim); font-size: 20px; line-height: 1; cursor: pointer; }
.trace-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.trace-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 14px; }
.trace-meta-item { display: flex; gap: 6px; font-size: 12px; }
.trace-meta-name { color: var(--dim-2); }
.trace-meta-value { color: var(--text); }
.trace-blocks { display: grid; gap: 5px; margin-bottom: 14px; }
.trace-block { display: grid; grid-template-columns: 140px 1fr 48px; align-items: center; gap: 8px; font-size: 12px; }
.trace-block-name { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trace-block-bar { height: 6px; background: rgba(255, 255, 255, 0.05); border-radius: 3px; overflow: hidden; }
.trace-block-bar i { display: block; height: 100%; background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.35), rgba(var(--accent-rgb), 0.8)); }
.trace-block-size { color: var(--dim-2); text-align: right; font-variant-numeric: tabular-nums; }
.trace-empty { font-size: 12px; color: var(--dim-2); }
.trace-said { padding: 10px 12px; margin-bottom: 12px; font-size: 13px; color: var(--dim); background: rgba(255, 255, 255, 0.03); border-left: 2px solid var(--line-2); border-radius: 8px; white-space: pre-wrap; }
.trace-full summary { font-size: 12px; color: var(--dim-2); cursor: pointer; }
.trace-full pre { margin: 10px 0 0; padding: 12px; max-height: 46vh; overflow: auto; font-size: 11.5px; line-height: 1.5; white-space: pre-wrap; color: var(--dim); background: rgba(0, 0, 0, 0.25); border-radius: 10px; }
