/* SwipeRoll — mobile-first 390px UI */
:root {
  --bg: #0f0f12;
  --bg-elevated: #1a1a22;
  --bg-card: #22222c;
  --text: #f4f4f8;
  --text-muted: #9b9bad;
  --keep: #34d399;
  --keep-dim: rgba(52, 211, 153, 0.15);
  --delete: #f87171;
  --delete-dim: rgba(248, 113, 113, 0.15);
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.2);
  --border: rgba(255, 255, 255, 0.08);
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --font: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100dvh;
}

.app {
  width: 100%;
  max-width: 390px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(129, 140, 248, 0.18), transparent),
    var(--bg);
  overflow: hidden;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 20px 12px;
  flex-shrink: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

.brand-name {
  font-weight: 650;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.header-stats {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
}

.stat.keep { color: var(--keep); font-weight: 600; }
.stat.delete { color: var(--delete); font-weight: 600; }
.stat.remaining { color: var(--text-muted); }
.stat-sep { opacity: 0.4; }

/* Screens */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 20px calc(20px + var(--safe-bottom));
  min-height: 0;
}

.screen[hidden] { display: none !important; }

/* Pick screen */
.screen-pick {
  justify-content: center;
  align-items: center;
}

.hero-card {
  text-align: center;
  max-width: 320px;
  width: 100%;
}

.hero-icon {
  width: 88px;
  height: 88px;
  margin: 0 auto 24px;
  border-radius: 24px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.hero-card h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 12px;
}

.lede {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 28px;
}

.hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.8;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 16px 24px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  width: 100%;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #818cf8, #a78bfa);
  color: #fff;
  box-shadow: 0 8px 24px rgba(129, 140, 248, 0.35);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-file {
  position: relative;
  overflow: hidden;
}

.btn-file input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

/* Swipe screen */
.screen-swipe {
  gap: 12px;
}

.stack {
  flex: 1;
  position: relative;
  min-height: 0;
  margin: 8px 0;
  touch-action: none;
}

.card {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  overflow: hidden;
  will-change: transform;
  cursor: grab;
  border: 1px solid var(--border);
}

.card:active { cursor: grabbing; }

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  display: block;
  background: #111;
}

.card-badge {
  position: absolute;
  top: 20px;
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  border: 3px solid;
  transform: rotate(-12deg);
  pointer-events: none;
}

.card-badge.keep {
  left: 18px;
  color: var(--keep);
  border-color: var(--keep);
  background: var(--keep-dim);
}

.card-badge.delete {
  right: 18px;
  color: var(--delete);
  border-color: var(--delete);
  background: var(--delete-dim);
  transform: rotate(12deg);
}

.card.behind {
  transform: scale(0.96);
  opacity: 0.7;
  pointer-events: none;
}

.swipe-hints {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0 8px;
}

.hint-left { color: var(--delete); opacity: 0.7; }
.hint-right { color: var(--keep); opacity: 0.7; }

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 8px 0 4px;
}

.btn-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-circle:active:not(:disabled) { transform: scale(0.92); }
.btn-circle:disabled { opacity: 0.35; cursor: default; }

.btn-delete {
  color: var(--delete);
  background: var(--delete-dim);
  border-color: rgba(248, 113, 113, 0.25);
}

.btn-keep {
  color: var(--keep);
  background: var(--keep-dim);
  border-color: rgba(52, 211, 153, 0.25);
}

.btn-undo {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
}

.progress-label {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Summary */
.screen-summary {
  justify-content: center;
  align-items: center;
}

.summary-card {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.summary-card h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 28px 0 20px;
}

.summary-stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 12px;
}

.summary-stat .num {
  display: block;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: 6px;
}

.summary-stat.keep .num { color: var(--keep); }
.summary-stat.delete .num { color: var(--delete); }

.summary-stat .label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.summary-note {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 24px;
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Empty stack placeholder */
.stack-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

@media (min-width: 400px) {
  .app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}
