:root {
  --bg: #0b0f17;
  --bg2: #121826;
  --panel: #161d2e;
  --panel2: #1e2740;
  --line: #28324b;
  --text: #e9eefb;
  --muted: #8d99b5;
  --gold: #ffce3a;
  --gold2: #ffb020;
  --teal: #2dd4bf;
  --blue: #4f8cff;
  --green: #3ddc84;
  --red: #ff5d6c;
  --purple: #a78bfa;
  --radius: 14px;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Manrope", system-ui, sans-serif;
  background: radial-gradient(1100px 560px at 50% -220px, #17223c 0%, var(--bg) 62%) fixed;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
.container { width: min(1200px, 94vw); margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 80; background: rgba(11,15,23,.93); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { width: min(1260px, 96vw); margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 11px 0; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #1a1200; font-weight: 800; border-radius: 11px; box-shadow: 0 0 0 3px rgba(255,206,58,.14); }
.brand-text { font-weight: 800; font-size: 1.15rem; letter-spacing: .3px; }
.nav { display: flex; align-items: center; gap: 4px; flex: 1; margin-left: 8px; }
.nav-link { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--text); cursor: pointer; font: inherit; font-size: .92rem; padding: 8px 12px; border-radius: 10px; white-space: nowrap; }
.nav-link:hover, .nav-link.active { background: var(--panel2); color: var(--gold); text-decoration: none; }
.caret { font-size: .7em; opacity: .7; }
.nav-item { position: relative; }
.dropdown { position: absolute; top: 100%; left: 0; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: var(--shadow); display: none; z-index: 90; }
.dropdown-right { left: auto; right: 0; }
.nav-item:hover > .dropdown, .nav-item.open > .dropdown { display: block; }
.dropdown a, .dropdown .link-btn { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: .9rem; background: none; border: 0; cursor: pointer; font: inherit; }
.dropdown a:hover, .dropdown .link-btn:hover { background: var(--panel2); color: var(--gold); text-decoration: none; }
.link-btn { margin: 0; }
.auth-area { display: flex; align-items: center; gap: 8px; }
.msg-link { position: relative; }
.badge-num, .badge { background: var(--red); color: #fff; border-radius: 999px; font-size: .7rem; padding: 1px 7px; font-weight: 700; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); padding: 4px 12px 4px 4px; border-radius: 999px; cursor: pointer; font: inherit; }
.mini-avatar { width: 34px; height: 34px; border-radius: 50%; background: #080b12; object-fit: cover; object-position: top; }
.nav-toggle { display: none; background: none; border: 0; color: var(--text); font-size: 22px; cursor: pointer; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; font: inherit; font-weight: 700; font-size: .92rem; text-align: center; }
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn-primary { background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #1a1200; }
.btn-teal { background: linear-gradient(135deg, var(--teal), #0f9e8f); color: #04201c; }
.btn-blue { background: linear-gradient(135deg, var(--blue), #2b62cc); color: #fff; }
.btn-ghost { background: var(--panel2); border-color: var(--line); color: var(--text); }
.btn-danger { background: #3a1620; border-color: #6b2438; color: #ff9aa6; }
.btn-success { background: #123a26; border-color: #1f6b42; color: #a6f0c6; }
.btn-sm { padding: 7px 13px; font-size: .84rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Layout */
main.container { padding: 24px 0 64px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 1.7rem; margin: 0; }
.section { margin: 34px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { font-size: 1.2rem; margin: 0; padding-left: 12px; border-left: 4px solid var(--gold); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.card { background: linear-gradient(180deg, var(--panel), var(--bg2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
a.card { color: var(--text); display: block; transition: transform .15s, border-color .15s; }
a.card:hover { text-decoration: none; transform: translateY(-3px); border-color: var(--gold); }

/* Hero */
.hero { border-radius: 20px; padding: 38px; background: linear-gradient(120deg, #16233f, #101a30 55%, #1c1733); border: 1px solid var(--line); }
.hero h1 { font-size: clamp(22px, 3.4vw, 38px); margin: 0 0 10px; }
.hero .accent { color: var(--gold); }
.hero p { max-width: 640px; color: #c6d1e8; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 24px; }
.stat { background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.35rem; color: var(--gold); }
.stat span { font-size: .76rem; color: var(--muted); }

/* Listing card */
.listing-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.lc-thumb { height: 150px; background: linear-gradient(135deg, #1d2740, #12192b); display: grid; place-items: center; position: relative; }
.lc-thumb img { width: 78px; height: 78px; object-fit: contain; image-rendering: pixelated; }
.lc-flags { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.lc-status { position: absolute; top: 10px; right: 10px; }
.lc-body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.lc-title { font-weight: 700; margin: 0; }
.lc-price { color: var(--gold); font-weight: 800; font-size: 1.05rem; }
.lc-seller { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--line); }
.lc-seller img { width: 30px; height: 30px; border-radius: 50%; background: #080b12; object-fit: cover; object-position: top; }
.lc-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }

/* Tags */
.tag { font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--panel2); color: var(--muted); display: inline-block; }
.tag-rare { background: #3b2a05; color: var(--gold); }
.tag-cloth { background: #12303a; color: var(--teal); }
.tag-mobi { background: #14233a; color: var(--blue); }
.tag-wall { background: #2a2140; color: var(--purple); }
.tag-verified { background: #123a26; color: var(--green); }
.tag-sold { background: #3a1620; color: #ff9aa6; }
.tag-flag { background: #3a2a05; color: var(--gold); }

/* Item grid */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.item-tile { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; color: var(--text); }
.item-tile:hover { border-color: var(--gold); text-decoration: none; transform: translateY(-2px); }
.item-tile img { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; }
.item-tile .n { display: block; font-size: .78rem; margin-top: 6px; }
.item-tile .c { display: block; font-size: .68rem; color: var(--muted); word-break: break-word; }

/* Forms */
.form { max-width: 460px; }
.form-wide { max-width: 780px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; margin-bottom: 6px; color: #c3cbdd; }
input, select, textarea { width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: #0d1320; color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
textarea { min-height: 120px; resize: vertical; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.checkbox input { width: auto; }
.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .9rem; }
.alert-error { background: #3a1620; border: 1px solid #6b2438; color: #ffb3bc; }
.alert-success { background: #123a26; border: 1px solid #1f6b42; color: #a6f0c6; }
.alert-info { background: #14233a; border: 1px solid #2a4a78; color: #bcd6ff; }
.alert-warn { background: #3a2a05; border: 1px solid #6b520f; color: #ffe6a1; }

/* Item picker */
.picker { position: relative; }
.item-results { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; max-height: 300px; overflow-y: auto; margin-top: 4px; }
.item-result { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--text); padding: 8px 10px; cursor: pointer; font: inherit; text-align: left; }
.item-result:hover { background: var(--panel2); }
.item-result img { width: 32px; height: 32px; object-fit: contain; image-rendering: pixelated; }
.picked { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--bg2); }
.picked img { width: 36px; height: 36px; object-fit: contain; image-rendering: pixelated; }
.picked-name { flex: 1; display: flex; flex-direction: column; }

/* Messages */
.msg-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; }
.conv-list { display: flex; flex-direction: column; gap: 8px; }
.conv-item { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); color: var(--text); }
.conv-item:hover { border-color: var(--gold); text-decoration: none; }
.conv-item.unread { border-color: var(--gold); background: #241f10; }
.conv-item img { width: 42px; height: 42px; border-radius: 50%; background: #080b12; object-fit: cover; object-position: top; }
.conv-body { flex: 1; min-width: 0; }
.conv-body .t { display: flex; justify-content: space-between; gap: 8px; }
.conv-body .last { color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; gap: 10px; height: 60vh; overflow-y: auto; padding: 16px; background: #0c111d; border: 1px solid var(--line); border-radius: 14px; }
.bubble { max-width: 74%; padding: 10px 14px; border-radius: 14px; background: var(--panel2); }
.bubble.me { align-self: flex-end; background: linear-gradient(135deg, #2a3c22, #1d2f18); border: 1px solid #3d5a2c; }
.bubble.them { align-self: flex-start; }
.bubble .who { font-size: .72rem; color: var(--gold); font-weight: 700; display: block; margin-bottom: 2px; }
.bubble .meta { font-size: .68rem; color: var(--muted); display: block; margin-top: 4px; }
.bubble.flagged { border: 1px solid var(--gold); }
.thread-form { display: flex; gap: 8px; margin-top: 12px; }
.thread-form input { flex: 1; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; }
.table tr:hover td { background: rgba(255,255,255,.02); }

/* Pills / tabs / pager */
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill { padding: 6px 13px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); font-size: .84rem; }
.pill.active { background: var(--gold); color: #1a1200; border-color: var(--gold); font-weight: 700; }
.tabs-inline { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs-inline a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs-inline a.active, .tabs-inline a:hover { color: var(--gold); border-bottom-color: var(--gold); text-decoration: none; }
.search-row { display: flex; gap: 8px; margin-bottom: 16px; max-width: 640px; }
.search-row input { flex: 1; }
.pager { display: flex; gap: 6px; justify-content: center; margin: 24px 0; flex-wrap: wrap; }
.pager a, .pager span { padding: 7px 12px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); }
.pager .active { background: var(--gold); color: #1a1200; font-weight: 700; }

/* KV */
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.kv span:first-child { color: var(--muted); }

/* Profile */
.profile-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.avatar-frame { background: linear-gradient(180deg, #1d2740, #12192b); border-radius: 14px; display: grid; place-items: center; padding: 16px; }
.avatar-frame img { height: 200px; image-rendering: pixelated; }
.trust-bar { height: 8px; background: var(--panel2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.trust-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold), var(--green)); }

/* Toast */
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 200; background: var(--panel); border: 1px solid var(--gold); color: var(--text); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); max-width: 340px; opacity: 0; transform: translateY(10px); transition: .3s; }
.toast.show { opacity: 1; transform: translateY(0); }

/* Footer */
.footer { background: #080b12; border-top: 1px solid var(--line); margin-top: 40px; padding: 36px 0 20px; }
.footer-cols { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 24px; }
.footer-cols h4 { color: var(--gold); font-size: .95rem; }
.footer-cols a { display: block; color: var(--muted); font-size: .88rem; padding: 3px 0; }
.footer-cols a:hover { color: var(--gold); }
.footer-brand { font-weight: 800; font-size: 1.15rem; margin-bottom: 10px; }
.footer-bottom { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* Registration wizard */
.reg-wrap { display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: start; margin: 24px 0; }
.reg-preview { background: linear-gradient(180deg, var(--panel), var(--bg2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; text-align: center; position: sticky; top: 84px; }
.reg-avatar { width: 100%; min-height: 210px; }
.reg-avatar img { height: 200px; image-rendering: pixelated; }
.reg-steps { list-style: none; padding: 0; margin: 20px 0 0; text-align: left; }
.reg-steps li { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--muted); font-size: .9rem; }
.reg-steps li span { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); border: 1px solid var(--line); font-size: .8rem; font-weight: 700; }
.reg-steps li.active { color: var(--gold); }
.reg-steps li.active span { background: var(--gold); color: #1a1200; border-color: var(--gold); }
.reg-form { min-height: 380px; }
.progress { height: 8px; background: var(--panel2); border-radius: 999px; overflow: hidden; margin-bottom: 22px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold2)); transition: width .35s ease; border-radius: 999px; }
.reg-step h2 { margin-top: 0; }
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 1.5rem; font-weight: 800; letter-spacing: 3px; text-align: center; padding: 14px 16px; border: 2px dashed var(--gold); border-radius: 12px; background: #0d1320; color: var(--gold); margin: 14px 0; }
.code-box span { flex: 1; }
.instruction-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.instruction { display: flex; gap: 12px; align-items: flex-start; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: .92rem; }
.instruction .num { flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: #1a1200; display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.motto-current { display: flex; justify-content: space-between; gap: 10px; align-items: center; background: #0d1320; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: .88rem; }
.motto-current b { color: var(--teal); text-align: right; word-break: break-word; }
.reg-code-mini { margin-top: 16px; background: #0d1320; border: 1px dashed var(--gold); border-radius: 12px; padding: 10px; }
.reg-code-mini span { display: block; font-size: .72rem; color: var(--muted); }
.reg-code-mini b { color: var(--gold); letter-spacing: 2px; font-size: 1.05rem; }
.reg-avatar img { transition: opacity .3s; }
@media (max-width: 820px) {
  .reg-wrap { grid-template-columns: 1fr; }
  .reg-preview { position: static; }
}

@media (max-width: 1000px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .msg-layout { grid-template-columns: 1fr; }
  .footer-cols { grid-template-columns: 1fr 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 980px) {
  .nav-toggle { display: block; margin-left: auto; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px; gap: 2px; }
  .nav.open { display: flex; }
  .dropdown { position: static; display: none; border: 0; box-shadow: none; background: #0d1320; }
  .nav-item.open > .dropdown { display: block; }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .footer-cols { grid-template-columns: 1fr; }
  .profile-head { flex-direction: column; text-align: center; }
}
