/* PATINA marketplace: collection page, cards, sidebar, tables, bag, dialogs.
   Same tokens as styles.css: a dark gallery with gold, not a clone of anyone. */

.market-page { --wide: 1520px; }
.wrap-wide { max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.up { color: var(--ok); }
.down { color: var(--bad); }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--gold-hi); cursor: pointer; font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; justify-self: start; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-icon.sm { width: 32px; height: 32px; font-size: 12px; }
.h-md { font: 600 28px var(--font-display); margin: 0 0 6px; }
.k-offer, .k-coffer { color: var(--verdigris); }
.k-offer-cancel, .k-coffer-cancel { color: var(--muted); }

/* ---------- banner + collection header ---------- */

.banner {
  height: 240px; display: flex; gap: 2px; overflow: hidden; position: relative;
  margin-top: -1px; background: var(--surface);
}
.banner div { flex: 0 0 240px; height: 240px; }
.banner img { width: 100%; height: 100%; object-fit: cover; filter: saturate(0.9); }
.banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(15, 13, 10, 0.1) 0%, rgba(15, 13, 10, 0.55) 60%, var(--bg) 100%); }
@media (max-width: 640px) { .banner, .banner div { height: 150px; } .banner div { flex-basis: 150px; } }

.coll { padding-top: 0; }
.coll-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 24px; align-items: start; margin-top: -64px; position: relative; z-index: 2; }
.coll-meta, .coll-actions { padding-top: 76px; }
@media (max-width: 760px) { .coll-head { grid-template-columns: 1fr; gap: 14px; margin-top: -48px; } .coll-meta, .coll-actions { padding-top: 0; } }
.coll-avatar { width: 128px; height: 128px; border-radius: 22px; overflow: hidden; border: 4px solid var(--bg); box-shadow: 0 0 0 1px var(--gold-deep), 0 20px 40px -20px #000; background: var(--surface); }
@media (max-width: 760px) { .coll-avatar { width: 96px; height: 96px; } }
.coll-avatar img { width: 100%; height: 100%; }
.coll-title { font: 600 clamp(38px, 5vw, 56px)/1 var(--font-display); letter-spacing: 0.06em; margin: 0 0 10px; }
.meta-chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 12px; }
.meta-chips li { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.coll-desc { color: var(--muted); max-width: 72ch; margin: 0; font-size: 15px; }
.coll-actions { display: flex; gap: 10px; align-items: center; }

.stats-bar { display: flex; flex-wrap: wrap; gap: 28px; margin: 26px 0 20px; padding: 0; }
.stats-bar div { min-width: 100px; }
.stats-bar dt { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.stats-bar dd { margin: 0; font: 600 22px var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats-bar dd small { display: block; font: 400 12px var(--font-body); color: var(--muted); }
.stats-bar.small { margin-top: 0; }

.tabs-line { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); margin-bottom: 18px; overflow-x: auto; }
.tabs-line button { background: none; border: 0; color: var(--muted); padding: 12px 16px; font: 500 15px var(--font-body); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; min-height: 44px; }
.tabs-line button:hover { color: var(--text); }
.tabs-line button[aria-selected='true'] { color: var(--text); border-bottom-color: var(--gold); }

/* ---------- toolbar ---------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 0 14px; position: sticky; top: 64px; z-index: 15; background: linear-gradient(180deg, var(--bg) 80%, transparent); }
.tool-btn { gap: 8px; }
.tool-btn svg { width: 18px; height: 18px; }
.badge-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: var(--on-gold); font: 600 11px var(--font-mono); }
.live { display: inline-flex; align-items: center; color: var(--muted); font-size: 14px; margin-right: auto; }
.search { position: relative; flex: 0 1 300px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 38px !important; }
.toolbar select { width: auto; min-width: 190px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.segmented button { width: 44px; height: 42px; display: grid; place-items: center; background: var(--surface); border: 0; color: var(--muted); cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-pressed='true'] { background: var(--surface-2); color: var(--gold-hi); }
.segmented svg { width: 18px; height: 18px; }
@media (max-width: 760px) { .search { flex: 1 1 100%; order: 5; } .toolbar select { flex: 1; min-width: 0; } .toolbar { top: 56px; } }

/* ---------- layout + sidebar ---------- */

.items-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
.items-layout.filters-closed { grid-template-columns: minmax(0, 1fr); }
.items-layout.filters-closed .sidebar { display: none; }
.sidebar { position: sticky; top: 132px; max-height: calc(100vh - 150px); overflow-y: auto; padding-right: 6px; scrollbar-width: thin; }
@media (max-width: 900px) {
  .items-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 16px; padding: 12px; }
}
.facet { border-bottom: 1px solid var(--line-soft); padding: 10px 0; }
.facet h3, .facet summary { font: 600 15px var(--font-body); margin: 0; padding: 8px 0; cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; }
.facet h3 { cursor: default; }
.facet summary::-webkit-details-marker { display: none; }
.facet summary::after { content: ''; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform var(--t-fast); margin-left: auto; }
.facet[open] summary::after { transform: rotate(-135deg); }
.facet-body { display: grid; gap: 2px; padding: 4px 0 6px; }
.check { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: center; padding: 8px 6px; border-radius: 8px; cursor: pointer; text-transform: none; letter-spacing: 0; font: 400 14px var(--font-body); color: var(--text); margin: 0; }
.check:hover { background: var(--surface); }
.check input { width: 18px; height: 18px; accent-color: var(--gold); margin: 0; }
.check small { color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
.seg-status { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; }
.seg-status button { min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 500; }
.seg-status button[aria-checked='true'] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--gold-deep); }
.price-range { grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.price-range span { color: var(--muted); font-size: 13px; }
.price-range .btn { grid-column: 1 / -1; min-height: 40px; }

.active-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.active-filters:empty { display: none; }
.pill-x { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; font-size: 13px; }
.pill-x:hover { border-color: var(--gold); }
.pill-x span[aria-hidden] { color: var(--muted); font-size: 16px; line-height: 1; }

.sweep { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 14px; background: linear-gradient(90deg, rgba(201, 162, 39, 0.12), var(--surface)); border: 1px solid var(--gold-deep); border-radius: 14px; }
.sweep > span { font-weight: 600; }
.sweep input[type='range'] { flex: 1 1 160px; height: 32px; }
.sweep output { font: 600 18px var(--font-mono); min-width: 24px; text-align: center; }

/* ---------- cards ---------- */

.cards.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.cards.compact { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 14px; overflow: hidden; position: relative; transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med), border-color var(--t-fast); }
.card:hover { transform: translateY(-4px); border-color: var(--line); box-shadow: 0 18px 40px -22px #000; }
.card .card-img { display: block; position: relative; aspect-ratio: 1; border: 0; border-radius: 0; }
.card .card-img img { width: 100%; height: 100%; transition: transform 600ms var(--ease-out); }
.card:hover .card-img img { transform: scale(1.04); }
.corner { position: absolute; top: 10px; font: 600 11px var(--font-mono); border-radius: 999px; padding: 3px 8px; letter-spacing: 0.04em; }
.corner.you { left: 10px; }
.corner.gold-tag { right: 10px; background: rgba(15, 13, 10, 0.75); color: var(--gold-hi); border: 1px solid var(--gold-deep); backdrop-filter: blur(4px); }
.card-body { padding: 12px 14px 14px; display: grid; gap: 2px; }
.card-title { color: var(--text); text-decoration: none; font-weight: 600; font-size: 15px; }
.card-title:hover { color: var(--gold-hi); }
.card-price { font: 600 17px var(--font-mono); }
.card-price b { font-weight: 600; }
.card-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: grid; grid-template-columns: 1fr auto; position: absolute; left: 0; right: 0; bottom: 0; transform: translateY(100%); transition: transform var(--t-med) var(--ease-out); }
.card:hover .card-actions, .card:focus-within .card-actions { transform: none; }
.card-actions .btn { border-radius: 0; min-height: 46px; border: 0; }
.card-actions .bag-btn { width: 52px; padding: 0; background: var(--surface-2); border-left: 1px solid var(--line); }
.card-actions .bag-btn svg { width: 20px; height: 20px; }
.card-actions .bag-btn[aria-pressed='true'] { color: var(--gold-hi); }
@media (hover: none) {
  .card-actions { position: static; transform: none; }
}
.cards.compact .card-body { padding: 8px 10px 10px; }
.cards.compact .card-title { font-size: 13px; }
.cards.compact .card-price { font-size: 14px; }
.cards.compact .card-sub, .cards.compact .corner.gold-tag { display: none; }
.cards.compact .card-actions .btn { min-height: 38px; font-size: 13px; }

