@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap');

:root {
  --bg0: #05080f; --bg-card: #151820; --ink: #eef4ff; --muted: #8899ac;
  --accent: #00a3ff; --accent-glow: rgba(0, 163, 255, 0.4);
  --success: #00ff9d; --danger: #ff4d6d;
  --border: rgba(255, 255, 255, 0.1);
  --glass: rgba(20, 25, 40, 0.7);
  --header-h: 60px;
  --radius: 16px;
}

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg0); color: var(--ink); font-family: 'Inter', sans-serif; min-height: 100vh; overflow-x: hidden; }
.bg-gradient { position: fixed; inset: 0; z-index: -1; background: radial-gradient(circle at 50% 0%, #1a2035 0%, #05080f 80%); pointer-events: none; }
body.template-on .bg-gradient { opacity: 0; }

.template-wrap {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.template-wrap.show { opacity: 1; }
.template-bg {
  position: absolute;
  inset: 0;
  background: #0b0f17;
  background-size: cover;
  background-position: center;
}
.tpl-canvas, .tpl-particles, .tpl-glow, .tpl-noise, .tpl-vignette {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.tpl-canvas { display: none; }
.template-wrap.fx-particles.particles-starfield #tplStars { display: block; }
.template-wrap.fx-particles.particles-leaf #tplLeaves { display: block; }
.template-wrap.fx-particles.particles-meteor #tplMeteors { display: block; }
.tpl-particles { opacity: 0; }
.template-wrap.fx-particles.particles-dust .tpl-particles {
  opacity: 0.6;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.3) 1px, transparent 2px),
    radial-gradient(circle, rgba(0,163,255,0.25) 1px, transparent 2px);
  background-size: 60px 60px, 90px 90px;
  background-position: 10px 10px, 40px 80px;
}
.template-wrap.fx-particles.particles-spark .tpl-particles {
  opacity: 0.7;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.7) 1px, transparent 2px),
    radial-gradient(circle, rgba(0,163,255,0.5) 1px, transparent 2px),
    radial-gradient(circle, rgba(255,255,255,0.4) 1px, transparent 2px);
  background-size: 40px 40px, 70px 70px, 110px 110px;
}
.template-wrap.fx-particles.particles-bubble .tpl-particles {
  opacity: 0.45;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.18) 6px, transparent 7px),
    radial-gradient(circle, rgba(0,163,255,0.15) 4px, transparent 5px);
  background-size: 120px 120px, 160px 160px;
  filter: blur(0.4px);
}
.tpl-glow {
  opacity: 0;
  background: radial-gradient(circle at 20% 20%, rgba(0,163,255,0.35), transparent 55%),
              radial-gradient(circle at 80% 10%, rgba(255,255,255,0.18), transparent 50%);
}
.tpl-noise {
  opacity: 0;
  background-image: repeating-radial-gradient(circle at 10% 20%, rgba(255,255,255,0.08) 0 1px, transparent 1px 4px);
  mix-blend-mode: soft-light;
}
.tpl-vignette {
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(0,0,0,0.65) 100%);
}
.template-wrap.fx-glow .tpl-glow { opacity: 0.9; }
.template-wrap.fx-noise .tpl-noise { opacity: 0.25; }
.template-wrap.fx-vignette .tpl-vignette { opacity: 0.8; }

