:root {
  --bg: #110813;
  --bg-2: #1b0c17;
  --panel: rgba(255, 236, 246, 0.08);
  --panel-strong: rgba(255, 236, 246, 0.14);
  --line: rgba(255, 211, 232, 0.16);
  --text: #fff4fb;
  --muted: #e6bfd2;
  --accent: #ff4fa3;
  --accent-2: #ff86c0;
  --accent-3: #ffd6ea;
  --shadow: 0 20px 80px rgba(255, 52, 145, 0.2);
}

.app-shell.theme-light {
  --bg: #ffe2f0;
  --bg-2: #ffc2df;
  --panel: rgba(255, 211, 231, 0.92);
  --panel-strong: rgba(255, 191, 220, 0.96);
  --line: rgba(228, 89, 160, 0.34);
  --text: #67223f;
  --muted: #a24e76;
  --accent: #f03d95;
  --accent-2: #ff6db6;
  --accent-3: #9d2d63;
  --shadow: 0 24px 80px rgba(236, 80, 153, 0.28);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: ui-rounded, "SF Pro Display", "Helvetica Neue", sans-serif;
  scroll-behavior: smooth;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
body {
  min-height: 100vh;
  background: #140814;
}
button, input, textarea, select { font: inherit; }
.app-shell.theme-dark { color-scheme: dark; }
.app-shell.theme-light { color-scheme: light; }
.hidden { display: none !important; }
.app-shell {
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 111, 181, 0.28), transparent 32%),
    radial-gradient(circle at bottom right, rgba(255, 191, 224, 0.18), transparent 25%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 55%, var(--bg) 100%);
}

.frame {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px 16px 110px;
  position: relative;
  z-index: 1;
  transform: translateZ(0);
}
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.06) 0.8px, transparent 0.8px);
  background-size: 16px 16px;
  opacity: .08;
}
.blur-panel,
.state-card,
.profile-card,
.hero-card,
.stat-card,
.command-card,
.gift-form-card,
.resolved-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  backface-visibility: hidden;
}
.state-card {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
}
.denied-topbar {
  align-self: stretch;
  display: flex;
  justify-content: flex-end;
  margin-bottom: auto;
}
.app-shell.theme-light #deniedView.state-card {
  background:
    radial-gradient(circle at top left, rgba(255, 86, 170, 0.24), transparent 38%),
    linear-gradient(180deg, rgba(255, 203, 228, 0.96), rgba(255, 177, 214, 0.9));
  border-color: rgba(232, 83, 158, 0.38);
  box-shadow: 0 28px 90px rgba(231, 73, 151, 0.34);
}
.spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,.12);
  border-top-color: var(--accent-2);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.badge, .chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.09);
  border: 1px solid var(--line);
}
.app-shell.theme-light .badge,
.app-shell.theme-light .chip {
  background: rgba(255, 183, 217, 0.84);
  border-color: rgba(220, 73, 145, 0.34);
}
.badge.denied { background: rgba(255, 94, 164, 0.12); }
.app-shell.theme-light .badge.denied { background: rgba(255, 68, 154, 0.18); }
.chip.muted { color: var(--muted); }
.chip-button { cursor: pointer; color: var(--text); }
.theme-toggle {
  width: 46px;
  height: 46px;
  padding: 0;
  justify-content: center;
  flex: 0 0 46px;
}
.theme-icon {
  width: 24px;
  height: 24px;
  display: block;
  object-fit: contain;
  pointer-events: none;
}
.theme-toggle:hover .theme-icon {
  transform: scale(1.06);
}
.meta-grid, .stats-grid {
  display: grid;
  gap: 12px;
  width: 100%;
}
.meta-grid { grid-template-columns: 1fr; max-width: 720px; }
.meta-grid div, .stat-card {
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}
.app-shell.theme-light .meta-grid div,
.app-shell.theme-light .stat-card,
.app-shell.theme-light .command-card,
.app-shell.theme-light .profile-card,
.app-shell.theme-light .hero-card,
.app-shell.theme-light .gift-form-card,
.app-shell.theme-light .resolved-card,
.app-shell.theme-light .blur-panel {
  background: rgba(255, 196, 224, 0.86);
}
.app-shell.theme-light #deniedView .meta-grid div {
  background: rgba(255, 218, 235, 0.86);
  border-color: rgba(223, 89, 154, 0.32);
}
.meta-grid span, .stat-card span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.meta-grid strong, .stat-card strong { word-break: break-word; }

.app-topbar {
  position: sticky;
  top: 10px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}
.eyebrow, .bio, .command-subtitle, .hero-subtitle, .section-head p {
  color: var(--muted);
}

