/* ============================================================
   MM · Marketplace — design system + app shell
   ============================================================ */

/* ---------------- Tokens ---------------- */
:root {
  color-scheme: light dark;

  --accent:      #4f46e5;
  --accent-ink:  #ffffff;
  --accent-soft: #eef0ff;

  --bg:        #fafafb;
  --surface:   #ffffff;
  --surface-2: #f4f4f7;

  --text:  #0f1115;
  --muted: #6b7280;
  --line:  #e9e9ef;

  --ok:      #0f9d58;
  --ok-soft: #e7f6ee;
  --warn:      #b45309;
  --warn-soft: #fdf3e3;
  --danger:      #dc2626;
  --danger-soft: #fdecec;

  --radius:    16px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  --shadow-sm: 0 1px 2px rgba(15, 17, 21, .05);
  --shadow:    0 1px 2px rgba(15, 17, 21, .04),
               0 10px 30px -12px rgba(15, 17, 21, .16);

  --sidebar-w: 248px;
  --topbar-h:  60px;
  --tabbar-h:  62px;
  --content-max: 1080px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent:      #8b87ff;
    --accent-ink:  #0b0b12;
    --accent-soft: #1a1a2b;

    --bg:        #08080b;
    --surface:   #101014;
    --surface-2: #17171d;

    --text:  #f3f3f7;
    --muted: #9898a6;
    --line:  #22222b;

    --ok:      #34d399;
    --ok-soft: #0e2a20;
    --warn:      #fbbf24;
    --warn-soft: #2a2110;
    --danger:      #f87171;
    --danger-soft: #2a1414;

    --shadow: 0 1px 2px rgba(0, 0, 0, .5),
              0 10px 30px -12px rgba(0, 0, 0, .65);
  }
}

/* ---------------- Reset ---------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent); color: var(--accent-ink); }

/* ============================================================
   Prevent double-tap and pinch zoom
   ============================================================ */
html, body {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

input, textarea, select {
  font-size: 16px;
}

/* ---------------- App shell ---------------- */
body.app {
  display: flex;
  min-height: 100dvh;
  background: var(--bg);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 18px 16px 32px;
}

@media (max-width: 899px) {
  .content { padding-left: 12px; padding-right: 12px; }
}

.sidebar { display: none; }

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 16px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.page-title {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -.02em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---- Tabbar (mobile only) ---- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  align-items: stretch;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 550;
  letter-spacing: .01em;
  color: var(--muted);
  transition: color .16s var(--ease);
  position: relative;
}

.tab svg { width: 21px; height: 21px; }
.tab.is-active { color: var(--accent); }
.tab.is-active::before {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 26px; height: 2.5px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .1s var(--ease), background .16s var(--ease),
              border-color .16s var(--ease), opacity .16s var(--ease);
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .55; pointer-events: none; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-danger:hover { background: color-mix(in srgb, var(--danger-soft) 80%, var(--danger)); }

.btn-block { width: 100%; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------------- Avatars ---------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px; height: 36px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #7c6cf5);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  user-select: none;
}
.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  object-fit: cover;
}
.avatar-lg { width: 72px; height: 72px; font-size: 25px; }

/* ---------------- Cards & surfaces ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------------- Forms ---------------- */
.field { display: block; margin-bottom: 14px; }

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.input::placeholder { color: var(--muted); opacity: .7; }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3.5px var(--danger-soft);
}

.field-error {
  display: none;
  margin-top: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--danger);
}
.field-error.is-shown { display: block; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.check input {
  width: 17px; height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 18px;
}
.row-between a { font-size: 13.5px; font-weight: 600; color: var(--accent); }

/* ---------------- Auth pages ---------------- */
body.auth {
  display: grid;
  min-height: 100dvh;
  background: var(--bg);
}

.auth-wrap {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
}

.auth-aside { display: none; }

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom));
}

.auth-card { width: 100%; max-width: 400px; }

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.auth-card h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.03em;
  margin-bottom: 6px;
}

.auth-card .sub {
  font-size: 14.5px;
  color: var(--muted);
  margin-bottom: 26px;
}

