:root {
  --bg: #0d0f14;
  --sidebar: #11131a;
  --panel: #151822;
  --text: #eceff7;
  --muted: #9aa4bf;
  --border: #2a3145;
  --danger: #ff5d6c;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
}

.hidden { display: none !important; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}
.auth-card h2 { margin: 0 0 6px; }

.tabs { display: flex; gap: 8px; margin: 12px 0; }
.tab { flex: 1; }
.tab.active { border-color: #5a7fda; background: #202b47; }

.auth-form { display: grid; gap: 10px; }
input, textarea, button {
  background: #101623;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
}
button { cursor: pointer; }
button:hover { border-color: #4d5d83; }
button.ghost { background: transparent; }
button.danger { border-color: #6a2f3a; color: #ffb7bf; }

.auth-msg { min-height: 24px; margin-top: 10px; }

.app {
  height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand { font-weight: 700; font-size: 15px; color: #dce6ff; padding: 8px 10px; }

.user-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}

.new-chat-btn { width: 100%; text-align: left; }

.sidebar-section-title { margin-top: 8px; padding: 0 4px; color: var(--muted); font-size: 12px; }

.conversation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow: auto;
}

.conversation-item {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #d7def3;
}
.conversation-item:hover { background: #1a2236; }
.conversation-item.active { background: #1f2a45; border-color: #3e5487; }

.sidebar-footer { margin-top: auto; color: var(--muted); font-size: 12px; padding: 8px 4px; }

.chat-main { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; }

.chat-header {
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
}

.header-left { display: flex; gap: 10px; align-items: center; }
.chat-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  max-width: 50vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions { display: flex; gap: 8px; }

.messages {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 0;
}

.msg-wrap { width: 100%; display: flex; justify-content: center; padding: 0 16px; }
.msg {
  width: min(820px, 100%);
  border-radius: 12px;
  padding: 14px 16px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.msg.user { background: #1d2640; border: 1px solid #32456f; }
.msg.assistant { background: transparent; border: 1px solid transparent; }
.msg.system { background: #30220f; border: 1px solid #7a5f30; color: #ffdba2; }

.chat-input-wrap { display: flex; justify-content: center; padding: 12px 16px 20px; }
.composer-shell {
  width: min(860px, 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  padding: 10px;
}

textarea {
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  min-height: 24px;
  max-height: 220px;
}

.composer-actions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hint { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.mobile-only { display: none; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: grid;
  place-items: center;
  padding: 14px;
}

.modal-card {
  width: min(740px, 100%);
  max-height: 80vh;
  overflow: auto;
  background: #111722;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.admin-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}

@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 280px;
    transform: translateX(-100%);
    z-index: 10;
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-block; }
}
