/*
  VOICE  calm, practical, student-friendly marketplace
  IDEA   a tidy campus noticeboard: white cards pinned on a clean ground
  PICTURE item photos lead; one illustrated parcel + price tags on sign-in
  COLOUR Warwick-style aubergine, white, warm grey, gold accent
  TYPE   Lato (as used across Warwick's web), four sizes
*/
:root {
  color-scheme: light;
  --brand: #3c1053;
  --brand-2: #5b2a73;
  --brand-soft: #efe7f3;
  --gold: #d4a017;
  --bg: #f6f5f7;
  --card: #ffffff;
  --ink: #1d1a21;
  --muted: #6b6573;
  --line: #e4e0e8;
  --danger: #b3261e;
  --ok: #1f7a4d;
  --r: 12px;
  --shadow: 0 1px 2px rgba(30, 10, 40, .06), 0 4px 14px rgba(30, 10, 40, .05);
}
* { box-sizing: border-box; min-width: 0; }
html { scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 Lato, "Segoe UI", system-ui, -apple-system, sans-serif; overflow-x: clip; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: 30px; font-weight: 900; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 22px; font-weight: 900; }
h3 { font-size: 16px; font-weight: 700; }
img { display: block; max-width: 100%; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hidden { display: none !important; }
.center { text-align: center; margin-top: 24px; }
.stack { display: grid; gap: 14px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.row-between { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.boot, .loading { padding: 80px 0; text-align: center; color: var(--muted); }

/* Controls */
label { display: grid; gap: 6px; font-weight: 700; font-size: 14px; }
input, select, textarea {
  font: inherit; font-size: 16px; font-weight: 400; color: var(--ink); background: #fff;
  border: 1px solid #cfc8d6; border-radius: 10px; padding: 11px 13px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); outline-offset: 1px; border-color: var(--brand); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 15px; cursor: pointer; padding: 4px 0; }
.check input { width: 18px; height: 18px; margin-top: 3px; flex: none; accent-color: var(--brand); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  font: inherit; font-weight: 700; font-size: 15px; border-radius: 10px; border: 1px solid #cfc8d6; background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--brand); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost-danger { color: var(--danger); }
.btn-ghost-danger:hover { border-color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-lg { min-height: 52px; font-size: 17px; }
.linkbtn { background: none; border: 0; padding: 6px 0; font: inherit; font-size: 15px; color: var(--brand); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn:disabled { color: var(--muted); text-decoration: none; cursor: default; }
.field-err { color: var(--danger); font-size: 14px; margin: 0; min-height: 0; }
.field-err:empty { display: none; }

/* Top bar */
.demo-bar { background: var(--gold); color: #2a1d00; text-align: center; font-size: 14px; padding: 6px 12px; }
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-in { display: flex; align-items: center; gap: 20px; min-height: 68px; flex-wrap: wrap; padding-block: 10px; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 900; font-size: 19px; white-space: nowrap; }
.logo-mark { width: 34px; height: 34px; border-radius: 8px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 900; }
.top-search { flex: 1 1 320px; display: flex; background: #fff; border-radius: 10px; overflow: hidden; max-width: 560px; }
.top-search input { border: 0; border-radius: 0; padding: 10px 14px; }
.top-search input:focus { outline: none; }
.top-search button { border: 0; background: none; padding: 0 14px; color: var(--brand); cursor: pointer; }
.topnav { display: flex; align-items: center; gap: 18px; margin-left: auto; flex-wrap: wrap; }
.topnav > a:not(.btn), .topnav .linkbtn { color: #fff; text-decoration: none; font-weight: 700; font-size: 15px; opacity: .88; }
.topnav > a:not(.btn):hover, .topnav .linkbtn:hover, .topnav a.on { opacity: 1; text-decoration: underline; text-underline-offset: 6px; }
.topnav .btn-primary { background: #fff; color: var(--brand); border-color: #fff; }
.topnav .btn-primary:hover { background: var(--brand-soft); }

#app { min-height: 100vh; display: flex; flex-direction: column; }
.main { padding-top: 28px; padding-bottom: 56px; flex: 1; width: 100%; }
.back { display: inline-block; margin-bottom: 16px; text-decoration: none; font-weight: 700; font-size: 15px; }

/* Footer */
.footer { border-top: 1px solid var(--line); background: #fff; font-size: 14px; }
.footer-in { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-block: 22px; }
.footer-links { display: grid; gap: 4px; text-align: right; }

/* Auth */
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px); gap: 48px; align-items: center; max-width: 980px; margin: 24px auto; }
.auth-art svg { width: 100%; max-width: 420px; margin: 0 auto; display: block; }
.auth-card { background: var(--card); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.auth-card.narrow { max-width: 520px; margin: 24px auto; }
.auth-card h1 { font-size: 32px; }
.code-input { font-size: 26px; letter-spacing: .35em; text-align: center; font-weight: 700; }

/* Browse */
.browse { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; align-items: start; }
.filters { background: var(--card); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); position: sticky; top: 92px; }
.filters h3 { font-size: 13px; color: var(--muted); margin: 18px 0 8px; font-weight: 700; }
.filters h3:first-child { margin-top: 0; }
.catlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.catlist button { width: 100%; text-align: left; background: none; border: 0; font: inherit; font-size: 15px; padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--ink); }
.catlist button:hover { background: var(--bg); }
.catlist button.on { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.price-row { display: flex; align-items: center; gap: 6px; }
.price-row input { padding: 8px 9px; font-size: 15px; }
.results-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.results-head h1 { margin: 0; }
.results-head p { margin: 4px 0 0; }
.sort { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.sort select { width: auto; padding: 8px 10px; font-size: 15px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.card { background: var(--card); border-radius: var(--r); overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 22px rgba(30, 10, 40, .12); }
.card-img { aspect-ratio: 4 / 5; background: var(--brand-soft); }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 12px 14px 14px; }
.card .price { font-weight: 900; font-size: 18px; }
.card .title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta { font-size: 13px; color: var(--muted); }
.card.skeleton { aspect-ratio: 4 / 6.3; background: linear-gradient(90deg, #ece9ef, #f6f4f8, #ece9ef); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { grid-column: 1 / -1; text-align: center; padding: 56px 20px; background: var(--card); border-radius: var(--r); }

/* Item */
.item { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.gallery { position: relative; background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; aspect-ratio: 4 / 4.4; background: #f1eef4; }
.slides::-webkit-scrollbar { display: none; }
.slides img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain; scroll-snap-align: center; }
.gallery .nav { position: absolute; top: 42%; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); font-size: 26px; line-height: 1; cursor: pointer; color: var(--brand); }
.gallery .prev { left: 12px; } .gallery .next { right: 12px; }
.thumbs { display: flex; gap: 8px; padding: 10px; overflow-x: auto; }
.thumbs button { flex: none; width: 64px; height: 64px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: none; }
.thumbs button.on { border-color: var(--brand); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.info h1 { font-size: 32px; margin-top: 4px; }
.big-price { font-size: 30px; font-weight: 900; color: var(--brand); margin-bottom: 14px; }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0 0 16px; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.desc { white-space: pre-wrap; margin: 0 0 20px; }
.panel { background: var(--card); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); display: grid; gap: 10px; margin-bottom: 12px; }
.panel h3 { margin: 0; }
.panel p { margin: 0; }
.copy-row { display: flex; gap: 8px; align-items: center; background: var(--bg); border-radius: 8px; padding: 6px 6px 6px 12px; }
.copy-row code { flex: 1; font-size: 14px; overflow-wrap: anywhere; font-family: inherit; }
.safety { margin: 4px 0 0; padding-left: 18px; color: var(--muted); }
.safety li { margin: 2px 0; }
.report-link { font-size: 14px; color: var(--muted); }
.admin-panel { border: 1px dashed var(--danger); display: flex; flex-wrap: wrap; align-items: center; }
.admin-panel h3 { width: 100%; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--bg); color: var(--muted); text-transform: capitalize; margin-left: 6px; vertical-align: middle; }
.badge.sold { background: #e3f3ea; color: var(--ok); margin-left: 0; }
.badge.removed { background: #fbe5e3; color: var(--danger); margin-left: 0; }

/* Sell */
.sell { max-width: 760px; }
.block { background: var(--card); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow); }
.block h3 { margin-bottom: 12px; }
.drop { border: 2px dashed #cfc8d6; border-radius: var(--r); padding: 18px; transition: background .15s, border-color .15s; }
.drop.over { background: var(--brand-soft); border-color: var(--brand); }
.drop-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.drop.has .drop-actions { margin-top: 14px; }
.thumbs-edit { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.thumbs-edit:empty { display: none; }
.thumbs-edit .t { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg); }
.thumbs-edit .t.cover { outline: 3px solid var(--brand); }
.thumbs-edit img { width: 100%; height: 100%; object-fit: cover; }
.thumbs-edit .tag, .thumbs-edit .mk { position: absolute; left: 6px; bottom: 6px; font-size: 12px; font-weight: 700; border-radius: 6px; padding: 3px 7px; border: 0; }
.thumbs-edit .tag { background: var(--brand); color: #fff; }
.thumbs-edit .mk { background: rgba(255, 255, 255, .92); cursor: pointer; font-family: inherit; }
.thumbs-edit .rm { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.cam video { width: 100%; border-radius: 10px; background: #000; max-height: 60vh; }

/* My listings / admin */
.me-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.me-head h1 { margin: 0; }
.me-head p { margin: 0; }
.me-head .btn { margin-left: auto; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 20px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-color: var(--brand); }
.rows { display: grid; gap: 10px; }
.row { display: flex; gap: 14px; align-items: center; background: var(--card); border-radius: var(--r); padding: 12px; box-shadow: var(--shadow); }
.row-img { flex: none; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; background: var(--brand-soft); }
.row-img img { width: 100%; height: 100%; object-fit: cover; }
.row-main { flex: 1; }
.row-title { font-weight: 700; color: var(--ink); text-decoration: none; }
.row-title:hover { color: var(--brand); text-decoration: underline; }
.row-main .small { margin-top: 2px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.admin-search { display: flex; gap: 8px; margin-bottom: 16px; max-width: 560px; }

/* Admin stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 8px 0 20px; }
.stat { background: var(--card); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); display: grid; gap: 2px; }
.stat b { font-size: 28px; font-weight: 900; color: var(--brand); line-height: 1.1; }
.stat span { font-size: 14px; color: var(--muted); }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Terms */
.terms { max-width: 760px; background: var(--card); border-radius: 16px; padding: 36px; box-shadow: var(--shadow); }
.terms h2 { font-size: 19px; margin-top: 28px; }
.terms li { margin: 4px 0; }

/* Modal + toast */
.modal-back { position: fixed; inset: 0; background: rgba(20, 8, 28, .45); display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade .15s; }
.modal { background: #fff; border-radius: 16px; padding: 26px; width: min(480px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); max-height: 90vh; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 60; box-shadow: var(--shadow); max-width: calc(100% - 40px); animation: rise .2s; transition: opacity .4s; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
.toast.out { opacity: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Narrower screens (desktop-first, but nothing should break) */
@media (max-width: 900px) {
  .browse, .item, .auth { grid-template-columns: minmax(0, 1fr); }
  .filters { position: static; }
  .auth-art { display: none; }
}
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .two { grid-template-columns: minmax(0, 1fr); }
  .row { flex-wrap: wrap; }
  .row-actions { width: 100%; justify-content: flex-start; }
  .auth-card, .terms { padding: 22px; }
  .footer-links { text-align: left; }
}
