:root {
  --bg: #0b0d10;
  --sidebar: #111419;
  --surface: #171b22;
  --border: #252b36;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #ffffff;
  --ok: #2ea043;
  --warn: #d29922;
  --err: #f85149;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}
.hidden { display: none !important; }

.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  text-align: center;
  max-width: 380px;
}
.btn-primary {
  display: inline-block;
  margin-top: 18px;
  padding: 12px 24px;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  border-radius: 12px;
  text-decoration: none;
}

.app {
  display: flex;
  height: 100vh;
}
.sidebar {
  width: 270px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
}
.btn-new {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
.btn-new:hover { border-color: #444c56; }
.section-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}
.quota-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quota-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 6px 8px;
  background: var(--surface);
  border-radius: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.ok { background: var(--ok); }
.dot.limited { background: var(--warn); }

.chats-wrap { flex: 1; overflow-y: auto; }
.chat-list { display: flex; flex-direction: column; gap: 4px; }
.chat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}
.chat-item:hover, .chat-item.active {
  background: var(--surface);
  color: var(--text);
}
.chat-item .del { opacity: 0.5; font-size: 12px; padding: 2px 5px; }
.chat-item .del:hover { opacity: 1; color: var(--err); }

.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}
.btn-ghost:hover { color: var(--text); }
.user-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
.logout-link { color: var(--muted); text-decoration: none; }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.controls { display: flex; gap: 8px; flex-wrap: wrap; }
select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
}
.run-indicator { font-size: 12px; color: var(--warn); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 480px;
}
.msg {
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  line-height: 1.5;
  font-size: 14px;
}
.msg.user {
  background: #1f2630;
  border-color: #30363d;
}
.msg.system {
  background: #16181d;
  border-style: dashed;
  color: var(--muted);
  font-size: 13px;
}
.msg-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  gap: 8px;
}
.badge {
  background: #252b36;
  color: var(--text);
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 600;
}
.msg pre {
  background: #0d1117;
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
}

.composer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
textarea {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
}
.btn-send {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 12px;
  padding: 0 18px;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 768px) {
  .sidebar { display: none; }
}
