/* App concept card art (card-template-light 630x1080 canvas) + detail + aha moments.
   Box positions use exact 630x1080 percentages so WebKit zoom/cqw never shifts the overlay layer;
   --u = 1/630 of the card width scales typography. */
.sc-card { position: relative; width: 100%; aspect-ratio: 630 / 1080; container-type: inline-size; overflow: hidden;
  border-radius: 10px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.18); user-select: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.sc-canvas { position: absolute; inset: 0; --u: calc(100cqw / 630); font-family: Inter, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.sc-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.sc-subject { position: absolute; top: calc(14 / 1080 * 100%); left: calc(530 / 630 * 100%); width: calc(72 / 630 * 100%); height: calc(72 / 1080 * 100%); object-fit: contain; z-index: 2; }
.sc-title { position: absolute; top: calc(84 / 1080 * 100%); left: calc(40 / 630 * 100%); width: calc(550 / 630 * 100%); min-height: calc(96 / 1080 * 100%);
  display: flex; align-items: center; justify-content: center; text-align: center; z-index: 1;
  font-family: "Playfair Display", Georgia, "Times New Roman", "Songti SC", serif; font-weight: 700; font-size: calc(36 * var(--u)); line-height: calc(48 * var(--u)); color: #000; }
.sc-role { position: absolute; top: calc(184 / 1080 * 100%); left: calc(164 / 630 * 100%); width: calc(302 / 630 * 100%); height: calc(37 / 1080 * 100%);
  display: flex; align-items: center; justify-content: center; text-align: center; z-index: 1;
  font-family: "Playfair Display", Georgia, serif; font-weight: 700; font-size: calc(20 * var(--u)); line-height: 1.15; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-quote { position: absolute; top: calc(236 / 1080 * 100%); left: calc(20 / 630 * 100%); width: calc(590 / 630 * 100%); text-align: center; z-index: 1;
  font-family: "Playfair Display", Georgia, serif; font-style: italic; font-weight: 700; font-size: calc(20 * var(--u)); line-height: calc(27 * var(--u)); color: #000; }
.sc-illust { position: absolute; top: calc(296 / 1080 * 100%); left: calc(51 / 630 * 100%); width: calc(528 / 630 * 100%); height: calc(312 / 1080 * 100%);
  border-radius: calc(14 * var(--u)); overflow: hidden; background: transparent; box-shadow: none; z-index: 1; }
.sc-illust img { width: 100%; height: 100%; object-fit: contain; }
.sc-sec { position: absolute; left: calc(118 / 630 * 100%); height: calc(26 / 1080 * 100%); display: flex; align-items: center; line-height: 1.1; font-size: calc(21 * var(--u)); font-weight: 700; z-index: 2; }
.sc-sec[hidden] { display: none !important; }
.sc-sec-summary { top: calc(644 / 1080 * 100%); } .sc-sec-kp { top: calc(832 / 1080 * 100%); }
.sc-r-uncommon .sc-sec { color: #0b3b07; } .sc-r-rare .sc-sec { color: #0f3f8a; } .sc-r-epic .sc-sec { color: #493982; } .sc-r-legendary .sc-sec { color: #a95a16; }
.sc-summary { position: absolute; top: calc(682 / 1080 * 100%); left: calc(68 / 630 * 100%); width: calc(494 / 630 * 100%); height: calc(116 / 1080 * 100%);
  padding: calc(6 * var(--u)) 0; box-sizing: border-box; display: flex; align-items: center; z-index: 1;
  font-size: calc(17.5 * var(--u)); line-height: calc(21.5 * var(--u)); color: #000; overflow: hidden; }
.sc-kps { position: absolute; top: calc(868 / 1080 * 100%); left: calc(68 / 630 * 100%); width: calc(494 / 630 * 100%); height: calc(160 / 1080 * 100%);
  padding: calc(6 * var(--u)) 0; box-sizing: border-box; overflow: hidden; z-index: 1; display: flex; flex-direction: column; justify-content: center; }
.sc-kp { display: flex; gap: calc(8 * var(--u)); margin-bottom: calc(3 * var(--u)); font-size: calc(17 * var(--u)); line-height: calc(21 * var(--u)); color: #000; }
.sc-summary .katex, .sc-kp .katex { font-size: 1em; }
.sc-summary strong, .sc-kp strong { font-weight: 700; color: #5b2eff; }
.sc-card-skeleton { background: linear-gradient(100deg, #f1eefb 30%, #faf8ff 50%, #f1eefb 70%) 0 0 / 200% 100%; animation: sc-shimmer 1.2s linear infinite; box-shadow: none; }
@keyframes sc-shimmer { to { background-position: -200% 0; } }
.sc-card-plain { display: flex; flex-direction: column; justify-content: flex-end; padding: 14% 10%; box-sizing: border-box; color: #fff;
  background: linear-gradient(150deg, #8c55f2, #5fa8f5); }
.sc-card-plain.sc-r-legendary { background: linear-gradient(150deg, #f3ab26, #e2662e); }
.sc-card-plain.sc-r-rare { background: linear-gradient(150deg, #3d7be0, #62b0fd); }
.sc-plain-subject { font-size: 11px; opacity: .85; } .sc-plain-name { font: 700 17px/1.25 "Playfair Display", Georgia, serif; }

/* ---------- rail in the solution (front + memory + example, App scan-result-cards) */
.sc-rail { position: relative; margin-top: 12px; }
.sc-rail.is-unlocking .sc-rail-track, .sc-rail.is-unlocking .sc-rail-view, .sc-rail.is-unlocking::after { display: none; }
.sc-rail-track { display: flex; align-items: flex-end; justify-content: center; gap: 14px; height: 210px; padding: 0 14px; overflow: hidden;
  border-radius: 14px; background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #f6f2ff 100%); }
.sc-rail-item { flex: 0 0 auto; width: 150px; height: 100%; overflow: hidden; border-radius: 8px 8px 0 0; cursor: pointer; transition: transform .25s ease; }
.sc-rail-item:hover { transform: translateY(-4px); }
.sc-rail-track[data-count="3"] .sc-rail-item { width: calc((100% - 56px) / 3); max-width: 170px; }
.sc-rail-item .sc-card { border-radius: 8px 8px 0 0; }
.sc-image { width: 100%; height: 100%; border-radius: 8px 8px 0 0; overflow: hidden; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.sc-image img { width: 100%; height: auto; display: block; }
.sc-image-memo { border: 6px solid #d7ddff; box-sizing: border-box; }
.sc-rail-view { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 3; padding: 4px 14px; border: 0; cursor: pointer;
  border-radius: 9px 9px 0 0; background: #ecdeff; color: #8c55f2; font: italic 700 12px/1.4 Inter, sans-serif; }
.sc-rail::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 46%; pointer-events: none; border-radius: 0 0 14px 14px;
  background: linear-gradient(180deg, rgba(246,242,255,0) 0%, #f6f2ff 100%); z-index: 2; }
.sc-settle { animation: sc-track-in .35s ease; }
.sc-settle .sc-rail-item:first-child { animation: sc-pop .5s cubic-bezier(.2,1.4,.4,1); }
@keyframes sc-track-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes sc-pop { 0% { transform: scale(.92); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }

/* ---------- aha: "You unlocked a new concept card!" (App concept-card-discover-msg sway-drop) */
.sc-unlock { position: relative; overflow: hidden; border-radius: 14px; margin-bottom: 0; padding: 14px 14px 0; opacity: 0; transition: opacity .3s ease; }
.sc-unlock.is-in { opacity: 1; } .sc-unlock.is-out { opacity: 0; transition: opacity .45s ease; }
.sc-unlock-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.sc-unlock-title { position: relative; z-index: 1; text-align: center; font-weight: 700; font-size: 15px; color: #000; margin-bottom: 10px;
  opacity: 0; transform: translateY(-6px); transition: opacity .35s ease 1.35s, transform .35s ease 1.35s; }
.sc-unlock.is-in .sc-unlock-title { opacity: 1; transform: none; }
.sc-unlock-card { position: relative; z-index: 1; width: min(200px, 60%); height: 190px; margin: 0 auto; overflow: hidden; border-radius: 8px 8px 0 0;
  opacity: 0; transform: translateY(-180%) rotate(-7.5deg); }
.sc-unlock.is-in .sc-unlock-card { animation: sc-sway-drop 1.3s ease-in-out forwards; }
@keyframes sc-sway-drop { 0% { transform: translateY(-180%) rotate(-7.5deg); opacity: 0; } 1% { opacity: 1; transform: translateY(-178%) rotate(-7.5deg); }
  61.54% { transform: translateY(-10%) rotate(12deg); opacity: 1; } 100% { transform: translateY(0) rotate(0); opacity: 1; } }
.sc-glow { box-shadow: 0 0 0 2px #f3ab26, 0 0 22px rgba(243,171,38,.55); }

.sc-confetti { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 5; }
.sc-confetti i { position: absolute; top: 38%; width: 7px; height: 11px; border-radius: 2px; opacity: 0;
  animation: sc-burst var(--d) cubic-bezier(.15,.7,.3,1) forwards; }
@keyframes sc-burst { 0% { opacity: 1; transform: translate(0,0) rotate(0); }
  100% { opacity: 0; transform: translate(calc(var(--x) * 170px), 150px) rotate(var(--r)); } }

/* A saved mastery transition: one quiet card flip, then the collection state. */
.sc-levelup { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1300;
  display: flex; align-items: center; gap: 16px; width: min(350px, calc(100vw - 32px)); box-sizing: border-box; padding: 18px 44px 18px 18px;
  border: 1px solid var(--line, #d8dcd3); border-radius: 20px; background: var(--card, #fffdf9); color: var(--ink, #31382f);
  box-shadow: 0 12px 40px rgba(35, 44, 30, .14); animation: sc-moment-in .28s ease-out; }
.sc-moment-card { width: 62px; height: 94px; flex: 0 0 62px; perspective: 600px; }
.sc-moment-turn { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; animation: sc-moment-flip .6s cubic-bezier(.22,.7,.3,1) both; }
.sc-moment-back, .sc-moment-front { position: absolute; inset: 0; border-radius: 8px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.sc-moment-back { transform: rotateY(180deg); display: grid; place-items: center; border: 1px solid var(--line-strong, #b9c3ae);
  background: var(--paper, #f3f1e8); color: var(--primary-strong, #ad513a); }
.sc-moment-back span { display: grid; place-items: center; width: 35px; height: 55px; border: 1px solid currentColor; border-radius: 4px; font: italic 700 26px/1 Georgia, serif; }
.sc-moment-front .sc-card { height: 100%; aspect-ratio: auto; border-radius: 8px; box-shadow: 0 3px 8px rgba(35,44,30,.12); }
.sc-moment-front .sc-plain-name { font-size: 9px; line-height: 1.3; overflow-wrap: anywhere; }
.sc-moment-front .sc-card-plain { border: 1px solid var(--line, #d8dcd3); background: var(--paper, #f3f1e8); color: var(--ink, #31382f); }
.sc-moment-front .sc-plain-subject { display: none; }
.sc-moment-check { position: absolute; right: -6px; bottom: -5px; display: grid; place-items: center; width: 23px; height: 23px; border: 2px solid var(--card, #fffdf9);
  border-radius: 50%; background: var(--brand-leaf, #396c51); color: #fff; font-size: 13px; font-weight: 700; }
.sc-moment-copy { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; gap: 3px; line-height: 1.4; }
.sc-moment-title, .sc-moment-saved { font-size: 11px; color: var(--ink-soft, #626c63); }
.sc-moment-copy b { font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.sc-levelup-path { font-size: 12px; color: var(--ink-soft, #626c63); }
.sc-moment-saved { color: var(--brand-leaf, #396c51); }
.sc-moment-view { margin: 4px 0 -8px -8px; padding: 8px; min-height: 40px; border: 0; background: transparent; color: var(--primary-strong, #ad513a); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.sc-moment-close { position: absolute; right: 4px; top: 4px; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0;
  border-radius: 50%; background: transparent; color: var(--ink-soft, #626c63); font-size: 24px; cursor: pointer; }
.sc-moment-view:focus-visible, .sc-moment-close:focus-visible { outline: 2px solid var(--primary-strong, #ad513a); outline-offset: 2px; }
.sc-moment-announcement { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@keyframes sc-moment-in { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
@keyframes sc-moment-flip { from { transform: rotateY(180deg); } to { transform: rotateY(0); } }
html.night .sc-moment-saved { color: #9bc3a7; }
html.night .sc-moment-title, html.night .sc-moment-close, html.night .sc-levelup-path { color: var(--ink-soft, #c1c8bc); }
html.night .sc-moment-view { color: var(--primary-strong, #efaa91); }
@media (max-width: 480px) { .sc-levelup { bottom: max(18px, env(safe-area-inset-bottom)); gap: 14px; } }

/* ---------- card detail */
.sc-detail { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; }
.sc-detail-backdrop { position: absolute; inset: 0; background: rgba(20,16,32,.55); opacity: 0; transition: opacity .22s ease; }
.sc-detail.is-open .sc-detail-backdrop { opacity: 1; }
.sc-detail-sheet { position: relative; width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: 18px 18px 16px; border-radius: 22px;
  background: #fff; box-shadow: 0 24px 60px rgba(0,0,0,.3); transform: translateY(16px) scale(.97); opacity: 0; transition: transform .25s cubic-bezier(.2,1.2,.4,1), opacity .2s ease; }
.sc-detail.is-open .sc-detail-sheet { transform: none; opacity: 1; }
.sc-detail-close { position: absolute; top: 10px; right: 12px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: #f4f5f9; cursor: pointer; font-size: 14px; color: #555; z-index: 2; }
.sc-detail-tabs { display: flex; gap: 6px; margin: 0 40px 12px 0; }
.sc-detail-tab { border: 0; border-radius: 999px; padding: 5px 12px; background: #f4f5f9; color: #6b6878; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.sc-detail-tab.is-on { background: #8c55f2; color: #fff; }
.sc-detail-stage { perspective: 1200px; }
.sc-detail-stage.is-flipping .sc-face.is-on { animation: sc-flip .45s ease; }
@keyframes sc-flip { 0% { transform: rotateY(90deg); opacity: .4; } 100% { transform: rotateY(0); opacity: 1; } }
.sc-face { display: none; } .sc-face.is-on { display: block; }
.sc-face .sc-image { height: auto; border-radius: 10px; }
.sc-detail-flip { display: flex; align-items: center; gap: 6px; margin: 10px auto 0; border: 0; background: none; color: #8c55f2; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.sc-detail-flip img { width: 16px; height: 16px; }
.sc-detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.sc-btn { border: 0; border-radius: 999px; padding: 11px 12px; background: #f4f5f9; color: #1d1b26; font-weight: 700; font-size: 13.5px; cursor: pointer; }
.sc-btn-dark { background: #000; color: #fff; }
.sc-btn:focus-visible, .sc-detail-tab:focus-visible, .sc-rail-view:focus-visible { outline: 2px solid #8c55f2; outline-offset: 2px; }

html.night .sc-rail-track, html.night .sc-rail::after { background: linear-gradient(180deg, rgba(28,28,28,0) 0%, #4b4458 100%); }
html.night .sc-rail-view { background: #4b4458; color: #c9a8ff; }
html.night .sc-detail-sheet { background: #24222b; color: #ece9f5; }
html.night .sc-detail-tab, html.night .sc-btn { background: #34313d; color: #ece9f5; } html.night .sc-btn-dark { background: #fff; color: #000; }
html.night .sc-detail-close { background: #34313d; color: #ddd; }

@media (prefers-reduced-motion: reduce) {
  .sc-levelup, .sc-moment-turn { animation: none !important; }
  .sc-moment-turn { transform: none; }
  .sc-unlock-card, .sc-settle .sc-rail-item:first-child, .sc-confetti i, .sc-detail-stage.is-flipping .sc-face.is-on { animation: none !important; opacity: 1; transform: none; }
}

/* Card art is a light paper canvas in both reading modes, including WKWebView. */
.sc-card { flex:none; isolation:isolate; color-scheme:light; }
.sc-canvas { width:100%; height:100%; }
.sc-bg { display:block; color-scheme:light; filter:none; opacity:1; }
.sc-illust img { display:block; filter:none; opacity:1; }
.sc-load-error { width:100%; text-align:center; color:var(--ink-soft,#595652); padding:24px; }
.sc-load-error button { min-height:44px; padding:10px 20px; border:1px solid var(--line,#ddd); border-radius:12px; color:var(--primary-strong,#6c38c3); background:var(--card,#fff); }
.sc-detail-tab,.sc-detail-flip { min-height:44px; }
