:root {
  color-scheme: dark;
  --bg: #1e1e1f;
  --panel: #2a2a2c;
  --border: #3a3a3d;
  --text: #ececec;
  --muted: #9a9a9d;
  --accent: #d97757;
  --accent-text: #1e1e1f;
}

* { box-sizing: border-box; }

/* Explicit, since later rules below (e.g. `form { display: flex }`) would
   otherwise silently beat the browser's own default [hidden] UA rule --
   any user stylesheet rule outranks a user-agent one regardless of
   selector specificity or source order. */
[hidden] { display: none !important; }

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

.view { height: 100%; }

/* Login */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: min(400px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}

.login-card h1 { margin-top: 0; font-size: 1.4rem; }
.hint { color: var(--muted); font-size: 0.9rem; line-height: 1.4; }

form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
label { font-size: 0.85rem; color: var(--muted); }

input, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
}

button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: default; }

.error { color: #f27979; font-size: 0.85rem; }

/* Chat */
#chat-view {
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.chat-header button {
  background: transparent;
  color: var(--muted);
  font-weight: 400;
  border: 1px solid var(--border);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-text);
}
.message.assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
}

.status-line {
  padding: 0 16px 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}

.send-form {
  flex-direction: row;
  align-items: flex-end;
  padding: 12px 16px 18px;
  border-top: 1px solid var(--border);
  gap: 10px;
}
.send-form textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
}

.header-actions { display: flex; gap: 8px; }

.link-button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 4px 8px;
}

/* Gendoc */
#gendoc-view {
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
}

.gendoc-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
}

.gendoc-phase {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gendoc-phase h3 { margin: 12px 0 4px; font-size: 0.95rem; }

.bullet-list, .checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bullet-list li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.checklist li button {
  width: 100%;
  text-align: left;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 400;
}
.checklist li button.excluded {
  opacity: 0.5;
  text-decoration: line-through;
}

.progress-bar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
}
.progress-fill {
  background: var(--accent);
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

.run-summary {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.run-summary a { color: var(--accent); }

.score-row { display: flex; gap: 8px; }
.gendoc-score-button {
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 1.3rem;
  padding: 8px 14px;
}
.gendoc-score-button.selected { border-color: var(--accent); }

#gendoc-reasoning-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
#gendoc-reasoning-buttons button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 400;
  padding: 6px 10px;
}
#gendoc-reasoning-output p {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.88rem;
  white-space: pre-wrap;
}

/* Subscribe / Donate */
#subscribe-view, #donate-view {
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
}
#donate-presets { flex-wrap: wrap; }

/* Admin */
#admin-view {
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--border);
}
.admin-tab-button {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  border: none;
  border-radius: 8px 8px 0 0;
  padding: 8px 14px;
}
.admin-tab-button.selected {
  background: var(--panel);
  color: var(--text);
}

.admin-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.admin-add-row input { flex: 1; }

.admin-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.admin-remove-button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 400;
  padding: 4px 10px;
  flex-shrink: 0;
}
