:root {
  --primary-color: #10b981; /* Emerald green for nature/birds */
  --primary-dark: #059669;
  --secondary-color: #3b82f6; /* Sky blue */
  --accent-color: #f59e0b; /* Amber for highlights */
  --bg-light: #f8fafc; /* Near white */
  --fg-light: #1e293b; /* Dark slate */
  --muted-light: #64748b; /* Slate */
  --line-light: #e2e8f0; /* Light slate */
  --shadow-light: 0 4px 20px rgba(0,0,0,.08);
  --shadow-md: 0 10px 40px rgba(0,0,0,.12);
}
:root.dark {
  --primary-color: #10b981; /* Keep emerald in dark */
  --primary-dark: #059669;
  --secondary-color: #60a5fa; /* Lighter sky blue */
  --accent-color: #fbbf24; /* Lighter amber */
  --bg-dark: #0f172a; /* Very dark blue */
  --fg-dark: #f1f5f9; /* Near white */
  --muted-dark: #94a3b8; /* Light slate */
  --line-dark: #334155; /* Dark slate */
  --shadow-dark: 0 10px 40px rgba(0,0,0,.5);
}

:root {
  --bg: var(--bg-light);
  --fg: var(--fg-light);
  --muted: var(--muted-light);
  --line: var(--line-light);
  --shadow: var(--shadow-light);
}
:root.dark {
  --bg: var(--bg-dark);
  --fg: var(--fg-dark);
  --muted: var(--muted-dark);
  --line: var(--line-dark);
  --shadow: var(--shadow-dark);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--fg);
  background-image: linear-gradient(135deg, var(--bg) 0%, color-mix(in oklab, var(--bg) 90%, var(--primary-color)) 100%);
  background-attachment: fixed;
  line-height: 1.6;
}

.app-header { 
  position: sticky; 
  top: 0; 
  backdrop-filter: saturate(180%) blur(16px); 
  border-bottom: 1px solid color-mix(in oklab, var(--line) 50%, transparent); 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  padding: 16px 24px; 
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  z-index: 100; 
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.app-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
}
.logo-icon { 
  height: 40px; 
  width: 40px; 
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.1));
}
.header-actions { 
  display: flex; 
  gap: 8px; 
}

.container { 
  max-width: 1200px; 
  margin: 40px auto; 
  padding: 0 20px; 
  display: grid; 
  gap: 24px; 
}

.panel { 
  background: color-mix(in oklab, var(--bg) 95%, var(--fg) 5%);
  border: 1px solid var(--line); 
  border-radius: 20px; 
  box-shadow: var(--shadow); 
  padding: 28px;
  transition: box-shadow .3s ease, transform .2s ease;
}
.panel:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.uploader { 
  border: 2px dashed var(--line); 
  border-radius: 16px; 
  padding: 48px 24px; 
  transition: border-color .2s, background .2s, transform .2s;
  background: color-mix(in oklab, var(--primary-color) 2%, var(--bg));
}
.uploader.dragover { 
  border-color: var(--primary-color); 
  background: color-mix(in oklab, var(--primary-color) 8%, var(--bg));
  transform: scale(1.02);
}
.uploader-inner { 
  text-align: center; 
  display: grid; 
  gap: 12px; 
}
.uploader-icon-img { 
  height: 64px; 
  width: 64px; 
  object-fit: contain; 
  opacity: .85;
  margin: 0 auto;
}
.uploader-title { 
  font-weight: 700; 
  margin: 8px 0; 
  font-size: 18px;
  color: var(--fg);
}
.uploader-sub, .uploader-hint { 
  color: var(--muted); 
  font-size: 14px;
  margin: 2px 0;
}
.uploader-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 12px 0;
}

.preview { 
  display: grid; 
  gap: 12px; 
  margin-top: 20px;
  animation: slideIn .3s ease-out;
}
.preview img { 
  width: 100%; 
  max-height: 420px; 
  object-fit: contain; 
  background: color-mix(in oklab, var(--fg) 2%, var(--bg)); 
  border: 1px solid var(--line); 
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.actions { 
  display: flex; 
  justify-content: center;
  gap: 12px;
  margin-top: 20px; 
}

.primary-btn, .secondary-btn, .ghost-btn, .icon-btn { 
  border: none;
  background: var(--bg); 
  color: var(--fg); 
  padding: 12px 24px; 
  border-radius: 10px; 
  cursor: pointer; 
  font-weight: 600;
  font-size: 15px;
  transition: all .2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary-btn { 
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white; 
  box-shadow: 0 4px 12px color-mix(in oklab, var(--primary-color) 40%, transparent);
}
.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px color-mix(in oklab, var(--primary-color) 50%, transparent);
}
.secondary-btn { 
  background: linear-gradient(135deg, var(--secondary-color) 0%, color-mix(in oklab, var(--secondary-color) 80%, var(--primary-color)) 100%);
  color: white;
  box-shadow: 0 4px 12px color-mix(in oklab, var(--secondary-color) 30%, transparent);
}
.secondary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px color-mix(in oklab, var(--secondary-color) 40%, transparent);
}
.ghost-btn { 
  background: transparent;
  border: 1px solid var(--line);
}
.ghost-btn:hover {
  background: color-mix(in oklab, var(--fg) 3%, var(--bg));
  border-color: var(--primary-color);
}
.icon-btn { 
  padding: 8px 12px; 
  border-radius: 8px;
  border: 1px solid var(--line);
}
.icon-btn:hover {
  background: color-mix(in oklab, var(--fg) 5%, var(--bg));
}
.primary-btn:disabled { 
  opacity: .5; 
  cursor: not-allowed;
  transform: none;
}

