/* Kolobok Web — рабочее пространство. Токены: docs/02-design.md (тёмная продуктовая тема). */
:root {
  --bg: #17161A;
  --surface: #201E24;
  --surface-2: #2A2830;
  --ink: #F2EFE8;
  --ink-muted: #A8A29B;
  --line: #37343D;
  --accent: #FFC107;
  --accent-strong: #E5A800;
  --on-accent: #3A2E00;
  --danger: #EF5350;
  --ok: #66BB6A;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}
[hidden] { display: none !important; }
img { max-width: 100%; }
a { color: var(--accent); }
.muted { color: var(--ink-muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 2px; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border: 1px solid transparent; border-radius: var(--radius);
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--surface-2); color: var(--ink);
  transition: background-color .15s ease;
}
.btn:hover { background: #33303A; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { background: var(--surface-2); color: var(--ink-muted); cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 14px; }

/* Экран входа */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 32px 28px;
  display: grid; gap: 14px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.auth-card .muted { margin: 0 0 4px; }
.auth-legal { margin: 4px 0 0; }
.field { display: grid; gap: 6px; font-size: 14px; color: var(--ink-muted); }
.field input, .search, .model-pick select {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; font: inherit;
}
.field input::placeholder { color: #6E6960; }
.form-error { margin: 0; color: var(--danger); font-size: 14px; }

/* Разметка приложения */
.app { display: grid; grid-template-columns: 288px 1fr; height: 100vh; }

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--line);
}
.sidebar-top { display: grid; gap: 10px; padding: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; color: var(--ink); padding: 4px; }
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; display: grid; align-content: start; gap: 2px; }
.conv {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 10px; border-radius: 10px; cursor: pointer;
  border: none; background: none; color: var(--ink);
  font: inherit; text-align: left; width: 100%;
}
.conv:hover { background: var(--surface-2); }
.conv.is-active { background: var(--surface-2); }
.conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.conv-del {
  border: none; background: none; color: var(--ink-muted);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 6px; border-radius: 8px;
}
.conv-del:hover { color: var(--danger); background: #2E2A33; }
.sidebar-bottom { border-top: 1px solid var(--line); padding: 12px 14px; display: grid; gap: 8px; }
.balance { font-size: 13px; color: var(--ok); }
.who { font-size: 13px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; }
.sidebar-actions { display: flex; gap: 8px; }

/* Чат */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 28px 0 12px; }
.msg { max-width: 780px; margin: 0 auto 20px; padding: 0 24px; }
.msg-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-muted); margin-bottom: 6px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-body p { margin: 0 0 10px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body pre {
  background: #121116; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; overflow-x: auto; white-space: pre; font-size: 14px; margin: 10px 0;
}
.msg-body code { background: #121116; border-radius: 6px; padding: 1px 6px; font-size: .92em; }
.msg-body pre code { background: none; padding: 0; }
.msg-user .msg-body {
  background: var(--accent); color: var(--on-accent);
  border-radius: 14px; padding: 10px 16px; display: inline-block;
}
.msg-user { text-align: right; }
.msg-user .msg-body { text-align: left; max-width: 85%; }
.reasoning { color: var(--ink-muted); font-size: 14px; border-left: 3px solid var(--line); padding-left: 12px; margin-bottom: 10px; white-space: pre-wrap; }
.cites { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cite {
  font-size: 13px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px; text-decoration: none; color: var(--ink-muted);
}
.cite:hover { color: var(--ink); }
.msg-copy { align-self: flex-start; margin-top: 8px; }
.msg-failed .msg-body { color: var(--danger); }

.cursor::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.empty { margin: auto; text-align: center; padding: 40px 24px; max-width: 560px; }
.empty h2 { margin: 12px 0 6px; }
.hints { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.hint {
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  border-radius: 999px; padding: 10px 18px; font: inherit; font-size: 14px; cursor: pointer;
}
.hint:hover { background: var(--surface-2); }

/* Поле ввода */
.composer { padding: 8px 24px 20px; max-width: 828px; width: 100%; margin: 0 auto; }
.composer-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.composer textarea {
  width: 100%; resize: none; border: none; background: none; color: var(--ink);
  font: inherit; padding: 14px 16px; max-height: 200px; outline: none;
}
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.model-pick select { min-width: 160px; }
.composer-actions { display: flex; gap: 8px; }

/* Мобильная раскладка */
.menu-toggle { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 284px; z-index: 30;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.is-open { transform: none; }
  .menu-toggle {
    display: inline-flex; position: fixed; top: 12px; left: 12px; z-index: 20;
    min-height: 40px; padding: 8px 12px; border-radius: 10px;
    background: var(--surface); border: 1px solid var(--line); color: var(--ink); cursor: pointer;
  }
  .messages { padding-top: 60px; }
  .msg { padding: 0 14px; }
  .composer { padding: 8px 14px 16px; }
}
