:root {
  --cream: #faf6f0;
  --ink: #221f1c;
  --muted: #8a8078;
  --accent: #c98f7a;
  --line: #e8ded3;
  --danger: #b3453a;
  --success: #4a7a5c;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* Only the full-screen story feed locks scrolling on the page itself —
   it manages its own fixed viewport. Form pages (submit/admin) scroll normally. */
body.lock-scroll {
  height: 100%;
  overflow: hidden;
}

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

/* ---------- Buyer story feed ---------- */

.story-app {
  position: relative;
  height: 100dvh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  background: #000;
}

.brand-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  padding: 14px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  pointer-events: none;
}

.brand-bar .brand-name {
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 1rem;
}

.brand-bar .shop-link {
  pointer-events: auto;
  color: #fff;
  font-size: 0.8rem;
  text-decoration: underline;
}

.progress-track {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 21;
  display: flex;
  gap: 4px;
  padding: 8px 10px 0;
}

.progress-seg {
  flex: 1;
  height: 3px;
  border-radius: 3px;
  background: rgba(255,255,255,0.35);
  overflow: hidden;
}

.progress-seg .fill {
  height: 100%;
  width: 0%;
  background: #fff;
}

.progress-seg.done .fill { width: 100%; }

.card-stack {
  position: relative;
  height: 100%;
  width: 100%;
}

.story-card {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.story-card.active { display: flex; }

.story-photo {
  flex: 1;
  width: 100%;
  object-fit: cover;
  background: #111;
  min-height: 0;
}

.tap-zone {
  position: absolute;
  top: 0;
  bottom: 140px;
  width: 34%;
  z-index: 15;
}
.tap-zone.left { left: 0; }
.tap-zone.right { right: 0; }

.story-info {
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0));
  color: #fff;
  position: relative;
  z-index: 18;
}

.story-info .brand {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0 0 2px;
}

.story-info .item-name {
  font-size: 0.9rem;
  opacity: 0.9;
  margin: 0 0 6px;
}

.story-meta {
  display: flex;
  gap: 10px;
  font-size: 0.8rem;
  opacity: 0.85;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.story-meta span {
  background: rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: 20px;
}

.story-price {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.orig-price {
  font-size: 0.85rem;
  font-weight: 400;
  opacity: 0.7;
  text-decoration: line-through;
}

.photo-dots {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.photo-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
}

.photo-dots .dot.active {
  background: #fff;
  width: 7px;
  height: 7px;
}

.buy-btn {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  padding: 14px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.buy-btn:active { opacity: 0.85; }

.empty-state, .loading-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  background: var(--cream);
  text-align: center;
  padding: 32px;
}

.empty-state h2 {
  color: var(--ink);
  font-size: 1.2rem;
  margin: 0;
}

.nav-links {
  position: absolute;
  bottom: 12px;
  left: 0; right: 0;
  text-align: center;
  font-size: 0.8rem;
}

.nav-links a {
  text-decoration: underline;
}

/* ---------- Shop grid (browse everything available) ---------- */

.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.filter-bar select {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  font-size: 0.78rem;
  color: var(--ink);
  font-family: inherit;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.shop-card {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
}

.shop-card-photo {
  width: 100%;
  aspect-ratio: 1;
  background-size: cover;
  background-position: center;
  background-color: var(--line);
}

.shop-card-body {
  padding: 10px 12px 12px;
}

.shop-card-brand {
  margin: 0;
  font-weight: 700;
  font-size: 0.85rem;
}

.shop-card-name {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.shop-card-price {
  margin: 6px 0 0;
  font-weight: 700;
  font-size: 0.95rem;
}

.shop-card-size {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---------- Shared form pages (submit / admin) ---------- */

.page {
  min-height: 100dvh;
  overflow-y: auto;
  background: var(--cream);
  padding: 24px 18px 60px;
  max-width: 520px;
  margin: 0 auto;
}

.page header {
  margin-bottom: 20px;
}

.page h1 {
  font-size: 1.4rem;
  margin: 0 0 4px;
}

.page .subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.field .hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field input[type="password"],
.field textarea,
.field select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
}

.field textarea { resize: vertical; min-height: 80px; }

.field input[type="file"] {
  width: 100%;
  padding: 10px 0;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.submit-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  margin-top: 8px;
}

.submit-btn:disabled { opacity: 0.5; }

.status-msg {
  margin-top: 14px;
  padding: 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  display: none;
}

.status-msg.show { display: block; }
.status-msg.success { background: #e7f0ea; color: var(--success); }
.status-msg.error { background: #f5e6e4; color: var(--danger); }

/* ---------- Admin dashboard ---------- */

.admin-login {
  max-width: 360px;
  margin: 80px auto;
  padding: 0 18px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  background: none;
  padding: 10px 4px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.admin-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  display: flex;
  gap: 12px;
}

.admin-card img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--line);
  flex-shrink: 0;
}

.admin-card .details {
  flex: 1;
  min-width: 0;
}

.admin-card .details h3 {
  margin: 0 0 2px;
  font-size: 0.95rem;
}

.admin-card .details p {
  margin: 0 0 2px;
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-card .actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.chip-btn {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
}

.chip-btn.approve { background: var(--success); color: #fff; }
.chip-btn.reject { background: var(--danger); color: #fff; }
.chip-btn.sold { background: var(--ink); color: #fff; }
.chip-btn.relist { background: var(--accent); color: #fff; }

.tag-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.tag-chip {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
}

.tag-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.status-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin-top: 8px;
}

.status-badge.scheduled {
  background: #fbead2;
  color: #8a5a10;
}

.status-badge.live-now {
  background: #e7f0ea;
  color: var(--success);
}

.schedule-block {
  margin-top: 10px;
}

.schedule-block .actions {
  margin-bottom: 8px;
}

.schedule-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
}

.empty-list {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 30px 0;
  text-align: center;
}

.logout-link {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: underline;
  float: right;
}