.small { padding: 8px 16px; font-size: 14px; }
.large { padding: 14px 32px; font-weight: 700; }

.status { 
  min-height: 24px; 
  color: var(--accent-color); 
  margin-top: 16px;
  font-weight: 500;
  animation: fadeIn .3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.result-header { 
  display: flex; 
  flex-wrap: wrap; 
  align-items: baseline; 
  gap: 20px; 
  margin-bottom: 28px; 
  padding-bottom: 20px; 
  border-bottom: 2px solid var(--line);
  animation: slideIn .4s ease-out;
}
.result-header h2 { 
  margin: 0; 
  font-size: 32px; 
  line-height: 1.2;
  color: var(--primary-color);
  font-weight: 800;
}
.result-header .mono { 
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco; 
  font-size: 15px;
}
.result-header .muted { 
  color: var(--muted);
  font-size: 14px;
}
.confidence-display { 
  margin-left: auto; 
  white-space: nowrap;
  background: color-mix(in oklab, var(--accent-color) 10%, var(--bg));
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--accent-color);
  font-weight: 600;
  color: var(--accent-color);
}
.small-text { 
  font-size: 14px; 
  line-height: 1.5; 
  margin-top: 8px;
  color: var(--muted);
}

.bird-description { 
  margin-top: 0; 
  line-height: 1.7;
  font-size: 16px;
  color: var(--fg);
}

.result-grid { 
  display: grid; 
  grid-template-columns: 1fr minmax(240px, 0.6fr); 
  gap: 24px; 
  margin-top: 16px; 
}
.traits { 
  margin: 0; 
  padding-left: 20px; 
  line-height: 1.8;
  list-style-type: none;
  padding: 0;
}
.traits li {
  padding: 10px 0;
  padding-left: 24px;
  position: relative;
}
.traits li:before {
  content: "🐦";
  position: absolute;
  left: 0;
}
.traits li strong { 
  font-weight: 700;
  color: var(--primary-color);
}

.meta { display: grid; gap: 12px; align-content: start; }

.details-section { 
  margin-top: 28px;
  padding: 20px;
  background: color-mix(in oklab, var(--primary-color) 2%, var(--bg));
  border-left: 4px solid var(--primary-color);
  border-radius: 8px;
  animation: slideIn .4s ease-out;
}
.details-section h3 { 
  margin: 0 0 12px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.details-section p { 
  margin-top: 0; 
  line-height: 1.7;
  font-size: 15px;
  color: var(--fg);
}

.notes { 
  margin-top: 32px; 
  padding: 20px;
  background: color-mix(in oklab, var(--accent-color) 5%, var(--bg));
  border-left: 4px solid var(--accent-color);
  border-radius: 8px;
}
.notes h3 { 
  margin: 0 0 12px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.notes p { 
  margin: 0;
  font-style: italic; 
  color: var(--muted);
  line-height: 1.6;
}

.modal { 
  border: none; 
  border-radius: 20px; 
  padding: 0; 
  max-width: 720px; 
  width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal::backdrop { 
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
}
.modal-content { 
  padding: 24px; 
  display: grid; 
  gap: 16px;
  background: var(--bg);
}
.modal-header { 
  display: flex; 
  align-items: center; 
  justify-content: space-between;
}
.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
}
.field { display: grid; gap: 8px; }
.field input { 
  padding: 12px 16px; 
  border: 1px solid var(--line); 
  border-radius: 10px; 
  background: color-mix(in oklab, var(--fg) 2%, var(--bg));
  color: var(--fg);
  font-size: 15px;
  transition: border-color .2s ease;
}
.field input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.camera-wrap { 
  position: relative; 
  background: color-mix(in oklab, var(--fg) 3%, var(--bg)); 
  border: 1px solid var(--line); 
  border-radius: 12px; 
  overflow: hidden;
  aspect-ratio: 16/9;
}
video { 
  width: 100%; 
  height: 100%;
  object-fit: cover;
  display: block; 
}
canvas { 
  width: 100%; 
  height: 100%;
  object-fit: cover;
  display: block; 
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
}

@media (max-width: 780px) {
  .result-header { 
    flex-direction: column; 
    align-items: flex-start;
    gap: 12px;
  }
  .confidence-display { 
    margin-left: 0; 
    margin-top: 8px; 
  }
  .actions {
    flex-direction: column;
  }
  .actions button {
    width: 100%;
  }
  .container {
    margin: 24px auto;
  }
  .panel {
    padding: 20px;
  }
}

/* Styles for name labels */
.name-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.name-label {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bird-name-display {
  margin: 0;
  font-size: 32px;
  line-height: 1.2;
  color: var(--primary-color);
  font-weight: 800;
}

.scientific-name-val {
  font-size: 15px;
  margin-top: 0;
  color: var(--muted);
  font-style: italic;
}