/* ============ Fabergé Market — design system ============ */
:root {
  --bg: #0e1621;
  --panel: #17212b;
  --panel2: #1d2a38;
  --line: #263646;
  --text: #eef4fa;
  --mut: #8fa3b5;
  --gold: #e8c76a;
  --gold-d: #b98a2e;
  --red: #c94b57;
  --red-d: #8f1f2e;
  --blue: #4aa8ff;
  --chipbg: #14344f;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-image: radial-gradient(#1c2a3a 1px, transparent 1.4px);
  background-size: 26px 26px;
}
#app { max-width: 760px; margin: 0 auto; min-height: 100vh; position: relative; padding-bottom: 86px; }
.hidden { display: none !important; }
.mut { color: var(--mut); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.pad { padding: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
h2, h3 { margin: 4px 0 10px; font-weight: 700; }
a { color: var(--blue); text-decoration: none; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(180deg, #131c27f2, #0e1621e6);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-egg {
  width: 20px; height: 25px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 35% 28%, #ff97a0, #c94b57 55%, #8f1f2e);
  border: 1.6px solid var(--gold);
  box-shadow: 0 0 10px #c94b5788;
}
.brand-t { font-family: Georgia, "Times New Roman", serif; font-size: 17px; letter-spacing: .4px; color: var(--gold); }
.brand-t b { color: var(--text); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.demo-badge {
  font-size: 10px; font-weight: 800; letter-spacing: 1px; color: #0e1621;
  background: var(--gold); border-radius: 6px; padding: 2px 6px;
}
.lang-sw { display: flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang-sw button {
  border: 0; background: transparent; color: var(--mut); font-size: 12px; font-weight: 700;
  padding: 5px 10px; cursor: pointer;
}
.lang-sw button.on { background: var(--gold); color: #241a05; }
.bal-chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; font-size: 13px;
}
.bal-chip b { color: var(--text); }
.bal-chip span { color: var(--mut); font-size: 11px; }

/* ---------- hero ---------- */
.hero {
  display: flex; align-items: center; gap: 14px;
  margin: 12px 14px; padding: 14px;
  border-radius: 18px;
  background:
    radial-gradient(90% 130% at 85% 10%, #c94b5733 0%, transparent 60%),
    linear-gradient(160deg, #2a1620 0%, #17212b 70%);
  border: 1px solid #3a2430;
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(#c94b5722 2px, transparent 2.6px);
  background-size: 34px 34px; pointer-events: none;
}
.hero-img {
  width: 92px; height: 92px; object-fit: cover; border-radius: 16px;
  border: 1px solid #c94b5766; box-shadow: 0 6px 22px #c94b5740;
  flex: none;
}
.hero-title { font-family: Georgia, serif; font-size: 24px; color: var(--gold); letter-spacing: .5px; }
.hero-title b { color: var(--text); font-weight: 600; }
.hero-sub { color: var(--mut); font-size: 12.5px; margin-top: 2px; }
.hero-stats { margin-top: 8px; display: flex; gap: 8px; align-items: center; color: var(--gold); font-size: 12px; font-weight: 600; }
.hero-stats .dot { opacity: .6; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 8px; margin: 0 14px 12px; }
.filters select {
  flex: 1; min-width: 0;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 8px; font-size: 13px;
}

/* ---------- market grid ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 14px; }
@media (min-width: 640px) { .grid { grid-template-columns: 1fr 1fr 1fr; } }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  overflow: hidden; cursor: pointer; transition: transform .12s ease, border-color .12s;
}
.card:active { transform: scale(.98); }
.card:hover { border-color: #35506b; }
.card-egg { display: flex; align-items: flex-end; justify-content: center; padding: 14px 0 4px; position: relative; overflow: hidden; }
.card .collection-card-stage,
.card[data-collection-key="jingle-bells"] .card-egg,
.card[data-collection-key="surge-board"] .card-egg,
.card[data-collection-key="clover-pin"] .card-egg {
  aspect-ratio: 1 / 1;
  min-height: 132px;
  padding: 0;
  contain: layout paint;
}
.card-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display:block; }
.card .collection-card-stage .card-art { transform: translateZ(0); backface-visibility: hidden; }
.card .collection-card-stage.collection-art-missing .card-art { visibility:hidden; }
@media (max-width:390px) {
  .card .collection-card-stage,
  .card[data-collection-key="jingle-bells"] .card-egg,
  .card[data-collection-key="surge-board"] .card-egg,
  .card[data-collection-key="clover-pin"] .card-egg { min-height:126px; }
}
.card-b { padding: 8px 12px 12px; }
.card-num { font-weight: 700; font-size: 13.5px; }
.card-attrs { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; color: var(--mut); font-size: 12px; }
.chip {
  background: var(--chipbg); color: var(--blue); border-radius: 999px;
  font-size: 11px; font-weight: 700; padding: 2px 8px; white-space: nowrap;
}
.card-price { display: flex; align-items: center; gap: 6px; font-size: 15px; }
.card-price b { font-size: 16px; }
.card-price span { color: var(--mut); font-size: 11px; }

/* ---------- panels / forms ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  margin: 12px 14px; padding: 14px;
}
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--mut); font-weight: 600; }
.form input, .form select {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 15px; width: 100%;
}
.form input:focus, .form select:focus { outline: none; border-color: var(--gold-d); }
.form.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .wide { grid-column: 1 / -1; }
.form label.chk { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.form label.chk input { width: auto; }
.hint { font-size: 12.5px; color: var(--mut); }
.hint b { color: var(--gold); }
.note {
  margin-top: 12px; padding: 10px 12px; border-radius: 12px;
  background: #c94b5714; border: 1px dashed #c94b5766;
  color: var(--mut); font-size: 12.5px;
}
.addr {
  margin-top: 6px; padding: 8px 10px; border-radius: 8px;
  background: var(--panel2); color: var(--gold); font-family: ui-monospace, Menlo, monospace;
  font-size: 12px; word-break: break-all;
}

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  border-radius: 12px; padding: 11px 16px; font-size: 14.5px; font-weight: 700; cursor: pointer;
}
.btn.gold {
  background: linear-gradient(180deg, #f0d080, #c9962e);
  border-color: #8a5a12; color: #241a05;
  box-shadow: 0 4px 14px #c9962e44;
}
.btn.ghost { background: transparent; color: var(--mut); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 9px; }
.btn.wide { width: 100%; }

/* ---------- wallet ---------- */
.wallet-card { text-align: center; }
.wallet-bal { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 34px; margin: 8px 0 14px; }
.wallet-bal b { font-size: 36px; }
.wallet-bal span { color: var(--mut); font-size: 14px; }
.wallet-btns { display: flex; gap: 10px; margin-bottom: 10px; }
.wallet-btns .btn { flex: 1; }
.txrow { display: flex; justify-content: space-between; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.txrow:last-child { border-bottom: 0; }
.tx-amt { font-weight: 700; white-space: nowrap; }
.tx-amt.plus { color: #4cd97b; }
.tx-amt.minus { color: #ff7a86; }

/* ---------- my listings ---------- */
.lrow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.lrow:last-child { border-bottom: 0; }
.lrow-egg { width: 46px; height: 52px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; position: relative; overflow: hidden; }
.lrow-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lrow-info { flex: 1; min-width: 0; }
.stchip { border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 700; }
.st-pending { background: #4f3a14; color: #ffcf6a; }
.st-active { background: #123c2a; color: #4cd97b; }
.st-sold, .st-confirmed, .st-paid { background: var(--chipbg); color: var(--blue); }
.st-rejected, .st-cancelled { background: #402028; color: #ff7a86; }

/* ---------- bottom nav ---------- */
.bnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: center; gap: 4px;
  background: #17212bf5; border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.bnav { max-width: 760px; margin: 0 auto; border-radius: 18px 18px 0 0; }
.bnav-btn {
  flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: transparent; border: 0; color: var(--mut); font-size: 11.5px; font-weight: 700;
  padding: 7px 4px; border-radius: 12px; cursor: pointer;
}
.bnav-btn svg { width: 24px; height: 24px; }
.bnav-btn.on { color: var(--gold); }
.bnav-btn.on svg { filter: drop-shadow(0 0 6px #e8c76a66); }

/* ---------- sheet / modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: #000a; display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 760px; max-height: 92vh; max-height: min(92dvh, calc(var(--fm-visual-height, 100vh) - 8px)); overflow-y: auto;
  background: var(--panel); border-radius: 22px 22px 0 0;
  border: 1px solid var(--line); border-bottom: 0;
  animation: up .22s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-x {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  width: 32px; height: 32px; border-radius: 999px; border: 0;
  background: #00000055; color: #fff; font-size: 14px; cursor: pointer;
}
.sheet-pad { padding: 18px 16px 26px; position: relative; }
.row-btns { display: flex; gap: 10px; margin-top: 14px; }
.row-btns .btn { flex: 1; }

.item-hero { position: relative; text-align: center; padding: 26px 16px 18px; }
.item-hero img { width: 168px; height: 168px; object-fit: cover; border-radius: 24px; border: 1px solid #ffffff2e; box-shadow: 0 10px 34px #0009; }
.item-name { font-size: 22px; font-weight: 800; margin-top: 12px; }
.item-name span { color: #ffffffb0; font-weight: 600; }
.item-model { color: #ffffffc9; margin-top: 2px; }
.item-table { padding: 4px 16px; }
.irow {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.irow:last-child { border-bottom: 0; }
.ikey { color: var(--mut); font-weight: 700; }
.ival { text-align: right; }
.owner { color: var(--blue); font-weight: 600; }
.item-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
}
.price-big { display: flex; align-items: center; gap: 8px; font-size: 22px; }
.price-big b { font-size: 24px; }
.price-big span { color: var(--mut); font-size: 13px; }
.confirm-box { margin-top: 8px; }

/* ---------- live feed ticker ---------- */
.feed {
  display: flex; gap: 10px; align-items: center;
  overflow-x: auto; scrollbar-width: none;
  padding: 8px 12px; margin: 0 0 10px;
  background: linear-gradient(90deg, rgba(201,75,87,.12), rgba(212,175,55,.10));
  border: 1px solid rgba(212,175,55,.25);
  border-radius: 12px; white-space: nowrap;
}
.feed::-webkit-scrollbar { display: none; }
.feed-live { color: #3ddc84; font-size: 10px; animation: feedpulse 1.6s infinite; flex: none; }
@keyframes feedpulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.feed-item { font-size: 12.5px; flex: none; color: #f3e7c9; }
.feed-item i { color: #b9a673; font-style: normal; font-size: 11px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 60; background: #243447; color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 8px 30px #000a; max-width: 88vw; text-align: center;
}

/* ================= admin ================= */
.admin-body #app { padding-bottom: 30px; }
.a-wrap { max-width: 1060px; margin: 0 auto; padding: 14px; }
.a-login { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.a-logo { font-family: Georgia, serif; font-size: 22px; color: var(--gold); margin-bottom: 8px; }
.a-logo b { color: var(--text); font-weight: 600; }
.a-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.a-top-r { display: flex; gap: 8px; }
.a-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.a-tab {
  border: 1px solid var(--line); background: var(--panel); color: var(--mut);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.a-tab.on { background: var(--gold); border-color: #8a5a12; color: #241a05; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat-v { font-size: 22px; font-weight: 800; color: var(--gold); }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--mut); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.arow-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.a-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.a-row select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; }
.cat-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cat-row:last-child { border-bottom: 0; }
.cat-row input[name=name] { flex: 2; min-width: 120px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 8px 10px; }
.cat-row input[name=rarity] { width: 74px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 8px; }
.cat-row input[type=color] { width: 40px; height: 34px; padding: 2px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; }

@media (max-width: 767px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]),
  textarea,
  select { font-size: 16px !important; }
}


/* ---------- Fabergé gift vault ---------- */
.gift-vault-panel { overflow: hidden; }
.gift-vault-intro { margin: 0 0 12px; }
.gift-vault-steps { display: grid; gap: 8px; margin: 10px 0 12px; }
.gift-vault-steps > div { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.018); }
.gift-vault-steps b { flex: 0 0 24px; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(232,199,106,.15); color: var(--gold); font-size: 12px; }
.gift-vault-steps span { color: var(--text); font-size: 13px; line-height: 1.4; }
.gift-vault-warning { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; padding: 11px 12px; border-radius: 12px; background: rgba(201,75,87,.12); border: 1px solid rgba(201,75,87,.5); }
.gift-vault-warning b { color: #ff9ba5; font-size: 13px; }
.gift-vault-warning span { color: #d8e0e7; font-size: 12.5px; line-height: 1.4; }
.gift-vault-open { margin-bottom: 8px; }

.gift-vault-status { margin: 10px 0 12px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.025); border: 1px solid var(--line); }
.gift-vault-state { font-size: 13px; font-weight: 800; margin-bottom: 5px; }
.gift-vault-state.ok { color: #63df8b; }
.gift-vault-state.wait { color: #f0c96b; }
.gift-vault-state.bad { color: #ff8d99; }
.gift-vault-recipient { display:flex; align-items:center; justify-content:space-between; gap:10px; margin:6px 0; }
.gift-vault-recipient span { color: var(--mut); font-size:12px; }
.gift-vault-recipient b { color: var(--gold); font-size:14px; overflow-wrap:anywhere; text-align:right; }
