/* Шива-кабинет v2 — визуальный клон claude.ai (спек 2026-07-05-kabinet-klon-claude-ai-spek.md).
   Ф1: токены тёплой палитры (светлая — дефолт, тёмная — data-theme/система), антиква Lora
   в ответах и заголовках, каркас сайдбара с разделами. Контракт двух вёрсток сохранён:
   десктоп (сайдбар слева) и ≤640px. Яркое — только терракотовый акцент и семантика. */

/* ── Шрифт: Lora (аналог фирменной антиквы claude.ai, кириллица, self-host) ── */
@font-face { font-family: "Lora"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/lora-normal-400-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Lora"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/lora-normal-400-cyrillic-ext.woff2) format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "Lora"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/lora-normal-400-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Lora"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(fonts/lora-normal-600-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Lora"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(fonts/lora-normal-600-cyrillic-ext.woff2) format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "Lora"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(fonts/lora-normal-600-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Lora"; font-style: italic; font-weight: 400; font-display: swap;
  src: url(fonts/lora-italic-400-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Lora"; font-style: italic; font-weight: 400; font-display: swap;
  src: url(fonts/lora-italic-400-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ── Токены. Светлая тема (дефолт claude.ai): тёплый крем + терракота ── */
:root {
  --bg: #faf9f5;            /* полотно чата */
  --bg-side: #f0eee6;       /* сайдбар «овсянка» */
  --surface: #ffffff;       /* карточки, композер */
  --surface-2: #ece9de;     /* ховеры, инлайн-код, шапки таблиц */
  --border: #e0ddd1;
  --text: #1f1e1d;          /* тёплый почти-чёрный */
  --dim: #75726b;
  --accent: #d97757;        /* терракота — единственный яркий */
  --accent-hover: #c4623f;
  --accent-ink: #ffffff;    /* текст на терракоте */
  --user-bubble: #f0eee6;
  --code-bg: #1f1e1d;       /* код всегда тёмный, как у claude.ai */
  --shadow: 0 2px 12px rgba(31, 30, 29, .07);
  --ok: #5b8a5e;
  --err: #b3564d;
  --err-bg: rgba(179, 86, 77, .09);
  --radius: 12px;
  --font-serif: "Lora", Georgia, "Times New Roman", serif;
  font-size: 16px;
}
/* Тёмная тема — тёплый графит claude.ai (не сине-чёрный) */
:root[data-theme="dark"] {
  --bg: #262624;
  --bg-side: #1f1e1d;
  --surface: #30302e;
  --surface-2: #3a3936;
  --border: #413f3c;
  --text: #eceae4;
  --dim: #a6a29a;
  --accent: #d97757;
  --accent-hover: #e08a6d;
  --accent-ink: #ffffff;
  --user-bubble: #3a3936;
  --code-bg: #1f1e1d;
  --shadow: 0 2px 12px rgba(0, 0, 0, .35);
  --ok: #8fbf8f;
  --err: #e38c7f;
  --err-bg: rgba(227, 140, 127, .12);
}
/* Авто по системе: пока владелец не выбрал руками — слушаем ОС */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #262624;
    --bg-side: #1f1e1d;
    --surface: #30302e;
    --surface-2: #3a3936;
    --border: #413f3c;
    --text: #eceae4;
    --dim: #a6a29a;
    --accent: #d97757;
    --accent-hover: #e08a6d;
    --accent-ink: #ffffff;
    --user-bubble: #3a3936;
    --code-bg: #1f1e1d;
    --shadow: 0 2px 12px rgba(0, 0, 0, .35);
    --ok: #8fbf8f;
    --err: #e38c7f;
    --err-bg: rgba(227, 140, 127, .12);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
}
.hidden { display: none !important; }
button { font-family: inherit; }

/* ── Вход ── */
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 360px; text-align: center; }
.login-logo { width: 56px; height: 56px; line-height: 56px; margin: 0 auto 16px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 26px; font-weight: 600; font-family: var(--font-serif); }
.login-card h1 { font-size: 22px; font-weight: 600; font-family: var(--font-serif); }
.login-sub { color: var(--dim); font-size: 13px; margin: 4px 0 24px; }
.login-card input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 16px; padding: 12px 14px; margin-bottom: 12px; outline: none; }
.login-card input:focus { border-color: var(--accent); }
.login-card button { width: 100%; background: var(--accent); border: none; border-radius: 10px; color: var(--accent-ink); font-size: 15px; font-weight: 600; padding: 12px; cursor: pointer; }
.login-card button:hover { background: var(--accent-hover); }
.login-err { color: var(--err); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ── Каркас кабинета ── */
.cabinet { display: flex; height: 100vh; }

/* Сайдбар — «овсянка», разделы с ярлыками (Ф1-каркас: Чаты; Telegram придёт в Ф6) */
.sidebar { width: 268px; flex: 0 0 268px; background: var(--bg-side); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 14px 16px 10px; }
.brand { font-weight: 600; font-family: var(--font-serif); font-size: 17px; letter-spacing: .2px; }
.head-btns { display: flex; gap: 6px; }
.ghost { background: none; border: none; border-radius: 8px; color: var(--dim); padding: 4px 8px; cursor: pointer; font-size: 14px; }
.ghost:hover { background: var(--surface-2); color: var(--text); }
.new-thread { margin: 0 12px 12px; padding: 9px 12px; background: none; border: none; border-radius: 8px; color: var(--accent); font-size: 14px; font-weight: 500; cursor: pointer; text-align: left; }
.new-thread:hover { background: var(--surface-2); }
.side-label { padding: 2px 20px 6px; color: var(--dim); font-size: 12px; font-weight: 600; letter-spacing: .4px; }
.threads { overflow-y: auto; flex: 1; padding: 0 8px 12px; }
.thread {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px; margin-bottom: 1px;
  background: none; border: none; border-radius: 8px;
  color: var(--text); font-size: 14px; text-align: left; cursor: pointer;
}
.thread:hover { background: var(--surface-2); }
.thread.active { background: var(--surface-2); font-weight: 500; }
.thread-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Статус-точки: пульс = работает, сплошная терракота = есть результат, пустая = тихо */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: 0 0 8px; }
.dot.busy { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.dot.unread { background: var(--accent); }
@keyframes pulse { 50% { opacity: .35; } }

/* Чат */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--bg); }
.chat-head { display: flex; align-items: baseline; gap: 12px; padding: 14px 20px 10px; }
.chat-title { font-weight: 600; font-family: var(--font-serif); font-size: 16px; }
.chat-status { color: var(--dim); font-size: 13px; }

