* { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --text: #14161c;
  --muted: #5d6572;
  --border: #e2e5ea;
  --accent: #1683ef;
  --accent-soft: #e0efff;
  --danger: #d64545;
  --warn-bg: #fdf1e2;
  --warn-border: #ecc377;
  --warn-text: #6b5313;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #171a22;
    --surface-2: #1e222c;
    --text: #e8eaf0;
    --muted: #9aa1b2;
    --border: #262b38;
    --accent: #4c9aff;
    --accent-soft: #1b2b45;
    --danger: #e06c6c;
    --warn-bg: #2a2214;
    --warn-border: #6b5313;
    --warn-text: #f5b82e;
  }
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

.boot-splash {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
}
.boot-mark {
  width: 58px;
  height: 58px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
}

.auth-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background: radial-gradient(circle at 50% 20%, var(--accent-soft), var(--bg) 48%);
}

.auth-card, .account-card {
  width: min(100%, 390px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 22px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .14);
}

.auth-card { text-align: center; }
.auth-card h1 { margin: 12px 0 4px; font-size: 28px; }
.auth-card > p { margin: 0 0 24px; color: var(--muted); }
.auth-mark {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 18px;
  display: grid; place-items: center; background: var(--accent); color: #fff;
  font-size: 30px; font-weight: 750;
}

.auth-button {
  width: 100%; min-height: 50px; display: flex; align-items: center; justify-content: center;
  margin-top: 12px; padding: 12px 16px; border: 0; border-radius: 14px;
  font: 600 16px/1.2 system-ui, sans-serif; text-decoration: none; cursor: pointer;
}
.auth-passkey { background: var(--text); color: var(--surface); }
.auth-yandex { background: #ffcc00; color: #111; }
.auth-message { min-height: 22px; margin: 16px 0 0 !important; color: var(--danger) !important; font-size: 14px; }
.account-button { border: 0; background: transparent; color: var(--muted); font-size: 22px; padding: 4px; }
.account-card { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 10px; }
.account-card h2, .account-card p { margin: 0; }

/* Visual skin for the AgentChat-copied shell lives in agentchat-ui.css (loaded
   right after this file). The rules below are the structural base layer only
   (flex/layout/behavior); they intentionally leave colors, spacing and
   sizing to agentchat-ui.css so there is a single source of truth for the
   look, matching production 1:1. */

button, input, select, textarea { font-size: 16px; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg);
}

/* --- messages --- */

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty {
  margin: auto;
  max-width: 320px;
  text-align: center;
  color: var(--muted);
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.empty-text { font-size: 14px; margin: 0; }

.msg {
  align-self: flex-end;
  max-width: 88%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--surface-2);
}

.msg-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 16px;
}

.msg-status {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.msg-attachments {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg-attachments li {
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 5px 8px;
  overflow-wrap: break-word;
}

/* --- notice --- */

.notice {
  flex: none;
  margin: 0 12px 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  font-size: 14px;
}

/* --- composer ---
   Only the structural bits not already covered (by selector or by
   specificity) in agentchat-ui.css's `.input-box`-scoped rules. A plain
   `#composer-input { flex: 1; ... }` here previously won the cascade on the
   `flex` property (not set anywhere else) and, with flex-basis:0 inside the
   auto-height `.input-box` column, collapsed the textarea back to
   min-height on every keystroke — silently defeating the JS autoGrow(). */

.composer {
  flex: none;
}

#composer-input {
  min-width: 0;
  resize: none;
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.icon-btn.send {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

#mic-btn.recording { background: #c62828; color: #fff; }
#mic-btn.transcribing { opacity: .5; pointer-events: none; }
#mic-btn.recording svg { display: none; }
#mic-btn.recording::after { content: ''; width: 13px; height: 13px; border-radius: 3px; background: #fff; }
.att-progress { font-size: 11px; color: var(--muted); }

/* --- attachments --- */

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 6px 5px 12px;
  font-size: 13px;
  color: var(--muted);
}

.att-chip img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; }
.msg-attachments li { display: flex; align-items: center; gap: 8px; }
.msg-attachments img { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; }

.att-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.att-remove, .att-preview {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 13px;
  border-radius: 999px;
}

.att-remove:hover, .att-preview:hover { color: var(--danger); }
.att-preview:hover { color: var(--accent); }

/* --- recording bar --- */

.recording-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 8px 12px;
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  border-radius: 12px;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  flex: none;
  animation: rec-pulse 1.2s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.rec-time {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}

.rec-label {
  flex: 1;
  font-size: 13px;
  color: var(--warn-text);
}

.btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 15px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-ghost { background: transparent; }

/* --- modal --- */

.modal[hidden], .recording-bar[hidden], .attachments[hidden], .notice[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.modal-body {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.modal-body img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 12px;
}

.modal-close {
  background: var(--surface);
  color: var(--text);
}

@media (min-width: 641px) {
  .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
