:root {
  color-scheme: dark;
  --bg: #0c1210;
  --panel: rgba(20, 33, 29, 0.65);
  --ink: #eef8f2;
  --muted: #a9bdb4;
  --line: #385249;
  --accent: #f3b35b;
  --accent-2: #53ad92;
  --danger: #e06c53;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(243, 179, 91, 0.12), transparent 30rem),
    radial-gradient(circle at 90% 10%, rgba(83, 173, 146, 0.1), transparent 28rem),
    var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
}

.topbar-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

button.compact {
  min-height: 32px;
  padding: 6px 10px;
}

.nav-link {
  background: transparent;
  border: 1px solid var(--accent-2);
  border-radius: 8px;
  color: var(--accent-2);
  font-weight: 700;
  min-height: 32px;
  padding: 6px 10px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.nav-link:hover {
  background: var(--accent-2);
  color: #0c1210;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  margin-bottom: 14px;
}

p,
label,
dt {
  color: var(--muted);
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  min-width: 128px;
  padding: 8px 12px;
  text-align: center;
}

.status-pill.connected {
  background: rgba(83, 173, 146, 0.2);
  border-color: var(--accent-2);
  color: var(--accent-2);
}

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

.panel {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.panel:hover {
  border-color: var(--line);
}

details.legacy-tools {
  grid-column: 1 / -1;
  background: rgba(20, 33, 29, 0.4);
  border: 1px dashed var(--line);
}

details.legacy-tools summary {
  cursor: pointer;
  padding: 10px 0;
  user-select: none;
  color: var(--muted);
}

details.legacy-tools summary:hover {
  color: var(--accent);
}

details.legacy-tools summary h2 {
  display: inline-block;
  margin-bottom: 0;
}

.panel-note,
.vogon-safety {
  font-size: 12px;
}

.vogon-safety {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 8px;
  padding: 8px;
}

.row {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.output-row output {
  min-width: 36px;
  text-align: right;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin: 12px 0 6px;
  text-transform: uppercase;
}

select,
textarea,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="range"] {
  min-width: 0;
  width: 100%;
}

select,
textarea,
input[type="text"],
input[type="password"],
input[type="number"] {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  padding: 8px;
  transition: border-color 0.2s ease;
}

select {
  background: #202624;
  font-weight: bold;
}

select option {
  background: #14211d;
  color: #fff;
  font-weight: bold;
}

select:focus,
textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
  border-color: var(--accent);
  outline: none;
}

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: #0c1210;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 36px;
  padding: 8px 12px;
  white-space: nowrap;
  transition: background 0.2s ease, transform 0.1s ease;
}

button:hover:not(:disabled) {
  background: #f5c480;
  transform: translateY(-1px);
}

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

button.secondary {
  background: var(--line);
  color: var(--ink);
}

button.secondary:hover:not(:disabled) {
  background: #47665b;
}

button.danger {
  background: var(--danger);
  color: #fff;
}

button.wide {
  margin-top: 12px;
  width: 100%;
}

.button-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

dl {
  display: grid;
  gap: 6px 12px;
  grid-template-columns: 100px minmax(0, 1fr);
  margin: 8px 0 0;
}

.voice-conversation-status {
  margin: 10px 0 0;
}

.voice-loop-control audio,
.voice-loop-control a {
  margin-top: 6px;
  max-width: 100%;
}

dt,
dd {
  margin: 0;
}

dd {
  overflow-wrap: anywhere;
}

.log-panel {
  grid-column: 1 / -1;
}

pre {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  color: var(--ink);
  max-height: 360px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.pipeline-records {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.pipeline-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.pipeline-summary {
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
  display: grid;
  gap: 8px;
  grid-template-columns: 150px 90px 1fr auto;
  padding: 10px;
}

.pipeline-summary code {
  overflow-wrap: anywhere;
}

.pipeline-status {
  border-radius: 999px;
  color: #fff;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  text-align: center;
}

.pipeline-status.success {
  background: var(--accent);
}

.pipeline-status.warning {
  background: var(--accent-2);
}

.pipeline-status.error {
  background: var(--danger);
}

.pipeline-detail {
  background: rgba(0, 0, 0, 0.4);
  color: var(--ink);
  display: none;
  margin: 0;
  padding: 12px;
}

.pipeline-card.open .pipeline-detail {
  display: block;
}

.copy-button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: #0c1210;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 36px;
  padding: 8px 12px;
  white-space: nowrap;
  transition: background 0.2s ease, transform 0.1s ease;
}

button:hover:not(:disabled) {
  background: #f5c480;
  transform: translateY(-1px);
}

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

.network-lanterns {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.network-lantern {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow-wrap: anywhere;
  padding: 8px;
}

.audio-action-stack {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.audio-action-stack .wide,
.audio-action-stack .row {
  margin: 0;
}

.review-checks {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.review-checks label {
  margin: 0;
  text-transform: none;
}

.audio-review-library {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.audio-review-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.audio-review-card p {
  font-size: 12px;
  margin: 5px 0;
}

.audio-review-card audio {
  width: 100%;
}

@media (max-width: 820px) {
  .app {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}
