:root {
  color-scheme: dark;
  --bg: #07110b;
  --panel: #0e1b13;
  --panel2: #13251a;
  --text: #e9f7ee;
  --muted: #9db4a6;
  --border: #294232;
  --accent: #45e075;
  --danger: #ff7373;
  --warn: #ffce73;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at top, #0e2415, var(--bg) 42rem);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea {
  font: inherit;
}
button {
  border: 1px solid #3dea75;
  border-radius: 0.8rem;
  background: #2bc75d;
  color: #041006;
  padding: 0.7rem 1rem;
  font-weight: 700;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
button.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: #08140d;
  color: var(--text);
  padding: 0.75rem;
}
textarea { resize: vertical; line-height: 1.35; }
label { display: grid; gap: 0.4rem; color: var(--muted); }
.centered-page {
  display: grid;
  place-items: center;
  padding: 1rem;
}
.login-card, .card, .composer-card {
  background: color-mix(in srgb, var(--panel) 94%, black);
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  box-shadow: 0 1rem 3rem rgba(0,0,0,0.25);
}
.login-card {
  width: min(100%, 28rem);
  padding: 2rem;
}
.stack { display: grid; gap: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.alert {
  padding: 0.8rem 1rem;
  border-radius: 0.8rem;
  border: 1px solid var(--border);
  margin: 1rem 0;
}
.alert.error { color: #ffd6d6; border-color: #7c3131; background: #321313; }
.alert.success { color: #dfffe8; border-color: #2d7c45; background: #12361e; }
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(7,17,11,0.86);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 800; color: var(--text); }
.topbar nav { margin-left: auto; display: flex; gap: 1rem; align-items: center; }
.topbar form { margin: 0; }
.runner-status { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.92rem; }
.dot { width: 0.75rem; height: 0.75rem; border-radius: 50%; display: inline-block; background: #899389; }
.dot.online { background: var(--accent); box-shadow: 0 0 0.8rem rgba(69,224,117,0.45); }
.dot.offline { background: var(--danger); }
.dot.unknown { background: var(--warn); }
.page { padding: 1.2rem; margin: 0 auto; }
.page.narrow { max-width: 42rem; }
.page.wide { max-width: 82rem; }
.card { padding: 1rem; margin: 1rem 0; }
.grid-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; align-items: end; }
.check { display: flex; gap: 0.5rem; align-items: center; color: var(--muted); }
.check input { width: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.pill { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; background: var(--panel2); color: var(--muted); font-size: 0.8rem; margin-right: 0.25rem; }
.pill.warn { color: #ffe1a3; }
.actions { display: grid; gap: 0.45rem; }
.inline-form { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
.inline-form input[type=password] { width: 15rem; }
.chat-shell {
  min-height: calc(100vh - 4rem);
  display: grid;
  grid-template-rows: 1fr auto;
  max-width: 58rem;
  margin: 0 auto;
  padding: 1rem;
  gap: 1rem;
}
.messages {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding-bottom: 1rem;
}
.message {
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  padding: 0.9rem 1rem;
  background: rgba(14,27,19,0.92);
  white-space: pre-wrap;
  line-height: 1.45;
}
.message.user { align-self: flex-end; max-width: 85%; background: #12341e; }
.message.assistant { align-self: flex-start; max-width: 95%; }
.message.error { border-color: #7c3131; background: #321313; color: #ffd6d6; }
details.thinking {
  margin-bottom: 0.75rem;
  color: var(--muted);
  border-left: 3px solid var(--border);
  padding-left: 0.75rem;
}
details.thinking summary { cursor: pointer; }
.composer-card { padding: 0.85rem; position: sticky; bottom: 1rem; }
.composer-options { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: 0.65rem; flex-wrap: wrap; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 0.75rem; align-items: end; }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .topbar nav { margin-left: 0; }
  .grid-form { grid-template-columns: 1fr; }
  .composer { grid-template-columns: 1fr; }
  .message.user, .message.assistant { max-width: 100%; }
}