/* === Navbar === */
.nav { 
  position: fixed; top: 0; width: 100%; height: var(--header-h); 
  display: flex; align-items: center; justify-content: space-between; 
  padding: 0 24px; background: rgba(5,8,15,0.85); backdrop-filter: blur(12px);
  z-index: 1000; border-bottom: 1px solid var(--border);
}
.logo { font-weight: 800; font-size: 1.2rem; color: #fff; text-decoration: none; letter-spacing: 1px; }

/* === User Area === */
.user-area { position: relative; }
.hidden { display: none !important; }

.avatar-btn {
  width: 40px; height: 40px; border-radius: 50%; padding: 0; border: 2px solid rgba(255,255,255,0.1);
  background: #000; cursor: pointer; position: relative; transition: .2s; overflow: visible;
}
.avatar-btn:hover { border-color: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.status-dot {
  position: absolute; bottom: 0; right: 0; width: 10px; height: 10px;
  background: var(--success); border-radius: 50%; border: 2px solid var(--bg0);
}

.user-dropdown {
  position: absolute; top: 55px; right: 0; width: 260px;
  background: rgba(20, 24, 35, 0.95); backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
  opacity: 0; transform: translateY(-10px) scale(0.95); pointer-events: none;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); overflow: hidden;
}
.user-dropdown.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.menu-header { padding: 20px; background: rgba(255,255,255,0.03); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.mh-avatar img { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--border); }
.mh-info { display: flex; flex-direction: column; }
.mh-nick { font-weight: 700; font-size: 1rem; color: #fff; }
.mh-bal { font-family: monospace; color: var(--success); font-size: 0.9rem; margin-top: 2px; }

.menu-body { padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  color: var(--ink); text-decoration: none; border-radius: 8px; font-size: 0.95rem;
  transition: .2s; background: transparent; border: none; width: 100%; text-align: left; cursor: pointer;
}
.menu-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.menu-item.highlight { color: var(--accent); }
.menu-item.danger { color: var(--danger); }
.sep { height: 1px; background: var(--border); margin: 4px 8px; }

/* === Layout & Views === */
.main-content { padding-top: 100px; padding-bottom: 60px; max-width: 1200px; margin: 0 auto; width: 90%; position: relative; }

/* 視圖切換動畫 */
.view-section { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from{opacity:0; transform:translateY(10px)} to{opacity:1; transform:translateY(0)} }

.filter-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; flex-wrap: wrap; gap: 20px; }
.page-title { margin: 0; font-size: 1.8rem; font-weight: 800; text-shadow: 0 0 20px rgba(0,163,255,0.2); }
.search-box { display: flex; background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 50px; padding: 4px 4px 4px 20px; width: 300px; transition: .3s; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 15px var(--accent-glow); }
.search-box input { background: transparent; border: none; color: #fff; flex: 1; font-size: 0.95rem; }
.search-box button { background: var(--accent); color: #fff; border: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.search-box button#searchBtn { padding: 0; }

/* === Grid System === */
.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }

/* 創作者卡片 */
.creator-card {
  background: rgba(20, 25, 35, 0.6); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: .3s; position: relative; cursor: pointer;
}
.creator-card:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.c-banner { aspect-ratio: 3 / 1; background-size: cover; background-position: center; background-color: #222; }
.c-body { padding: 60px 20px 20px 20px; position: relative; }
.c-avatar { 
  width: 80px; height: 80px; border-radius: 50%; border: 4px solid #1a1e29; 
  position: absolute; top: -40px; left: 20px; object-fit: cover; background: #000;
}
.c-name { font-weight: 700; font-size: 1.1rem; margin-bottom: 4px; color: #fff; }
.c-slug { color: var(--muted); font-size: 0.85rem; margin-bottom: 12px; }

/* === Creator Profile View === */
.btn-back { background: transparent; border: none; color: var(--muted); font-size: 1rem; cursor: pointer; margin-bottom: 20px; padding: 0; transition: .2s; }
.btn-back:hover { color: #fff; transform: translateX(-5px); }

.c-profile-header {
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: rgba(20, 25, 35, 0.6); margin-bottom: 40px;
}
.cp-banner { aspect-ratio: 3 / 1; background-size: cover; background-position: center; background-color: #222; }
.cp-info { padding: 20px 30px 30px 30px; display: flex; gap: 24px; position: relative; align-items: flex-end; }
.cp-avatar { width: 120px; height: 120px; border-radius: 50%; border: 5px solid #1a1e29; margin-top: -60px; object-fit: cover; background: #000; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.cp-meta h1 { margin: 0; font-size: 2rem; font-weight: 800; text-shadow: 0 0 20px rgba(0,0,0,0.5); }
.cp-slug { color: var(--accent); margin-bottom: 10px; font-weight: 600; }
.cp-bio { color: var(--muted); line-height: 1.6; max-width: 600px; margin: 0; font-size: 0.95rem; }

.section-head { font-size: 1.4rem; margin-bottom: 20px; color: #fff; }

/* === Showcase === */
.showcase { margin: 10px 0 30px 0; }
.showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  grid-auto-rows: 8px;
  gap: 16px;
}
.showcase-card {
  border-radius: 18px;
  overflow: hidden;
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  align-self: start;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.showcase-card.wide { grid-column: span 2; }
.showcase-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow: 0 16px 40px rgba(0,0,0,0.55);
}
.showcase-card img { width: 100%; height: 100%; object-fit: contain; display: block; }
.showcase-frame {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255,255,255,0.12);
  pointer-events: none;
}
.showcase-title {
  position: absolute;
  left: 16px;
  bottom: 16px;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 6px 20px rgba(0,0,0,0.6);
}

@media (max-width: 900px) {
  .showcase-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .showcase-card.wide { grid-column: span 1; }
}
@media (max-width: 600px) {
  .showcase-grid { grid-template-columns: 1fr; grid-auto-rows: 6px; }
  .showcase-card.wide { grid-column: span 1; }
}

@media (max-width: 768px) {
  .main-content { padding-top: 90px; width: 92%; }
  .filter-bar { flex-direction: column; align-items: stretch; gap: 12px; }
  .search-box { width: 100%; }
  .page-title { font-size: 1.6rem; text-align: left; }
  .cp-info { flex-direction: column; align-items: flex-start; gap: 16px; }
  .cp-avatar { width: 96px; height: 96px; margin-top: -48px; }
  .grid-container { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .modal { width: 92%; max-width: 520px; }
  .control-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .highlight-row .switch { align-self: flex-end; }
  .total-row { align-items: flex-end; }
  .final-price { text-align: right; margin-left: auto; }
  body { -webkit-overflow-scrolling: touch; }
  .bg-gradient, .template-wrap, .nav {
    transform: translateZ(0);
    backface-visibility: hidden;
  }
  .view-section { animation: none; }
}

/* 商品卡片 */
.item-card {
  background: rgba(20, 25, 35, 0.4); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: .3s; cursor: pointer; display: flex; flex-direction: column;
}
.item-card:hover { border-color: var(--accent); box-shadow: 0 10px 30px rgba(0,0,0,0.5); transform: translateY(-5px); }
.i-img { height: 180px; width: 100%; object-fit: cover; background: #222; }
.i-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.i-name { font-weight: 700; font-size: 1rem; margin-bottom: 8px; color: #fff; flex: 1; }
.i-price { color: var(--success); font-family: monospace; font-size: 1.2rem; font-weight: 700; text-align: right; }

/* === Modal === */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.modal-back.show { opacity: 1; pointer-events: auto; }
.modal {
  width: 450px; max-width: 90%; background: #1a1e29; border: 1px solid var(--border);
  border-radius: 24px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  transform: scale(0.9) translateY(20px); transition: .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-back.show .modal { transform: scale(1) translateY(0); }
.modal-head { padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.modal-body { padding: 24px; max-height: 60vh; overflow-y: auto; }
.modal-foot { padding: 20px 24px; border-top: 1px solid var(--border); background: rgba(0,0,0,0.2); }
.product-summary { display: flex; gap: 15px; margin-bottom: 20px; align-items: center; }
.p-img { width: 70px; height: 70px; border-radius: 12px; object-fit: cover; background: #000; }
.p-info { flex: 1; }
.p-name { font-weight: 700; font-size: 1.1rem; color: #fff; margin-bottom: 4px; }
.p-price { color: var(--accent); font-family: monospace; font-size: 1rem; }
.control-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.highlight-row { background: rgba(0, 163, 255, 0.08); padding: 12px; border-radius: 12px; border: 1px solid rgba(0, 163, 255, 0.15); }
.switch { position: relative; display: inline-block; width: 48px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #333; transition: .4s; border-radius: 34px; border: 1px solid var(--border); }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--accent); border-color: var(--accent); }
input:checked + .slider:before { transform: translateX(22px); }
.qty-control { display: flex; align-items: center; background: rgba(0,0,0,0.3); border-radius: 8px; border: 1px solid var(--border); }
.qty-control button { width: 32px; height: 32px; background: transparent; border: none; color: #fff; cursor: pointer; font-size: 1.2rem; }
.qty-control input { width: 40px; text-align: center; background: transparent; border: none; color: #fff; font-weight: 700; }
.btn-primary { background: var(--accent2); border: none; color: #fff; padding: 14px; border-radius: 12px; font-weight: 700; cursor: pointer; width: 100%; font-size: 1rem; transition: .2s; }
.btn-primary:hover { box-shadow: 0 0 15px var(--accent-glow); transform: translateY(-2px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-icon { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 1.2rem; transition: .2s; }
.btn-icon:hover { color: #fff; transform: rotate(90deg); }
.total-row { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 20px; padding-top: 15px; border-top: 1px dashed var(--border); }
.final-price strong { font-size: 1.5rem; color: var(--success); font-family: monospace; }
.toast-host { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #1a1d26; border-left: 4px solid var(--accent); padding: 15px 20px; border-radius: 8px; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,0.5); min-width: 250px; animation: slideIn 0.3s; border: 1px solid var(--border); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