.profile-card { padding: 22px; margin-bottom: 16px; }
.profile-top { display: flex; gap: 18px; align-items: center; }
.avatar-wrap { position: relative; }
.avatar,
.mini-avatar {
  width: 88px;
  height: 88px;
  border-radius: 28px;
  object-fit: cover;
  background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.18);
}
.mini-avatar { width: 52px; height: 52px; border-radius: 18px; }
.avatar.fallback,
.mini-avatar.fallback {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent), #ff8cc7);
}
.avatar.fallback { font-size: 32px; }
.mini-avatar.fallback { font-size: 18px; }
.profile-text h1 {
  margin: 4px 0 10px;
  font-size: clamp(26px, 5vw, 38px);
  line-height: 1;
}
.profile-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.subline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--accent-3);
  font-size: 14px;
}
.bio { margin: 10px 0 0; }
.profile-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.emoji-chip .chip-label { color: var(--muted); }
.emoji-status-wrap,
.emoji-player,
.emoji-inline,
.emoji-asset-host {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.emoji-asset-host canvas {
  width: 24px !important;
  height: 24px !important;
  display: block;
}
.emoji-asset-host svg,
.emoji-asset-host svg svg {
  width: 24px !important;
  height: 24px !important;
  display: block;
  overflow: visible;
}
.emoji-inline {
  flex: 0 0 auto;
  margin-top: -2px;
  filter: none;
  animation: emojiPulse 2.6s ease-in-out infinite;
}
.emoji-player-image {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: block;
  object-fit: contain;
}
.emoji-fallback { font-size: 18px; line-height: 1; }
@keyframes emojiPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.92; }
}

.hero-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 24px;
}
.hero-label {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.hero-title { font-size: clamp(28px, 6vw, 46px); font-weight: 700; }
.primary-action,
.launch-button {
  border: 0;
  border-radius: 20px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(255, 79, 163, 0.3);
}
.primary-action { white-space: nowrap; }
.launch-button { width: 100%; margin-top: 8px; }
.launch-button:disabled { opacity: .5; box-shadow: none; }

.stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-card.wide { grid-column: 1 / -1; }
.command-grid { display: grid; gap: 14px; }
.command-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 18px;
  cursor: pointer;
}
.command-card.active-card {
  background: linear-gradient(180deg, rgba(255,92,171,.16), rgba(255,255,255,.04));
}
.app-shell.theme-light .command-card.active-card {
  background: linear-gradient(180deg, rgba(255, 133, 194, 0.38), rgba(255, 225, 239, 0.74));
}
.command-icon { font-size: 26px; }
.command-title { font-weight: 700; font-size: 18px; }
.command-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head { margin-bottom: 16px; }
.section-head.compact { margin-top: 12px; }
.section-head h2, .section-head h3 { margin: 0 0 6px; }

