:root {
  color-scheme: light;
  --ink: #352642;
  --muted: #6d6077;
  --plum: #654394;
  --purple: #6e49a4;
  --purple-dark: #5c378f;
  --lavender: #e7d9f9;
  --paper: #fffcf5;
  --pink: #fae3e9;
  --mint: #dff0e3;
  --gold: #f8e9bc;
  --page: #f9f6fb;
  --white: #fff;
  --line: #e3d9eb;
  --radius: 1.4rem;
  --shadow: 0 9px 25px #492f6111;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 10% 0%, #f1e8f9 0, transparent 37rem), var(--page);
  color: var(--ink);
  overflow-wrap: anywhere;
}
button, input, select { font: inherit; }
button, a, select, summary { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button, select, summary { cursor: pointer; }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; z-index: 10; top: .5rem; left: .5rem; padding: .7rem; background: var(--white); transform: translateY(-160%); }
.skip:focus { transform: translateY(0); }
.masthead { padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--line); background: #fffcffde; }
.header-inner, .shell, .footer { max-width: 1052px; margin-inline: auto; padding-inline: 1.6rem; }
.header-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; gap: .65rem; align-items: center; font-size: 1.08rem; font-weight: 780; white-space: nowrap; }
.brand img { border-radius: .85rem; }
.nav { display: flex; gap: .4rem; align-items: center; }
.nav a {
  display: inline-flex; align-items: center; justify-content: center; gap: .42rem; min-height: 44px;
  padding: .4rem .95rem; border-radius: .8rem; font-size: .92rem; font-weight: 700; color: var(--muted);
}
.nav a > span:first-child { color: var(--plum); font-size: 1.15rem; line-height: 1; }
.nav a[aria-current=page] { background: var(--lavender); color: var(--plum); }
.nav-count { align-self: center; border-radius: 1rem; padding: .08rem .36rem; font-size: .72rem; background: var(--pink); color: var(--ink); }
.shell { padding-top: 2rem; }
.cover {
  position: relative; isolation: isolate; display: flex; align-items: center; min-height: 264px;
  border: 1px solid #d9c4f0; border-radius: 1.8rem; background-color: #ebddfa;
  background-image: radial-gradient(ellipse at 6% 87%, #f9edf6aa 1%, transparent 60%), linear-gradient(#fff5 1px, transparent 1px), linear-gradient(90deg, #fff5 1px, transparent 1px);
  background-size: auto, 22px 22px, 22px 22px;
  box-shadow: var(--shadow); overflow: hidden;
}
.cover::before {
  content: ""; position: absolute; z-index: -1; width: clamp(180px, 32vw, 390px); aspect-ratio: 1;
  right: 4%; top: 50%; transform: translateY(-50%); border-radius: 50%;
  background: radial-gradient(circle, #fff5d6 0%, #faecf0a0 50%, transparent 72%);
}
.cover-copy { z-index: 1; padding: 2rem 0 2rem clamp(1.4rem, 5vw, 3.5rem); }
.cover-topic {
  display: inline-flex; gap: .35rem; align-items: center; padding: .32rem .65rem; margin: 0 0 .6rem;
  border: 1px solid #d4b9ed; border-radius: .55rem; background: #f8efff; color: var(--plum);
  font-size: .88rem; font-weight: 720; transform: rotate(-3deg);
}
.cover h1 { margin: 0; font-size: clamp(2.3rem, 5.3vw, 4.05rem); font-weight: 900; letter-spacing: .025em; line-height: 1.18; }
.cover h1 span { color: var(--plum); }
.cover-description { margin: .7rem 0 0; font-size: clamp(.95rem, 2vw, 1.12rem); color: #655471; }
.cover-art {
  position: absolute; width: clamp(183px, 34vw, 318px); height: auto; top: 50%; right: 5.1%;
  transform: translateY(-50%) rotate(4deg); filter: drop-shadow(0 7px 8px #613f6c38);
  padding:0;border:0;background:transparent;appearance:none;touch-action:manipulation;z-index:2;border-radius:1rem;
}
.cover-art img {position:absolute;inset:0;width:100%;height:100%;object-fit:contain;pointer-events:none}
.dragon-wave {opacity:0}
.cover-art.greeting .dragon-idle {opacity:0}
.cover-art.greeting .dragon-wave {opacity:1}
.cover-sparkle { position: absolute; color: #8057ac; font-size: 2rem; pointer-events: none; }
.sparkle-one { top: 16%; right: 31%; transform: rotate(10deg); }
.sparkle-two { bottom: 16%; right: 4.5%; color: #ac6f89; font-size: 1.45rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: 1.8rem 0 .9rem; }
.section-heading h2 { font-size: clamp(1.25rem, 3vw, 1.65rem); margin: 0; font-weight: 800; }
.section-heading h2 span { color: var(--plum); margin-right: .15rem; }
.select-wrap { position: relative; max-width: 59%; display: inline-flex; }
.select-wrap::after {
  content: ""; width: .43rem; height: .43rem; position: absolute; top: 45%; right: .9rem;
  border: solid var(--plum); border-width: 0 2px 2px 0; transform: rotate(45deg); pointer-events: none;
}
select, .search-wrap { border: 1px solid var(--line); border-radius: .85rem; background: var(--white); color: var(--ink); }
select { appearance: none; min-height: 44px; width: 100%; min-width: 0; padding: .45rem 2rem .45rem .75rem; font-size: .94rem; text-overflow: ellipsis; }
.study-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 28%); align-items: start; gap: 1.2rem; }
.round-progress {
  min-height: 42px; display: grid; grid-template-columns: auto minmax(24px,1fr) auto; gap: .75rem; align-items: center;
  padding: 0 .12rem; margin-bottom: .55rem; color: var(--muted); font-size: .875rem; font-weight: 650;
}
#round-count { font-variant-numeric: tabular-nums; }
progress { appearance: none; -webkit-appearance: none; width: 100%; height: .52rem; border: 0; border-radius: 2rem; overflow: hidden; background: #e9e0f1; color: #9166bf; }
progress::-webkit-progress-bar { background: #e9e0f1; }
progress::-webkit-progress-value { background: #9166bf; border-radius: 2rem; transition: width .2s ease; }
progress::-moz-progress-bar { background: #9166bf; border-radius: 2rem; }
.paper {
  position: relative; padding: 1.25rem clamp(1.1rem, 4vw, 2.2rem) 1.55rem; min-height: 328px; display: flex; flex-direction: column;
  border: 1px solid #e7d8b9; border-radius: var(--radius); background-color: var(--paper);
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, #c29c5a19 31px 32px);
  box-shadow: 0 6px 0 -3px #efe0c8, var(--shadow);
}
.paper::after {
  content: ""; position: absolute; right: 13%; top: -.55rem; width: 4.3rem; height: 1.12rem; transform: rotate(7deg);
  background: repeating-linear-gradient(124deg, #dec7f5cc 0 5px, #ecdcf9d9 5px 10px);
  border-radius: 2px; pointer-events: none;
}
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: .55rem; font-size: .82rem; color: var(--muted); }
.tag { display: inline-flex; padding: .3rem .58rem; border-radius: .5rem; background: var(--lavender); color: var(--plum); font-size: .82rem; font-weight: 700; }
.card-kicker { margin: 1.55rem 0 .35rem; color: var(--plum); font-size: .91rem; font-weight: 700; }
.paper h3 { margin: 0; font-size: clamp(1.28rem, 3vw, 1.9rem); line-height: 1.44; font-weight: 800; }
.answer {
  margin: 1rem 0 .3rem; padding: .72rem .95rem .82rem; border-left: 3px solid #ae88cf; border-radius: .25rem .75rem .75rem .25rem; background: #f3eafd;
}
.answer h4 { margin: 0 0 .32rem; font-size: .92rem; color: var(--plum); }
.answer p, .note-body p { margin: .38rem 0 0; line-height: 1.7; }
.card-actions { padding-top: 1.25rem; margin-top: auto; }
.button {
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; text-align: center;
  padding: .56rem 1.3rem; font-weight: 750; line-height: 1.25; border: 1px solid transparent; border-radius: .9rem;
  transition: background-color .15s ease, transform .15s ease; touch-action: manipulation;
}
.primary { color: var(--white); background: var(--purple); border-color: var(--purple); box-shadow: 0 3px 0 var(--purple-dark); }
.primary:active { background: var(--purple-dark); transform: translateY(2px); }
.secondary { background: #f3e9fc; color: var(--plum); border-color: #decaee; }
.secondary:active { background: var(--lavender); transform: translateY(2px); }
.reveal { width: min(100%, 16rem); }
.ratings, .empty-actions { display: flex; gap: .7rem; flex-wrap: wrap; }
.ratings > * { flex: 1; }
.study-stats { padding: 1.05rem .95rem .9rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fffdfd; box-shadow: var(--shadow); }
.study-stats h3 { font-size: 1rem; margin: .15rem 0 .8rem; padding-left: .3rem; }
.study-stats p { color: var(--muted); font-size: .82rem; margin: .65rem .3rem 0; line-height: 1.5; }
.stats-list { display: grid; gap: .38rem; }
.stats-list > div { display: grid; grid-template-columns: 1.8rem minmax(0,1fr) auto; align-items: center; gap: .42rem; padding: .32rem; font-size: .9rem; }
.stats-list strong { font-variant-numeric: tabular-nums; font-size: 1.06rem; }
.stat-icon { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: .48rem; color: var(--ink); font-weight: 750; }
.stat-today { background: var(--gold); }
.stat-known { background: var(--mint); }
.stat-retry { background: var(--pink); }
.empty { justify-content: center; align-items: flex-start; }
.empty-icon { color: var(--plum); font-size: 1.8rem; margin-bottom: .35rem; }
.empty p { color: var(--muted); margin: .65rem 0 1.1rem; line-height: 1.65; }
.notes-controls { display: flex; align-items: stretch; gap: .65rem; }
.search-wrap { display: flex; align-items: center; gap: .35rem; padding: 0 .7rem; flex: 1; min-width: 0; }
.search-wrap > span[aria-hidden] { color: var(--plum); font-size: 1.35rem; }
.search-wrap input { width: 100%; min-height: 44px; min-width: 0; border: 0; background: transparent; color: var(--ink); outline: none; }
.search-wrap:focus-within { outline: 3px solid var(--purple); outline-offset: 2px; }
.result-count { min-height: 1.3rem; color: var(--muted); font-size: .88rem; margin: .8rem 0; }
.note-group { margin: 1rem 0 1.5rem; }
.note-group h3 { margin: 0 0 .55rem .2rem; font-size: 1.05rem; color: var(--plum); }
.note { border: 1px solid var(--line); background: var(--white); border-radius: .9rem; margin-bottom: .48rem; }
.note summary { display: grid; grid-template-columns: minmax(0,1fr) auto 1rem; align-items: center; gap: .55rem; padding: .65rem .75rem; min-height: 49px; font-weight: 700; list-style: none; }
.note summary::-webkit-details-marker { display: none; }
.note summary::after { content: "+"; text-align: center; color: var(--plum); }
.note[open] summary::after { content: "−"; }
.note-source { color: var(--muted); font-size: .8rem; font-weight: 400; }
.note-body { padding: .25rem .75rem .9rem; }
.storage-message { background: var(--gold); border-radius: .75rem; padding: .75rem; }
.footer { padding-top: 1.3rem; padding-bottom: 1.5rem; font-size: .79rem; color: var(--muted); }
@media (hover: hover) {
  .nav a:hover { background: #f0e7f9; }
  .primary:hover { background: var(--purple-dark); }
  .secondary:hover { background: var(--lavender); }
  .note summary:hover { color: var(--plum); }
}
@media (max-width: 700px) {
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .header-inner, .shell, .footer { padding-inline: max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right)); }
  .header-inner { min-height: 58px; }
  .brand { font-size: .98rem; }
  .brand img { width: 35px; height: 35px; border-radius: .68rem; }
  .shell { padding-top: .95rem; }
  .nav {
    position: fixed; inset: auto 0 0; z-index: 5; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem;
    padding: .34rem max(.6rem, env(safe-area-inset-right)) calc(.35rem + env(safe-area-inset-bottom)) max(.6rem, env(safe-area-inset-left));
    background: #fffcff; border-top: 1px solid var(--line); box-shadow: 0 -4px 20px #49305d0d;
  }
  .nav a { position: relative; flex-direction: column; min-height: 50px; gap: .23rem; padding: .15rem; font-size: .82rem; }
  .nav-count { position: absolute; top: .1rem; left: calc(50% + .65rem); }
  .cover { min-height: 178px; border-radius: 1.23rem; }
  .cover-copy { padding: .8rem 0 .85rem 1rem; }
  .cover h1 { font-size: clamp(1.75rem, 6.9vw, 2.8rem); }
  .cover-description { font-size: .88rem; margin-top: .43rem; }
  .cover-art { width: clamp(112px, 36vw, 230px); right: 1.2%; }
  .cover::before { right: -6%; }
  .cover-topic { font-size: .78rem; margin-bottom: .48rem; }
  .sparkle-one { display: none; }
  .sparkle-two { font-size: .95rem; right: 3%; }
  .section-heading { margin: 1.25rem 0 .37rem; }
  .study-layout { grid-template-columns: minmax(0,1fr); gap: 1rem; }
  .round-progress { min-height: 37px; }
  .paper { min-height: 276px; padding-bottom: 1.25rem; }
  .reveal { width: 100%; }
  .study-stats { padding: .7rem .75rem; }
  .study-stats h3 { margin: .15rem 0 .5rem; }
  .stats-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-list > div { grid-template-columns: .95rem minmax(0,1fr) auto; gap: .22rem; padding: .15rem; font-size: .78rem; }
  .stat-icon { width: .95rem; height: 1.2rem; background: transparent; color: var(--plum); }
  .stats-list strong { font-size: .88rem; }
  input, select { font-size: 1rem; }
  .notes-controls { margin-top: .58rem; }
  .notes-controls .select-wrap { max-width: 40%; }
  .footer { padding-top: 1rem; }
}
@media (max-width: 355px) {
  .cover { min-height: 150px; }
  .cover h1 { font-size: 1.55rem; }
  .cover-art { right: 0; width: 106px; }
  .cover-description { font-size: .82rem; }
  .stats-list > div { grid-template-columns: minmax(0,1fr) auto; }
  .stat-icon { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
.cover-art { height: 97%; width: 36%; object-fit: contain; right: 5%; transform: translateY(-50%) rotate(2deg); }
.presenter { display:flex;align-items:center;gap:.7rem;margin:1.05rem 0 .65rem; }
.presenter img { width:64px;height:64px;object-fit:contain;background:#f4eafb;border-radius:45% 50% 42% 48%; }
.presenter strong,.presenter small,.portrait-grid small { display:block; }
.presenter strong { font-size:1rem; }
.presenter small,.portrait-grid small { color:var(--muted);font-size:.8rem;margin-top:.2rem; }
#roster h3 { font-size:1.08rem;margin:1.25rem 0 .65rem; }
.portrait-grid { display:grid;grid-template-columns:repeat(auto-fill,minmax(135px,1fr));gap:.85rem; }
.portrait-grid figure { margin:0;min-width:0;text-align:center;border:1px solid var(--line);border-radius:1.2rem;overflow:hidden;background:var(--paper);box-shadow:var(--shadow); }
.portrait-grid img { width:100%;height:clamp(96px,13vw,150px);object-fit:contain;display:block;background:radial-gradient(ellipse at bottom,#f0e4fb,#f9f6fb);padding:.45rem .4rem 0; }
.portrait-grid figure:nth-child(3n+2) img { background:radial-gradient(ellipse at bottom,#fae7d6,#fcf7ef); }
.portrait-grid figure:nth-child(3n) img { background:radial-gradient(ellipse at bottom,#ddedf4,#f5faf9); }
.portrait-grid figcaption { padding:.55rem .2rem .7rem;font-weight:750; }
.portrait-grid small {font-weight:500}
.credits { margin:1.25rem 0;color:var(--muted);font-size:.88rem;line-height:1.65; }
.credits summary { padding:.7rem 0; }
.credits a {color:var(--plum);text-decoration:underline;}
@media(max-width:700px) { .nav {grid-template-columns:repeat(4,minmax(0,1fr))} .cover-art {right:1%; width:36%; height:93%;} .portrait-grid {grid-template-columns:repeat(3,minmax(0,1fr));gap:.48rem} .portrait-grid figcaption {font-size:.87rem} .presenter img {width:52px;height:52px} .presenter {margin:.7rem 0 .5rem} }
@media(max-width:355px) { .portrait-grid {grid-template-columns:repeat(2,minmax(0,1fr))} }

.daily {display:flex;align-items:center;gap:.8rem;background:#fff8e6;border:1px solid #ead6aa;border-radius:1rem;padding:.45rem .85rem;margin:.85rem 0 .35rem;}
.sticker-slot {width:48px;height:48px;flex:none;display:grid;place-items:center;background:#f7eac7;border-radius:50%;border:1px dashed #bf9967;}
.sticker-slot img {height:45px;width:45px;object-fit:contain;filter:saturate(.65);}
.daily-copy {min-width:0;flex:1;}
.daily-copy strong,.daily-copy small {display:block}
.daily-copy small {color:#655349;font-size:.82rem;margin-top:.12rem;}
.daily-track {display:flex;gap:4px;}
.daily-track i {width:clamp(9px,2.4vw,22px);height:12px;background:#f4e6c7;border:1px solid #c8af7c;border-radius:6px;transform:rotate(-6deg);}
.daily-track .lit {background:#a57fc4;border-color:#8965a7}
.earned .sticker-slot {border:2px solid #c09149;background:#fff5cc}
.earned img {filter:none}
.album {border-radius:1rem;padding:.8rem 1rem;background:#fff8e7;border:1px solid #ead6aa;}
.album h3 {margin:0;font-size:1rem}.sticker-strip {display:flex;overflow-x:auto;gap:.8rem;}
.sticker-strip figure {text-align:center;margin:.6rem 0 0;flex:none;font-size:.78rem;color:var(--muted);}
.reward-toast:not(:empty) {position:fixed;bottom:calc(4.75rem + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);z-index:6;width:max-content;max-width:90vw;padding:.65rem .95rem;background:#473453;color:white;box-shadow:var(--shadow);border-radius:1rem;pointer-events:none;}
@media(max-width:700px){.daily{gap:.5rem;padding:.35rem .55rem}.daily-copy strong{font-size:.91rem}.daily-track{gap:3px}.sticker-slot{width:42px;height:42px}.sticker-slot img{width:39px;height:39px}}

@keyframes drift {0%,100% {translate:0 2px;rotate:-2deg} 50% {translate:0 -5px;rotate:2deg}}
@keyframes twinkle {0%,100% {opacity:.55} 50% {opacity:1;scale:1.12}}
@keyframes stamp {0% {opacity:0;scale:.8} 65% {opacity:1;scale:1.055} 100% {scale:1}}
@media (prefers-reduced-motion:no-preference) {
  .cover-art img {animation:drift 5s ease-in-out infinite}
  .cover-sparkle {animation:twinkle 3s ease-in-out infinite}
  .sparkle-two {animation-delay:1s}
  .daily-track .lit {animation:stamp .35s ease-out}
  .reward-toast:not(:empty),.daily.earned .sticker-slot {animation:stamp .4s ease-out}
  #roles-view:not([hidden]) .portrait-grid figure {animation:stamp .32s backwards}
  .portrait-grid figure:nth-child(3n+2) {animation-delay:.04s !important}
  .portrait-grid figure:nth-child(3n) {animation-delay:.08s !important}
}
.answer {transform-origin:top left;}
.write-label {margin:1rem 0 .35rem;font-size:.89rem;font-weight:700;color:var(--plum);}
#written-answer {width:100%;min-height:4.5rem;padding:.6rem .8rem;border:1px solid #cdbaDC;border-radius:.72rem;background:#fffcff;color:var(--ink);font:inherit;font-size:1rem;line-height:1.55;resize:vertical;scroll-margin-block:1rem 6rem;}
#written-answer::placeholder {color:#776b7e;}
#written-answer:focus {outline:2px solid var(--purple);outline-offset:1px;}
#written-answer:read-only {background:#faf5fc;}
