/* ============ Design tokens ============ */
:root {
  --bg: #0b0d1a;
  --bg-2: #12152b;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.1);
  --text: #eef0ff;
  --muted: #9aa0c3;
  --primary: hsl(258, 90%, 66%);
  --primary-2: hsl(196, 95%, 60%);
  --pink: hsl(330, 90%, 66%);
  --forgot: hsl(0, 85%, 63%);
  --hard: hsl(32, 95%, 58%);
  --easy: hsl(150, 70%, 48%);
  --new: hsl(210, 90%, 62%);
  --custom: hsl(280, 80%, 68%);
  --radius: 22px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  --grad: linear-gradient(135deg, var(--primary), var(--primary-2));
  --font: "Outfit", "Noto Sans TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 800px at 10% -10%, #1e1b4b 0%, transparent 60%),
              radial-gradient(1000px 700px at 110% 10%, #0c3b4d 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; color: inherit; }
kbd {
  font-family: inherit; font-size: .72rem; padding: 2px 7px; border-radius: 6px;
  background: rgba(255,255,255,.1); border: 1px solid var(--border); border-bottom-width: 2px;
}
[hidden] { display: none !important; }

/* background orbs */
.bg-orbs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-orbs span {
  position: absolute; width: 420px; height: 420px; border-radius: 50%;
  filter: blur(90px); opacity: .35; animation: float 18s ease-in-out infinite;
}
.bg-orbs span:nth-child(1) { background: var(--primary); top: 10%; left: -120px; }
.bg-orbs span:nth-child(2) { background: var(--primary-2); bottom: -120px; right: 5%; animation-delay: -6s; }
.bg-orbs span:nth-child(3) { background: var(--pink); top: 45%; left: 45%; width: 300px; height: 300px; opacity: .18; animation-delay: -12s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, -40px) scale(1.1); }
}

.glass {
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
}

