:root {
  --bg: #0f1115;
  --bg-2: #161a21;
  --panel: #1c2129;
  --border: #2a313c;
  --text: #e6e9ef;
  --muted: #8b93a1;
  --accent: #4f7cff;
  --accent-2: #6b8bff;
  --danger: #ff5c5c;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Чат-экран занимает ровно видимую область и не скроллится целиком:
   прокручиваются только внутренние списки (сообщения, задачи, уведомления),
   а верхнее меню всегда остаётся прижатым к верху. */
#chat-screen {
  min-height: 0;
  height: 100vh; /* fallback для старых браузеров */
  height: 100dvh; /* корректная высота на мобильных (без адресной строки и клавиатуры) */
  overflow: hidden;
}

/* ---------- Login ---------- */
#login-screen {
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 42px; text-align: center; }
.login-title { text-align: center; margin: 8px 0 2px; font-size: 24px; }
.login-sub { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 14px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.field input:focus { border-color: var(--accent); }

.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; }

.btn {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  padding: 10px 16px;
  transition: background 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-block { width: 100%; font-size: 15px; padding: 12px; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-stop { background: var(--danger); color: #fff; }
.btn-stop:hover { background: #ff7a7a; }
.mic { font-size: 18px; line-height: 1; padding: 10px 12px; }
.attach { font-size: 18px; line-height: 1; padding: 10px 12px; }

/* ---------- Image attachments ---------- */
.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.attach-preview.hidden { display: none; }
.preview-item {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-2);
}
.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.preview-rm {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  line-height: 1;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.65);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}
.preview-rm:hover { background: var(--danger); }

.msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.msg-image {
  max-width: 220px;
  max-height: 220px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  display: block;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 30px;
}
.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}
.brand { font-weight: 600; font-size: 15px; margin-right: 10px; white-space: nowrap; }
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-label {
  color: var(--muted);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 20px;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Messages ---------- */
.messages {
  flex: 1;
  min-height: 0; /* даём контейнеру сжиматься, чтобы скроллился он, а не страница */
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
.msg {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.5;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg.loading { color: var(--muted); font-style: italic; }
.msg-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  opacity: 0.85;
}
.msg.assistant .msg-meta { text-align: right; }
.msg.user .msg-meta { text-align: right; color: rgba(255,255,255,0.8); }

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 400px;
  padding: 20px;
}
.empty-state .big { font-size: 44px; margin-bottom: 12px; }

/* ---------- Composer ---------- */
.composer {
  padding: 16px 20px 20px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}
.composer-box {
  display: flex;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  align-items: flex-end;
}
.composer-box:focus-within { border-color: var(--accent); }
#prompt-input {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.4;
  max-height: 160px;
  min-height: 30px;
  padding: 4px;
}
.composer-actions { display: flex; gap: 8px; flex-shrink: 0; }
#mic-btn.recording { background: var(--danger); color: #fff; border-color: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.voice-status {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.hint {
  margin: 10px 2px 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Tabs & panels ---------- */
.tabs { display: flex; gap: 2px; margin-left: 6px; flex-wrap: wrap; }
.tab {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 6px 11px; border-radius: 8px; cursor: pointer; font-size: 13px;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--bg); color: var(--text); border-color: var(--border); font-weight: 600; }

.tabpanel { display: none; flex-direction: column; flex: 1; min-height: 0; }
.tabpanel.active { display: flex; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 12px; max-width: 900px; width: 100%; margin: 0 auto;
}
.section-head h2 { margin: 0; font-size: 20px; }

/* ---------- Tasks ---------- */
.tasks-list, .notifs-list {
  max-width: 900px; width: 100%; margin: 0 auto; padding: 4px 20px 40px;
  display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1;
  min-height: 0;
}
.task-card, .notif-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.task-card.done { opacity: 0.55; }
.task-card .tick {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border); cursor: pointer;
  background: transparent; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: transparent;
}
.task-card.done .tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.task-card .tinfo { flex: 1; min-width: 0; }
.task-card .ttitle { font-weight: 600; font-size: 15px; word-break: break-word; }
.task-card.done .ttitle { text-decoration: line-through; }
.task-card .tdetails { color: var(--muted); font-size: 13px; margin-top: 3px; word-break: break-word; white-space: pre-wrap; }
.task-card .tdue { font-size: 12px; color: var(--accent-2); margin-top: 5px; }
.task-card .tdue.overdue { color: var(--danger); }
.task-card .tacts { display: flex; gap: 6px; flex-shrink: 0; }
.task-actions .btn { padding: 7px 10px; }

/* ---------- Notifications ---------- */
.notif-card { align-items: flex-start; }
.notif-card .nicon { font-size: 20px; flex-shrink: 0; }
.notif-card .ntitle { font-weight: 600; }
.notif-card .nbody { color: var(--muted); font-size: 13px; margin-top: 3px; }
.notif-card .nts { font-size: 12px; color: var(--muted); margin-top: 6px; }
.notif-card.unread { border-color: var(--accent); }
.notif-card .nunread { font-size: 11px; background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 10px; margin-left: 8px; }

.empty-note { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty-note .big { font-size: 40px; margin-bottom: 10px; }

/* ---------- Push banner ---------- */
.push-banner {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--accent); border-radius: 12px;
  padding: 12px 16px; display: flex; align-items: center; gap: 12px; z-index: 50;
  box-shadow: var(--shadow); max-width: 92vw; flex-wrap: wrap; justify-content: center;
  font-size: 14px;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 440px; box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 16px; }
.field.row { display: flex; align-items: center; }
.field textarea { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 15px; resize: vertical; font-family: inherit; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------- Mobile / narrow ---------- */
@media (max-width: 560px) {
  .topbar { padding: 8px 10px; }
  .topbar-left { width: 100%; justify-content: space-between; }
  .topbar-right { width: 100%; justify-content: flex-end; }
  .brand { font-size: 14px; }
  .tab { padding: 6px 9px; font-size: 12px; }
  .user-label { display: none; }
  .messages { padding: 16px 12px; }
  .composer { padding: 12px 10px 14px; }
}
