/* ============ MYTHOS — modern dark ============ */
:root {
  --bg: #0b100e;
  --surface: #121a16;
  --surface-2: #172019;
  --border: #26332c;
  --border-strong: #36443c;
  --text: #eceef2;
  --text-soft: #b6bac4;
  --muted: #7c818d;
  --accent: #2fd49c;
  --accent-2: #7ce7c4;
  --accent-soft: rgba(47, 212, 156, 0.12);
  --danger: #f0655a;
  --radius: 8px;
  --font: 'Sora', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  position: relative;
  background:
    radial-gradient(700px 360px at 50% -180px, rgba(47, 212, 156, 0.13), transparent 65%),
    var(--bg);
}

/* --- header --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 34px;
  height: 34px;
  box-shadow: 0 4px 14px rgba(47, 212, 156, 0.35);
  border-radius: 8px;
}

.brand-text { display: flex; flex-direction: column; }

.brand-name {
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

.topbar-actions { display: flex; gap: 4px; }

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s ease;
}

.icon-btn svg { width: 17px; height: 17px; }

.icon-btn:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}

/* --- chat --- */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 8px;
  scroll-behavior: smooth;
}

.chat::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
.chat::-webkit-scrollbar-thumb:hover { background: #3e4554; }

/* --- empty state --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 18px 20px;
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.empty-emblem {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(47, 212, 156, 0.4);
}

.empty-state h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 7px;
}

.empty-state p {
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 26px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

/* --- messages --- */
.messages { display: flex; flex-direction: column; gap: 14px; padding-bottom: 8px; }

.msg {
  max-width: 88%;
  animation: msg-in 0.3s ease both;
}

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

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), #10936b);
  color: #fff;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  padding: 9px 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.5;
  font-size: 14px;
}

.msg.assistant {
  align-self: flex-start;
  width: 100%;
  max-width: 100%;
}

.msg-author {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.msg-body {
  line-height: 1.6;
  word-wrap: break-word;
  color: var(--text);
  font-size: 14px;
}

.msg-body p { margin: 0 0 10px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body h1, .msg-body h2, .msg-body h3 {
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 16px 0 8px;
}
.msg-body h1 { font-size: 17px; }
.msg-body h2 { font-size: 15.5px; }
.msg-body h3 { font-size: 14.5px; }
.msg-body ul, .msg-body ol { margin: 0 0 10px 20px; }
.msg-body li { margin-bottom: 4px; }
.msg-body li::marker { color: var(--accent); }
.msg-body a { color: var(--accent-2); text-decoration-color: rgba(56, 189, 248, 0.4); }
.msg-body blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 12px;
  margin: 0 0 10px;
  color: var(--text-soft);
}
.msg-body hr {
  border: none;
  height: 1px;
  margin: 14px 0;
  background: var(--border);
}
.msg-body strong { font-weight: 700; }

.msg-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

.code-block {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #0e1511;
}

.code-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.code-copy {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 5px;
  transition: color 0.15s;
}
.code-copy:hover { color: var(--text); }

.code-block pre {
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
}
.code-block pre code {
  background: none;
  border: none;
  padding: 0;
}

/* streaming caret */
.msg.streaming .msg-body::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 14px;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 2px;
  background: var(--accent);
  animation: blink 0.9s steps(2) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}
.msg.assistant:hover .msg-actions { opacity: 1; }

.msg-action-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--font);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}
.msg-action-btn:hover { color: var(--text); background: var(--surface-2); }

.msg.error .msg-body { color: var(--danger); }

/* thinking dots */
.thinking {
  display: inline-flex;
  gap: 5px;
  padding: 4px 0;
}
.thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
.thinking span:nth-child(2) { animation-delay: 0.18s; }
.thinking span:nth-child(3) { animation-delay: 0.36s; }

@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* --- composer --- */
.composer-wrap {
  padding: 10px 14px 12px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 212, 156, 0.15);
}

#input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 21px;
  padding: 6.5px 4px 6.5px 9px; /* 21px строка + 13px отступов = 34px, как кнопка */
  max-height: 150px;
}

#input::placeholder { color: var(--muted); }

.send-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: 0 2px 10px rgba(47, 212, 156, 0.35);
}

.send-btn svg { width: 16px; height: 16px; }
.send-btn .ico-stop { display: none; }
.send-btn.stop .ico-send { display: none; }
.send-btn.stop .ico-stop { display: block; }

.send-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.4; cursor: default; transform: none; filter: none; }
.send-btn.stop {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--danger);
  box-shadow: none;
}

.composer-hint {
  text-align: center;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 7px;
}

/* --- history --- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: rgba(8, 9, 12, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.history {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  width: min(320px, 88vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  transition: transform 0.3s cubic-bezier(0.25, 0.9, 0.3, 1);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.45);
}
.history.open { transform: none; }

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.history-head h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.history-group-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 8px 6px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  color: var(--text-soft);
  font-family: var(--font);
  transition: all 0.15s;
}

.history-item:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.history-item.active {
  background: var(--accent-soft);
  border-color: rgba(47, 212, 156, 0.35);
  color: var(--text);
}

.history-item-title {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-del {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  opacity: 0;
  transition: all 0.15s;
  display: grid;
  place-items: center;
}
.history-item:hover .history-item-del { opacity: 1; }
.history-item-del:hover { color: var(--danger); }
.history-item-del svg { width: 13px; height: 13px; }

.history-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 30px 16px;
}

.clear-all {
  margin: 10px 14px 14px;
  padding: 9px;
  background: none;
  border: 1px solid rgba(240, 101, 90, 0.35);
  border-radius: 10px;
  color: var(--danger);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}
.clear-all:hover { background: rgba(240, 101, 90, 0.1); }
