:root {
  color-scheme: dark;
  --bg: #151d27;
  --panel: #1e2934;
  --panel-raised: #283441;
  --line: #36424f;
  --muted: #a9b3bf;
  --text: #e9edf3;
  --gold: #9fb1c8;
  --gold-light: #c5d0de;
  --violet: #7187a5;
  --danger: #ff8f91;
  --tg-bg: var(--tg-theme-bg-color, var(--bg));
  --tg-text: var(--tg-theme-text-color, var(--text));
  --tg-hint: var(--tg-theme-hint-color, var(--muted));
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
:focus-visible { outline: 2px solid #9cb2ce; outline-offset: 3px; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--tg-text);
  background: linear-gradient(155deg, #18222d 0%, #141c26 52%, #151d27 100%);
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; }
button { color: inherit; }
.ambient { display: none; }
.shell { width: min(100%, 760px); margin: 0 auto; padding: 8px 14px 34px; }
.topbar { height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { min-width: 0; display: inline-flex; gap: 9px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; display: grid; flex: none; place-items: center;
  border: 1px solid #a6bad455; border-radius: 12px; color: #fff;
  background: linear-gradient(145deg, #6f89aa, #536b8d); box-shadow: 0 4px 12px #40566e30;
}
.brand-mark svg { width: 21px; height: 21px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { overflow: hidden; font: 700 12px "Space Grotesk", sans-serif; letter-spacing: .08em; text-overflow: ellipsis; white-space: nowrap; }
.brand-name span { color: #a9abb3; font-weight: 500; }
.topbar-actions { display: flex; flex: none; align-items: center; gap: 8px; }
.profile-chip { max-width: 132px; display: flex; align-items: center; gap: 7px; color: #d4d5d9; font-size: 11px; font-weight: 600; }
.user-avatar { width: 31px; height: 31px; display: grid; flex: none; place-items: center; overflow: hidden; border: 1px solid #ffffff20; border-radius: 50%; color: #fff; background: linear-gradient(145deg, #647f9f, #405772); font-weight: 700; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button {
  width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid #ffffff17; border-radius: 12px;
  background: #222d38; color: #c4ccd6; cursor: pointer; transition: background .18s, border-color .18s;
}
.icon-button svg, .filter-icon-button svg, .search-box svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover, .filter-icon-button:hover { border-color: #71869f; background: #2a303a; }
.market-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border: 1px solid #35414d; border-radius: 16px; background: #1c2630; }
.market-tab { min-height: 42px; display: flex; justify-content: center; align-items: center; gap: 8px; border: 0; border-radius: 12px; color: #aab3bf; background: transparent; font-size: 13px; font-weight: 700; cursor: pointer; transition: background .18s, color .18s; }
.market-tab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.market-tab.selected { color: #fff; background: #5d7695; box-shadow: 0 3px 9px #40566e2b; }
.market-heading { display: flex; justify-content: space-between; align-items: end; gap: 12px; padding: 21px 1px 16px; }
.eyebrow { display: flex; align-items: center; gap: 7px; color: #aab9cc; font: 700 9px "Space Grotesk", sans-serif; letter-spacing: .12em; }
.eyebrow-dot { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: #7f96b4; }
.market-heading h1 { margin: 6px 0 4px; font: 650 24px/1.18 "DM Sans", sans-serif; letter-spacing: -.025em; }
.market-heading .hero-copy { color: #a2a5ad; font-size: 11px; line-height: 1.45; }
.stock-badge { min-width: 57px; display: grid; grid-template-columns: 8px auto; column-gap: 6px; align-items: center; margin-bottom: 3px; padding: 8px 9px; border: 1px solid #35373d; border-radius: 11px; background: #202227; }
.live-dot { width: 6px; height: 6px; grid-row: span 2; border-radius: 50%; background: #5dd99a; box-shadow: 0 0 8px #5dd99a88; }
.stock-badge strong { font: 700 12px "Space Grotesk", sans-serif; }
.stock-badge small { grid-column: 2; color: #9699a1; font-size: 8px; }
h1, h2, p { margin-top: 0; }
.catalog-tools { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; margin: 0 0 9px; }
.search-box { min-width: 0; min-height: 44px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid #37434f; border-radius: 14px; color: #9ca8b6; background: #202b36; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: #f5f6f8; background: transparent; font-size: 12px; }
.search-box input::placeholder { color: #888b93; }
.filter-icon-button { width: 44px; min-height: 44px; display: grid; place-items: center; border: 1px solid #37434f; border-radius: 14px; color: #adb7c3; background: #202b36; cursor: pointer; }
.filter-row { min-height: 39px; display: flex; align-items: center; gap: 7px; margin: 0 0 12px; }
.filter-select-wrap { min-width: 0; display: block; }
.filter-select { max-width: 100%; min-height: 36px; padding: 0 25px 0 10px; border: 1px solid #37434f; border-radius: 11px; appearance: none; color: #d0d7df; background: #202b36; font-size: 10px; }
.filter-select-wrap:first-child { flex: 1 1 auto; }
.filter-select-wrap:nth-child(2) { flex: 0 1 auto; }
.result-count { margin-left: auto; color: #8f939d; font-size: 10px; white-space: nowrap; }
.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; }
.catalog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.nft-card {
  position: relative; overflow: hidden; min-width: 0; padding: 0; text-align: left;
  border: 1px solid #323e4a; border-radius: 16px; background: #1d2833;
  box-shadow: 0 7px 20px #080d1420; transition: border-color .18s ease, transform .18s ease;
}
.nft-card:active { transform: scale(.985); }
.nft-card:hover { border-color: #70849d; }
.card-open { width: 100%; display: block; padding: 0; border: 0; text-align: left; color: inherit; background: transparent; cursor: pointer; }
.card-art { position: relative; aspect-ratio: 1 / 1; display: grid; place-items: center; overflow: hidden; background: linear-gradient(145deg, #465461, #303d49 56%, #26323d); }
.card-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 66%, #08090c26); pointer-events: none; }
.card-art img { width: 100%; height: 100%; display: block; object-fit: cover; }
.card-art .card-backdrop, .dialog-art-image .card-backdrop { position: absolute; z-index: 0; inset: 0; opacity: .34; filter: blur(14px); transform: scale(1.12); }
.card-art img:not(.card-backdrop), .dialog-art-image img:not(.card-backdrop) { position: relative; z-index: 1; }
.art-placeholder { color: #d1b0ff; opacity: .7; font-size: 66px; text-shadow: 0 4px 28px #000; }
.card-copy { padding: 0 9px 9px; }
.card-metadata-line { display: flex; justify-content: space-between; align-items: center; gap: 5px; padding: 8px 9px 0; }
.card-collection { min-width: 0; overflow: hidden; color: #a7aab2; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.card-index { flex: none; color: #8e9199; font-size: 9px; }
.card-name { margin: 4px 9px 9px; overflow: hidden; font: 600 13px/1.3 "Space Grotesk", sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.card-price { min-height: 38px; display: flex; justify-content: space-between; align-items: center; gap: 6px; padding-left: 9px; border-radius: 11px; color: #e9edf3; background: #293642; font: 700 11px "Space Grotesk", sans-serif; }
.card-buy { width: 38px; height: 36px; display: grid; flex: none; place-items: center; border: 0; border-radius: 10px; color: #fff; background: #5d7695; cursor: pointer; }
.card-buy svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card-buy:active { background: #506782; }
.notice { margin: 0 0 17px; padding: 12px 14px; border: 1px solid #766b5866; border-radius: 15px; color: #d5cbb9; background: linear-gradient(135deg, #302d27, #292923); font-size: 12px; line-height: 1.55; }
.notice.error { border-color: #9b686b70; color: #e1c8c9; background: #75484c2b; }
.empty-state { padding: 62px 22px 44px; text-align: center; }
.empty-gem { color: var(--gold); font-size: 48px; }
.empty-state h2 { margin: 12px 0 8px; font: 600 20px "Space Grotesk", sans-serif; }
.empty-state p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.hidden { display: none !important; }
.view { display: none; padding-top: 20px; }
.view.active { display: block; }
.section-heading { padding: 13px 2px 25px; }
.section-heading h1 { font-size: clamp(28px, 7vw, 37px); }
.rent-heading { padding: 19px 2px 22px; }
.rent-heading h1 { margin-top: 12px; font-size: clamp(30px, 8vw, 38px); }
.rent-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 13px; }
.rent-toolbar-title { font: 600 14px "Space Grotesk", sans-serif; }
.rent-filters { display: flex; align-items: center; gap: 9px; margin: 0 0 15px; }
.filter-control { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 11px; min-height: 44px; border: 1px solid var(--line); border-radius: 14px; color: var(--muted); background: #202b36; font-size: 10px; }
.filter-control select { max-width: 65%; padding: 7px 2px; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 10px; text-align: right; }
.rent-refresh { flex: none; }
.rent-card { text-align: left; }
.rent-card .card-name { margin-bottom: 7px; }
.rent-card .card-price { align-items: baseline; color: #fff; font-size: 12px; }
.rent-card .card-copy { padding: 12px 12px 14px; }
.rent-price-day { color: var(--gold-light); white-space: nowrap; }
.rent-period-badge { position: absolute; z-index: 2; top: 9px; right: 9px; padding: 5px 8px; border: 1px solid #ffffff35; border-radius: 20px; color: #fff; background: #080b10b8; backdrop-filter: blur(8px); font-size: 9px; font-weight: 700; }
.rental-price-line { display: flex; align-items: baseline; gap: 4px; margin: 15px 0 20px; color: #aeb8c7; font-size: 12px; }
.rental-price-line strong { color: var(--gold-light); font: 700 20px "Space Grotesk", sans-serif; }
.rental-select { appearance: auto; }
.rental-total { margin: 15px 0 20px; }
.tonconnect-input { height: 83px; padding: 11px 13px; resize: vertical; line-height: 1.45; }
.fragment-help-link { display: inline-block; margin: -5px 0 15px; color: #b3c0d0; font-size: 10px; text-decoration: none; }
.fragment-help-link:hover { text-decoration: underline; }
.rental-dialog { max-height: min(94dvh, 860px); }
.rental-dialog .dialog-image { height: min(53vw, 255px); }
.admin-rent-controls { display: grid; grid-template-columns: 1.25fr .75fr .75fr auto; gap: 7px; align-items: end; margin-top: 11px; padding-top: 11px; border-top: 1px solid #ffffff12; }
.admin-rent-controls label { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: 9px; }
.admin-rent-controls input { min-width: 0; width: 100%; height: 34px; padding: 0 8px; border: 1px solid #343e4d; border-radius: 9px; color: #fff; background: #0b1018; font-size: 10px; }
.rent-admin-status { margin: 7px 0 0; color: #9ac8a7; font-size: 9px; }
.bottom-nav {
  position: fixed; z-index: 5; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: center; gap: 5px;
  padding: 9px 14px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid #303d49; background: #18212bee; backdrop-filter: blur(18px);
}
.nav-item {
  width: min(25vw, 145px); min-height: 52px; display: flex; flex-direction: column;
  justify-content: center; align-items: center; gap: 2px; border: 0; border-radius: 14px;
  color: #848d9b; background: transparent; cursor: pointer;
}
.nav-item svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-item small { font-size: 10px; }
.nav-item.selected { color: #fff; background: #5d7695; box-shadow: 0 4px 12px #40566e28; }
.purchase-dialog {
  width: min(100%, 540px); max-height: 92vh; padding: 0; overflow: auto;
  border: 1px solid #3a4652; border-radius: 20px; color: var(--text); background: #1d2833;
  box-shadow: 0 22px 64px #050a10a8;
}
.purchase-dialog::backdrop { background: #0c131bbd; backdrop-filter: blur(7px); }
.dialog-dismiss { position: absolute; z-index: 2; top: 10px; right: 10px; }
.dialog-x { width: 44px; height: 44px; border: 1px solid #ffffff39; border-radius: 50%; background: #070a11b8; font-size: 22px; cursor: pointer; }
.dialog-image { height: min(60vw, 290px); display: grid; place-items: center; overflow: hidden; background: linear-gradient(145deg, #465461, #303d49 60%, #1d2833); }
.dialog-image img { width: 100%; height: 100%; object-fit: cover; }
.dialog-body { padding: 23px 21px 25px; }
.dialog-collection { margin-top: 12px; color: #afbdce; font-size: 11px; }
.dialog-body h2 { margin: 10px 0 7px; font: 600 24px "Space Grotesk", sans-serif; }
.dialog-description { max-height: 88px; margin: 0; overflow: auto; color: #aab3c0; font-size: 12px; line-height: 1.55; }
.dialog-attributes { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.attribute-chip { min-width: 90px; display: grid; gap: 3px; padding: 8px 10px; border: 1px solid #3a4652; border-radius: 11px; background: #25313d; }
.attribute-chip small { color: #9c9fa8; font-size: 9px; }
.attribute-chip strong { color: #f0ebf8; font-size: 10px; }
.dialog-price { display: flex; justify-content: space-between; align-items: center; margin: 20px 0; padding: 14px 0; border-top: 1px solid #ffffff16; border-bottom: 1px solid #ffffff16; color: #aab3c0; font-size: 12px; }
.dialog-price strong { color: var(--gold-light); font: 700 18px "Space Grotesk", sans-serif; }
.wallet-label { display: block; margin: 0 0 8px; font-size: 11px; font-weight: 700; }
.wallet-input { width: 100%; height: 47px; padding: 0 13px; border: 1px solid #3a4855; border-radius: 14px; outline: 0; color: var(--text); background: #17212c; font-size: 12px; }
.wallet-input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px #8574ae24; }
.wallet-input::placeholder { color: #687587; }
.wallet-hint { margin: 8px 0 16px; color: #8994a3; font-size: 10px; }
.buy-button { width: 100%; min-height: 49px; display: flex; justify-content: space-between; align-items: center; padding: 0 16px; border: 0; border-radius: 14px; color: #fff; background: #5d7695; font-size: 13px; font-weight: 700; cursor: pointer; box-shadow: 0 4px 12px #40566e28; }
.buy-button:disabled { opacity: .55; cursor: wait; }
.payment-note { margin: 12px 0 0; color: #8490a0; font-size: 9px; line-height: 1.5; text-align: center; }
.orders-list, .admin-inventory, .admin-orders { display: grid; gap: 11px; }
.order-card, .info-card, .language-card, .admin-wallet, .admin-item, .review-card {
  border: 1px solid #34414e; border-radius: 17px; background: linear-gradient(135deg, #202b36, #1b2530);
}
.order-card { padding: 15px; }
.order-connect-button { margin-top: 12px; min-height: 46px; border: 1px solid #8fa3bc; color: #fff; background: #5d7695; box-shadow: 0 4px 12px #40566e28; }
.order-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.order-card h3 { margin: 0 0 7px; font: 600 14px "Space Grotesk", sans-serif; }
.order-card p, .review-card p { margin: 0; color: #929dac; font-size: 10px; line-height: 1.6; overflow-wrap: anywhere; }
.status-pill { flex: none; padding: 5px 8px; border-radius: 20px; color: #f5d99d; background: #db9a3724; font-size: 9px; }
.status-pill.done { color: #a8e4c2; background: #3fbd7921; }
.status-pill.pending_review, .status-pill.processing { color: #ffd4a1; background: #e9933228; }
.status-pill.awaiting_fragment { color: #c5d0de; background: #627a9a2e; }
.info-card { display: flex; gap: 14px; padding: 17px; }
.info-icon { color: #80bbff; font-size: 25px; }
.info-card strong { font-size: 13px; }
.info-card p { margin: 6px 0 0; color: #96a0af; font-size: 11px; line-height: 1.55; }
.language-card { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding: 14px 15px; font-size: 12px; }
.language-card select { padding: 7px 10px; border: 1px solid #3a4855; border-radius: 11px; color: var(--text); background: #202b36; font-size: 11px; }
.admin-wallet { margin-bottom: 17px; padding: 16px; }
.admin-wallet strong { display: block; margin-bottom: 8px; font: 600 13px "Space Grotesk", sans-serif; }
.admin-wallet p { margin: 0; color: #a8b1bd; font-size: 10px; line-height: 1.55; overflow-wrap: anywhere; }
.admin-wallet code { color: var(--gold-light); font-size: 10px; }
.admin-toolbar { display: flex; justify-content: space-between; align-items: center; margin: 12px 0; }
.muted { color: var(--muted); font-size: 10px; }
.small-button { padding: 8px 12px; border: 1px solid #745e3f; border-radius: 10px; color: var(--gold-light); background: #c7943a16; font-size: 10px; font-weight: 700; cursor: pointer; }
.admin-item { padding: 12px; }
.admin-item-top { display: flex; gap: 11px; align-items: center; }
.admin-thumb { width: 57px; height: 57px; flex: none; display: grid; place-items: center; overflow: hidden; border-radius: 12px; color: var(--gold); background: #282431; }
.admin-thumb img { width: 100%; height: 100%; object-fit: cover; }
.admin-item h3 { margin: 0 0 4px; font: 600 12px "Space Grotesk", sans-serif; }
.admin-item code { color: #8490a0; font-size: 8px; overflow-wrap: anywhere; }
.admin-controls { display: flex; gap: 9px; align-items: center; margin-top: 12px; }
.admin-controls input { min-width: 0; width: 100%; height: 36px; padding: 0 9px; border: 1px solid #3a4855; border-radius: 11px; color: var(--text); background: #17212c; font-size: 11px; }
.admin-controls label { display: flex; flex: none; gap: 5px; align-items: center; color: #bac2cc; font-size: 10px; }
.admin-controls input[type="checkbox"] { width: 17px; height: 17px; accent-color: #8778a8; }
.admin-controls button { flex: none; padding: 8px 11px; }
.admin-subtitle { margin: 27px 0 12px; font: 600 15px "Space Grotesk", sans-serif; }
.review-card { padding: 13px; }
.review-card h3 { margin: 0 0 6px; font: 600 12px "Space Grotesk", sans-serif; }
.review-card button { margin-top: 10px; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: calc(78px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); padding: 10px 15px; border: 1px solid #ffffff22; border-radius: 12px; color: white; background: #272c36; font-size: 11px; opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 560px) {
  .shell { padding-right: 28px; padding-left: 28px; }
  .catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .market-heading { padding-top: 26px; padding-bottom: 20px; }
  .view { padding-top: 24px; }
}
@media (max-width: 370px) {
  .shell { padding-right: 14px; padding-left: 14px; }
  .profile-chip { max-width: 36px; }
  .user-name { display: none; }
  .admin-rent-controls { grid-template-columns: 1fr 1fr; }
  .admin-rent-controls button { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
