:root {
  --bg: #0f1115;
  --panel: #191c23;
  --panel-2: #22262f;
  --text: #e8eaf0;
  --muted: #9aa1ad;
  --accent: #4f8cff;
  --good: #34c07c;
  --bad: #e5534b;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  position: sticky; top: 0;
  background: rgba(15,17,21,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid #262a33;
  z-index: 5;
}
header h1 { font-size: 1.15rem; letter-spacing: .3px; }

.pill {
  font-size: .72rem; color: var(--muted);
  border: 1px solid #2c313c; border-radius: 999px; padding: 4px 10px;
}
.pill.ok { color: var(--good); border-color: #22503a; }

main { padding: 16px; max-width: 760px; margin: 0 auto; }
.hint { color: var(--muted); font-size: .88rem; margin-bottom: 14px; line-height: 1.45; }

.btn {
  display: inline-block; text-align: center; cursor: pointer;
  border: none; border-radius: var(--radius);
  padding: 13px 18px; font-size: 1rem; font-weight: 600;
  background: var(--panel-2); color: var(--text);
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.block { display: block; width: 100%; margin-bottom: 16px; }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.card {
  background: var(--panel); border-radius: var(--radius); overflow: hidden;
  border: 1px solid #262a33;
}
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.card .meta { padding: 8px 10px; font-size: .8rem; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.card .score-tag { font-weight: 700; }
.score-tag.good { color: var(--good); }
.score-tag.mid  { color: #e0a83c; }
.score-tag.low  { color: var(--bad); }

.card .actions { display: flex; }
.card .actions button {
  flex: 1; border: none; padding: 11px 0; font-size: .95rem; font-weight: 700;
  cursor: pointer; color: #fff;
}
.card .actions .accept { background: var(--good); }
.card .actions .reject { background: var(--bad); }
.card .actions .del { background: var(--panel-2); color: var(--muted); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px; font-size: 1rem;
  background: var(--panel); color: var(--text);
  border: 1px solid #2c313c; border-radius: 10px;
}

.progress .bar {
  height: 10px; border-radius: 999px; background: var(--panel-2); overflow: hidden;
  margin-bottom: 8px;
}
#gen-bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.progress p { font-size: .85rem; color: var(--muted); }

.err { color: var(--bad); font-size: .85rem; margin-top: 6px; white-space: pre-wrap; }

.section-title { font-size: .95rem; margin-bottom: 8px; color: var(--text); }
.row { display: flex; gap: 10px; margin-bottom: 16px; }
.btn.danger { background: #3a2224; color: #f0a8a4; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
.checkbox input { width: 18px; height: 18px; }
.filter-flag {
  text-align: center; font-size: .9rem; margin: 8px auto; max-width: 90%;
  padding: 8px 12px; border-radius: 10px;
}
.filter-flag.warn { background: #3a2f1c; color: #e6c05a; }
.filter-flag.clean { background: #1c3326; color: var(--good); }

.score-img {
  width: 160px; height: 160px; object-fit: cover; border-radius: var(--radius);
  display: block; margin: 12px auto;
  border: 1px solid #2c313c;
}
.gauge {
  height: 16px; border-radius: 999px; background: var(--panel-2);
  overflow: hidden; margin: 10px 0;
}
#gauge-fill { height: 100%; width: 0; transition: width .6s; border-radius: 999px; }
#tab-score h2 { text-align: center; font-size: 2.2rem; margin: 6px 0; }
#score-verdict { text-align: center; font-size: 1rem; margin-bottom: 4px; }
#score-raw { text-align: center; }
.mini-grid { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.mini-grid .mini { text-align: center; font-size: .78rem; color: var(--muted); }
.mini-grid img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; display: block; margin-bottom: 4px; }

nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: rgba(15,17,21,.95); backdrop-filter: blur(8px);
  border-top: 1px solid #262a33;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}
nav button {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: .82rem; font-weight: 600; padding: 14px 0 12px; cursor: pointer;
  position: relative;
}
nav button.active { color: var(--accent); }
.badge {
  position: absolute; top: 6px; right: 18%;
  background: var(--bad); color: #fff; border-radius: 999px;
  font-size: .65rem; padding: 1px 6px;
}

.toast {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--panel-2); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: .9rem;
  border: 1px solid #2c313c; z-index: 10; max-width: 90vw;
}

.login {
  position: fixed; inset: 0; z-index: 20;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.login-card { width: min(90vw, 340px); text-align: center; }
.login-card h1 { margin-bottom: 6px; }
.login-card p { color: var(--muted); margin-bottom: 16px; }
.login-card input {
  width: 100%; padding: 13px; font-size: 1rem; margin-bottom: 12px;
  background: var(--panel); color: var(--text);
  border: 1px solid #2c313c; border-radius: 10px; text-align: center;
}
.login-card .btn { width: 100%; }

/* ---------------------------------------------------------------- swipe deck */

.deck {
  position: relative;
  height: min(66vh, 520px);
  max-width: 420px;
  margin: 0 auto;
}
.swipe-card {
  position: absolute; inset: 0;
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,.45);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.swipe-card img {
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.swipe-score {
  position: absolute; bottom: 12px; left: 12px;
  font-size: .95rem; padding: 5px 12px;
}
.swipe-stamp {
  position: absolute; top: 22px;
  font-size: 1.6rem; font-weight: 800; letter-spacing: 2px;
  padding: 5px 14px; border: 3px solid; border-radius: 8px;
  opacity: 0; transform: rotate(-12deg);
  pointer-events: none;
}
.swipe-stamp.yes { left: 16px; color: var(--good); border-color: var(--good); }
.swipe-stamp.no { right: 16px; color: var(--bad); border-color: var(--bad); transform: rotate(12deg); }

.deck-actions {
  display: flex; align-items: center; justify-content: center;
  gap: 26px; margin-top: 18px;
}
.deck-btn {
  width: 64px; height: 64px; border-radius: 50%;
  border: none; cursor: pointer;
  font-size: 1.5rem; font-weight: 700;
  background: var(--panel-2); color: var(--text);
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.deck-btn.yes { color: var(--good); }
.deck-btn.no { color: var(--bad); }
.deck-btn:active { transform: scale(.92); }
.deck-count { color: var(--muted); font-size: .9rem; min-width: 60px; text-align: center; }

/* ---------------------------------------------------------------- master toggle & panels */

.master-panel {
  background: var(--panel); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 18px;
  border: 1px solid #262a33;
}
.master-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch {
  width: 58px; height: 32px; border-radius: 999px; border: none; cursor: pointer;
  background: var(--panel-2); position: relative; flex-shrink: 0;
  transition: background .2s;
}
.switch span {
  position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--muted); transition: transform .2s, background .2s;
}
.switch.on { background: rgba(52,192,124,.35); }
.switch.on span { transform: translateX(26px); background: var(--good); }

.seg {
  display: flex; background: var(--panel); border-radius: 999px;
  padding: 4px; margin-bottom: 14px; max-width: 320px;
}
.seg button {
  flex: 1; border: none; background: none; color: var(--muted);
  padding: 9px 0; border-radius: 999px; font-size: .9rem; font-weight: 600; cursor: pointer;
}
.seg button.active { background: var(--panel-2); color: var(--text); }

/* deck sizing: leave room for the accept/reject buttons above the bottom nav */
.deck { height: min(52vh, 430px); }
.deck-actions { margin-top: 14px; padding-bottom: 8px; }
.deck-btn.yes { background: rgba(52,192,124,.16); border: 2px solid var(--good); }
.deck-btn.no  { background: rgba(229,83,75,.16);  border: 2px solid var(--bad); }

/* slightly roomier tap targets on the bottom nav */
nav button { min-height: 52px; font-size: .95rem; }