.feed { flex: 1; overflow-y: auto; }
.feed-inner { max-width: 760px; margin: 0 auto; padding: 8px 20px 24px; }

/* Сообщение-джоб: вопрос владельца (карточка) → работа (свёртка) → ответ (документ) */
.msg { content-visibility: auto; contain-intrinsic-size: auto 160px; margin-bottom: 26px; }
.msg-user { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.msg-user-inner {
  background: var(--user-bubble); border-radius: 16px 16px 6px 16px;
  padding: 10px 14px; max-width: 85%;
  white-space: pre-wrap; word-break: break-word; font-size: 15px;
}
.msg-time { color: var(--dim); font-size: 11px; margin-top: 4px; text-align: right; }

/* Свёртка работы («Работал N мин» + шаги) */
.work { margin: 8px 0; }
.work summary {
  list-style: none; cursor: pointer; color: var(--dim); font-size: 13px;
  display: flex; align-items: center; gap: 8px; user-select: none;
}
.work summary::-webkit-details-marker { display: none; }
.work summary::before { content: "▸"; transition: transform .15s; }
.work[open] summary::before { transform: rotate(90deg); }
.work-steps { margin: 8px 0 0 14px; border-left: 2px solid var(--border); padding-left: 12px; }
.step { color: var(--dim); font-size: 13px; padding: 2px 0; display: flex; gap: 8px; }
.step-t { color: var(--border); font-size: 11px; flex: 0 0 34px; padding-top: 2px; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Ответ — «как документ», антиква (фирменный приём claude.ai) */
.answer { font-size: 16px; line-height: 1.65; word-break: break-word; font-family: var(--font-serif); }
.answer > * + * { margin-top: 12px; }
.answer h1, .answer h2, .answer h3 { font-size: 1.15em; font-weight: 600; margin-top: 20px; }
.answer ul, .answer ol { padding-left: 22px; }
.answer li + li { margin-top: 4px; }
.answer blockquote { border-left: 3px solid var(--border); padding-left: 12px; color: var(--dim); }
.answer a { color: var(--accent); }
.answer code { background: var(--surface-2); border-radius: 5px; padding: 1px 6px; font-size: .85em; font-family: ui-monospace, Menlo, monospace; }
.answer pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; overflow-x: auto; }
.answer pre code { background: none; padding: 0; font-size: 13px; line-height: 1.5; }
.tblwrap { overflow-x: auto; }
.answer table { border-collapse: collapse; font-size: 14px; min-width: 240px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.answer th, .answer td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.answer th { background: var(--surface-2); }
.answer-failed { color: var(--err); background: var(--err-bg); border-radius: 10px; padding: 10px 14px; font-size: 14px; }

.to-bottom {
  position: absolute; right: 24px; bottom: 84px;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); cursor: pointer; font-size: 16px;
  box-shadow: var(--shadow);
}

/* Композер. Ручка изменения высоты — на ВЕРХНЕЙ границе (как у claude.ai):
   нативный resize тянет поле вниз, а внизу — край экрана, поэтому он бесполезен. */
.grip {
  height: 14px; cursor: ns-resize; touch-action: none; user-select: none;
  display: flex; align-items: center; justify-content: center;
  max-width: 800px; margin: 0 auto; width: 100%;
}
.grip span { width: 48px; height: 4px; border-radius: 2px; background: var(--border); transition: background .15s, width .15s; }
.grip:hover span, .grip.dragging span { background: var(--accent); width: 72px; }
.composer { display: flex; gap: 10px; padding: 0 20px 16px; max-width: 800px; margin: 0 auto; width: 100%; }
.composer textarea {
  flex: 1; resize: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; padding: 11px 14px;
  font-size: 15px; font-family: inherit; line-height: 1.45; outline: none;
  min-height: 44px; max-height: 70vh; box-shadow: var(--shadow);
}
.composer textarea:focus { border-color: var(--accent); }
.composer textarea::placeholder { color: var(--dim); }
.composer button {
  flex: 0 0 44px; height: 44px; align-self: flex-end;
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: 14px;
  font-size: 16px; cursor: pointer;
}
.composer button:hover { background: var(--accent-hover); }
.composer button:disabled { opacity: .4; cursor: default; }

.empty { color: var(--dim); text-align: center; margin-top: 15vh; font-size: 15px; font-family: var(--font-serif); }

/* ── Мобильная вёрстка (контракт 640px): треды — горизонтальная лента сверху.
   Полный мобильный клон claude.ai (шторка) — Ф8 спека. ── */
@media (max-width: 640px) {
  .cabinet { flex-direction: column; }
  .sidebar { width: 100%; flex: 0 0 auto; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-head { padding: 10px 14px 6px; }
  .new-thread { display: none; }
  .side-label { display: none; }
  .threads { display: flex; overflow-x: auto; overflow-y: hidden; padding: 0 10px 8px; gap: 6px; }
  .thread { flex: 0 0 auto; width: auto; max-width: 46vw; background: var(--surface); border: 1px solid var(--border); }
  .thread.active { background: var(--surface-2); }
  .chat-head { padding: 10px 14px 6px; }
  .feed-inner { padding: 6px 14px 18px; }
  .composer { padding: 10px 12px 12px; }
  .msg-user-inner { max-width: 92%; }
}