.auth-alt {
  margin-top: 22px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.auth-alt a { font-weight: 650; color: var(--accent); }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  font-size: 12.5px;
  color: var(--muted);
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------------- Brand mark ---------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.brand-name { font-size: 15.5px; }

/* ---------------- Topbar search ---------------- */
.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.topbar-search svg {
  position: absolute;
  left: 13px;
  width: 17px; height: 17px;
  color: var(--muted);
  pointer-events: none;
}
.topbar-search .input {
  height: 40px;
  padding-left: 39px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 14.5px;
}

/* ---------------- Listing grid ---------------- */
.grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}

.listing {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .16s var(--ease);
}
.listing:hover { border-color: color-mix(in srgb, var(--line) 40%, var(--accent)); }

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background-size: cover;
  background-position: center;
  font-weight: 800;
  letter-spacing: -.04em;
  color: rgba(255, 255, 255, .92);
  background: linear-gradient(135deg, var(--g1, #6366f1), var(--g2, #a855f7));
  user-select: none;
}

.listing-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 8px 9px;
  flex: 1;
}

.listing-title {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -.005em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.listing-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.price {
  margin-top: auto;
  padding-top: 4px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.02em;
}

@media (min-width: 600px) {
  .grid { gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (min-width: 900px) {
  .grid { gap: 11px; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
  .thumb { font-size: 26px; }
  .listing-title { font-size: 13px; }
}

/* ---------------- Tabs (generic) ---------------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: 999px;
  background: var(--surface-2);
}
.tab-pill {
  flex: 1;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .16s var(--ease);
}
.tab-pill.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---------------- Order cards ---------------- */
.order-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.order-thumb {
  flex: none;
  width: 64px;
  height: 64px;
  background-size: cover;
  background-position: center;
  border-radius: var(--radius-sm);
  background-color: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.92);
  font-weight: 800;
}
.order-main { flex: 1; min-width: 0; }
.order-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  flex: none;
}
.order-side .btn { min-width: 90px; }
.order-id {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.order-title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 2px 0 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.order-sub { font-size: 12.5px; color: var(--muted); }
.order-price { font-size: 15px; font-weight: 700; letter-spacing: -.02em; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .01em;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 999px;
  background: currentColor;
}
.pill-ok   { background: var(--ok-soft);   color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-mute { background: var(--surface-2); color: var(--muted); }

/* ---------------- Messages ---------------- */
.inbox {
  display: grid;
  grid-template-columns: 1fr;
  min-height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - 52px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.threads { display: flex; flex-direction: column; }

.thread {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .14s var(--ease);
}
.thread:hover { background: var(--surface-2); }
.thread.is-active { background: var(--accent-soft); }

.thread-main { flex: 1; min-width: 0; }
.thread-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.thread-name {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-time { flex: none; font-size: 11.5px; color: var(--muted); }
.thread-preview {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.thread.unread .thread-preview { color: var(--text); font-weight: 550; }

.unread-dot {
  flex: none;
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.chat {
  display: none;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.chat-head .thread-name { font-size: 14.5px; }

.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bubble {
  max-width: 76%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}
.bubble-in {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}
.bubble-out {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
  border-bottom-right-radius: 5px;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.composer .input { height: 42px; border-radius: 999px; }
.composer .btn { border-radius: 999px; padding: 0 15px; }

.back-btn { display: inline-flex; }
body:not(.chat-open) .chat { display: none; }
body.chat-open .threads { display: none; }
body.chat-open .chat { display: flex; }

/* ---------------- Profile ---------------- */
.profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.profile-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.025em;
}
.profile-handle { font-size: 13.5px; color: var(--muted); margin-top: 1px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat {
  padding: 14px 10px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat b {
  display: block;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.03em;
}
.stat span { font-size: 11.5px; color: var(--muted); font-weight: 550; }

.list-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  font-size: 14.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background .14s var(--ease);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.list-row svg { width: 19px; height: 19px; color: var(--muted); flex: none; }
.list-row .chev { margin-left: auto; color: var(--muted); }
.list-row .value { margin-left: auto; font-size: 13.5px; color: var(--muted); font-weight: 500; }

.section-label {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px 4px;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  z-index: 90;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Utilities ---------------- */
.empty {
  padding: 48px 20px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   Desktop breakpoint (900px+)
   ============================================================ */
@media (min-width: 900px) {

  .sidebar {
    display: flex;
    flex-direction: column;
    flex: none;
    width: var(--sidebar-w);
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 18px 14px;
    background: var(--surface);
    border-right: 1px solid var(--line);
  }

  .sidebar .brand { padding: 0 8px; margin-bottom: 24px; }

  .nav { display: flex; flex-direction: column; gap: 2px; }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    height: 42px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-weight: 550;
    color: var(--muted);
    transition: background .14s var(--ease), color .14s var(--ease);
  }
  .nav-item svg { width: 19px; height: 19px; flex: none; }
  .nav-item:hover { background: var(--surface-2); color: var(--text); }
  .nav-item.is-active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 650;
  }

  .nav-count {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 11px;
    font-weight: 700;
  }

  .side-foot {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--line);
  }

  .side-user {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background .14s var(--ease);
  }
  .side-user:hover { background: var(--surface-2); }
  .side-user-main { flex: 1; min-width: 0; }
  .side-user-name {
    font-size: 13.5px;
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .side-user-sub { font-size: 12px; color: var(--muted); }

  .tabbar { display: none; }
  .content { padding: 22px 28px 40px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

  .inbox {
    grid-template-columns: 320px 1fr;
    min-height: calc(100dvh - var(--topbar-h) - 84px);
  }
  .threads {
    border-right: 1px solid var(--line);
    overflow-y: auto;
  }
  .chat { display: flex; }
  .back-btn { display: none; }
  body.chat-open .threads { display: flex; }

  .auth-wrap { grid-template-columns: 1fr 1fr; }

  .auth-aside {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 44px;
    background: linear-gradient(150deg, #4f46e5 0%, #7c3aed 55%, #a855f7 100%);
    color: #fff;
  }
  .auth-aside .brand-mark { background: rgba(255, 255, 255, .18); color: #fff; }
  .auth-aside h2 {
    font-size: 34px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -.035em;
    max-width: 15ch;
    margin-bottom: 14px;
  }
  .auth-aside p {
    font-size: 15.5px;
    line-height: 1.6;
    color: rgba(255, 255, 255, .8);
    max-width: 34ch;
  }
  .auth-feats { display: flex; flex-direction: column; gap: 14px; margin-top: 30px; }
  .auth-feat {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14.5px;
    font-weight: 500;
    color: rgba(255, 255, 255, .92);
  }
  .auth-feat svg { width: 20px; height: 20px; flex: none; }

  .auth-panel { padding: 44px; }

  .toast { bottom: 28px; }
}

/* ---------------- Reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  .listing:hover { transform: none; }
}

/* ============================================================
   Product detail page
   ============================================================ */
.product { display: flex; flex-direction: column; gap: 14px; }

.hero {
  position: relative;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, var(--g1, #6366f1), var(--g2, #a855f7));
}
.hero-mono {
  font-size: 68px;
  font-weight: 800;
  letter-spacing: -.05em;
  color: rgba(255, 255, 255, .92);
  user-select: none;
}

.product-head { display: flex; flex-direction: column; gap: 6px; }
.product-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.25;
}
.product-price {
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -.035em;
}
.product-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.seller-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.seller-main { flex: 1; min-width: 0; }
.seller-name { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }
.seller-sub  { font-size: 12.5px; color: var(--muted); }

.panel {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel-title {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.desc {
  margin-top: 8px;
  font-size: 14.5px;
  line-height: 1.6;
}

.variant-group + .variant-group {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.variant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.chosen { font-size: 13px; font-weight: 600; color: var(--accent); }

.opts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.opt {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background .16s var(--ease), border-color .16s var(--ease),
              color .16s var(--ease);
}
.opt:hover { border-color: var(--accent); }
.opt.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}

.qty {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: 10px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.qty-btn {
  width: 36px; height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background .14s var(--ease), opacity .14s var(--ease);
}
.qty-btn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.qty-btn:disabled { opacity: .35; cursor: not-allowed; }
.qty-input {
  width: 46px; height: 36px;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.buy-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.buy-total { display: flex; flex-direction: column; }
.buy-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.buy-total strong { font-size: 19px; font-weight: 750; letter-spacing: -.03em; }
.buy-bar .btn { flex: 1; height: 46px; }

.has-buybar .content {
  padding-bottom: calc(var(--tabbar-h) + 92px + env(safe-area-inset-bottom));
}

@media (min-width: 900px) {
  .hero { aspect-ratio: 16 / 9; }
  .hero-mono { font-size: 96px; }

  .buy-bar {
    position: static;
    left: auto; right: auto; bottom: auto;
    padding: 0 0 36px;
    background: transparent;
    border-top: 0;
    justify-content: flex-end;
  }
  .buy-bar .btn { flex: none; min-width: 200px; }
  .buy-total { margin-right: auto; }

  .has-buybar .content { padding-bottom: 22px; }
}

/* ---------------- Category filter tag ---------------- */
.filter-bar { margin-bottom: 12px; }
.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 5px 0 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.filter-tag a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
  line-height: 1;
}

/* ---------------- Categories page ---------------- */
.cat-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px) { .cat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .cat-grid { grid-template-columns: repeat(4, 1fr); } }

.cat-tile {
  display: flex;
  flex-direction: column;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .16s var(--ease), transform .16s var(--ease);
}
.cat-tile:hover {
  border-color: color-mix(in srgb, var(--line) 40%, var(--accent));
  transform: translateY(-2px);
}
.cat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  margin-bottom: 10px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--g1, #6366f1), var(--g2, #a855f7));
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.03em;
}
.cat-name  { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }
.cat-count { font-size: 12px; color: var(--muted); margin-top: 1px; }

.cat-all {
  display: block;
  margin-top: 16px;
  padding: 14px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius);
}

/* ============================================================
   Purchase sheet
   ============================================================ */
.purchase-sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.purchase-sheet-inner {
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 20px 20px 0 0;
}
.purchase-title { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.purchase-sub   { font-size: 13.5px; color: var(--muted); margin: 4px 0 18px; }
.purchase-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 0; border-top: 1px solid var(--line); margin-top: 8px;
  font-size: 15px;
}
.purchase-total strong { font-size: 20px; font-weight: 750; letter-spacing: -.03em; }
.purchase-note { font-size: 12.5px; color: var(--muted); margin-bottom: 16px; }

@media (min-width: 900px) {
  .purchase-sheet { align-items: center; }
  .purchase-sheet-inner { border-radius: 20px; max-height: 80dvh; }
}

/* ============================================================
   Address card + add-address button
   ============================================================ */
.address-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.address-check {
  flex: none;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 15px;
  font-weight: 700;
}
.address-body { flex: 1; min-width: 0; }
.address-name {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.address-line {
  font-size: 13.5px;
  color: var(--text);
  margin-top: 2px;
  line-height: 1.35;
}
.address-meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.add-address-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  background: var(--surface);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.add-address-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.add-address-icon {
  flex: none;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 20px;
  font-weight: 600;
}
.add-address-btn:hover .add-address-icon {
  background: var(--accent);
  color: var(--accent-ink);
}
.add-address-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

/* ============================================================
   Order detail page
   ============================================================ */
.order-detail { display: flex; flex-direction: column; gap: 14px; }
.order-hero {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  background-size: cover; background-position: center;
  background-color: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; font-weight: 800; color: rgba(255,255,255,.9);
}
.order-detail-head { display: flex; flex-direction: column; gap: 6px; }
.order-block {
  padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.order-block.notice { background: var(--warn-soft); border-color: transparent; }
.order-dl {
  display: grid; grid-template-columns: 1fr auto;
  gap: 6px 14px; margin: 8px 0 0;
  font-size: 14px;
}
.order-dl dt { color: var(--muted); }
.order-dl dd { margin: 0; text-align: right; }
.wallet-line code {
  display: inline-block; padding: 8px 14px; margin: 6px 0 14px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  font-family: ui-monospace, monospace; font-size: 15px;
}
.timeline { list-style: none; margin: 6px 0 0; padding: 0; }
.timeline-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; font-size: 13.5px;
}
.timeline-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  flex: none;
}

.delivery-code {
  display: block;
  padding: 16px 20px;
  margin: 10px 0 0;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .04em;
  text-align: center;
  color: var(--text);
  user-select: all;
}
.delivery-code-block .delivery-code {
  background: var(--accent-soft);
  color: var(--accent);
}
.delivery-code-hint {
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 16px;
}
.delivery-code-hint b {
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px;
  letter-spacing: .04em;
}

/* ============================================================
   Modals — unified header + scrollbar
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 20px 20px 0 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.modal-sub {
  font-size: 13.5px;
  color: var(--muted);
  margin: 4px 0 18px;
}

/* Header with top-right X */
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-head > div { flex: 1; min-width: 0; }
.modal-head .modal-title { margin: 0; }
.modal-head .modal-sub { margin: 2px 0 0; }
.modal-head .icon-btn { flex: none; }

/* Wide proceed button */
.modal .form-actions {
  display: block;
  margin-top: 16px;
}
.modal .form-actions .btn {
  width: 100%;
}

@media (min-width: 900px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; max-height: 80dvh; }
}

/* Thin scrollbar inside modals */
.modal,
.purchase-sheet-inner {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.modal::-webkit-scrollbar,
.purchase-sheet-inner::-webkit-scrollbar {
  width: 6px;
}

.modal::-webkit-scrollbar-track,
.purchase-sheet-inner::-webkit-scrollbar-track {
  background: transparent;
  margin: 16px 0;
}

.modal::-webkit-scrollbar-thumb,
.purchase-sheet-inner::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--line) 80%, var(--muted) 20%);
  border-radius: 999px;
  transition: background .16s var(--ease);
}

.modal::-webkit-scrollbar-thumb:hover,
.purchase-sheet-inner::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

@supports not selector(::-webkit-scrollbar) {
  .modal,
  .purchase-sheet-inner {
    scrollbar-width: thin;
    scrollbar-color: var(--muted) transparent;
  }
}

/* Compact address modal */
.address-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.address-grid .field { margin-bottom: 14px; }

@media (max-width: 480px) {
  .address-grid { gap: 8px; }
  .address-grid .field > span { font-size: 12px; }
}

#address-modal .modal {
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
}
#address-modal .field { margin-bottom: 12px; }
#address-modal .field > span { margin-bottom: 4px; }
#address-modal .input { height: 42px; }
#address-modal textarea.input {
  height: auto;
  padding: 10px 14px;
  min-height: 60px;
}
#address-modal .form-actions { margin-top: 4px; }

/* ============================================================
   Ratings & reviews
   ============================================================ */
.rating-stars {
  color: #f59e0b;
  letter-spacing: -.02em;
}
.rating-stars-lg {
  font-size: 20px;
  letter-spacing: 0;
}
.rating-num { font-weight: 650; color: var(--text); }
.rating-count { color: var(--muted); font-size: 12px; }

.listing-rating {
  font-size: 11px;
  line-height: 1.2;
  margin: 1px 0 0;
  display: flex;
  align-items: center;
  gap: 3px;
}
.listing-rating .rating-stars { font-size: 11px; }
.listing-rating .rating-num  { font-size: 11px; }

.product-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  margin-top: 2px;
}

.star-input {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.star-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  transition: color .14s var(--ease), transform .1s var(--ease);
}
.star-btn:hover { color: #f59e0b; }
.star-btn.is-on { color: #f59e0b; }
.star-btn:active { transform: scale(.9); }

.rating-block { background: var(--warn-soft); border-color: transparent; }

.reviews-list { display: flex; flex-direction: column; gap: 12px; }
.review-card {
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.review-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.review-name {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.review-stars { font-size: 13px; margin-top: 2px; }
.review-text {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.5;
}
.review-image {
  margin-top: 10px;
  border-radius: 10px;
  max-width: 100%;
  display: block;
}

/* ============================================================
   Admin / seller rows
   ============================================================ */
.admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .16s var(--ease);
}
.admin-row:hover {
  border-color: color-mix(in srgb, var(--line) 50%, var(--accent));
}

.admin-thumb {
  flex: none;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 800;
  color: rgba(255, 255, 255, .92);
  background: linear-gradient(135deg, var(--g1, #6366f1), var(--g2, #a855f7));
  background-size: cover;
  background-position: center;
  user-select: none;
}

.admin-row-main {
  flex: 1;
  min-width: 0;
}

.admin-row .btn { flex: none; }

.kebab-btn { display: none; }

.row-actions-desktop {
  display: flex;
  gap: 6px;
  flex: none;
}
.row-actions {
  display: flex;
  gap: 6px;
  flex: none;
}

@media (max-width: 899px) {
  .row-actions-desktop { display: none; }
  .kebab-btn {
    display: inline-flex;
    flex: none;
    width: 34px;
    height: 34px;
  }
  .kebab-btn svg { width: 16px; height: 16px; }
}
@media (max-width: 480px) {
  .row-actions .btn {
    padding: 0 10px;
    font-size: 13px;
  }
}

.action-sheet {
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
}
.action-sheet-row {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
  transition: background .14s var(--ease);
}
.action-sheet-row:hover,
.action-sheet-row:active {
  background: var(--surface-2);
}
.action-sheet-row.is-danger { color: var(--danger); }
.action-sheet-row.is-cancel {
  margin-top: 6px;
  justify-content: center;
  color: var(--muted);
  font-weight: 600;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  border-radius: 0;
}

/* ============================================================
   Add-product card (inside store products list)
   ============================================================ */
.add-product-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.add-product-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.add-product-thumb {
  flex: none;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
}
.add-product-thumb svg { width: 22px; height: 22px; }
.add-product-card:hover .add-product-thumb {
  background: var(--accent);
  color: var(--accent-ink);
}
.add-product-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

/* ============================================================
   Icon tab bars (admin + store orders)
   ============================================================ */
.admin-tabs {
  max-width: 360px;
  margin: 0 auto 16px;
}
.admin-tabs .tab-pill {
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 36px;
  position: relative;
}
.admin-tabs .tab-pill svg {
  width: 17px;
  height: 17px;
  flex: none;
}
.admin-tabs .tab-count,
#store-orders-tabs .tab-count {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  min-width: 16px;
  text-align: center;
  line-height: 1.4;
}
.admin-tabs .tab-pill.is-active .tab-count,
#store-orders-tabs .tab-pill.is-active .tab-count {
  background: var(--accent);
  color: var(--accent-ink);
}

#store-orders-tabs {
  max-width: 420px;
  margin: 0 auto 16px;
}
#store-orders-tabs .tab-pill {
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
#store-orders-tabs .tab-pill svg {
  width: 16px;
  height: 16px;
  flex: none;
}

/* ============================================================
   Product wizard
   ============================================================ */
.wizard-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.wizard-head > div:first-child { flex: 1; min-width: 0; }
.wizard-head #wizard-close { flex: none; }
.wizard-head .modal-title { margin: 0; }
.wizard-head .modal-sub   { margin: 2px 0 0; }

.wizard-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}
.wizard-dot {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  transition: background .2s var(--ease);
}
.wizard-dot.is-done   { background: var(--accent); opacity: .5; }
.wizard-dot.is-active { background: var(--accent); }

.wizard-foot {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.wizard-foot .btn { flex: 1; }

#wizard-body .field:last-child { margin-bottom: 0; }

/* ============================================================
   Upload component (file picker + preview)
   ============================================================ */
.upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 20px 16px;
  background: var(--surface);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.upload:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload svg {
  width: 24px;
  height: 24px;
  color: var(--muted);
  flex: none;
}
.upload:hover svg { color: var(--accent); }
.upload b {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}
.upload span {
  font-size: 12px;
  color: var(--muted);
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.thumbs:empty { margin-top: 0; }

.thumb-item {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  flex: none;
}
.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .14s var(--ease);
}
.thumb-x:hover { background: rgba(0, 0, 0, .85); }

.store-pic-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.store-pic-preview {
  flex: none;
  width: 88px;
  height: 88px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.store-pic-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.store-pic-row .upload {
  flex: 1;
  padding: 14px 16px;
}

/* ============================================================
   Compact purchase sheet rows
   ============================================================ */
.purchase-compact-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.purchase-compact-row:first-of-type {
  padding-top: 0;
}
.purchase-compact-head {
  margin-bottom: 6px;
}
.purchase-compact-head .section-label {
  margin: 0;
}

.purchase-two-col {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.purchase-col {
  min-width: 0;
}
.purchase-col .qty {
  margin-top: 0;
}
.purchase-col .input {
  width: 100%;
}

@media (max-width: 480px) {
  .purchase-two-col {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

#purchase-sheet .purchase-sheet-inner {
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
#purchase-sheet .purchase-title {
  font-size: 17px;
}
#purchase-sheet .purchase-sub {
  margin: 4px 0 12px;
}
#purchase-sheet .purchase-total {
  padding: 12px 0;
  margin-top: 0;
}
#purchase-sheet .purchase-note {
  margin-bottom: 12px;
}
#purchase-sheet .form-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
}
#purchase-sheet .form-actions .btn {
  width: 100%;
}

/* ============================================================
   Buyer order — delivery code + compact clickable card
   ============================================================ */
.bo-code-block {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.bo-code-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
}
.bo-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--accent);
  user-select: all;
}

.order-row-compact {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.order-row-compact:hover {
  border-color: color-mix(in srgb, var(--line) 50%, var(--accent));
  background: color-mix(in srgb, var(--surface) 96%, var(--accent-soft));
}
.order-row-compact:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.order-row-compact .admin-thumb {
  width: 48px;
  height: 48px;
  font-size: 14px;
}

.orc-main {
  flex: 1;
  min-width: 0;
  padding-right: 32px;
}
.orc-main .order-title {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  margin: 0 0 3px;
}
.orc-main .order-sub {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 1px;
}
.orc-main .order-sub b {
  color: var(--text);
  font-weight: 700;
}

.bo-status {
  color: var(--text);
  font-weight: 600;
}

.row-kebab {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.row-kebab:hover {
  background: var(--surface-2);
  color: var(--text);
}
.row-kebab svg { width: 16px; height: 16px; }

/* ============================================================
   Store (seller) order cards
   ============================================================ */
.store-order-card {
  position: relative;
  padding: 12px 14px;
  padding-right: 44px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .16s var(--ease);
}
.store-order-card:hover {
  border-color: color-mix(in srgb, var(--line) 50%, var(--accent));
}
.store-order-card .row-kebab {
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
}

.soc-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.soc-info {
  flex: 1;
  min-width: 0;
}
.soc-info .order-title {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  margin: 0 0 3px;
}
.soc-info .order-sub {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 2px;
}
.soc-info .order-sub b {
  color: var(--text);
  font-weight: 700;
}
.soc-status {
  color: var(--text) !important;
  font-weight: 600;
}

.orc-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.orc-actions .btn {
  flex: 1;
}

@media (max-width: 480px) {
  .orc-actions .btn {
    font-size: 13px;
    padding: 0 10px;
  }
}

/* ============================================================
   Store details — payment configuration
   ============================================================ */
.origin-options {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.origin-radio {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
  transition: all .16s var(--ease);
  text-align: center;
}
.origin-radio input { display: none; }
.origin-radio:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

#payment-methods-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pm-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
  transition: border-color .16s var(--ease);
}
.pm-card.is-enabled {
  border-color: var(--accent);
}
.pm-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
}
.pm-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
  flex: none;
}
.pm-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.pm-details {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
}
.pm-qr-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pm-qr-preview {
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  position: relative;
  overflow: hidden;
}
.pm-qr-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pm-qr-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pm-qr-x:hover { background: rgba(0,0,0,.9); }

.pm-qr-upload {
  flex: 1;
  padding: 10px 14px;
  gap: 4px;
}
.pm-qr-upload svg { width: 18px; height: 18px; }
.pm-qr-upload b { font-size: 13px; }
.pm-qr-upload span { font-size: 11.5px; }

/* ============================================================
   Admin payment settings
   ============================================================ */
.ps-card {
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.ps-card-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 10px;
}

/* ============================================================
   Pay target preview
   ============================================================ */
.pay-target {
  margin-top: 12px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  display: flex;
  gap: 14px;
  align-items: center;
}
.pay-target-qr {
  flex: none;
  width: 88px;
  height: 88px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface);
}
.pay-target-info {
  flex: 1;
  min-width: 0;
}
.pay-target-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.pay-target-value {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}

/* ============================================================
   Order detail — payment block
   ============================================================ */
.payment-method-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 13.5px;
}
.payment-method-label {
  font-weight: 650;
  color: var(--text);
}
.payment-mode-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.pay-qr-block {
  margin-top: 12px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  text-align: center;
}
.pay-qr-image {
  width: 180px;
  height: 180px;
  object-fit: contain;
  margin: 0 auto;
  background: #fff;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: block;
}
.pay-qr-address {
  margin-top: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
  user-select: all;
}

/* ============================================================
   Buyer order — Pay now + pay modal
   ============================================================ */
.orc-pay-btn {
  margin-top: 10px;
  width: 100%;
}
.pay-amount {
  margin: 10px 0 12px;
  font-size: 14px;
  color: var(--text);
}
.pay-amount b {
  font-size: 18px;
  font-weight: 750;
  color: var(--text);
  letter-spacing: -.02em;
}

/* ============================================================
   Product wizard — product payment methods checklist
   ============================================================ */
#product-payment-methods {
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
#product-payment-methods .check {
  display: flex;
  padding: 8px 0;
  font-size: 14px;
  color: var(--text);
}
#product-payment-methods .check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}
#product-payment-methods .hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}
#product-payment-methods .hint a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

/* ============================================================
   Store profile view
   ============================================================ */
.store-profile {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.store-profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.store-profile-cover {
  flex: none;
  width: 88px;
  height: 88px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--surface-2);
}
.store-profile-cover.is-mono {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #7c6cf5);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.03em;
}
.store-profile-info {
  flex: 1;
  min-width: 0;
}
.store-profile-name {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -.03em;
  line-height: 1.2;
  margin-bottom: 2px;
}
.store-profile-loc {
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.store-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.store-stat {
  padding: 14px 10px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.store-stat b {
  display: block;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -.03em;
}
.store-stat span {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 550;
}

.store-actions-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.store-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 650;
  text-align: center;
  transition: border-color .16s var(--ease), background .16s var(--ease);
  cursor: pointer;
}
.store-action-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.store-action-btn svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

@media (max-width: 400px) {
  .store-action-btn span { font-size: 11.5px; }
  .store-action-btn { padding: 14px 6px; }
}

/* ============================================================
   Store details — overlay picture + compact payments
   ============================================================ */
.store-pic-overlay-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}
.store-pic-overlay-preview {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.store-pic-overlay-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.store-pic-overlay-preview .thumb-x {
  top: 4px;
  right: 4px;
}
.store-pic-overlay-btn {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .16s var(--ease);
}
.store-pic-overlay-btn:hover {
  background: rgba(0, 0, 0, .8);
}
.store-pic-overlay-btn svg {
  width: 14px;
  height: 14px;
}

/* Two-column form row */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-row-2 .field {
  margin-bottom: 14px;
}
@media (max-width: 480px) {
  .form-row-2 { gap: 8px; }
  .form-row-2 .field > span { font-size: 12px; }
}

/* Compact payment rows */
.pm-grid-compact {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pm-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .16s var(--ease);
}
.pm-row.is-enabled {
  border-color: var(--accent);
}
.pm-row-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}
.pm-row-head .pm-toggle {
  flex: 1;
  padding: 0;
  margin: 0;
}
.pm-mini-qr {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 10px;
  position: relative;
}
.pm-mini-qr img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pm-mini-qr .pm-qr-x {
  width: 16px;
  height: 16px;
  top: 1px;
  right: 1px;
  font-size: 12px;
}
.pm-details-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  padding: 0 12px 12px;
}
.pm-details-row .pm-qr-upload {
  padding: 8px 12px;
  min-height: 42px;
  gap: 3px;
}
.pm-details-row .pm-qr-upload svg {
  width: 16px;
  height: 16px;
}
.pm-details-row .pm-qr-upload b {
  font-size: 12px;
}
.pm-details-row .pm-addr {
  height: 42px;
}

/* Save button — blue accent when dirty */
.icon-btn-accent.is-dirty {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: dirty-pulse 2s ease-in-out infinite;
}
@keyframes dirty-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent-soft); }
  50%      { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent-soft) 60%, transparent); }
}


