/* ── Reset & custom properties ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-light: #eef2ff;
  --text:          #1e293b;
  --text-sub:      #64748b;
  --border:        #e2e8f0;
  --bg:            #f1f5f9;
  --card:          #ffffff;
  --radius-lg:     18px;
  --radius-md:     12px;
  --shadow:        0 2px 24px rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 16px 56px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.header {
  text-align: center;
  padding: 40px 0 24px;
}

.header-emoji {
  display: block;
  font-size: 56px;
  margin-bottom: 10px;
  line-height: 1;
}

.header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
  margin-bottom: 6px;
}

.header p {
  font-size: 14px;
  color: var(--text-sub);
}

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 14px;
}

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 14px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sub);
  transition: color 0.15s, border-color 0.15s;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

/* ── Panel ──────────────────────────────────────────────────────────────── */
.panel { padding: 20px; }

/* ── Dropzone ───────────────────────────────────────────────────────────── */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 44px 20px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon {
  color: var(--text-sub);
  margin-bottom: 6px;
}

.dropzone-main {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.dropzone-sub {
  font-size: 13px;
  color: var(--text-sub);
}

/* ── Camera ─────────────────────────────────────────────────────────────── */
.camera-wrap {
  position: relative;
  background: #0f172a;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 4 / 3;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#canvas { display: none; }

.camera-no-support {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  text-align: center;
  padding: 20px;
  line-height: 1.6;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 16px 20px 22px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.5) 0%, transparent 55%);
}

/* Camera shutter button */
.shutter-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: transparent;
  border: 4px solid rgba(255, 255, 255, 0.85);
  position: relative;
  cursor: pointer;
  transition: transform 0.1s;
  flex-shrink: 0;
}

.shutter-btn::after {
  content: '';
  position: absolute;
  inset: 5px;
  background: white;
  border-radius: 50%;
  transition: background 0.1s;
}

.shutter-btn:active {
  transform: scale(0.9);
}

.shutter-btn:active::after {
  background: rgba(255, 255, 255, 0.7);
}

/* Flip / icon buttons */
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.icon-btn:hover  { background: rgba(0, 0, 0, 0.55); }
.icon-btn:active { background: rgba(0, 0, 0, 0.7); }

.icon-btn-placeholder { width: 44px; flex-shrink: 0; }

.camera-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-sub);
  text-align: center;
}

/* ── Preview card ───────────────────────────────────────────────────────── */
.preview-card { position: relative; }

.preview-card img {
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  display: block;
  background: #f8fafc;
}

.retake-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.retake-btn:hover { background: rgba(0, 0, 0, 0.75); }

/* ── Error box ──────────────────────────────────────────────────────────── */
.error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-size: 14px;
  margin-bottom: 14px;
  line-height: 1.5;
}

/* ── Primary button ─────────────────────────────────────────────────────── */
.primary-btn {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  margin-bottom: 14px;
  letter-spacing: -0.1px;
}

.primary-btn:not(:disabled):hover  { background: var(--primary-dark); }
.primary-btn:not(:disabled):active { transform: scale(0.99); }
.primary-btn:disabled              { opacity: 0.35; cursor: not-allowed; }

/* ── Loading card ───────────────────────────────────────────────────────── */
.loading-card {
  padding: 36px 20px;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 14px;
}

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

.loading-card p {
  font-size: 15px;
  color: var(--text-sub);
}

/* ── Results card ───────────────────────────────────────────────────────── */
.top-result {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 22px 20px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
}

.trophy { font-size: 38px; flex-shrink: 0; line-height: 1; }

.top-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.75;
  margin-bottom: 3px;
}

.top-breed {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.2;
}

.top-pct {
  font-size: 14px;
  opacity: 0.8;
  margin-top: 3px;
}

.bars-section {
  padding: 18px 20px 22px;
}

.bar-item { margin-bottom: 16px; }
.bar-item:last-child { margin-bottom: 0; }

.bar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 13px;
}

.bar-name { font-weight: 500; }
.bar-pct  { color: var(--text-sub); font-variant-numeric: tabular-nums; }

.bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), #a78bfa);
  width: 0;
  transition: width 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Utility ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
