/* AgentGacha Mini App — design system (2026-10-27 UI reskin).
 *
 * One system for all ten views: palette, radii, spacing scale and type
 * scale live in the variables below and nowhere else. Views compose
 * .card / .btn / .lrow / .stat primitives; no per-view bespoke styles.
 * Rarity colors: common grey-blue, rare blue, epic purple, gold legendary.
 */
:root {
  --bg: #0B0E23;
  --panel: #151936;
  --panel-2: #1B2044;
  --inset: #0E1130;
  --line: rgba(255, 255, 255, 0.08);
  --text: #EEF0FF;
  --muted: #9AA3D6;
  --muted-2: #6E76AC;
  --accent: #7C5CFF;
  --cyan: #38E1FF;
  --grad: linear-gradient(135deg, #7C5CFF, #38E1FF);
  --gold: #FFB92E;
  --gold-grad: linear-gradient(135deg, #FFD25E, #FF9E2E);
  --ok: #3DDC84;
  --warn: #FFCF5C;
  --danger: #FF7A90;
  --r-common: #9FB0D8;
  --r-rare: #4DA3FF;
  --r-epic: #B07CFF;
  --r-legendary: #FFB92E;
  --r-card: 16px;
  --r-btn: 12px;
  --tabbar-h: 62px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
body.skin-aurora {
  background: linear-gradient(160deg, #0B2B26, #101736 55%, #241055);
}

/* ------------------------------------------------ header (brand row) */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; position: sticky; top: 0; z-index: 20;
  background: rgba(11, 14, 35, 0.88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; letter-spacing: 0.2px; }
.brand-img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.points-chip {
  background: var(--panel); border: 1px solid var(--line);
  padding: 5px 12px; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums;
}
#lang-toggle {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; margin: 0;
}

/* ------------------------------------------------ layout */
main { padding: 16px 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px); max-width: 560px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.stack > * + * { margin-top: 12px; }
.loading-line { color: var(--muted); text-align: center; padding: 32px 0; }
.page-head { margin: 2px 0 10px; }
.back-btn {
  width: 36px; height: 36px; border-radius: 50%; padding: 0; margin: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
.back-btn svg { width: 20px; height: 20px; }
.page-title { font-size: 20px; font-weight: 800; margin: 2px 0 12px; }
h2 { margin: 0 0 10px; font-size: 17px; font-weight: 700; }
h3 { margin: 0 0 8px; font-size: 15px; font-weight: 700; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 13px; }
.aux { color: var(--muted-2); font-size: 12px; }
.center { text-align: center; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.fine { color: var(--muted-2); font-size: 12px; }
code { font-size: 12px; word-break: break-all; }

/* ------------------------------------------------ cards & lists */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: 16px;
}
.card + .card { margin-top: 12px; }
.list-card { padding: 4px 16px; }
.lrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.lrow:last-child { border-bottom: none; }
.lrow-main { min-width: 0; }
.lrow-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.lrow-side { text-align: right; flex: 0 0 auto; }
.price { font-weight: 800; font-variant-numeric: tabular-nums; }
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.lrow .rank-badge { margin-right: 10px; }
.lrow-left { display: flex; align-items: center; min-width: 0; }

/* ------------------------------------------------ buttons (3 tiers) */
button, .btn {
  font: inherit; color: var(--text); cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-btn); padding: 10px 14px; margin: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; font-size: 14px;
}
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn.disabled { opacity: 0.42; pointer-events: none; }
.btn-primary, button.primary {
  background: var(--grad); border: none; color: #fff; font-weight: 700;
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.35);
}
.btn-block { width: 100%; height: 48px; font-size: 15px; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); box-shadow: none; }
.btn-gold, button.gold {
  background: var(--gold-grad); border: none; color: #2A1A00; font-weight: 700;
  box-shadow: 0 6px 18px rgba(255, 158, 46, 0.28);
}
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions > * { flex: 1; }

/* ------------------------------------------------ forms */
input, textarea {
  width: 100%; background: var(--inset); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-btn);
  padding: 11px 12px; margin: 0 0 8px; font: inherit; font-size: 14px;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25);
}
textarea { min-height: 64px; resize: vertical; }
pre, .linkbox {
  background: var(--inset); border: 1px solid var(--line); border-radius: var(--r-btn);
  padding: 10px 12px; font-size: 12px; word-break: break-all; white-space: pre-wrap; margin: 0 0 8px;
}
.field-row { display: flex; gap: 8px; }
.field-row > input { flex: 1; }
.field-row > button { flex: 0 0 auto; height: 44px; }

