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

:root {
  --bg:               #0d0f0e;
  --surface:          #141714;
  --surface2:         #1c201c;
  --surface3:         #232823;
  --border:           #2d332d;
  --border-strong:    #3d4a3d;

  --accent:           #c97f2a;
  --accent-hover:     #b36e1f;
  --accent-dim:       rgba(201, 127, 42, 0.12);
  --accent-text:      #e8a04a;

  --signal-green:     #4a9e6b;
  --signal-red:       #c0392b;

  --text:             #dde3d8;
  --text-muted:       #7a8c7a;
  --text-strong:      #f0f4ed;

  --user-bubble:      #1e2e1e;
  --user-bubble-border: #4a9e6b;
  --assistant-bubble: #1c201c;

  --radius:           14px;
  --radius-sm:        8px;
  --radius-xs:        6px;
  --shadow:           0 12px 40px rgba(0, 0, 0, 0.7);
}

body {
  background: var(--bg);
  background-image:
    linear-gradient(rgba(45, 51, 45, 0.25) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 51, 45, 0.25) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Page header ─── */
.page-header {
  width: 100%;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 9px 24px;
  flex-shrink: 0;
}

.page-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header-icon {
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex-shrink: 0;
}

.page-header-brand {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  flex: 1;
}

.page-header-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--signal-green);
  background: rgba(74, 158, 107, 0.12);
  border: 1px solid rgba(74, 158, 107, 0.28);
  padding: 2px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Chat wrapper ─── */
.chat-wrapper {
  width: 100%;
  max-width: 1100px;
  flex: 1;
  max-height: calc(100dvh - 43px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 16px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* ─── Header ─── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 22px;
  background: var(--surface2);
  border-bottom: 2px solid var(--accent);
  flex-shrink: 0;
}

.header-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-xs);
  background: var(--accent-dim);
  border: 1px solid rgba(201, 127, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-avatar svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.header-info {
  flex: 1;
}

.header-info h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.header-subtitle {
  font-size: 10.5px;
  color: var(--text-muted);
  margin: 2px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.status {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.status.online::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--signal-green);
  display: inline-block;
  box-shadow: 0 0 6px var(--signal-green);
}

.header-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent-dim);
  border: 1px solid rgba(201, 127, 42, 0.3);
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ─── Quick actions ─── */
.quick-actions-panel {
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  overflow: hidden;
  max-height: 200px;
  transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.3s ease;
}

.quick-actions-panel.hidden {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.quick-actions-label {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  margin-bottom: 10px;
}

.quick-actions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.quick-action-btn svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.quick-action-btn:hover {
  background: var(--accent-dim);
  border-color: rgba(201, 127, 42, 0.5);
  color: var(--text-strong);
}

.quick-action-btn:active {
  transform: scale(0.97);
}

/* ─── Messages area ─── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ─── Individual message ─── */
.message {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 82%;
  animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.assistant {
  align-self: flex-start;
}

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-xs);
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-avatar svg {
  width: 15px;
  height: 15px;
}

.message.user .message-avatar {
  color: var(--text-muted);
  font-size: 11px;
}

.message-bubble {
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.message.assistant .message-bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-xs);
}

.message.user .message-bubble {
  background: var(--user-bubble);
  border: 1px solid var(--user-bubble-border);
  color: var(--text-strong);
  border-bottom-right-radius: var(--radius-xs);
}

/* ─── Typing indicator ─── */
.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 15px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ─── Info bar ─── */
.chat-info-bar {
  padding: 6px 20px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.info-bar-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.info-bar-item svg {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

.info-bar-sep {
  color: var(--border-strong);
  font-size: 11px;
}

/* ─── Input area ─── */
.chat-input-area {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: rgba(201, 127, 42, 0.5);
}

#userInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}

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

#sendBtn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}

#sendBtn:hover {
  background: var(--accent-hover);
}

#sendBtn:active {
  transform: scale(0.92);
}

#sendBtn:disabled {
  background: var(--border);
  cursor: not-allowed;
}

#sendBtn svg {
  width: 16px;
  height: 16px;
  color: #fff;
  margin-left: 2px;
}

/* ─── Error ─── */
.message-bubble.error {
  color: #ff6b6b;
  border-color: #ff6b6b44;
}

/* ─── Mobile ─── */
@media (max-width: 540px) {
  .page-header { padding: 8px 14px; }
  .page-header-badge { display: none; }
  .chat-wrapper {
    border-radius: 0;
    max-height: calc(100dvh - 38px);
  }
  .message { max-width: 92%; }
  .quick-actions-grid { gap: 6px; }
  .quick-action-btn { padding: 6px 10px; font-size: 12px; }
  .header-badge { display: none; }
  .chat-info-bar { display: none; }
}
