:root {
  --bg: #0f1216;
  --bg-2: #161b22;
  --panel: #1b212b;
  --panel-2: #212935;
  --line: #2a323d;
  --text: #e6ebf2;
  --muted: #8a97a8;
  --red: #c23c2a;
  --red-2: #e35d44;
  --green: #4caf6a;
  --gold: #e4ae39;
  --radius: 12px;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background:
    radial-gradient(1100px 500px at 50% -8%, #1a2230, var(--bg)) fixed;
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
img { -webkit-user-drag: none; user-select: none; }
.img-fallback { object-fit: contain !important; padding: 18%; opacity: .55; background: #0c1014; }
h1 { font-size: 24px; margin: 0; }
.sub-h { font-size: 15px; color: var(--muted); font-weight: 600; margin: 22px 0 10px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 22px;
  padding: 11px 20px;
  background: rgba(12, 15, 20, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark {
  background: linear-gradient(135deg, var(--red), var(--red-2));
  color: #fff; font-weight: 900; letter-spacing: .5px;
  padding: 4px 8px; border-radius: 6px; font-size: 14px;
}
.brand-text { font-weight: 700; }
.proto {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); border: 1px solid var(--line);
  padding: 2px 6px; border-radius: 20px;
}
.tabs { display: flex; gap: 4px; }
.tab {
  background: none; border: none; color: var(--muted);
  font-size: 14.5px; font-weight: 600; padding: 8px 13px;
  border-radius: 8px; cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--bg-2); }
.tab.active { color: var(--text); background: var(--panel); }
.badge {
  background: var(--red-2); color: #fff; font-size: 11px; font-weight: 800;
  padding: 1px 7px; border-radius: 20px; margin-left: 2px;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.ext-pill {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--text); padding: 6px 11px; border-radius: 20px;
  cursor: pointer; font-size: 13px;
}
.ext-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.ext-pill.offline .dot { background: var(--muted); }
.ext-pill.offline { color: var(--muted); }
.wallet-chip {
  display: flex; flex-direction: column; line-height: 1.1;
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 5px 12px; border-radius: 9px;
}
.wallet-chip b { font-size: 15px; color: var(--gold); }
.steam-btn {
  background: linear-gradient(135deg, #1b2838, #2a475e);
  border: 1px solid #3d6c8d; color: #c7d5e0; font-weight: 600;
  display: flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px; cursor: pointer;
}
.steam-btn:hover { filter: brightness(1.12); }
.steam-btn[hidden] { display: none; }
.steam-ico { color: #66c0f4; font-size: 14px; }
.steam-avatar { width: 20px; height: 20px; border-radius: 4px; object-fit: cover; vertical-align: middle; margin-right: 2px; }

/* signed-in profile block: nickname + balance, avatar on the right */
.profile {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 4px 5px 4px 13px; border-radius: 10px;
}
.profile[hidden] { display: none; }
.profile-info { display: flex; flex-direction: column; line-height: 1.18; text-align: right; }
.profile-name { font-size: 13.5px; font-weight: 700; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-balance { font-size: 11.5px; color: var(--muted); }
.profile-balance b { color: var(--gold); font-weight: 700; }
.profile-avatar { width: 34px; height: 34px; border-radius: 7px; object-fit: cover; flex: 0 0 34px; background: #0c1014; }
.logout-btn { padding: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.logout-btn:hover { color: var(--text); }
.logout-btn[hidden] { display: none; }
.market-head { display: flex; align-items: center; justify-content: space-between; }
.sort-bar { display: flex; align-items: center; gap: 3px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.sort-bar > .muted { padding: 0 6px; }
.sort-btn { background: none; border: none; color: var(--muted); padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600; }
.sort-btn:hover { color: var(--text); }
.sort-btn.active { background: var(--panel); color: var(--text); }
.rarity-opt { font-weight: 700; }

/* inventory card badges + sellable hover */
.inv-card .ic-badge { font-size: 11px; color: var(--muted); }
.inv-card .ic-badge.hold { color: var(--gold); }
.inv-card.sellable { cursor: pointer; }
.inv-card.sellable:hover { border-color: var(--green); }
.inv-card:not(.sellable) { cursor: default; }

/* non-tradable inventory items: darkened thumbnail + a "Not tradable" sign */
.ic-thumb { position: relative; }
.inv-card.nontradable .nt-veil {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
}
.inv-card.nontradable .nt-sign {
  color: #fff; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px;
  background: rgba(0, 0, 0, .55); border: 1px solid rgba(255, 255, 255, .25);
  padding: 4px 9px; border-radius: 6px;
}
.inv-card.nontradable .ic-name { color: var(--muted) !important; }

/* ---------- buttons / inputs ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer;
  font-weight: 600; font-size: 13.5px;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #3a4452; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--red), var(--red-2)); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.buy { background: linear-gradient(135deg, var(--green), #3f9d5d); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12.5px; }
.btn.sell { color: var(--green); border-color: #2f5c3a; background: #16301e; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.icon-btn:hover { color: var(--text); }
.input {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  padding: 9px 11px; border-radius: 8px; font-size: 13.5px; outline: none; width: 100%;
}
.input:focus { border-color: var(--red-2); }

/* ---------- views ---------- */
.view { display: none; flex: 1; }
.view.active { display: flex; }
#view-market { gap: 0; }
#view-inventory, #view-trades, #view-wallet { flex-direction: column; padding: 22px 26px; }
.section-head { display: flex; align-items: center; gap: 16px; margin-bottom: 6px; }

/* ---------- filters ---------- */
.filters {
  width: 250px; flex: 0 0 250px; border-right: 1px solid var(--line);
  padding: 16px; display: flex; flex-direction: column; gap: 9px;
  max-height: calc(100vh - 56px); overflow-y: auto;
  background: rgba(20, 25, 33, .5);
}
.f-label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-top: 6px; }
.checks { display: flex; flex-direction: column; gap: 5px; }
.checks label { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.checks .swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- market grid ---------- */
.market-main { flex: 1; padding: 18px 22px; overflow-y: auto; }
.market-head { margin-bottom: 12px; }
.item-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px; align-content: start;
}
.item-card {
  background: var(--panel); border: 1px solid var(--line);
  border-bottom: 3px solid var(--rarity, #555);
  border-radius: 11px; padding: 11px; cursor: pointer; position: relative;
  transition: transform .1s, border-color .15s;
}
.item-card:hover { transform: translateY(-2px); border-color: #3a4452; border-bottom-color: var(--rarity); }
.item-card .ic-thumb {
  width: calc(100% + 22px);
  margin: -11px -11px 9px;
  height: 140px;
  overflow: hidden;
  border-radius: 11px 11px 0 0;
  background: #0c1014;
  display: flex; align-items: center; justify-content: center;
}
.item-card .ic-hero {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
}
.item-card .ic-name {
  font-size: 13px; font-weight: 600; margin-top: 8px; line-height: 1.25;
  /* reserve up to 3 lines so a long name never changes the card height */
  min-height: 49px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.item-card .ic-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.item-card .ic-attr {
  font-size: 11px; color: #b9c6d6; margin-top: 3px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.attr-block {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 6px 12px; margin: 12px 0;
}
.attr-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.attr-row:last-child { border-bottom: none; }
.sockets-wrap { margin: 10px 0; }
.sockets-h { text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.sockets { display: flex; flex-direction: column; gap: 7px; }
.socket {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 11px;
}
.socket-ico {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  border: 1.5px solid; display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.socket-type { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.socket-name { font-size: 14px; font-weight: 600; }
.effect-chip {
  display: inline-block; background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--gold); border-radius: 8px; padding: 7px 11px;
  font-size: 13.5px; margin-bottom: 6px;
}
.modal .im-top img { object-fit: contain !important; }
.item-card .ic-foot { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; }
.item-card .ic-price { font-weight: 800; color: var(--gold); font-size: 15px; }
.item-card .ic-count { font-size: 11px; color: var(--muted); }
.rarity-tag { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: var(--rarity); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 460px; max-width: 96vw; max-height: 90vh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.modal.wide { width: 660px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-size: 19px; }

/* ---------- item modal body ---------- */
.im-top { display: flex; gap: 14px; align-items: center; margin: 8px 0 14px; }
.im-top img { width: 84px; height: 84px; border-radius: 10px; object-fit: contain; background: var(--panel); border-bottom: 3px solid var(--rarity); }
.im-ref { display: flex; gap: 18px; margin: 6px 0 16px; }
.im-ref .r { display: flex; flex-direction: column; }
.im-ref b { font-size: 16px; }
.im-ref .gold { color: var(--gold); }
.im-ref .green { color: var(--green); }
.listing-row, .order-row {
  display: grid; align-items: center; gap: 10px;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); margin-bottom: 7px;
}
.listing-row { grid-template-columns: 1fr auto auto; }
.order-row { grid-template-columns: 1fr auto auto; }
.lr-main { display: flex; flex-direction: column; }
.lr-sub { font-size: 11.5px; color: var(--muted); }
.lr-price { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.q-tag { font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); margin-left: 4px; }
.gem-tag { font-size: 10.5px; color: #7ad; }
.place-order { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 8px; }

/* ---------- listings / trades rows ---------- */
.list-rows, .trade-rows, .tx-rows { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: grid; grid-template-columns: 44px 1fr auto auto; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--rarity, #555); border-radius: 10px; padding: 9px 12px;
}
.list-row img { width: 44px; height: 44px; border-radius: 7px; object-fit: contain; background: var(--bg-2); }
.trade-row {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.trade-row.warn { border-color: #5a4a2a; }
.trade-row img { width: 44px; height: 44px; border-radius: 7px; object-fit: contain; background: var(--bg-2); }
.tr-state { font-size: 12px; font-weight: 700; }
.tr-state.await { color: var(--gold); }
.tr-state.done { color: var(--green); }
.tr-state.fail { color: var(--red-2); }
.tr-actions { display: flex; gap: 8px; align-items: center; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--gold); }
.empty { color: var(--muted); font-size: 13.5px; padding: 8px 2px; }
.tip { max-width: 760px; margin: 2px 0 10px; }

/* ---------- inventory ---------- */
.inv-stats { display: flex; gap: 16px; color: var(--muted); font-size: 13.5px; }
.inv-stats b { color: var(--text); }
.inv-card .ic-q { font-size: 11px; color: var(--muted); margin-top: 2px; }
.inv-card .hold { color: var(--gold); font-size: 11.5px; }
.inv-actions { display: flex; gap: 6px; margin-top: 8px; }
.inv-actions .btn { flex: 1; padding: 6px; font-size: 12px; }

/* ---------- wallet ---------- */
.wallet-cards { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.wcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
  padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 190px;
}
.wcard b { font-size: 22px; }
#w-balance { color: var(--gold); }
#w-escrow { color: var(--red-2); }
.wallet-actions { display: flex; gap: 10px; margin-top: 4px; }
.tradeurl-row { display: flex; gap: 8px; align-items: center; max-width: 760px; }
.tradeurl-row .input { flex: 1; }
.tx-row {
  display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; font-size: 13px;
}
.tx-amt.pos { color: var(--green); font-weight: 700; }
.tx-amt.neg { color: var(--red-2); font-weight: 700; }
.tx-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }

/* ---------- forms in modals ---------- */
.field { margin: 10px 0; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.hintrow { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.hintrow b { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.method-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.method { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 11px; cursor: pointer; font-size: 13px; }
.method.active { border-color: var(--red-2); color: #fff; }

/* ---------- item page ---------- */
#view-item { flex-direction: column; padding: 16px 26px 30px; }
#item-back { align-self: flex-start; margin-bottom: 14px; }
.ip-grid { display: grid; grid-template-columns: 340px 1fr; gap: 26px; align-items: start; }
.ip-left { display: flex; flex-direction: column; gap: 14px; }
.ip-img {
  width: 100%; aspect-ratio: 4 / 3; height: auto; object-fit: cover;
  background: #0c1014;
  border: 1px solid var(--line); border-bottom: 3px solid var(--rarity, #555); border-radius: 12px;
}
.ip-price-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 15px; display: flex; flex-direction: column; gap: 9px; }
.ipp-row { display: flex; justify-content: space-between; align-items: baseline; }
.ipp-row b { font-size: 16px; }
.ip-price-card .btn.big { width: 100%; margin-top: 6px; }
.ip-offer { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.ip-offer-row { display: grid; grid-template-columns: 1fr 64px auto; gap: 8px; }
.ip-title { margin: 8px 0 16px; font-size: 26px; }
.ip-right .attr-block { margin-top: 0; }
.carousel { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.offer-card { flex: 0 0 132px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; cursor: pointer; transition: border-color .15s, transform .1s; }
.offer-card:hover { border-color: #3a4452; transform: translateY(-2px); }
.offer-card.mine { border-color: var(--gold); }
.offer-card.sel { border-color: var(--red-2); box-shadow: 0 0 0 1px var(--red-2); }
.offer-card img { width: 100%; height: 70px; object-fit: contain; background: #0c1014; border-radius: 7px; }
.offer-card .oc-price { font-size: 17px; font-weight: 800; color: var(--gold); margin: 7px 0 2px; }
.ipp-focus { background: color-mix(in srgb, var(--red-2) 18%, transparent); border: 1px solid var(--red-2); border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; text-align: center; }

/* ---------- gem sockets (images) ---------- */
.socket-img {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 8px;
  background: #0c1014; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.socket-img img { width: 100%; height: 100%; object-fit: cover; }
.empty-img { border: 1.5px dashed var(--line); background: transparent; }

/* ---------- styles (unlocked / locked + progress) ---------- */
.style-row { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; margin-bottom: 7px; }
.style-row.locked { opacity: 0.95; }
.style-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.style-name { font-weight: 600; font-size: 14px; }
.style-badge { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.style-badge.unlocked { color: #5fd27a; background: rgba(95, 210, 122, 0.13); }
.style-badge.locked { color: var(--muted); background: rgba(255, 255, 255, 0.05); }
.style-prog { margin-top: 9px; }
.style-bar { height: 6px; background: var(--bg-2); border-radius: 4px; overflow: hidden; margin-bottom: 5px; }
.style-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--red-2)); border-radius: 4px; }
.socket.empty { opacity: .7; }
.socket-type { font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }

/* ---------- price slider / pager / inv prompt ---------- */
.price-slider { width: 100%; accent-color: var(--red-2); margin: 0; }
#price-readout { font-weight: 600; color: var(--text); }
.inv-prompt { text-align: center; padding: 56px 20px; }
.inv-prompt p { margin-bottom: 16px; }
.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin: 16px 0; }

/* fixed page-turn arrows on the screen edges (always visible, no scrolling) */
.page-arrow {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px; border-radius: 50%; padding: 0;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  font-size: 26px; line-height: 1; cursor: pointer; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); transition: background .15s, border-color .15s;
}
.page-arrow:hover:not(:disabled) { background: var(--panel-2); border-color: #3a4452; }
.page-arrow:disabled { opacity: .3; cursor: not-allowed; }
.page-arrow.left { left: 12px; }
.page-arrow.right { right: 12px; }
.page-arrow[hidden] { display: none; }
.inv-search { max-width: 320px; margin-bottom: 14px; }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: center; }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent, var(--red-2));
  padding: 10px 16px; border-radius: 9px; font-size: 13.5px; box-shadow: var(--shadow);
  animation: slidein .22s ease;
}
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a323d; border-radius: 6px; }

@media (max-width: 820px) {
  #view-market { flex-direction: column; }
  .filters { width: 100%; flex: none; border-right: none; border-bottom: 1px solid var(--line); max-height: none; }
}
