:root {
  --bg: #0c0e12;
  --surface: #151922;
  --surface-2: #1c2230;
  --border: #2a3344;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #6ea8fe;
  --accent-dim: #3d6cb4;
  --success: #3dd68c;
  --warning: #f5c542;
  --error: #ff6b6b;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  font-family: "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(110, 168, 254, 0.12), transparent),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(21, 25, 34, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

header h1 span {
  color: var(--muted);
  font-weight: 400;
}

.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.health-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.health-pill.ok .dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.health-pill.err .dot {
  background: var(--error);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  gap: 1.25rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.panel-body {
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

input[type="text"],
input[type="url"],
input[type="number"],
textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 168, 254, 0.15);
}

textarea {
  min-height: 72px;
  resize: vertical;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: end;
}

.row-3 {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 0.75rem;
  align-items: end;
}

@media (max-width: 640px) {
  .row,
  .row-3 {
    grid-template-columns: 1fr;
  }
}

button {
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #0c0e12;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}

button:hover:not(:disabled) {
  background: #8bbaff;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

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

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

details.settings {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

details.settings summary {
  padding: 0.65rem 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  user-select: none;
}

.settings-grid {
  padding: 0 0.8rem 0.8rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.88rem;
}

.checkbox-row input {
  width: auto;
}

.status-card {
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: none;
}

.status-card.visible {
  display: grid;
  gap: 0.5rem;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-badge.queued,
.status-badge.processing {
  background: rgba(245, 197, 66, 0.15);
  color: var(--warning);
}

.status-badge.ready {
  background: rgba(61, 214, 140, 0.15);
  color: var(--success);
}

.status-badge.failed {
  background: rgba(255, 107, 107, 0.15);
  color: var(--error);
}

.status-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.status-meta strong {
  color: var(--text);
}

.error-text {
  color: var(--error);
  font-size: 0.85rem;
}

.hits {
  display: grid;
  gap: 1rem;
}

.hit-card {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

@media (max-width: 720px) {
  .hit-card {
    grid-template-columns: 1fr;
  }
}

.hit-media video {
  width: 100%;
  border-radius: 6px;
  background: #000;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

.hit-score {
  display: inline-block;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  background: rgba(110, 168, 254, 0.15);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
}

.hit-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.hit-times {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.transcript {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
}

.transcript-empty {
  color: var(--muted);
  font-style: italic;
}

.segments-toggle {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-weight: 500;
}

.segments-list {
  margin-top: 0.5rem;
  padding-left: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--muted);
  display: none;
}

.segments-list.open {
  display: grid;
  gap: 0.25rem;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.35rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}