/* ------------------------------------------------ home hero */
.hero { text-align: center; padding: 8px 0 4px; position: relative; }
.hero::before {
  content: ""; position: absolute; left: 50%; top: 44%; width: 300px; height: 300px;
  transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(124, 92, 255, 0.32), rgba(56, 225, 255, 0.10) 55%, transparent 72%);
}
.gigi { position: relative; display: inline-block; cursor: pointer; }
.gigi-img {
  width: 216px; height: 216px; max-width: 62vw; max-height: 62vw; object-fit: cover;
  display: block; border-radius: 32px;
  -webkit-mask-image: radial-gradient(closest-side, #000 68%, transparent 99%);
  mask-image: radial-gradient(closest-side, #000 68%, transparent 99%);
  animation: gigi-float 3.6s ease-in-out infinite;
}
@keyframes gigi-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
.hero-hi { position: relative; font-size: 15px; font-weight: 600; color: var(--muted); margin: 10px 0 8px; }
.pill {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }

/* ------------------------------------------------ home stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 6px 10px; text-align: center;
}
.stat-num { font-size: 24px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-cap { color: var(--muted); font-size: 11px; margin-top: 2px; }
.ebar { background: var(--inset); border-radius: 999px; height: 5px; overflow: hidden; margin-top: 8px; }
.ebar-fill { background: var(--grad); height: 100%; border-radius: 999px; }
.energy { background: var(--inset); border-radius: 999px; height: 8px; overflow: hidden; margin: 8px 0; }
.energy-fill { background: var(--grad); height: 100%; }
.og-card { width: 100%; margin-top: 12px; height: 48px; font-size: 15px; }

/* ------------------------------------------------ rates */
.rates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; text-decoration: none; }
.rate {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); padding: 5px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
}
.rate b { color: var(--text); font-variant-numeric: tabular-nums; }
.rate .dot { width: 7px; height: 7px; border-radius: 50%; }
.dot-common { background: var(--r-common); } .dot-rare { background: var(--r-rare); }
.dot-epic { background: var(--r-epic); } .dot-legendary { background: var(--r-legendary); }
.rates-note { color: var(--muted); font-size: 12px; width: 100%; margin-bottom: 2px; }

/* ------------------------------------------------ slim banner */
.banner {
  display: flex; align-items: center; gap: 10px; margin-top: 12px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 12px 14px; font-size: 13px; text-align: left; width: 100%;
}
.banner svg { width: 20px; height: 20px; flex: 0 0 auto; }
.banner .chev { margin-left: auto; color: var(--muted-2); width: 18px; height: 18px; }
.banner-warn { border-color: rgba(255, 207, 92, 0.35); }
.banner-warn svg:first-child { color: var(--warn); }
.banner-ok { border-color: rgba(61, 220, 132, 0.3); cursor: default; }
.banner-ok svg:first-child { color: var(--ok); }

