:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #666666;
  --border: #e0e0e0;
  --accent: #2f6fed;
  --bubble-user: #eef3ff;
  --bubble-assistant: #f5f5f5;
  --code-bg: #f0f0f0;
  --danger: #c0392b;
  --danger-bg: #fde2e2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --fg: #eaeaea;
    --muted: #9a9a9a;
    --border: #2c2f36;
    --accent: #6d9bff;
    --bubble-user: #24304a;
    --bubble-assistant: #232529;
    --code-bg: #2d2f34;
    --danger: #ff8a80;
    --danger-bg: #3a2020;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  height: 100vh;
}
#app-shell {
  display: flex;
  flex-direction: row;
  height: 100vh;
}
header {
  flex: 0 0 200px;
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
}
header h1 { font-size: 1rem; font-weight: 600; margin: 0; }
nav#tabs { display: flex; flex-direction: column; gap: 0.2rem; }
nav#tabs button {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}
nav#tabs button.active { 
  color: var(--fg); 
  background: var(--code-bg); 
  font-weight: 600; 
}
#status { 
  color: var(--muted); 
  font-size: 0.8rem; 
  margin-top: auto;
}
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
#login-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}
#login-view a {
  background: var(--accent);
  color: white;
  text-decoration: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-size: 0.95rem;
}
#chat-view {
  flex: 1;
  display: none;
  flex-direction: column;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  overflow: hidden;
}
#messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 1rem;
}
#chat-status {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2em;
  padding: 0 0.1rem 0.4rem;
}
.msg {
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  max-width: 85%;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 0.95rem;
}
.msg.user { align-self: flex-end; background: var(--bubble-user); }
.msg.assistant { align-self: flex-start; background: var(--bubble-assistant); }
.msg.error { align-self: flex-start; background: var(--danger-bg); color: var(--danger); }
.msg code, .msg pre {
  background: var(--code-bg);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}
.msg pre { padding: 0.6rem; overflow-x: auto; }
.citations {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.citation {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
form {
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
textarea {
  flex: 1;
  resize: none;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.95rem;
}
button {
  padding: 0 1.2rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 0.95rem;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }

#home-view, #aws-view, #mcp-view, #admin-view {
  flex: 1;
  display: none;
  flex-direction: column;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  overflow-y: auto;
  gap: 1rem;
}
#home-view h2, #aws-view h2, #mcp-view h2, #admin-view h2 { 
  font-size: 0.9rem; 
  font-weight: 600; 
  margin: 0; 
  color: var(--muted);
}
#admin-error, #aws-error, #mcp-error {
  display: none;
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
}
#profile-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--code-bg);
  border-radius: 10px;
  padding: 1rem 1.2rem;
}
#profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border);
}
.profile-name { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.3rem; }
.profile-detail { font-size: 0.85rem; margin-top: 0.15rem; }
.profile-detail .field-label { display: inline-block; width: 70px; color: var(--muted); }
.role-badge {
  display: inline-block;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.home-cards { display: flex; flex-direction: column; gap: 0.75rem; }
.home-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  color: var(--fg);
  text-align: left;
  font-size: 0.95rem;
  cursor: pointer;
}
.home-card strong { font-size: 1rem; }
.home-card span { color: var(--muted); font-size: 0.85rem; font-weight: normal; }
#repos-section h2 { font-size: 0.9rem; font-weight: 600; margin: 0 0 0.5rem; color: var(--muted); }
.repos-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.repos-list a {
  display: block;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}
.repos-list a:hover { background: var(--code-bg); }
.reveal-box {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--code-bg);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.row { display: flex; gap: 0.5rem; }
.reveal-box .field-label { 
  color: var(--muted); 
  font-size: 0.8rem;
}
.reveal-box input[readonly] {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}
#add-user-form, #add-repo-form { display: flex; gap: 0.5rem; }
#add-user-form input[type="text"], #add-repo-form input[type="text"] {
  flex: 1;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-size: 0.9rem;
}
#add-user-form select, table.users-table select {
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-size: 0.85rem;
}
#add-user-form button, #add-repo-form button { padding: 0 1rem; }
.user-repos-cell { display: flex; flex-direction: column; gap: 0.35rem; min-width: 160px; }
.user-repo-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.user-repo-tags .citation { display: inline-flex; align-items: center; gap: 0.3rem; }
.tag-remove-btn {
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.user-repos-cell .row select { font-size: 0.8rem; padding: 0.3rem 0.4rem; }
.user-repos-cell .row button { font-size: 0.75rem; padding: 0.3rem 0.6rem; }
table.users-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.users-table th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
}
table.users-table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
.remove-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; line-height: 1.5; }
.hint code {
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.1rem 0.3rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.next-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.next-steps-body { display: flex; gap: 0.75rem; align-items: flex-start; }
.next-steps-menu {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 0 0 auto;
  border-right: 1px solid var(--border);
  padding-right: 0.75rem;
}
.next-steps-menu button {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  text-align: left;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
}
.next-steps-menu button.active { color: var(--fg); background: var(--bg); font-weight: 600; }
.next-steps-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
}
.next-steps pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  overflow-x: auto;
  margin: 0;
}
.next-steps pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  white-space: pre;
}
