:root {
  color-scheme: dark;
  --bg: #0b1016;
  --panel: #121922;
  --panel-2: #17212c;
  --line: #263445;
  --text: #edf3f7;
  --muted: #9aa9b8;
  --accent: #76d4ff;
  --ok: #3ddc97;
  --warn: #f5c542;
  --bad: #ff6b7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: #0d131a;
}

.brand {
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 6px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

p,
.hint {
  color: var(--muted);
}

main {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.auth-panel,
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.panel {
  padding: 14px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.field-grid,
.release-form,
.feedback-form,
.generation-form,
.retrieval-form,
.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.toolbar {
  grid-template-columns: minmax(140px, 1fr) auto auto;
  margin-bottom: 12px;
}

.retrieval-form {
  grid-template-columns: minmax(260px, 1.5fr) minmax(150px, 0.7fr) minmax(150px, 0.7fr) minmax(220px, 1fr) repeat(5, minmax(120px, auto));
  align-items: end;
  margin-bottom: 12px;
}

.feedback-form {
  grid-template-columns: repeat(4, minmax(150px, 1fr)) repeat(3, minmax(120px, auto));
  align-items: end;
  margin-bottom: 12px;
}

.generation-form {
  grid-template-columns: minmax(160px, 0.8fr) minmax(160px, 0.8fr) minmax(220px, 1fr) repeat(2, minmax(150px, auto));
  align-items: end;
  margin-bottom: 12px;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.wide {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea,
select,
button {
  width: 100%;
  border: 1px solid var(--line);
  background: #0f161f;
  color: var(--text);
  border-radius: 7px;
  padding: 10px 11px;
  font: inherit;
}

textarea {
  resize: vertical;
}

button {
  cursor: pointer;
  background: #1d2a38;
  font-weight: 700;
}

button:hover {
  border-color: var(--accent);
}

button.secondary {
  background: #111a24;
  color: var(--muted);
}

.actions,
.status-strip {
  display: flex;
  gap: 10px;
  align-items: center;
}

.actions {
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid #2f4e61;
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.pill.ok {
  color: var(--ok);
  border-color: #2b6b53;
}

.pill.warn {
  color: var(--warn);
  border-color: #6c5b29;
}

.pill.bad {
  color: var(--bad);
  border-color: #74404a;
}

.pill.muted {
  color: var(--muted);
  border-color: var(--line);
}

.stack {
  display: grid;
  gap: 10px;
}

.card {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 12px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  margin-bottom: 8px;
}

.card h3 {
  margin: 0;
  font-size: 16px;
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.published-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.answer-box {
  border: 1px solid #2f4e61;
  background: #0f1822;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.retrieval-card {
  border-color: #31546b;
}

.empty {
  color: var(--muted);
}

.log-panel pre {
  min-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
  margin: 0;
  color: #c8d7e3;
}

@media (max-width: 900px) {
  .topbar,
  .auth-panel,
  .grid.two,
  .field-grid,
  .release-form,
  .feedback-form,
  .generation-form,
  .retrieval-form,
  .toolbar,
  .published-grid {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

  .topbar {
    display: grid;
  }
}