/* ------------------------------------------------ chips grid */
.tier-head { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 8px; }
.tier-head h3 { margin: 0; }
.tier-head .aux { font-variant-numeric: tabular-nums; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chip {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 8px 10px; text-align: center; overflow: hidden;
}
.chip::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--muted-2); }
.chip.r-common::before { background: var(--r-common); }
.chip.r-rare::before { background: var(--r-rare); }
.chip.r-epic::before { background: var(--r-epic); }
.chip.r-legendary::before { background: var(--r-legendary); }
.chip.missing { opacity: 0.55; }
.chip-name { font-size: 13px; font-weight: 600; min-height: 34px; display: flex; align-items: center; justify-content: center; }
.chip-own { color: var(--muted); font-size: 12px; }
.chip-badge {
  position: absolute; top: 6px; right: 6px; min-width: 22px; padding: 1px 6px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.chip .btn-sm { margin-top: 8px; width: 100%; }
.chip.found { box-shadow: 0 4px 14px rgba(124, 92, 255, 0.18); }
.tier-common { color: var(--r-common); } .tier-rare { color: var(--r-rare); }
.tier-epic { color: var(--r-epic); } .tier-legendary { color: var(--r-legendary); }

/* ------------------------------------------------ daily */
.combo-row { display: flex; gap: 8px; flex-wrap: wrap; }
.combo-row .chip { flex: 1 1 30%; }
.morse {
  font-size: 18px; letter-spacing: 2px; text-align: center; padding: 14px 10px;
  background: var(--inset); border: 1px solid var(--line); border-radius: var(--r-btn); margin-bottom: 8px;
}

.list-card h3 { padding: 12px 0 2px; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.task-actions .btn { margin: 0; }

/* ------------------------------------------------ misc views */
.step { margin-top: 12px; }
.rules-list { margin: 8px 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.rules-list li { margin: 6px 0; }
.product-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stars-pill {
  flex: 0 0 auto; background: rgba(255, 185, 46, 0.14); color: var(--gold);
  border: 1px solid rgba(255, 185, 46, 0.35); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.empty { text-align: center; padding: 22px 10px; color: var(--muted); }
.empty svg { width: 34px; height: 34px; color: var(--muted-2); margin-bottom: 8px; }
.empty p { margin: 0; font-size: 13px; }

/* ------------------------------------------------ me page */
.profile { display: flex; align-items: center; gap: 12px; }
.profile img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.profile > div { min-width: 0; }
.profile-name { font-size: 16px; font-weight: 800; }
.profile-points { margin-left: auto; text-align: right; flex: 0 0 auto; }
.profile-points .aux { white-space: nowrap; }
.profile-points .num { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.nav-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 0; background: none; border: none; border-bottom: 1px solid var(--line);
  border-radius: 0; color: var(--text); font-size: 14px; text-align: left; cursor: pointer;
  text-decoration: none;
}
.nav-row:last-child { border-bottom: none; }
.nav-row svg { width: 21px; height: 21px; color: var(--muted); flex: 0 0 auto; }
.nav-row .chev { margin-left: auto; color: var(--muted-2); width: 18px; height: 18px; }

/* ------------------------------------------------ footer + tabbar */
.foot {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 18px 2px 0; color: var(--muted-2); font-size: 12px;
}
.foot a { color: var(--muted); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(13, 16, 38, 0.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar .tab {
  flex: 1; background: none; border: none; border-radius: 12px; margin: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 0 3px; color: var(--muted-2); cursor: pointer; box-shadow: none;
}
.tabbar .tab svg { width: 23px; height: 23px; }
.tabbar .tab .tab-label { font-size: 10px; font-weight: 600; }
.tabbar .tab.active { color: var(--cyan); }
.tabbar .tab.active .tab-label { color: var(--text); }

/* ------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  background: #232858; border: 1px solid var(--accent); color: #fff;
  padding: 10px 16px; border-radius: 999px; max-width: 92vw; text-align: center; z-index: 50;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); font-size: 13px;
}

/* ------------------------------------------------ capsule opening */
@keyframes capsule-pop {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.06) rotate(-4deg); }
  50% { transform: scale(0.94) rotate(4deg); }
  75% { transform: scale(1.18) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.gigi.popping { animation: capsule-pop 0.6s ease-in-out; }
.gigi.popping .gigi-img { animation: none; }
