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

/* ── Tokens ─────────────────────────────────────────── */
:root {
  --bg:          #0d1525;
  --surface:     #162033;
  --surface-2:   #1c2a42;
  --border:      #243350;
  --border-focus:#6366f1;
  --primary:     #6366f1;
  --primary-dim: #4f46e5;
  --blue:        #3b82f6;
  --success:     #22c55e;
  --error:       #ef4444;
  --text:        #e2e8f0;
  --muted:       #7e92b4;
  --radius:      10px;
}

/* ── Base ───────────────────────────────────────────── */
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* ── Header ─────────────────────────────────────────── */
header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 2rem;
}

.logo {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  object-fit: contain;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

/* ── Tabs ───────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem;
  max-width: 480px;
  margin-inline: auto;
  margin-bottom: 1.75rem;
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab:hover { color: var(--text); }

.tab.active {
  background: var(--primary);
  color: #fff;
}

/* ── Panel ──────────────────────────────────────────── */
.panel { display: none; }
.panel.active { display: block; }

/* ── Text search bar ────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 0.5rem;
  max-width: 680px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 1rem;
  color: var(--text);
  min-width: 0;
}

.search-bar input::placeholder { color: var(--muted); }

/* ── Shared button style ────────────────────────────── */
button[id$="-btn"], button[id$="-search-btn"] {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.3rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

button[id$="-btn"]:hover { background: var(--primary-dim); }
button[id$="-btn"]:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Drop zone ──────────────────────────────────────── */
.drop-zone {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(99,102,241,0.06);
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  text-align: center;
  padding: 2rem;
  pointer-events: none;
}

.drop-placeholder svg { opacity: 0.5; }
.drop-placeholder p { font-size: 0.9rem; }
.drop-placeholder .hint { font-size: 0.78rem; opacity: 0.6; }
.drop-placeholder .link { color: var(--primary); }

.drop-preview {
  width: 100%;
  height: 220px;
  object-fit: contain;
  background: var(--surface-2);
  display: block;
}

/* ── Caption textarea ───────────────────────────────── */
.caption-wrap {
  max-width: 520px;
  margin: 0.85rem auto 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.caption-wrap label {
  font-size: 0.82rem;
  color: var(--muted);
}

.caption-wrap textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.caption-wrap textarea:focus { border-color: var(--border-focus); }
.caption-wrap textarea::placeholder { color: var(--muted); }

/* ── Panel action row ───────────────────────────────── */
.panel-actions {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

/* ── Status ─────────────────────────────────────────── */
.status {
  text-align: center;
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  color: var(--muted);
  margin: 1.25rem auto 0;
  max-width: 520px;
  border-radius: var(--radius);
}

.status.success { color: var(--success); background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.2); }
.status.error   { color: var(--error);   background: rgba(239,68,68,0.08);  border: 1px solid rgba(239,68,68,0.2);  }

/* ── Results meta ────────────────────────────────────── */
.results-meta {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  margin: 1.5rem 0 1rem;
}

.results-meta em { color: var(--text); font-style: normal; font-weight: 500; }

/* ── Grid ───────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

/* ── Card ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}

.card img {
  width: 100%;
  height: 175px;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}

.card-body {
  padding: 0.7rem 0.85rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.card-score {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.score-bar-wrap {
  flex: 1;
  height: 5px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}

.score-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--blue));
  border-radius: 99px;
}

.score-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  min-width: 2.8rem;
  text-align: right;
}

.card-caption {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

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