* { box-sizing: border-box; }
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e6eb;
  --border-strong: #c8ccd2;
  --text: #1a1f2b;
  --muted: #5b6373;
  --accent: #1f3a5f;
  --accent-hover: #163050;
  --user-bg: #eef2f8;
  --tool-bg: #fafbfc;
  --tool-border: #e8eaee;
  --error: #a4262c;
}
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", "Helvetica Neue", system-ui, "Noto Sans Armenian", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 18px; height: 18px;
  background: var(--accent);
  display: inline-block;
}
.brand h1 {
  margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.2px;
}
.status {
  font-size: 12px; color: var(--muted);
  padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: #fff;
}
.status.ok { color: #1f7a3d; border-color: #c5e1ce; background: #f1f9f3; }
.status.err { color: var(--error); border-color: #e7c2c4; background: #fdf2f3; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 53px);
}
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 20px;
  overflow-y: auto;
}
.sidebar-block { margin-bottom: 22px; }
.sidebar-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--muted); margin-bottom: 8px; font-weight: 600;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.examples {
  list-style: none; padding: 0; margin: 0;
}
.examples li {
  padding: 8px 12px; margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer; background: #fff;
  font-size: 13px; color: var(--text);
}
.examples li:hover { border-color: var(--accent); background: var(--user-bg); }

.chat {
  display: flex; flex-direction: column;
  background: var(--bg);
  height: 100%;
  min-height: 0;
}
.messages {
  flex: 1; overflow-y: auto;
  padding: 24px 24px; max-width: 1400px; width: 100%;
  margin: 0 auto;
}
.msg {
  margin-bottom: 18px;
}
.msg .role {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--muted); margin-bottom: 6px; font-weight: 600;
}
.msg .body {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 12px 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user .body {
  background: var(--user-bg);
  border-color: var(--border-strong);
}
.msg.assistant .body {
  background: var(--panel);
}
.body.md p { margin: 0 0 8px; }
.body.md p:last-child { margin-bottom: 0; }
.body.md h1, .body.md h2, .body.md h3 { margin: 12px 0 6px; font-weight: 600; }
.body.md h1 { font-size: 17px; } .body.md h2 { font-size: 15px; } .body.md h3 { font-size: 14px; }
.body.md ul, .body.md ol { margin: 4px 0 8px; padding-left: 22px; }
.body.md li { margin-bottom: 2px; }
.body.md strong { color: #0f1d33; }
.body.md table { border-collapse: collapse; margin: 8px 0; }
.body.md th, .body.md td { border: 1px solid var(--border); padding: 4px 10px; text-align: left; }
.body.md th { background: var(--user-bg); font-weight: 600; }
.body.md code {
  background: #f1f3f6; padding: 1px 5px;
  font-family: "JetBrains Mono", "Consolas", monospace; font-size: 12px;
}
.body.md pre {
  background: #f1f3f6; padding: 8px 12px; overflow-x: auto;
  font-family: "JetBrains Mono", "Consolas", monospace; font-size: 12px;
  margin: 6px 0;
}
.body.md pre code { background: transparent; padding: 0; }
.body.md blockquote {
  border-left: 3px solid var(--border-strong); margin: 6px 0; padding: 2px 12px;
  color: var(--muted);
}
.body.md a { color: var(--accent); }

.steps {
  margin-top: 8px; border: 1px solid var(--tool-border);
  background: var(--tool-bg);
  font-size: 12px;
  font-family: "JetBrains Mono", "Consolas", "SF Mono", monospace;
}
.steps summary {
  padding: 8px 12px; cursor: pointer; color: var(--muted);
  user-select: none;
}
.steps summary:hover { color: var(--accent); }
.steps[open] summary { border-bottom: 1px solid var(--tool-border); }
.step-list { padding: 8px 12px; }
.step {
  padding: 6px 0; border-bottom: 1px dashed var(--tool-border);
  white-space: pre-wrap; word-wrap: break-word;
}
.step:last-child { border-bottom: 0; }
.step .name { color: var(--accent); font-weight: 600; }
.step .args { color: var(--muted); }

.thinking {
  display: inline-block;
  color: var(--muted); font-style: italic;
}
.thinking::after {
  content: "…"; animation: dots 1.2s infinite steps(4);
  display: inline-block; min-width: 18px;
}
@keyframes dots { 0% {content:"";} 25% {content:".";} 50% {content:"..";} 75% {content:"...";} }

.composer {
  position: relative;
  background: var(--panel);
  margin: 8px 24px 20px;
  border: 1px solid var(--border-strong);
  border-radius: 26px;
  padding: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.08);
}
.composer textarea {
  display: block;
  width: 100%;
  resize: none;
  border: none;
  background: transparent;
  outline: none;
  padding: 14px 140px 14px 90px;
  font: inherit;
  color: var(--text);
  line-height: 1.5;
  min-height: 56px;
  max-height: 220px;
  box-sizing: border-box;
  border-radius: 26px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.composer textarea::placeholder {
  color: #98a0ad;
}
.composer textarea::-webkit-scrollbar { width: 8px; }
.composer textarea::-webkit-scrollbar-track {
  background: transparent;
  margin: 20px 0;
}
.composer textarea::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
  border: 1px solid transparent;
  background-clip: padding-box;
}
.composer textarea::-webkit-scrollbar-thumb:hover {
  background: #9aa3b1;
  background-clip: padding-box;
}
.composer button {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 8px 22px;
  background: var(--accent); color: #fff;
  border: 1px solid var(--accent);
  font: inherit; font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(15, 29, 51, 0.18);
  transition: background 0.15s;
}
.composer button#send:hover { background: var(--accent-hover); }
.composer button#send:disabled { opacity: 0.5; cursor: wait; }

/* ---- composer wrap + left tools ---- */
.composer-wrap {
  position: relative;
}
.composer-tools {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
  z-index: 2;
}
.icon-btn {
  position: static !important;
  transform: none !important;
  width: 34px;
  height: 34px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50% !important;
  background: transparent !important;
  color: var(--muted) !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: var(--user-bg) !important;
  color: var(--accent) !important;
}
.icon-btn.recording {
  background: #fdecec !important;
  color: var(--error) !important;
  animation: pulse 1.1s infinite;
}
.icon-btn.transcribing {
  color: var(--accent) !important;
  animation: spin 0.9s linear infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(164, 38, 44, 0.35) !important; }
  50% { box-shadow: 0 0 0 5px rgba(164, 38, 44, 0) !important; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---- attachment preview above composer ---- */
[hidden] { display: none !important; }
.attach-preview {
  position: relative;
  display: inline-block;
  margin: 0 24px 6px;
}
.attach-preview img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
}
.attach-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 1px 2px rgba(15, 29, 51, 0.18);
}
.attach-remove:hover { background: var(--user-bg); }