/* ============ Top bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(11, 13, 26, .65);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-logo {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px;
  background: var(--grad); font-size: 1.2rem; box-shadow: 0 8px 24px -8px var(--primary);
}
.brand-text { font-size: 1.35rem; font-weight: 600; letter-spacing: .5px; }
.brand-text b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav { display: flex; gap: 6px; margin: 0 auto; }
.nav a {
  display: flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 500; transition: .25s;
}
.nav a em { font-style: normal; }
.nav a:hover { color: var(--text); background: var(--glass); }
.nav a.active { color: #fff; background: var(--glass-strong); box-shadow: inset 0 0 0 1px var(--border); }
.streak {
  padding: 8px 14px; border-radius: 999px; background: rgba(255, 140, 50, .12);
  border: 1px solid rgba(255, 140, 50, .3); font-weight: 600;
}
.user-chip {
  display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted);
}
.ghost-btn.sm { padding: 5px 10px; font-size: .78rem; border-radius: 10px; }

/* ============ Layout ============ */
main { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 100px; }
.view { display: none; animation: viewIn .45s cubic-bezier(.2, .8, .2, 1); }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.page-title { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 700; margin: 4px 0 20px; }
.wave { display: inline-block; animation: wave 2.4s ease-in-out infinite; transform-origin: 70% 70%; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } }
.section-title { font-size: 1.15rem; font-weight: 600; margin: 34px 0 14px; color: #d8dbff; }
.muted { color: var(--muted); margin-top: -8px; }
.card { border-radius: var(--radius); padding: 24px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 999px;
  background: var(--glass-strong); border: 1px solid var(--border); font-size: .85rem; font-weight: 500;
}

/* ============ Dashboard ============ */
.grid-top { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.pet-card { display: flex; gap: 28px; align-items: center; position: relative; overflow: hidden; }
.pet-card::before {
  content: ""; position: absolute; inset: -40% -10% auto auto; width: 300px; height: 300px;
  background: radial-gradient(circle, hsla(258, 90%, 66%, .35), transparent 70%); pointer-events: none;
}
.pet-stage-wrap { position: relative; width: 170px; height: 170px; flex-shrink: 0; display: grid; place-items: center; }
.pet-halo {
  position: absolute; inset: 10px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--primary), var(--primary-2), var(--pink), var(--primary));
  filter: blur(22px); opacity: .45; animation: spin 10s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pet-emoji {
  position: relative; font-size: 104px; line-height: 1; cursor: pointer; user-select: none;
  animation: bob 3s ease-in-out infinite; filter: drop-shadow(0 14px 18px rgba(0, 0, 0, .45));
  transition: transform .2s;
}
.pet-emoji.small { font-size: 78px; }
.pet-emoji.shake { animation: shake 1.2s ease-in-out infinite; }
.pet-emoji.poke { animation: poke .5s ease; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes shake {
  0%, 100% { transform: rotate(0); } 15% { transform: rotate(-9deg); } 30% { transform: rotate(8deg); }
  45% { transform: rotate(-6deg); } 60% { transform: rotate(4deg); } 75% { transform: rotate(0); }
}
@keyframes poke { 0% { transform: scale(1); } 40% { transform: scale(1.25) rotate(-6deg); } 100% { transform: scale(1); } }
.pet-crown { position: absolute; top: 2px; font-size: 40px; animation: bob 3s ease-in-out infinite; animation-delay: -.2s; }
.pet-spark { position: absolute; right: 20px; top: 18px; font-size: 34px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }
.pet-info { flex: 1; min-width: 0; position: relative; }
.pet-name-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pet-name-row h2 { margin: 0; font-size: 1.6rem; }
.pet-quote { color: #cfd3f7; font-size: 1rem; margin: 10px 0 16px; min-height: 1.5em; transition: opacity .3s; }
.progress { height: 12px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.progress.slim { height: 6px; margin: 10px 0 24px; }
.progress-bar {
  height: 100%; width: 0; border-radius: inherit; background: var(--grad);
  box-shadow: 0 0 16px hsla(258, 90%, 66%, .6); transition: width .8s cubic-bezier(.2, .8, .2, 1);
}
.pet-meta { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.stage-dots { display: flex; gap: 6px; margin-top: 14px; }
.stage-dots span {
  flex: 1; text-align: center; font-size: .75rem; padding: 6px 2px; border-radius: 10px;
  background: rgba(255, 255, 255, .04); color: var(--muted); border: 1px solid transparent;
}
.stage-dots span.done { color: #fff; background: hsla(258, 90%, 66%, .18); }
.stage-dots span.current { border-color: var(--primary); color: #fff; }

.stats-card { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stat {
  display: flex; flex-direction: column; justify-content: center; padding: 16px; border-radius: 16px;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--border);
}
.stat b { font-size: 1.9rem; font-weight: 700; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat span { color: var(--muted); font-size: .85rem; }

.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.action {
  position: relative; overflow: hidden; text-align: left; border-radius: 20px; padding: 20px 18px;
  display: flex; flex-direction: column; gap: 6px; min-height: 150px;
  transition: transform .25s, box-shadow .25s, border-color .25s;
}
.action::after {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: .3s;
  background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,.12), transparent 40%);
}
.action:hover { transform: translateY(-5px); border-color: rgba(255, 255, 255, .25); }
.action:hover::after { opacity: 1; }
.a-icon { font-size: 2rem; margin-bottom: auto; }
.a-title { font-weight: 600; font-size: 1.05rem; }
.a-sub { color: var(--muted); font-size: .82rem; }
.a-sub b { color: #fff; }
.a-review { background: linear-gradient(160deg, hsla(258, 90%, 66%, .28), var(--glass)); }
.a-deck { background: linear-gradient(160deg, hsla(196, 95%, 60%, .22), var(--glass)); }
.a-filter { background: linear-gradient(160deg, hsla(32, 95%, 58%, .2), var(--glass)); }
.a-custom { background: linear-gradient(160deg, hsla(280, 80%, 68%, .2), var(--glass)); }
.a-search { background: linear-gradient(160deg, hsla(150, 70%, 48%, .18), var(--glass)); }
.mini-progress { height: 4px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; margin-top: 4px; }
.mini-progress i { display: block; height: 100%; width: 0; background: var(--primary-2); transition: width .6s; }

.charts { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; }
.chart-card h3 { margin: 0 0 14px; font-size: 1rem; font-weight: 600; color: #d8dbff; }
.chart-box { position: relative; height: 260px; }
.donut-box { height: 210px; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center b { font-size: 1.8rem; }
.donut-center span { font-size: .78rem; color: var(--muted); }
.legend { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: #cfd3f7; }
.legend i { width: 10px; height: 10px; border-radius: 50%; }
.legend b { margin-left: auto; color: #fff; }

.data-tools { display: flex; gap: 10px; justify-content: center; margin-top: 40px; flex-wrap: wrap; }

/* ============ Buttons ============ */
.primary-btn {
  border: 0; padding: 12px 22px; border-radius: 14px; font-weight: 600; font-size: .95rem; color: #fff;
  background: var(--grad); box-shadow: 0 10px 24px -10px var(--primary); transition: transform .2s, filter .2s;
}
.primary-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--glass); padding: 10px 18px; border-radius: 14px;
  font-weight: 500; font-size: .9rem; transition: .2s; cursor: pointer;
}
.ghost-btn:hover { background: var(--glass-strong); border-color: rgba(255, 255, 255, .25); }
.ghost-btn.danger:hover { border-color: var(--forgot); color: var(--forgot); }

/* ============ Practice ============ */
.practice-head { display: flex; align-items: center; gap: 16px; }
.practice-title { flex: 1; text-align: center; }
.practice-title h1 { margin: 0; font-size: 1.3rem; }
.practice-title span { color: var(--muted); font-size: .9rem; }
.practice-pet { font-size: 2.6rem; animation: bob 3s ease-in-out infinite; width: 80px; text-align: right; }
.practice-pet.cheer { animation: poke .6s ease; }

.flashcard-scene { perspective: 1600px; max-width: 680px; margin: 0 auto; }
.flashcard {
  position: relative; height: 380px; transform-style: preserve-3d; cursor: pointer; outline: none;
  transition: transform .7s cubic-bezier(.3, 1.3, .5, 1);
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard.enter { animation: cardIn .45s cubic-bezier(.2, .8, .2, 1); }
.flashcard.leave-left { animation: leaveL .3s ease forwards; }
.flashcard.leave-right { animation: leaveR .3s ease forwards; }
@keyframes cardIn { from { opacity: 0; transform: translateY(30px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes leaveL { to { opacity: 0; transform: translateX(-80px) rotate(-6deg); } }
@keyframes leaveR { to { opacity: 0; transform: translateX(80px) rotate(6deg); } }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 28px; padding: 28px 32px; display: flex; flex-direction: column;
  border: 1px solid rgba(255, 255, 255, .14); box-shadow: 0 30px 70px -25px rgba(0, 0, 0, .8);
}
.face.front { background: linear-gradient(150deg, #23205a 0%, #151838 55%, #102c3d 100%); }
.face.back { background: linear-gradient(150deg, #2a1650 0%, #181a3c 55%, #3a1838 100%); transform: rotateY(180deg); }
.face::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(500px circle at 0% 0%, rgba(255,255,255,.09), transparent 45%);
}
.face-top { display: flex; justify-content: space-between; align-items: center; }
.tag { font-size: .75rem; font-weight: 600; letter-spacing: .5px; padding: 5px 12px; border-radius: 999px; background: hsla(196, 95%, 60%, .18); color: #9be6ff; }
.tag.custom { background: hsla(280, 80%, 68%, .2); color: #e3b8ff; }
.level-chip { font-size: .8rem; color: var(--muted); }
.word-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: auto; }
.word { font-size: clamp(2.4rem, 6vw, 3.6rem); margin: 0; font-weight: 700; letter-spacing: .5px; text-align: center; word-break: break-word; }
.pos { text-align: center; color: var(--primary-2); font-weight: 600; margin-top: 6px; }
.example {
  margin: 26px auto auto; max-width: 560px; display: flex; gap: 10px; align-items: flex-start;
  background: rgba(255, 255, 255, .05); border-radius: 16px; padding: 14px 16px; border: 1px solid var(--border);
}
.example p { margin: 0; flex: 1; color: #dfe2ff; line-height: 1.55; }
.example mark { background: none; color: #ffd36b; font-weight: 600; }
.example.zh { flex-direction: column; gap: 8px; }
.en-small { font-size: .88rem; color: var(--muted) !important; }
.speak-btn {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--glass-strong); font-size: 1.2rem; transition: .2s;
}
.speak-btn.sm { width: 34px; height: 34px; font-size: .9rem; }
.speak-btn:hover, .speak-btn.playing { background: var(--grad); transform: scale(1.08); }
.flip-hint { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 16px; }
.back-word { text-align: center; font-size: 1.5rem; font-weight: 600; color: #cfd3f7; margin-top: auto; }
.meaning {
  text-align: center; font-size: clamp(1.8rem, 4.5vw, 2.5rem); font-weight: 700; margin: 10px 0 0;
  background: linear-gradient(135deg, #fff, #ffd2f0); -webkit-background-clip: text; background-clip: text; color: transparent;
}

.rate-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 680px; margin: 26px auto 0; }
.rate {
  position: relative; border-radius: 18px; padding: 16px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 1px solid var(--border); background: var(--glass); transition: transform .2s, background .2s, box-shadow .2s;
}
.rate b { font-size: 1.02rem; }
.rate small { color: var(--muted); font-size: .78rem; }
.rate kbd { position: absolute; top: 8px; right: 10px; opacity: .6; }
.rate:hover { transform: translateY(-3px); }
.rate.forgot:hover, .rate.forgot.pressed { background: hsla(0, 85%, 63%, .2); border-color: var(--forgot); box-shadow: 0 10px 30px -10px var(--forgot); }
.rate.hard:hover, .rate.hard.pressed { background: hsla(32, 95%, 58%, .2); border-color: var(--hard); box-shadow: 0 10px 30px -10px var(--hard); }
.rate.easy:hover, .rate.easy.pressed { background: hsla(150, 70%, 48%, .2); border-color: var(--easy); box-shadow: 0 10px 30px -10px var(--easy); }
.shortcut-hint { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 18px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; align-items: center; }

.empty { max-width: 560px; margin: 40px auto; text-align: center; border-radius: var(--radius); padding: 40px 28px; }
.empty-emoji { font-size: 4rem; animation: bob 3s ease-in-out infinite; }
.empty h2 { margin: 10px 0 6px; }
.empty p { color: var(--muted); }
.empty-actions { display: flex; gap: 12px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.done-stats { display: flex; gap: 12px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.done-stats div { padding: 12px 18px; border-radius: 14px; background: rgba(255,255,255,.05); border: 1px solid var(--border); }
.done-stats b { display: block; font-size: 1.5rem; }

/* ============ Custom deck ============ */
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.view-head .page-title { margin-bottom: 14px; }
.head-actions { display: flex; gap: 10px; }
.custom-toolbar { display: flex; gap: 12px; align-items: center; margin: 18px 0; }
.input {
  flex: 1; font-family: inherit; font-size: 1rem; color: var(--text); padding: 12px 16px; border-radius: 14px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--border); outline: none; transition: .2s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px hsla(258, 90%, 66%, .2); }
.input.big { font-size: 1.15rem; padding: 14px 18px; background: transparent; border: 0; box-shadow: none !important; }
.custom-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.word-item {
  border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 8px;
  animation: viewIn .4s ease both; transition: transform .2s, border-color .2s;
}
.word-item:hover { transform: translateY(-3px); border-color: rgba(255,255,255,.22); }
.wi-head { display: flex; align-items: center; gap: 10px; }
.wi-head h3 { margin: 0; font-size: 1.3rem; }
.wi-head .pos { margin: 0; font-size: .85rem; }
.wi-head .speak-btn { margin-left: auto; }
.wi-meaning { font-weight: 500; color: #ffd2f0; }
.wi-example { color: var(--muted); font-size: .88rem; line-height: 1.5; }
.wi-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: .8rem; color: var(--muted); }
.icon-btn { border: 1px solid var(--border); background: transparent; padding: 6px 12px; border-radius: 10px; font-size: .8rem; transition: .2s; }
.icon-btn:hover { border-color: var(--forgot); color: var(--forgot); background: hsla(0, 85%, 63%, .1); }

/* ============ Search ============ */
.eli5 { font-size: .9rem; padding: 4px 10px; border-radius: 8px; background: var(--grad); vertical-align: middle; }
.search-bar { display: flex; gap: 10px; padding: 8px; border-radius: 20px; margin: 18px 0 26px; }
.result-card { border-radius: var(--radius); padding: 28px; animation: viewIn .4s ease; }
.res-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.res-head h2 { margin: 0; font-size: 2.4rem; }
.phonetic { color: var(--primary-2); font-size: 1.05rem; }
.res-zh { font-size: 1.5rem; font-weight: 700; margin: 14px 0 6px; color: #ffd2f0; }
.eli5-box {
  margin: 20px 0; padding: 20px 22px; border-radius: 18px; position: relative;
  background: linear-gradient(135deg, hsla(50, 100%, 60%, .14), hsla(330, 90%, 66%, .12));
  border: 1px solid hsla(50, 100%, 60%, .3);
}
.eli5-box h4 { margin: 0 0 8px; font-size: .9rem; color: #ffe27a; letter-spacing: .4px; }
.eli5-box p { margin: 0; font-size: 1.25rem; line-height: 1.5; }
.meanings { display: grid; gap: 12px; }
.meaning-block { padding: 14px 16px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid var(--border); }
.meaning-block .pos { text-align: left; margin: 0 0 6px; }
.meaning-block ol { margin: 0; padding-left: 20px; color: #dfe2ff; line-height: 1.6; }
.meaning-block .ex { color: var(--muted); font-style: italic; font-size: .9rem; }
.res-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; align-items: center; }
.in-deck { color: var(--easy); font-size: .9rem; }
.loader { display: flex; gap: 8px; justify-content: center; padding: 40px; }
.loader span { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); animation: dot 1s ease-in-out infinite; }
.loader span:nth-child(2) { animation-delay: .15s; background: var(--primary-2); }
.loader span:nth-child(3) { animation-delay: .3s; background: var(--pink); }
@keyframes dot { 0%, 100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-12px); opacity: 1; } }

/* ============ Sanctuary ============ */
.sanctuary-summary { border-radius: var(--radius); padding: 20px 24px; margin: 20px 0; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.sanctuary-summary .progress { flex: 1; min-width: 200px; }
.pet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.pet-tile {
  position: relative; border-radius: 22px; padding: 24px 16px 18px; text-align: center; overflow: hidden;
  transition: transform .25s, border-color .25s, box-shadow .25s;
}
.pet-tile .pt-emoji { font-size: 4.2rem; line-height: 1.1; display: block; filter: drop-shadow(0 10px 14px rgba(0,0,0,.4)); transition: transform .3s; }
.pet-tile h3 { margin: 10px 0 2px; font-size: 1.1rem; }
.pet-tile p { margin: 0; font-size: .8rem; color: var(--muted); }
.pet-tile .pt-num { position: absolute; top: 12px; left: 14px; font-size: .75rem; color: var(--muted); }
.pet-tile.unlocked { cursor: pointer; }
.pet-tile.unlocked:hover { transform: translateY(-5px); border-color: rgba(255,255,255,.3); }
.pet-tile.unlocked:hover .pt-emoji { transform: scale(1.12) rotate(-5deg); }
.pet-tile.locked .pt-emoji { filter: grayscale(1) brightness(.25); }
.pet-tile.growing { border-color: hsla(196, 95%, 60%, .5); }
.pet-tile.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary), 0 20px 40px -15px var(--primary); }
.pet-tile.active::after { content: "陪伴中"; position: absolute; top: 12px; right: 12px; font-size: .7rem; padding: 3px 9px; border-radius: 999px; background: var(--grad); }
.pt-bar { height: 5px; border-radius: 5px; background: rgba(255,255,255,.08); margin-top: 10px; overflow: hidden; }
.pt-bar i { display: block; height: 100%; background: var(--primary-2); }

/* ============ Modals ============ */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: rgba(5, 6, 15, .7); backdrop-filter: blur(6px); animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal-card { width: min(520px, 100%); border-radius: 26px; padding: 28px; background: rgba(22, 24, 48, .92); animation: pop .35s cubic-bezier(.2, 1.3, .5, 1); }
@keyframes pop { from { transform: scale(.88); opacity: 0; } }
.modal-card h2 { margin: 0 0 14px; }
.filter-options { display: grid; gap: 10px; margin: 18px 0; }
.f-opt {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; text-align: left;
  border: 1px solid var(--border); background: rgba(255,255,255,.04); transition: .2s;
}
.f-opt:hover { background: rgba(255,255,255,.08); }
.f-opt.on { border-color: var(--primary); background: hsla(258, 90%, 66%, .16); }
.f-opt .f-check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--border); display: grid; place-items: center; font-size: .8rem; }
.f-opt.on .f-check { background: var(--grad); border-color: transparent; }
.f-opt .f-count { margin-left: auto; color: var(--muted); font-size: .85rem; }
.f-opt:disabled { opacity: .4; cursor: not-allowed; }
.limit-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; color: var(--muted); }
.seg { display: flex; background: rgba(255,255,255,.05); border-radius: 12px; padding: 4px; border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--grad); color: #fff; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

.unlock { background: radial-gradient(circle at center, rgba(40, 20, 90, .85), rgba(5, 6, 15, .95)); }
.unlock-card { position: relative; text-align: center; animation: pop .6s cubic-bezier(.2, 1.4, .5, 1); }
.unlock-rays {
  position: absolute; left: 50%; top: 90px; width: 600px; height: 600px; margin: -300px 0 0 -300px; z-index: -1;
  background: repeating-conic-gradient(from 0deg, hsla(50, 100%, 70%, .18) 0 10deg, transparent 10deg 20deg);
  border-radius: 50%; animation: spin 20s linear infinite;
  mask-image: radial-gradient(circle, #000 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 70%);
}
.unlock-emoji { font-size: 150px; line-height: 1.2; animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 20px 40px hsla(50, 100%, 60%, .5)); }
.unlock-card h2 { font-size: 2.2rem; margin: 10px 0 6px; background: linear-gradient(135deg, #fff3b0, #ffb3e6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.unlock-card p { color: #d8dbff; margin-bottom: 26px; }
.unlock-card .modal-actions { justify-content: center; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); z-index: 60;
  padding: 12px 22px; border-radius: 14px; background: rgba(30, 32, 64, .95); border: 1px solid var(--border);
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .3s; font-weight: 500;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ Responsive ============ */
@media (max-width: 1020px) {
  .actions { grid-template-columns: repeat(3, 1fr); }
  .grid-top, .charts { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { gap: 10px; }
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; margin: 0; justify-content: space-around; padding: 8px 6px 12px;
    background: rgba(11, 13, 26, .92); backdrop-filter: blur(16px); border-top: 1px solid var(--border);
  }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 10px; font-size: .72rem; border-radius: 12px; }
  .nav a span { font-size: 1.25rem; }
  .streak { margin-left: auto; }
  .actions { grid-template-columns: 1fr 1fr; }
  .pet-card { flex-direction: column; text-align: center; }
  .pet-name-row { justify-content: center; }
  .flashcard { height: 420px; }
  .face { padding: 22px 20px; }
  .rate b { font-size: .9rem; }
  .shortcut-hint { display: none; }
}
