:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f242e;
  --line: #2a2f3a;
  --text: #e7ebf0;
  --muted: #8b93a3;
  --accent: #4c8dff;
  --accent-2: #3a6fd6;
  --user: #274b8f;
  --danger: #ff6b6b;
  --ok: #46b877;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin-top: 8px; font-size: 14px; }

/* Вход */
.login { height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 20px; font-size: 14px; }
.login-card input {
  width: 100%; padding: 13px 14px; margin-bottom: 12px; font-size: 16px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
}
.login-card button {
  width: 100%; padding: 13px; font-size: 16px; font-weight: 600;
  background: var(--accent); color: #fff; border: none; border-radius: 10px; cursor: pointer;
}
.login-card button:active { background: var(--accent-2); }

/* Чат */
.chat { display: flex; flex-direction: column; height: 100dvh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar .title { font-weight: 600; }
.topbar .actions button {
  background: none; border: none; color: var(--muted); font-size: 20px;
  padding: 4px 8px; cursor: pointer;
}
.topbar .actions button:active { color: var(--text); }

.messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }

.bubble {
  max-width: 82%; padding: 10px 13px; border-radius: 14px; white-space: pre-wrap;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.bubble.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 4px; }
.bubble.bot.pending::after { content: "▋"; opacity: .5; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.tool {
  align-self: flex-start; max-width: 82%; font-size: 13px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 11px;
}
.tool code { color: var(--accent); font-size: 12px; word-break: break-all; }
.tool.blocked { color: var(--danger); border-color: var(--danger); }
.meta { align-self: center; font-size: 11px; color: var(--muted); opacity: .7; }

.confirm {
  align-self: stretch; background: var(--panel); border: 1px solid var(--danger);
  border-radius: 12px; padding: 12px;
}
.confirm .q { font-size: 14px; margin-bottom: 10px; }
.confirm code { color: var(--danger); font-size: 12px; word-break: break-all; }
.confirm .row { display: flex; gap: 10px; }
.confirm button { flex: 1; padding: 11px; border: none; border-radius: 9px; font-size: 15px; font-weight: 600; cursor: pointer; }
.confirm .yes { background: var(--danger); color: #fff; }
.confirm .no { background: var(--panel-2); color: var(--text); }

.composer {
  display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px; padding: 11px 13px; font-size: 16px; line-height: 1.35;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 20px; color: var(--text);
}
.composer button {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 18px; cursor: pointer;
}
.composer button:disabled { opacity: .5; }
