:root {
  --blue: #0a84ff;
  --blue-dark: #0877e6;
  --text: #111215;
  --muted: #838388;
  --surface: #fff;
  --soft: #f0f0f1;
  --page: #f6f6f6;
  --border: #e7e7e8;
  --danger: #d92c24;
  --green: #0caf55;
  --radius: 16px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--page);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body { margin: 0; background: var(--page); color: var(--text); }
button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { border: 0; cursor: pointer; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.topbar { height: 72px; background: rgba(255,255,255,.96); border-bottom: 1px solid #dedede; position: sticky; top: 0; z-index: 30; }
.topbar__inner { max-width: 1460px; height: 100%; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 160px; font-size: 18px; }
.brand img { width: 34px; height: 34px; border-radius: 10px; }
.desktop-nav { align-self: stretch; display: flex; gap: 32px; align-items: center; font-weight: 600; color: var(--muted); }
.desktop-nav a { height: 100%; display: grid; place-items: center; position: relative; }
.desktop-nav a.active { color: var(--text); }
.desktop-nav a.active::after { content: ""; position: absolute; height: 4px; border-radius: 4px 4px 0 0; background: var(--blue); bottom: 0; left: -5px; right: -5px; }
.account { min-width: 160px; display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
.account img { width: 40px; height: 40px; object-fit: cover; border-radius: 50%; }
.balance { display: flex; align-items: center; gap: 8px; padding: 10px 8px 10px 12px; border-radius: 20px; background: #fafafa; font-weight: 700; }
.balance span { display: grid; place-items: center; width: 21px; height: 21px; border-radius: 50%; color: white; background: var(--blue); font-size: 20px; font-weight: 400; line-height: 1; }

.page-shell { max-width: 1460px; margin: 0 auto; padding: 34px 16px 60px; }
.title-row { min-height: 50px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.title-group { display: flex; align-items: center; gap: 14px; }
h1 { margin: 0; font-size: 28px; line-height: 1; }
.rank { background: white; border-radius: 22px; padding: 11px 14px; font-weight: 700; }
.rank span { margin-left: 8px; color: var(--muted); font-size: 20px; }
.mobile-balance { display: none; }

.summary-card { min-height: 128px; background: var(--surface); border-radius: 18px; padding: 18px; display: flex; align-items: stretch; overflow: hidden; }
.summary-copy { min-width: 390px; display: flex; flex-direction: column; justify-content: center; }
.summary-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 17px; font-weight: 600; }
.summary-label i { font-style: normal; }
.summary-label button, .link-button { padding: 0; color: #087cdf; background: none; font-weight: 600; }
.summary-value { margin-top: 11px; font-size: 34px; font-weight: 500; letter-spacing: -.7px; white-space: nowrap; }
.loss { margin-left: 8px; font-size: 16px; color: var(--danger); letter-spacing: 0; }
.loss-pill { margin-left: 7px; padding: 3px 8px; border-radius: 5px; font-size: 14px; color: #b5201a; background: #fde6e5; letter-spacing: 0; }
.summary-value .gain { color: var(--green); }
.summary-value .gain-pill { color: #078b42; background: #dcf7e8; }
.chart { width: 100%; height: 112px; min-width: 0; align-self: flex-end; overflow: visible; }
.chart-fill { fill: url(#chartFade); }
.chart-line { fill: none; stroke: #12c46b; stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

.source-tabs { height: 54px; display: flex; align-items: stretch; border-bottom: 1px solid var(--border); }
.source-tabs__scroll { display: flex; min-width: 0; gap: 24px; overflow-x: auto; scrollbar-width: none; }
.source-tabs__scroll::-webkit-scrollbar { display: none; }
.source-tabs button { background: none; position: relative; white-space: nowrap; color: var(--muted); font-weight: 600; }
.source-tabs button.active { color: var(--text); }
.source-tabs button.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; border-radius: 4px 4px 0 0; background: var(--blue); }
.source-tabs .edit-tabs { margin-left: auto; width: 48px; font-size: 22px; color: #555; }

.add-banner { min-height: 52px; margin-top: 14px; padding: 8px; border-radius: 14px; background: white; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.add-banner > div { display: flex; align-items: center; gap: 11px; }
.add-banner img { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; }
.primary, .secondary { min-height: 34px; border-radius: 11px; padding: 7px 18px; font-weight: 650; }
.primary { color: white; background: var(--blue); }
.primary:hover { background: var(--blue-dark); }
.secondary { color: #2a2a2d; background: var(--soft); }

.toolbar { margin-top: 8px; display: flex; gap: 8px; }
.search { height: 50px; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-radius: 14px; background: var(--surface); color: #c5c5c7; flex: 1; }
.search span { font-size: 29px; line-height: 0; transform: rotate(-20deg); color: #c8c8ca; }
.search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; }
.search input::placeholder { color: #c3c3c6; }
.action-button { width: 52px; height: 50px; flex: none; border-radius: 14px; background: white; color: #9b9b9e; font-size: 23px; }
.action-button.active { color: var(--blue); background: #e7f3ff; }
.mobile-filter { display: none; }
.filter-icon { display: inline-block; transform: rotate(180deg); font-size: 16px; }
.sort-wrap { position: relative; }
.sort-popover { position: absolute; z-index: 25; right: 0; top: 58px; width: 210px; padding: 10px; border-radius: 14px; background: rgba(255,255,255,.98); box-shadow: 0 8px 30px rgba(0,0,0,.15); }
.sort-popover b { display: block; padding: 6px 9px 10px; color: var(--muted); font-size: 12px; }
.sort-popover button { width: 100%; padding: 11px 10px; border-radius: 9px; display: flex; justify-content: space-between; background: none; text-align: left; }
.sort-popover button.active { background: #edf6ff; color: var(--blue); font-weight: 650; }

.catalog-layout { margin-top: 14px; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; align-items: start; }
.filters { background: white; border-radius: 16px; padding: 12px; position: sticky; top: 86px; }
.filters__title { display: flex; align-items: center; }
.filters h2 { margin: 3px 0 12px; font-size: 20px; }
.sheet-close, .sheet-search, .filter-total, .sheet-actions, .sheet-handle { display: none; }
.filter-fields { display: grid; gap: 7px; }
.select-field { display: block; position: relative; padding: 10px 9px 7px; border-radius: 11px; background: #f4f4f4; }
.select-field::after { content: "›"; position: absolute; right: 10px; bottom: 12px; color: #777; }
.select-field span, legend { display: block; color: #89898d; font-size: 11px; font-weight: 500; }
.select-field select { width: 100%; appearance: none; padding: 2px 18px 0 0; border: 0; outline: 0; background: transparent; font-weight: 650; }
fieldset { padding: 0; margin: 14px 0 0; border: 0; }
legend { margin-bottom: 7px; }
.number-filter { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 7px; }
.number-filter legend { grid-column: 1 / -1; }
.number-filter input { width: 100%; min-width: 0; border: 0; outline: 0; border-radius: 9px; padding: 9px; background: #f4f4f4; }
.number-filter i { padding-bottom: 8px; font-style: normal; color: #777; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 7px 10px; border-radius: 18px; background: #f3f3f3; font-size: 12px; font-weight: 650; }
.chips button.active { color: white; background: #1e1e20; }

.catalog { min-width: 0; }
.catalog-meta { min-height: 36px; padding: 0 8px; display: flex; align-items: center; gap: 18px; color: #777; font-size: 13px; }
.catalog-meta b { margin-left: 7px; color: var(--text); }
.gift-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.summary-card.is-loading .chart { visibility: hidden; }
.is-loading #portfolioGiftTotal,
.is-loading #portfolioValue,
.is-loading #portfolioChange,
.is-loading #portfolioChangePercent,
.is-loading #giftCount,
.is-loading #filterCount {
  position: relative;
  display: inline-block;
  overflow: hidden;
  box-sizing: border-box;
  color: transparent !important;
  vertical-align: middle;
  border-radius: 999px;
  background: #e9edf2 !important;
  box-shadow: none;
}
.is-loading #portfolioGiftTotal::after,
.is-loading #portfolioValue::after,
.is-loading #portfolioChange::after,
.is-loading #portfolioChangePercent::after,
.is-loading #giftCount::after,
.is-loading #filterCount::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.78), transparent);
  animation: skeleton-shimmer 1.45s ease-in-out infinite;
}
.is-loading #portfolioGiftTotal { width: 42px; height: 18px; }
.is-loading #portfolioValue { width: 168px; height: 46px; border-radius: 12px; }
.is-loading #portfolioChange { width: 58px; height: 25px; }
.is-loading #portfolioChangePercent { width: 68px; height: 30px; }
.is-loading #giftCount, .is-loading #filterCount { width: 36px; height: 17px; }
.skeleton-card { pointer-events: none; overflow: hidden; }
.skeleton-block, .skeleton-line, .skeleton-actions span {
  position: relative;
  overflow: hidden;
  background: #e9edf2;
}
.skeleton-block::after, .skeleton-line::after, .skeleton-actions span::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.72), transparent);
  animation: skeleton-shimmer 1.45s ease-in-out infinite;
}
.skeleton-card .gift-image { min-height: 176px; border-radius: 12px; }
.skeleton-line { height: 12px; border-radius: 999px; margin: 10px 0; }
.skeleton-line--title { width: 72%; height: 16px; }
.skeleton-line--short { width: 46%; }
.skeleton-actions { display: grid; grid-template-columns: 34px 1fr; gap: 8px; margin-top: 18px; }
.skeleton-actions span { height: 34px; border-radius: 9px; }
@keyframes skeleton-shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  .skeleton-block::after, .skeleton-line::after, .skeleton-actions span::after,
  .is-loading #portfolioGiftTotal::after, .is-loading #portfolioValue::after,
  .is-loading #portfolioChange::after, .is-loading #portfolioChangePercent::after,
  .is-loading #giftCount::after, .is-loading #filterCount::after { animation: none; }
}
.gift-card { min-width: 0; overflow: hidden; padding: 8px; border-radius: 17px; background: white; position: relative; transition: transform .15s ease, box-shadow .15s ease; }
.gift-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.gift-image { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #eee url("assets/collection-bg.svg") center/cover; position: relative; }
.gift-image.has-backdrop { background: radial-gradient(circle at 50% 36%, var(--gift-center) 0%, var(--gift-center) 18%, var(--gift-edge) 100%); }
.gift-image .gift-model { position: relative; z-index: 2; width: 100%; height: 100%; display: block; object-fit: contain; }
.gift-image.photo .gift-model { object-fit: cover; }
.gift-pattern { position: absolute; z-index: 1; inset: -11%; display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; gap: 2%; opacity: .62; transform: rotate(-8deg) scale(1.06); pointer-events: none; }
.gift-pattern span { background: var(--gift-symbol); -webkit-mask: var(--gift-pattern-image) center/contain no-repeat; mask: var(--gift-pattern-image) center/contain no-repeat; }
.gift-pattern span:nth-child(4n + 2), .gift-pattern span:nth-child(4n + 4) { transform: translateY(28%); }
.gift-pattern span:nth-child(3n) { opacity: .72; transform: scale(.82); }
.gift-type { position: absolute; z-index: 4; top: 7px; right: 8px; color: white; text-shadow: 0 1px 4px rgba(0,0,0,.55); font-size: 12px; transform: rotate(44deg) translate(19px,-11px); }
.sale-badge { position: absolute; z-index: 4; left: 9px; top: 9px; border-radius: 9px; padding: 5px 7px; background: rgba(20,20,20,.75); color: white; font-size: 11px; font-weight: 650; }
.gift-select { position: absolute; top: 8px; right: 8px; z-index: 3; width: 27px; height: 27px; border: 2px solid white; border-radius: 50%; background: rgba(0,0,0,.22); display: grid; place-items: center; color: transparent; }
.gift-select.selected { color: white; background: var(--blue); }
.gift-info { padding: 10px 1px 1px; }
.gift-heading { display: flex; align-items: center; gap: 7px; min-width: 0; }
.gift-heading h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 19px; font-weight: 500; }
.gift-number { color: #777; font-size: 13px; }
.gift-subtitle { height: 22px; padding-top: 5px; color: #89898d; font-size: 13px; }
.gift-subtitle span { float: right; color: var(--blue); }
.gift-traits { display: grid; gap: 4px; margin: 2px 0 1px; }
.gift-trait { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; min-width: 0; font-size: 12px; }
.gift-trait span { color: #99999d; }
.gift-trait b { min-width: 0; overflow: hidden; color: #525257; font-weight: 500; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.stat-row { display: flex; justify-content: space-between; gap: 8px; margin-top: 7px; font-size: 13px; }
.stat-row span:first-child { color: #8b8b8f; white-space: nowrap; }
.stat-row b { font-weight: 500; }
.stat-row .negative { color: var(--danger); }
.stat-row .positive { color: var(--green); }
.card-actions { margin-top: 10px; display: grid; grid-template-columns: 31px 1fr; gap: 6px; }
.more-button { border-radius: 10px; background: #efefef; color: #8d8d90; font-weight: 700; }
.sell-button { border-radius: 10px; min-height: 34px; color: white; background: var(--blue); font-weight: 650; }
.card-menu { position: absolute; z-index: 8; left: 8px; right: 8px; bottom: 49px; padding: 6px; border-radius: 12px; background: white; box-shadow: 0 7px 25px rgba(0,0,0,.18); }
.card-menu button { width: 100%; padding: 9px; background: none; border-radius: 8px; text-align: left; }
.card-menu button:hover { background: #f2f2f2; }
.empty-state { margin: 40px auto; max-width: 380px; text-align: center; color: var(--muted); }
.empty-state > span { font-size: 50px; }
.empty-state h3 { color: var(--text); margin: 8px 0; }
.empty-state p { margin: 0 0 18px; }

.bottom-nav { display: none; }
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.34); backdrop-filter: blur(2px); }
.modal-layer { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; pointer-events: none; }
.modal { width: min(420px, 100%); max-height: calc(100vh - 36px); overflow: auto; border-radius: 20px; padding: 18px; background: white; box-shadow: 0 20px 80px rgba(0,0,0,.2); pointer-events: auto; }
.modal__top { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.modal h2 { margin: 0; font-size: 22px; }
.modal p { color: #747478; line-height: 1.45; }
.modal-close { width: 34px; height: 34px; border-radius: 50%; background: #f0f0f1; font-size: 20px; }
.modal-art { width: 104px; height: 104px; margin: 6px auto 12px; border-radius: 24px; display: grid; place-items: center; background: #e6f3ff; }
.modal-art img { width: 78px; height: 78px; object-fit: contain; }
.modal label { display: block; margin: 14px 0 6px; color: #777; font-size: 13px; }
.modal input { width: 100%; border: 1px solid #ddd; border-radius: 12px; padding: 12px; outline: none; }
.modal input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #ddecff; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions > * { flex: 1; }
.sale-preview { display: flex; gap: 12px; align-items: center; margin-top: 15px; padding: 10px; border-radius: 14px; background: #f4f4f4; }
.sale-preview img { width: 74px; height: 74px; border-radius: 11px; object-fit: contain; background: #e9e9e9; }
.sale-preview b, .sale-preview span { display: block; }
.sale-preview span { margin-top: 4px; color: #818184; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translateX(-50%); padding: 11px 16px; border-radius: 22px; background: #202023; color: white; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: toast-in .2s ease; }
.bulk-bar { position: fixed; z-index: 40; left: 50%; bottom: 24px; transform: translateX(-50%); min-width: 430px; padding: 10px; border-radius: 15px; background: white; box-shadow: 0 10px 40px rgba(0,0,0,.2); display: flex; gap: 8px; align-items: center; }
.bulk-bar > span { margin-right: auto; padding-left: 7px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%,8px); } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinning { display: inline-block; animation: spin .55s linear; }

@media (max-width: 1180px) {
  .gift-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  html { scrollbar-gutter: auto; }
  body { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .topbar { display: none; }
  .page-shell { padding: 24px 16px 26px; }
  .title-row { margin-bottom: 16px; }
  h1 { font-size: 22px; }
  .rank { padding: 9px 12px; }
  .mobile-balance { display: flex; }
  .summary-card { min-height: 132px; padding: 15px 16px; position: relative; }
  .summary-copy { min-width: 0; width: 58%; justify-content: flex-start; z-index: 2; }
  .summary-label { font-size: 16px; white-space: nowrap; }
  .summary-label i { display: none; }
  .summary-value { font-size: 31px; margin-top: 14px; }
  .summary-value .loss { display: inline-block; margin: 9px 7px 0 0; font-size: 15px; }
  .loss-pill { margin-left: 0; }
  .chart { position: absolute; right: 0; bottom: 0; width: 51%; height: 86px; opacity: .85; }
  .source-tabs { margin-left: 0; margin-right: -2px; }
  .source-tabs__scroll { gap: 20px; }
  .source-tabs .edit-tabs { width: 36px; flex: none; }
  .add-banner { padding: 8px; margin-top: 14px; display: grid; }
  .add-banner .primary { width: 100%; min-height: 38px; }
  .toolbar { margin-top: 10px; }
  .search { height: 48px; padding: 0 14px; }
  .mobile-filter { display: block; }
  .action-button { height: 48px; width: 48px; }
  .catalog-layout { grid-template-columns: 1fr; margin-top: 14px; }
  .filters { display: none; position: fixed; z-index: 70; inset: auto 0 0; max-height: min(78vh, 700px); overflow-y: auto; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; background: rgba(255,255,255,.94); backdrop-filter: blur(18px); }
  .filters.open { display: block; animation: sheet-in .22s ease; }
  .sheet-handle { display: block; width: 42px; height: 4px; margin: -4px auto 7px; border-radius: 4px; background: #d6d6d8; }
  .filters__title { justify-content: center; position: relative; }
  .filters h2 { font-size: 19px; margin: 4px 0 15px; }
  .sheet-close { display: block; position: absolute; right: 0; width: 34px; height: 34px; border-radius: 50%; background: #e8e8e9; font-size: 23px; }
  .sheet-search { display: flex; background: rgba(240,240,242,.8); }
  .filter-total { display: flex; justify-content: space-between; margin: 19px 0 12px; font-size: 13px; color: #747477; }
  .filter-total b { margin-left: 6px; color: var(--text); }
  .select-field { background: rgba(238,238,239,.8); }
  .sheet-actions { display: grid; gap: 8px; position: sticky; bottom: -12px; margin: 18px -2px -2px; padding: 10px 2px 2px; background: linear-gradient(transparent,rgba(255,255,255,.95) 24%); }
  .sheet-actions button { min-height: 44px; }
  .catalog-meta { padding: 0 10px 9px; justify-content: space-between; background: white; border-radius: 13px; min-height: 38px; }
  .gift-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .gift-card { border-radius: 16px; }
  .gift-card:hover { transform: none; box-shadow: none; }
  .gift-heading h3 { font-size: 18px; }
  .card-actions { display: none; }
  .bottom-nav { position: fixed; z-index: 35; left: 0; right: 0; bottom: 0; height: calc(68px + env(safe-area-inset-bottom)); padding: 5px 12px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4,1fr); background: rgba(255,255,255,.96); border-top: 1px solid #dedede; backdrop-filter: blur(14px); }
  .bottom-nav a { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; color: #777; font-size: 10px; }
  .bottom-nav span { font-size: 23px; line-height: 1; }
  .bottom-nav a.active { color: var(--blue); }
  .sort-popover { position: fixed; right: 16px; top: auto; bottom: 78px; }
  .bulk-bar { bottom: calc(76px + env(safe-area-inset-bottom)); min-width: 0; width: calc(100% - 28px); flex-wrap: wrap; }
  .bulk-bar > span { width: 100%; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); max-width: calc(100% - 30px); white-space: nowrap; }
  .modal-layer { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 86vh; border-radius: 22px 22px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  @keyframes sheet-in { from { transform: translateY(100%); } }
}

@media (max-width: 380px) {
  .page-shell { padding-left: 12px; padding-right: 12px; }
  .summary-value { font-size: 28px; }
  .gift-card { padding: 7px; }
  .stat-row { font-size: 12px; }
}
