:root {
  color-scheme: dark;
  --bg0: #07080d;
  --bg1: #0e1118;
  --bg2: #151a24;
  --fg: #eef2f8;
  --muted: #8b94a8;
  --accent: #38bdf8;
  --accent2: #a78bfa;
  --accent-glow: color-mix(in srgb, var(--accent) 35%, transparent);
  --card: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "SF Pro Display", "SF Pro Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-family: var(--font);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(56, 189, 248, 0.12), transparent),
    radial-gradient(900px 500px at -10% 30%, rgba(167, 139, 250, 0.1), transparent), linear-gradient(165deg, var(--bg0), var(--bg1) 45%, #0a0d14);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.top-brand {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 28px var(--accent-glow);
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-kicker {
  margin: 0 0 4px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-title {
  margin: 0 0 6px;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand-desc {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.tab-bar {
  display: flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  border: 1px solid var(--card-border);
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.tab-active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(167, 139, 250, 0.2));
  color: var(--fg);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.panel[hidden] {
  display: none !important;
}

.glass-card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
  margin-bottom: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

.results-card {
  margin-top: 8px;
}

.section-label {
  margin: 0 0 14px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.label {
  font-size: 0.82rem;
  font-weight: 600;
  color: color-mix(in srgb, var(--fg) 92%, transparent);
}

.label-hint {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
  margin: 0 0 4px;
}

input[type="text"],
textarea,
select {
  font: inherit;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--fg);
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.45;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

.chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1.35;
}

.chip input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.row-inline {
  margin-bottom: 10px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 0.88rem;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-ui {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  position: relative;
  flex-shrink: 0;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--fg);
  top: 3px;
  left: 4px;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-ui {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.toggle input:checked + .toggle-ui::after {
  transform: translateX(16px);
  background: #0a0c12;
}

.watch-interval select {
  max-width: 140px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  flex: 1;
  font: inherit;
  font-weight: 700;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: transform 0.08s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #22d3ee);
  color: #041018;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
  border: 1px solid var(--card-border);
}

.btn-full {
  width: 100%;
  margin-top: 12px;
}

.status {
  min-height: 1.4em;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 10px 4px;
}

.errors {
  font-size: 0.8rem;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
  line-height: 1.45;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-card,
.db-card {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: rgba(0, 0, 0, 0.28);
}

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

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent);
  flex-shrink: 0;
  max-width: 46%;
  text-align: right;
  line-height: 1.25;
}

.result-title {
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
}

.result-meta,
.db-meta {
  font-size: 0.76rem;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.4;
}

.result-actions,
.db-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 12px;
}

.result-actions a,
.db-actions button {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.result-actions a:hover,
.db-actions button:hover {
  text-decoration: underline;
}

.db-actions .btn-ghost {
  color: var(--accent2);
}

.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 0.88rem;
}

.base-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.base-head .section-label {
  margin: 0;
}

.pill-count {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.2);
  color: #ddd6fe;
}

.admin-user {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.22);
}

.admin-user-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.admin-user-id {
  font-weight: 800;
  font-size: 0.95rem;
}

.admin-save {
  flex: 0 0 auto;
  padding: 8px 14px;
  font-size: 0.78rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: min(92dvh, 900px);
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--fg);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.cache-meta {
  padding: 10px 14px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
}

.cache-meta strong {
  color: var(--fg);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 10px;
}

.btn-inline {
  flex: 1 1 auto;
  min-width: 120px;
}

.cache-iframe {
  flex: 1;
  min-height: 220px;
  width: 100%;
  border: none;
  border-top: 1px solid var(--card-border);
  background: #fff;
}

.cache-no-html {
  padding: 12px 14px 16px;
  margin: 0;
}
