@import url('https://realeasystudio.site/fonts/cygre/font.css');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

/* Фирменные токены Real Easy Studio (realeasystudio.site) — тёмная тема */
:root {
  --bg: #080912;
  --surface: #0e1022;
  --secondary: #16182e;
  --text: #ffffff;
  --hint: #8b8fb8;
  --accent: #3a43ee;
  --accent-2: #6e7bff;
  --accent-text: #ffffff;
  --link: #6e7bff;
  --line: rgba(255, 255, 255, 0.1);
  --danger: #ff5a6a;
  --grad: linear-gradient(135deg, #3a43ee 0%, #6e7bff 100%);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

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

/* ── Шапка ── */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.topbar .title { font-family: 'Cygre', 'Roboto', sans-serif; font-weight: 600; font-size: 17px; letter-spacing: .2px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  border: 0; background: transparent; color: var(--text);
  font-size: 20px; padding: 6px 8px; border-radius: 8px; cursor: pointer; line-height: 1;
}
.icon-btn:active { background: var(--secondary); }

/* ── Сайдбар (drawer) ── */
.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 9;
}
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(82vw, 320px);
  background: var(--bg); border-right: 1px solid var(--line);
  transform: translateX(-100%); transition: transform .2s ease; z-index: 10;
  display: flex; flex-direction: column;
}
body.drawer-open .sidebar { transform: translateX(0); }
body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
.sidebar-head { padding: 10px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 6px; background: var(--secondary); border-radius: 10px; padding: 4px; }
.tab {
  flex: 1; border: 0; background: transparent; color: var(--hint);
  font: inherit; font-size: 14px; font-weight: 600; padding: 8px; border-radius: 8px; cursor: pointer;
}
.tab.is-active { background: var(--bg); color: var(--text); }
.pane { padding: 8px; }
.project { margin-bottom: 4px; }
.project-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 12px; border-radius: 10px; cursor: pointer; font-size: 15px; font-weight: 500;
}
.project-head:active, .project-head.open { background: var(--secondary); }
.project-head .badge { color: var(--hint); font-size: 12px; min-width: 16px; text-align: center; }
.project-body { padding: 2px 0 8px 10px; border-left: 2px solid var(--line); margin-left: 12px; }
.new-chat.small { padding: 9px; font-size: 13px; margin-top: 4px; }
.new-chat {
  width: 100%; border: 0; border-radius: 10px; padding: 12px;
  background: var(--grad); color: var(--accent-text); font-size: 15px; font-weight: 600; cursor: pointer;
}
.conv-list { flex: 1; overflow-y: auto; padding: 8px; }
.conv-item {
  padding: 11px 12px; border-radius: 10px; cursor: pointer; font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-item:active { background: var(--secondary); }
.conv-item.active { background: var(--secondary); font-weight: 600; }

/* ── Меню действий (шапка) ── */
.topbar { position: relative; }
.menu {
  position: absolute; top: 48px; right: 10px; z-index: 20;
  min-width: 210px; padding: 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
}
.menu[hidden] { display: none; }
.menu button {
  text-align: left; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 15px; padding: 11px 12px; border-radius: 8px; cursor: pointer;
}
.menu button:active { background: var(--secondary); }
.menu button.danger { color: var(--danger, #e0533d); }

/* ── Лента сообщений ── */
.messages { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; font-size: 15px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--grad); color: var(--accent-text); border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--secondary); color: var(--text); border-bottom-left-radius: 5px; }
.msg.typing { color: var(--hint); }
.msg.system-bubble { align-self: stretch; max-width: 100%; background: var(--secondary); border: 1px solid var(--line); font-size: 14px; }
.empty { margin: auto; color: var(--hint); text-align: center; font-size: 15px; padding: 0 24px; }

/* ── Оверлей настроек ── */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center;
}
.overlay[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto;
  background: var(--bg); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--hint); }
.sheet input, .sheet select {
  font: inherit; font-size: 16px; color: var(--text); background: var(--secondary);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%;
}
.sheet input:focus, .sheet select:focus { outline: none; border-color: var(--accent); }
.save-btn {
  border: 0; border-radius: 12px; padding: 13px; margin-top: 4px;
  background: var(--grad); color: var(--accent-text); font-size: 15px; font-weight: 600; cursor: pointer;
}
.hint { min-height: 18px; font-size: 13px; color: var(--hint); text-align: center; }

/* ── Поле ввода ── */
.composer {
  flex: 0 0 auto; display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 18px;
  padding: 10px 14px; font: inherit; font-size: 15px; max-height: 120px;
  background: var(--secondary); color: var(--text);
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.send-btn {
  border: 0; border-radius: 50%; width: 40px; height: 40px; flex: 0 0 auto;
  background: var(--grad); color: var(--accent-text); font-size: 18px; cursor: pointer;
}
.send-btn:disabled { opacity: .5; }