/* ============================================================
   Compact payment rows — checkmark + configure modal
   ============================================================ */
.pm-check {
  flex: none;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.pm-check.is-complete {
  background: var(--ok-soft);
  color: var(--ok);
}
.pm-configure {
  flex: none;
}

/* Configure modal */
.pay-config-qr-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}
.pay-config-qr-preview {
  flex: none;
  width: 96px;
  height: 96px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
}
.pay-config-qr-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pay-config-qr-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

/* Public store view — reuse .store-profile classes */
.store-profile .grid {
  margin-top: 4px;
}

/* ============================================================
   Pull to refresh
   ============================================================ */
.ptr {
  position: fixed;
  top: calc(var(--topbar-h) - 50px);
  left: 50%;
  transform: translate(-50%, 0);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s var(--ease), transform .2s var(--ease);
}
.ptr.is-visible {
  opacity: 1;
}
.ptr.is-active {
  border-color: var(--accent);
}
.ptr-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  transform: rotate(0deg);
}
.ptr.is-active .ptr-spinner {
  transform: rotate(180deg);
  transition: transform .3s var(--ease);
}
.ptr.is-spinning .ptr-spinner {
  animation: ptr-spin .7s linear infinite;
}
@keyframes ptr-spin {
  to { transform: rotate(360deg); }
}

.quote-bubble {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 12px 8px 8px;
  text-decoration: none;
  color: inherit;
  max-width: 90%;
}
.quote-thumb {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,.92);
  background: linear-gradient(135deg, var(--g1, #6366f1), var(--g2, #a855f7));
}
.quote-info {
  min-width: 0;
}
.quote-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.quote-price {
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
  opacity: .85;
}