/* Минимальный тёмный чат-интерфейс (без фреймворков) */

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

:root {
  --bg: #1a1a1a;
  --panel: #212121;
  --text: #e0e0e0;
  --muted: #9e9e9e;
  --accent: #4f8cff;
  --user-bubble: #2f6fdb;
  --assistant-bubble: #2a2a2a;
  --border: #333;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* Шапка */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.title {
  font-size: 18px;
  font-weight: 600;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Диалог настроек */
.settings-dialog {
  width: min(92vw, 420px);
  max-width: none;
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

.settings-dialog::backdrop { background: rgba(0, 0, 0, 0.62); }
.settings-panel { padding: 18px; }
.settings-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.settings-heading h2 { font-size: 18px; }
.close-btn { width: 38px; height: 38px; font-size: 28px; line-height: 1; }
.settings-label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 14px; }
.settings-select {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--bg); color: var(--text); font-size: 16px;
}
.settings-hint { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.settings-divider { height: 1px; margin: 18px 0 14px; background: var(--border); }
.danger-btn { width: 100%; min-height: 44px; border: 1px solid #8f3333; border-radius: 10px; background: #452323; color: #ffdede; font-size: 15px; cursor: pointer; }
.danger-btn:disabled { opacity: 0.55; cursor: wait; }

/* Лента сообщений */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.msg {
  display: flex;
  max-width: 82%;
}

.msg.user { align-self: flex-end; justify-content: flex-end; }
.msg.assistant { align-self: flex-start; justify-content: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: 18px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .bubble {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.msg.assistant .bubble {
  background: var(--assistant-bubble);
  color: var(--text);
  border-bottom-left-radius: 6px;
}

/* Индикатор "печатает" */
body.typing .msg.assistant:last-child .bubble::after {
  content: "…";
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink { to { visibility: hidden; } }

/* Композер */
.composer {
  padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.composer-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input {
  flex: 1;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.input:focus { border-color: var(--accent); }

.mic-btn, .send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
}

.mic-btn {
  background: #2a2a2a;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.mic-btn.recording {
  background: #c62828;
  color: #fff;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.55); }
  70%  { box-shadow: 0 0 0 14px rgba(198, 40, 40, 0); }
  100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0); }
}

.mic-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Поле ввода заблокировано во время записи */
.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn {
  background: var(--accent);
  color: #fff;
}

.send-btn:active { transform: scale(0.94); }
/* Напоминания */
.reminder-submit {
  width: 100%; min-height: 46px; margin-top: 14px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.reminder-submit:disabled { opacity: 0.55; cursor: wait; }
.reminders-list { list-style: none; margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.reminder-item {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.reminder-copy { min-width: 0; overflow-wrap: anywhere; }
.reminder-time { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.reminder-cancel {
  flex-shrink: 0; border: 1px solid #8f3333; border-radius: 8px; padding: 6px 9px;
  background: #452323; color: #ffdede; cursor: pointer;
}
.reminder-cancel:disabled { opacity: 0.55; cursor: wait; }

/* Напоминания */
.reminder-submit {
  width: 100%; min-height: 46px; margin-top: 14px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.reminder-submit:disabled { opacity: 0.55; cursor: wait; }
.reminders-list { list-style: none; margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.reminder-item {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.reminder-copy { min-width: 0; overflow-wrap: anywhere; }
.reminder-time { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.reminder-cancel {
  flex-shrink: 0; border: 1px solid #8f3333; border-radius: 8px; padding: 6px 9px;
  background: #452323; color: #ffdede; cursor: pointer;
}
.reminder-cancel:disabled { opacity: 0.55; cursor: wait; }