/* list view */
.cards.list { display: grid; gap: 0; border: 1px solid var(--line-soft); border-radius: 14px; overflow: hidden; }
.row { display: grid; grid-template-columns: minmax(180px, 2fr) repeat(3, minmax(80px, 1fr)) minmax(100px, 1fr) 70px 110px; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line-soft); font-size: 14px; }
.row.head { border-top: 0; background: var(--surface); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; font-family: var(--font-mono); }
.row:not(.head):hover { background: var(--surface); }
.row-item { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; min-width: 0; }
.row-item img { width: 44px; height: 44px; border-radius: 8px; flex: none; }
.row-item span { display: grid; min-width: 0; }
.row-item small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  .row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .row > :nth-child(3), .row > :nth-child(4), .row > :nth-child(5), .row > :nth-child(6) { display: none; }
}

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: 14px; }
.mkt-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mkt-table th { text-align: left; font: 500 11px var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 12px 14px; background: var(--surface); white-space: nowrap; }
.mkt-table td { padding: 10px 14px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.mkt-table tbody tr:hover td { background: rgba(28, 24, 19, 0.6); }
.mkt-table td.act { text-align: right; white-space: nowrap; }
.mkt-table a { color: var(--text); }
.mkt-table .row-item img { width: 36px; height: 36px; }
.ev { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; }
.ev::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.section-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
#activityView .chips { margin-bottom: 14px; }
.chart-card.wide { padding: 20px; }
.chart-empty { padding: 30px 0; text-align: center; }
.sale-dot { fill: var(--gold); stroke: var(--bg-2); stroke-width: 2; transition: r var(--t-fast); }
.sale-dot.on { r: 8; fill: var(--gold-hi); }

/* ---------- bag ---------- */

.bag-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; width: 60px; height: 60px; border-radius: 50%;
  border: 1px solid #e2bd4a; background: linear-gradient(180deg, #e2bd4a, var(--gold)); color: var(--on-gold);
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 16px 34px -12px rgba(201, 162, 39, 0.8);
  animation: pop var(--t-med) var(--ease-out);
}
.bag-fab svg { width: 26px; height: 26px; }
.bag-count { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; border-radius: 999px; background: var(--text); color: var(--bg); font: 600 12px var(--font-mono); display: grid; place-items: center; padding: 0 6px; }
.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(420px, 100vw); max-width: 100vw; border-radius: 18px 0 0 18px; }
.drawer[open] { animation: slideIn var(--t-med) var(--ease-out); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.drawer .dlg-body { display: grid; gap: 12px; }
.bag-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.bag-list li { display: grid; grid-template-columns: 52px 1fr auto auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 12px; padding: 6px 8px; }
.bag-list a { color: var(--text); text-decoration: none; font-size: 14px; }
.bag-art { width: 52px; height: 52px; border-radius: 8px; overflow: hidden; display: block; }
.bag-list b { font: 500 13px var(--font-mono); }
.bag-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.bag-total b { font: 600 24px var(--font-display); }

/* ---------- dialogs ---------- */

.modal { max-width: min(480px, calc(100vw - 32px)); }
.modal.wide { max-width: min(640px, calc(100vw - 32px)); }
.dlg-form { display: grid; gap: 8px; }
.dlg-form label { margin: 8px 0 0; }
.dlg-form .btn-block { margin-top: 10px; }
.dlg-item { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.dlg-item img { width: 64px; height: 64px; border-radius: 10px; }
.dlg-item div { display: grid; }
.field-help { margin: 2px 0 0; font-size: 13px; color: var(--muted); min-height: 18px; }
.breakdown { display: grid; gap: 6px; margin: 8px 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 12px; }
.breakdown:empty { display: none; }
.breakdown div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.breakdown dt { color: var(--muted); }
.breakdown dd { margin: 0; font-family: var(--font-mono); }
.breakdown .total { border-top: 1px solid var(--line-soft); padding-top: 8px; font-weight: 600; }
.breakdown .total dd { color: var(--gold-hi); }
.pick { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.pick legend { font: 500 11px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.pick-item { position: relative; display: grid; gap: 4px; text-transform: none; letter-spacing: 0; font: 500 13px var(--font-body); color: var(--text); cursor: pointer; border: 2px solid var(--line-soft); border-radius: 12px; padding: 6px; margin: 0; }
.pick-item:has(input:checked) { border-color: var(--gold); }
.pick-item input { position: absolute; opacity: 0; }
.pick-item img { border-radius: 8px; }
.pick-item small { color: var(--muted); font-size: 11px; }

/* ---------- item page price card ---------- */

.price-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-bottom: 14px; }
.price-card .pc-head { padding: 12px 18px; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.price-card .pc-head svg { width: 16px; height: 16px; }
.price-card .pc-body { padding: 16px 18px 18px; display: grid; gap: 12px; }
.price-card .pc-label { color: var(--muted); font-size: 13px; }
.price-card .pc-price { font: 600 34px var(--font-display); line-height: 1; }
.price-card .pc-price small { font: 400 14px var(--font-body); color: var(--muted); margin-left: 8px; }
.pc-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.pc-actions.two { grid-template-columns: 1fr 1fr; }
.pc-actions .bag-btn { width: 52px; padding: 0; }
.pc-actions .bag-btn svg { width: 20px; height: 20px; }