/* ---- image inside chat message ---- */
.msg-image {
  display: block;
  max-width: 240px;
  max-height: 240px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.error {
  color: var(--error);
  border-color: #e7c2c4 !important;
  background: #fdf2f3 !important;
}

/* ---- mobile ---- */
@media (max-width: 768px) {
  body { font-size: 13px; }

  .topbar { padding: 10px 14px; }
  .brand h1 { font-size: 14px; }
  .logo { width: 14px; height: 14px; }
  .status { padding: 3px 10px; font-size: 11px; }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: calc(100vh - 45px);
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    max-height: 36vh;
  }
  .sidebar-block { margin-bottom: 12px; }
  .sidebar-block:last-child { margin-bottom: 0; }
  .sidebar-title { font-size: 10px; margin-bottom: 5px; }
  .examples li { padding: 6px 10px; font-size: 12px; margin-bottom: 4px; }

  .messages {
    padding: 14px 14px;
  }
  .msg { margin-bottom: 12px; }
  .msg .body { padding: 10px 12px; }

  .composer {
    margin: 6px 12px 12px;
    border-radius: 22px;
  }
  .composer textarea {
    padding: 12px 92px 12px 80px;
    min-height: 48px;
    max-height: 160px;
    border-radius: 22px;
    font-size: 14px;
  }
  .composer button#send {
    padding: 6px 14px;
    font-size: 12px;
    right: 6px;
  }
  .composer-tools { left: 8px; gap: 2px; }
  .icon-btn { width: 30px; height: 30px; }
  .attach-preview { margin: 0 12px 6px; }
  .composer textarea::-webkit-scrollbar { width: 6px; }
  .composer textarea::-webkit-scrollbar-track { margin: 14px 0; }

  .body.md pre { font-size: 11px; padding: 6px 10px; }
  .body.md table { font-size: 12px; display: block; overflow-x: auto; }
  .steps { font-size: 11px; }
}

/* ---- very narrow ---- */
@media (max-width: 420px) {
  .sidebar { max-height: 30vh; padding: 8px 10px; }
  .sidebar-block { margin-bottom: 8px; }
  .examples li { padding: 5px 8px; }
  .composer textarea { padding-right: 92px; }
}
