:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel-2: #1a2740;
  --border: #263450;
  --text: #e8edf7;
  --muted: #93a1bd;
  --accent: #00c896;
  --accent-2: #3b82f6;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 12px;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #0b1220 0%, #0e1626 100%);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

header.hero {
  text-align: center;
  padding: 32px 16px 24px;
}

header.hero h1 {
  font-size: 2rem;
  margin: 0 0 8px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

header.hero p {
  color: var(--muted);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.6;
}

.badges {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--panel);
}

nav.tabs {
  display: flex;
  gap: 8px;
  margin: 24px 0 16px;
  border-bottom: 1px solid var(--border);
}

nav.tabs button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  padding: 10px 18px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

nav.tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

h2 {
  margin-top: 0;
}

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

.status-line {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.4em;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  margin: 12px 0;
}

.status-line.error {
  color: #fecaca;
  background: #2a1214;
  border-color: var(--danger);
  white-space: pre-wrap;
}

.status-line.success {
  color: #bbf7d0;
  border-color: var(--accent);
}

button.primary,
button.secondary,
button.danger {
  font-size: 0.95rem;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
}

button.primary {
  background: var(--accent);
  color: #04231b;
  border-color: var(--accent);
}

button.secondary {
  background: var(--panel-2);
  color: var(--text);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

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

.trigger-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

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

.trigger-card .thumbs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.trigger-card img.thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.trigger-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.trigger-card .action-type {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.trigger-card .card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

form .field {
  margin-bottom: 14px;
}

form label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

input[type="file"] {
  color: var(--muted);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.hidden {
  display: none !important;
}

.recognize-source {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.recognize-source button.active {
  background: var(--accent);
  color: #04231b;
  border-color: var(--accent);
}

video#camera-preview,
canvas#camera-canvas {
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #000;
}

#upload-preview {
  max-width: 240px;
  max-height: 240px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: 10px;
}

.result-card {
  margin-top: 20px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.result-card.match {
  border-color: var(--accent);
}

.result-card.no-match {
  border-color: var(--warn);
}

.score-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
  margin: 8px 0;
}

.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

.action-output img,
.action-output video {
  max-width: 100%;
  border-radius: 10px;
  margin-top: 10px;
}

.weather-card {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.weather-metric {
  text-align: center;
}

.weather-metric .value {
  font-size: 1.8rem;
  font-weight: 700;
}

.weather-metric .label {
  font-size: 0.75rem;
  color: var(--muted);
}

.disclaimer {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--accent-2);
}

.threshold-note {
  font-size: 0.8rem;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 560px;
}

.modal h2 {
  margin-top: 0;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row > .field {
  flex: 1;
}

.ref-preview-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.ref-preview-list img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
