:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --panel: #151a22;
  --panel-strong: #1b222d;
  --text: #edf2f7;
  --muted: #93a4b7;
  --line: #2a3442;
  --accent: #26d09d;
  --accent-strong: #13b981;
  --blue: #67b7ff;
  --red: #ff6b6b;
  --amber: #f2b84b;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(38, 208, 157, 0.12), transparent 28%),
    linear-gradient(225deg, rgba(103, 183, 255, 0.1), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(32px, 4vw, 58px);
  line-height: 1;
}

h2 {
  font-size: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 112px;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(21, 26, 34, 0.82);
  color: var(--muted);
  box-shadow: var(--shadow);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.status-pill[data-state="ok"] {
  color: var(--accent);
}

.status-pill[data-state="ok"] .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(38, 208, 157, 0.12);
}

.status-pill[data-state="error"] {
  color: var(--red);
}

.status-pill[data-state="error"] .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(255, 107, 107, 0.12);
}

.status-pill[data-state="loading"] {
  color: var(--amber);
}

.status-pill[data-state="loading"] .status-dot {
  background: var(--amber);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 26, 34, 0.88);
  box-shadow: var(--shadow);
}

.config-panel,
.prompt-panel,
.response-panel {
  padding: 18px;
}

.metrics-panel,
.models-panel,
.logs-panel {
  padding: 16px;
}

.config-panel,
.prompt-panel,
.response-panel {
  grid-column: 1;
}

.metrics-panel,
.models-panel,
.logs-panel {
  grid-column: 2;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field.wide {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.slider-row span {
  color: var(--muted);
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #0f141b;
  color: var(--text);
}

input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 170px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: rgba(38, 208, 157, 0.72);
  box-shadow: 0 0 0 3px rgba(38, 208, 157, 0.12);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.primary,
.secondary,
.danger,
.icon-button,
.segmented button {
  min-height: 40px;
  border-radius: 8px;
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease;
}

.primary,
.secondary,
.danger {
  padding: 0 14px;
  font-weight: 700;
}

.primary {
  background: var(--accent);
  color: #04120e;
}

.secondary {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

.danger {
  background: rgba(255, 107, 107, 0.16);
  color: #ffb1b1;
}

.primary:hover,
.secondary:hover,
.danger:hover,
.icon-button:hover,
.segmented button:hover {
  transform: translateY(-1px);
}

.icon-button {
  width: 42px;
  min-width: 42px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font-size: 20px;
}

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

.metric {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10161e;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 23px;
  overflow-wrap: anywhere;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  min-width: 92px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: var(--panel-strong);
  color: var(--accent);
}

.slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 12px;
  margin-top: 12px;
}

.slider-row label {
  display: grid;
  gap: 8px;
}

.slider-row b {
  color: var(--accent);
  font-size: 13px;
}

input[type="range"] {
  min-height: 8px;
  padding: 0;
  accent-color: var(--accent);
}

.response-output {
  min-height: 360px;
  max-height: 540px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  background: #080b10;
  color: #dbe7f3;
  font:
    13px/1.65 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.count-badge {
  min-width: 34px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(103, 183, 255, 0.14);
  color: var(--blue);
  text-align: center;
  font-weight: 700;
}

.models-list,
.log-list {
  display: grid;
  gap: 8px;
}

.model-item,
.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10161e;
}

.model-item button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  background: rgba(38, 208, 157, 0.12);
  color: var(--accent);
}

.model-name,
.log-main {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10161e;
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.18s ease,
    opacity 0.18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .config-panel,
  .prompt-panel,
  .response-panel,
  .metrics-panel,
  .models-panel,
  .logs-panel {
    grid-column: 1;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pill,
  .segmented,
  .button-row button {
    width: 100%;
  }

  .field-grid,
  .metrics-panel,
  .slider-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 36px;
  }
}