.gift-form-card { padding: 20px; }
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.field input, .field textarea, .field select, .small-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 236, 246, .09);
  color: var(--text);
  padding: 14px 14px;
  outline: none;
  caret-color: var(--accent);
  appearance: none;
  -webkit-appearance: none;
}
.field textarea { resize: vertical; }
.app-shell.theme-light .field input,
.app-shell.theme-light .field textarea,
.app-shell.theme-light .field select,
.app-shell.theme-light .small-select {
  background: rgba(255, 214, 233, 0.72);
}
.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted);
}
.field input::-webkit-calendar-picker-indicator {
  opacity: .85;
}
.field-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.resolved-card {
  padding: 12px 14px;
  margin: -4px 0 14px;
}
.resolved-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.resolved-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.resolved-text span { color: var(--muted); font-size: 13px; }
.lookup-result {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}
.lookup-hero,
.lookup-section,
.lookup-empty {
  padding: 18px;
}
.lookup-hero {
  display: flex;
  gap: 14px;
  align-items: center;
}
.lookup-hero-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lookup-hero-title {
  font-size: 22px;
  font-weight: 700;
}
.lookup-hero-sub {
  color: var(--muted);
  font-size: 13px;
}
.lookup-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
}
.lookup-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(255, 87, 163, 0.25), rgba(255, 177, 212, 0.18));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.lookup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.lookup-item {
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
}
.app-shell.theme-light .lookup-item {
  background: rgba(255, 222, 236, 0.62);
}
.lookup-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.lookup-item strong,
.lookup-item code {
  font-size: 14px;
  word-break: break-word;
}
.lookup-list {
  display: grid;
  gap: 10px;
}
.lookup-list-dense {
  gap: 0;
}
.lookup-list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.lookup-list-row:last-child { border-bottom: 0; }
.lookup-list-row span {
  color: var(--muted);
  font-size: 13px;
}
.lookup-list-row strong {
  text-align: right;
  word-break: break-word;
}
.lookup-note-row {
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
  word-break: break-word;
}
.lookup-note-row:last-child {
  border-bottom: 0;
}
.lookup-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lookup-badge {
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 95, 167, 0.12);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
}
.lookup-empty {
  text-align: center;
  color: var(--muted);
}
.gift-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.gift-empty {
  grid-column: 1 / -1;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.05);
  color: var(--muted);
  text-align: center;
}
.gift-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,255,255,.05);
  padding: 14px;
  cursor: pointer;
  min-height: 188px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  color: var(--text);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.gift-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(255, 79, 163, 0.16);
}
.gift-card.selected {
  border-color: rgba(255, 139, 199, 0.9);
  box-shadow: 0 0 0 2px rgba(255, 139, 199, 0.3) inset;
  background: linear-gradient(180deg, rgba(255,89,170,.18), rgba(255,255,255,.04));
}
.gift-thumb {
  height: 84px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 208, 230, 0.34), rgba(255,255,255,.06));
  overflow: hidden;
  position: relative;
}
.gift-tgs-host {
  display: block;
  padding: 0;
  contain: layout paint size;
  transform: translateZ(0);
}
.gift-thumb-preview,
.gift-tgs-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64%;
  height: 64%;
  transform: translate(-50%, -50%);
}
.gift-thumb-preview {
  object-fit: contain !important;
  transform-origin: center center;
  transition: opacity .16s ease;
}
.gift-tgs-stage {
  opacity: 0;
  transition: opacity .18s ease;
  display: grid;
  place-items: center;
}
.gift-tgs-host.is-anim-ready .gift-thumb-preview {
  opacity: 0;
}
.gift-tgs-host.is-anim-ready .gift-tgs-stage {
  opacity: 1;
}
.gift-tgs-host .gift-thumb-loading,
.gift-thumb .gift-emoji {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.gift-tgs-host svg,
.gift-tgs-host canvas {
  width: 100% !important;
  height: 100% !important;
  transform: none;
  transform-origin: center center;
  object-fit: contain;
}
.gift-tgs-host[data-anim-key="5170233102089322756"],
.gift-tgs-host[data-anim-key="5170145012310081615"] {
  background: #0f1724;
}
.gift-tgs-host[data-anim-key="5170233102089322756"] .gift-thumb-preview,
.gift-tgs-host[data-anim-key="5170233102089322756"] .gift-tgs-stage,
.gift-tgs-host[data-anim-key="5170145012310081615"] .gift-thumb-preview,
.gift-tgs-host[data-anim-key="5170145012310081615"] .gift-tgs-stage {
  width: 86%;
  height: 86%;
}
.gift-tgs-host::after {
  display: none;
}
.gift-thumb-loading {
  font-size: 34px;
  animation: giftFloat 2.8s ease-in-out infinite;
}
.gift-thumb img:not(.gift-thumb-preview) {
  width: 100%;
  height: 100%;
}
.gift-thumb img:not(.gift-thumb-preview) { object-fit: cover; }
.gift-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,.18) 38%, transparent 62%);
  transform: translateX(-130%);
  animation: giftSheen 3.6s linear infinite;
}
.gift-emoji {
  font-size: 42px;
  animation: giftFloat 2.8s ease-in-out infinite;
}
.app-shell.theme-light .gift-card,
.app-shell.theme-light .gift-empty,
.app-shell.theme-light .gift-preview {
  background: rgba(255, 214, 231, 0.84);
}
.app-shell.theme-light .gift-thumb {
  background: linear-gradient(180deg, rgba(255, 196, 222, 0.92), rgba(255, 229, 240, 0.98));
}
.app-shell.theme-light .gift-card.selected {
  background: linear-gradient(180deg, rgba(255, 136, 198, 0.5), rgba(255, 223, 237, 0.88));
}
@keyframes giftFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px) scale(1.03); }
}
@keyframes giftSheen {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(130%); }
}
.gift-title { font-weight: 700; font-size: 14px; line-height: 1.2; }
.gift-meta { color: var(--muted); font-size: 12px; }
.code-row { word-break: break-all; }
.gift-price { font-weight: 700; }
.deleted-mark { color: #ff7aa5; }
.active-mark { color: #8fe0b3; }
.gift-preview {
  margin-top: 16px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
}
.miniapp-pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.45;
}
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent-3);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(720px, calc(100vw - 20px));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  z-index: 10;
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}
.bottom-tab {
  border: 0;
  border-radius: 18px;
  padding: 14px 12px;
  background: rgba(255,255,255,.06);
  color: var(--muted);
}
.bottom-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

body.is-scrolling .gift-card,
body.is-scrolling .gift-thumb,
body.is-scrolling .gift-thumb-preview,
body.is-scrolling .gift-tgs-stage,
body.is-scrolling .bottom-nav,
body.is-scrolling .app-topbar {
  will-change: transform, opacity;
}

@media (max-width: 720px) {
  .profile-top, .hero-card, .command-head { flex-direction: column; align-items: flex-start; }
  .field-row, .stats-grid { grid-template-columns: 1fr; }
  .lookup-grid { grid-template-columns: 1fr; }
  .lookup-list-row { flex-direction: column; }
  .lookup-list-row strong { text-align: left; }
  .frame { padding-bottom: 118px; }
}
