/* ── Base ─────────────────────────────────────────────────────────────── */

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #252525;
  --text: #e5e5e5;
  --text-dim: #888;
  --accent: #ffc700;
  --radius: 12px;
}

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

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

a { color: inherit; text-decoration: none; }

/* ── Layout ──────────────────────────────────────────────────────────── */

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px;
}

.page-header {
  text-align: center;
  padding: 32px 0 24px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-header .subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 6px;
}

/* ── Account Grid (index.html) ───────────────────────────────────────── */

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  padding: 8px 0;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  transition: background 0.15s, transform 0.1s;
  cursor: pointer;
}

.account-card:hover {
  background: var(--surface2);
  transform: translateY(-2px);
}

.card-swatch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
}

.card-label {
  font-size: 18px;
  font-weight: 600;
}

.card-remaining {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ── Generate Page ───────────────────────────────────────────────────── */

.gen-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.gen-header h1 {
  font-size: 24px;
  flex: 1;
}

#remaining-count {
  font-size: 14px;
  color: var(--text-dim);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

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

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
}

.btn-danger {
  background: #3a1a1a;
  color: #ff6b6b;
}

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
}

/* ── Progress Bar ────────────────────────────────────────────────────── */

.progress-bar {
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 16px;
}

.progress-track {
  background: var(--surface2);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.2s;
  width: 0%;
}

.progress-text {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 8px;
  text-align: center;
}

/* ── Preview Grid ────────────────────────────────────────────────────── */

.preview-area {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 0 16px;
  scroll-snap-type: x mandatory;
}

.slide-thumb {
  position: relative;
  flex-shrink: 0;
  scroll-snap-align: start;
}

.slide-thumb img {
  height: 240px;
  width: auto;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s;
  display: block;
}

.slide-thumb img:hover {
  transform: scale(1.03);
}

.thumb-label {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

/* ── Caption ─────────────────────────────────────────────────────────── */

.caption-section {
  margin-top: 16px;
}

.caption-section label {
  font-size: 14px;
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

.caption-text {
  width: 100%;
  min-height: 120px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
}

.caption-text:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Modal ───────────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal img {
  max-height: 90vh;
  max-width: 90vw;
  border-radius: 8px;
}

/* ── Save Overlay ───────────────────────────────────────────────────── */

.save-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.save-overlay-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--surface2);
  font-size: 15px;
  color: var(--text-dim);
}

.save-overlay-images {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.save-overlay-images img {
  width: 100%;
  max-width: 500px;
  border-radius: 8px;
}

/* ── Utility ─────────────────────────────────────────────────────────── */

.hidden { display: none !important; }

.mt-16 { margin-top: 16px; }

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .container { padding: 16px 12px; }
  .page-header h1 { font-size: 22px; }
  .account-grid { grid-template-columns: 1fr; }
  .gen-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .btn-row { flex-direction: column; }
  .btn { width: 100%; }
  .slide-thumb img { height: 180px; }
}
