/* 《靈芽學園》 phase-1 prototype. Fluid layout: phone (bottom nav), tablet (2 columns),
   desktop (side nav + multi-column panels). Light backgrounds behind sprites (PNG edges). */
:root {
  --bg: #FFF7E8; --card: #FFFFFF; --ink: #2E2A3B; --muted: #6B6478; --line: #EDE3D1;
  --primary: #5B7CFA; --primary-ink: #fff; --secondary: #FFD66B; --ok: #22A06B; --warn: #E8833A; --danger: #D64545;
  --radius: 20px; --shadow: 0 6px 20px rgba(80, 60, 20, .08);
  --nav-h: 72px; --top-h: 60px;
  font-size: clamp(16px, 1.2vw + 11px, 19px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Noto Sans HK", "PingFang HK", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5; -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
h1 { font-size: 1.5rem; margin: 0 0 .6rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; }
.row.gap { gap: .6rem; } .row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; } .row.center { justify-content: center; }

/* ---------- shell ---------- */
#app { min-height: 100vh; min-height: 100dvh; }
#topbar {
  position: sticky; top: 0; z-index: 20; min-height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
  padding: .5rem max(1rem, env(safe-area-inset-left)); background: rgba(255, 247, 232, .95);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.25rem; display: flex; align-items: center; gap: .35rem; letter-spacing: .05em; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .2rem .7rem; font-weight: 700; font-size: .9rem; white-space: nowrap; }
.chip-link { color: inherit; text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; gap: .15rem; }
.chip-link:hover, .chip-link:focus-visible { border-color: var(--secondary); background: #FFF8E1; outline: none; }
.chip-star { background: #FFF3C4; }
.chip-level { background: #E7ECFF; }
#view { padding: 1rem; padding-bottom: calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom)); max-width: 1320px; margin: 0 auto; }
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  background: #fff; border-top: 1px solid var(--line); padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,.05);
}
#nav:empty { display: none; }
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  min-height: 56px; border-radius: 14px; text-decoration: none; color: var(--muted); font-weight: 700; font-size: .8rem;
}
.nav-icon { font-size: 1.5rem; line-height: 1; }
.nav-btn.active { color: var(--primary); background: #EEF1FF; }

/* ---------- cards / controls ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; border: 1px solid var(--line); min-width: 0; }
.card + .card { margin-top: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.btn {
  appearance: none; border: 0; border-radius: 14px; min-height: 48px; padding: .6rem 1.1rem; font: inherit; font-weight: 800;
  cursor: pointer; background: #EEE; color: var(--ink); touch-action: manipulation; transition: transform .08s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-secondary { background: var(--secondary); }
.btn-ghost { background: #fff; border: 2px solid var(--line); }
.btn-small { min-height: 44px; padding: .4rem .8rem; font-size: .9rem; }
.btn-big { min-height: 56px; font-size: 1.1rem; padding: .7rem 1.4rem; }
.btn-tick { background: var(--ok); color: #fff; min-width: 112px; }
.danger { color: var(--danger); }
.form { display: grid; gap: .7rem; }
.field { display: grid; gap: .3rem; font-weight: 700; border: 0; padding: 0; margin: 0; }
.field legend { margin-bottom: .3rem; }
input, select { font: inherit; min-height: 48px; padding: .5rem .8rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, .btn:focus-visible, .nav-btn:focus-visible { outline: 3px solid #A9B8FF; outline-offset: 2px; }
.check { display: flex; gap: .6rem; align-items: flex-start; }
.check input { width: 26px; min-height: 26px; height: 26px; flex: none; }
.hint { margin: -.3rem 0 0; font-size: .85rem; color: var(--muted); }
.form-error { color: var(--danger); font-weight: 700; margin: 0; }
.notice { background: #FFF1E0; border-radius: 12px; padding: .6rem .8rem; color: #8A4B12; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem .5rem; }
.badge { display: inline-block; border-radius: 999px; padding: .1rem .6rem; font-size: .8rem; font-weight: 700; background: #F1EEE8; white-space: nowrap; }
.shop-list .badge { white-space: normal; max-width: 100%; }
.badge.warn { background: #FFE6CC; color: #8A4B12; }
.st-todo { background: #F1EEE8; } .st-pending_confirm { background: #FFF1C2; color: #7A5A00; }
.st-confirmed { background: #D9F5E7; color: #146C45; } .st-returned { background: #FFE0E0; color: #9B2C2C; } .st-expired { background: #EEE; color: #888; }
.who-parent { background: #E7ECFF; color: #2F46B8; } .who-child { background: #FDE7F3; color: #9D2A6B; }
.subj { font-size: .8rem; font-weight: 700; border-left: 4px solid var(--subj); padding-left: .4rem; }
.bar { flex: 1; height: 14px; background: #F1EEE8; border-radius: 999px; overflow: hidden; min-width: 60px; }
.bar.small { height: 10px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #7C9BFF, var(--primary)); border-radius: 999px; transition: width .5s; }
.bubble {
  position: relative; background: #FFFBEF; border: 2px solid #F3E2B5; border-radius: 16px; padding: .6rem .9rem; margin: .6rem 0; font-weight: 600;
}
.bubble::before { content: ""; position: absolute; top: -10px; left: 50%; margin-left: -8px; border: 8px solid transparent; border-bottom-color: #F3E2B5; border-top: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; margin-bottom: .6rem; }
.stat { background: #FBF8F2; border-radius: 14px; padding: .6rem; text-align: center; display: grid; }
.stat-num { font-size: 1.35rem; font-weight: 800; }
.stat-label { font-size: .8rem; color: var(--muted); }

/* ---------- sprite on the 512x512 body template ---------- */
.sp-canvas { position: relative; aspect-ratio: 1 / 1; width: 100%; margin: 0 auto; border-radius: 24px;
  background: radial-gradient(circle at 50% 62%, #FFFFFF 0%, #FFF6DF 55%, #FDEFD2 100%); overflow: hidden; }
.sp-lg { max-width: 420px; } .sp-md { max-width: 240px; } .sp-sm { max-width: 140px; }
.sp-inner { position: absolute; inset: 0; animation: bob 3s ease-in-out infinite; transform-origin: 50% 93.75%; }
.stage-egg .sp-inner { animation: wobble 2.4s ease-in-out infinite; }
.sp-layer { position: absolute; }
.sp-sprite { inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; }
.sp-item { object-fit: contain; pointer-events: none; }
.sp-background { object-fit: cover; }
.sp-scale { position: absolute; inset: 0; }
.sp-slot-xf { position: absolute; inset: 0; pointer-events: none; }
.sp-glow { left: 15%; right: 15%; top: 30%; bottom: 2%; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 55%, var(--glow) 0%, color-mix(in srgb, var(--glow) 35%, transparent) 45%, transparent 72%);
  opacity: .75; animation: pulse 2.6s ease-in-out infinite; }
.sp-accent { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 20% 30%, var(--accent) 0 5px, transparent 6px), radial-gradient(circle at 82% 26%, var(--accent) 0 4px, transparent 5px), radial-gradient(circle at 78% 70%, var(--accent) 0 5px, transparent 6px); opacity: .85; }
.sp-mood { position: absolute; right: 6%; top: 6%; font-size: clamp(1.4rem, 5vw, 2rem); background: #fff; border-radius: 50%; width: 1.8em; height: 1.8em; display: grid; place-items: center; box-shadow: var(--shadow); }
.sp-canvas.jump .sp-inner { animation: jump .5s ease; }
@keyframes bob { 50% { transform: translateY(-2.5%); } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
@keyframes jump { 40% { transform: translateY(-10%) scale(1.03, .97); } }
@keyframes pulse { 50% { opacity: .45; transform: scale(.95); } }
.sprite-btn { all: unset; display: block; width: 100%; cursor: pointer; border-radius: 24px; }
.sprite-btn:focus-visible { outline: 3px solid #A9B8FF; }

/* ---------- home ---------- */
.home-grid { display: grid; gap: 1rem; }
.home-grid .card + .card { margin-top: 0; }
.home-side { display: grid; gap: 1rem; align-content: start; }
.sprite-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .5rem; }
.sprite-name { font-size: 1.5rem; font-weight: 800; }
.el-badge { background: color-mix(in srgb, var(--el) 25%, #fff); border: 2px solid var(--el); border-radius: 999px; padding: .15rem .8rem; font-weight: 800; white-space: nowrap; }
.level-row { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin-top: .4rem; }
.level-big { font-weight: 800; font-size: 1.2rem; }
.glow-hint { border-left: 5px solid var(--el); padding-left: .6rem; }
.attr-list { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .5rem; }
.attr { display: grid; grid-template-columns: 6.5em 1fr 2.5em 2em; align-items: center; gap: .5rem; }
.attr-name { font-weight: 700; white-space: nowrap; }
.attr-val { font-weight: 800; text-align: right; }

/* ---------- homework ---------- */
.hw-grid, .games-grid, .shop-grid, .play-grid { display: grid; gap: 1rem; align-items: start; }
.hw-grid .card + .card, .hw-side .card + .card { margin-top: 1rem; }
.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.task { display: flex; align-items: center; gap: .7rem; padding: .8rem; border-radius: 16px; background: #FBF8F2; border: 2px solid transparent; flex-wrap: wrap; }
.task.pending_confirm { border-color: #F6DE8D; } .task.confirmed { background: #EFFAF4; } .task.returned { border-color: #F5B5B5; }
.task-main { flex: 1 1 14rem; min-width: 0; }
.task-title { font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; gap: .35rem .5rem; align-items: center; margin-top: .25rem; }
.task-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.rules ul { padding-left: 1.2rem; margin: 0; display: grid; gap: .3rem; }
.done-group { margin-top: .6rem; }
.done-group summary { cursor: pointer; font-weight: 700; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.done-group .task-list { margin-top: .4rem; }
.count { background: #F1EEE8; border-radius: 999px; padding: 0 .5rem; font-size: .8rem; }

/* ---------- games / play ---------- */
.mg-cards { display: grid; gap: .8rem; }
.mg-card { display: flex; align-items: center; gap: 1rem; background: #F4F6FF; border-radius: 18px; padding: 1rem; flex-wrap: wrap; }
.mg-icon { font-size: 2.4rem; width: 64px; height: 64px; display: grid; place-items: center; background: #fff; border-radius: 18px; }
.mg-body { flex: 1 1 12rem; }
.mg-body h2 { margin: 0; }
.mg-body p { margin: .2rem 0; }
.play-title { text-align: center; }
.qa { display: grid; gap: .8rem; }
.qa-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-weight: 800; }
.qa-timer { height: 12px; background: #F1EEE8; border-radius: 999px; overflow: hidden; }
.qa-timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #FFB547, #FF8A3D); transition: width .25s linear; }
.qa-time { text-align: center; color: var(--muted); font-size: .9rem; margin-top: -.4rem; }
.qa-prompt { text-align: center; font-size: clamp(2.2rem, 7vw, 3.6rem); font-weight: 800; padding: 1.2rem .5rem; background: #FFFBEF; border-radius: 20px; letter-spacing: .03em; }
.qa-choices { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.qa-choice { font: inherit; font-size: clamp(1.5rem, 5vw, 2.1rem); font-weight: 800; min-height: 84px; border-radius: 20px; border: 3px solid #DCE3FF; background: #fff; color: var(--ink); cursor: pointer; touch-action: manipulation; }
.qa-choice:active { transform: scale(.97); }
.qa-choice.is-correct, .qa-choice.is-answer { background: #D9F5E7; border-color: var(--ok); }
.qa-choice.is-wrong { background: #FFE0E0; border-color: var(--danger); }
.play-side { text-align: center; }
@media (max-width: 759px) { .play-side { display: none; } }
.result { text-align: center; display: grid; gap: .4rem; }
.result-big { font-size: 2rem; font-weight: 800; }
.result-reward { font-size: 1.2rem; font-weight: 800; color: var(--ok); }

/* ---------- shop ---------- */
.shop-preview { text-align: center; }
.stars-big { font-size: 1.6rem; font-weight: 800; margin: .5rem 0; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.item-card { background: #FBF8F2; border-radius: 16px; padding: .8rem; display: grid; gap: .4rem; justify-items: center; text-align: center; border: 2px solid transparent; }
.item-card.equipped { border-color: var(--primary); }
.item-img { width: 84px; height: 84px; display: grid; place-items: center; background: #fff; border-radius: 14px; font-size: 2.4rem; }
.item-img img { max-width: 76px; max-height: 76px; }
.item-name { font-weight: 800; }

/* ---------- parent ---------- */
.parent-grid { display: grid; gap: 1rem; }
.parent-grid .card + .card { margin-top: 0; }
.parent-head { margin-bottom: .6rem; gap: .5rem; }

/* Parent page tabs (design_direction_parent_ux_v0.1) */
.parent-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .4rem;
  margin: 0 0 .85rem;
}
.parent-tab {
  padding: .55rem .65rem;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: #FBF8F1;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: .92rem;
  cursor: pointer;
  text-align: center;
  min-width: 0;
}
.parent-tab.is-on { border-color: var(--primary); background: #EEF2FF; }
@media (min-width: 520px) {
  .parent-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 720px) {
  .parent-tabs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* Parent 遊戲題庫 subject→game drill-down (parent_ux_v0.2) */
.bank-nav .bank-crumb { margin-bottom: .35rem; align-items: center; }
.bank-nav-list { display: grid; gap: .55rem; margin-top: .55rem; }
.bank-nav-btn {
  display: flex; align-items: center; gap: .75rem;
  width: 100%; text-align: left;
  padding: .85rem 1rem;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit; font-weight: 800; font-size: 1.05rem;
  cursor: pointer;
}
.bank-nav-btn:hover, .bank-nav-btn:focus-visible { border-color: var(--primary); background: #EEF2FF; outline: none; }
.bank-nav-ico { font-size: 1.6rem; line-height: 1; flex: 0 0 auto; }
.bank-nav-label { min-width: 0; }
.bank-nav-count { font-weight: 600; margin-left: .15rem; }
.subject-heading { font-weight: 800; margin: 0; }

.rest-row { margin-top: 1rem; }
.gate { max-width: 460px; margin: 2rem auto; text-align: center; }
.pin-input { font-size: 2rem; text-align: center; letter-spacing: .6em; max-width: 260px; margin: 0 auto; }
.setup { width: min(100%, 560px); margin: 0 auto; }
.avatar-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.avatar-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.avatar-opt span { display: grid; place-items: center; width: 64px; height: 64px; font-size: 2rem; border-radius: 18px; border: 3px solid var(--line); background: #fff; cursor: pointer; }
.avatar-opt input:checked + span { border-color: var(--primary); background: #EEF1FF; }

/* ---------- overlays ---------- */
#overlay { position: relative; z-index: 50; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(46, 42, 59, .45); display: grid; place-items: center; padding: 1rem; overflow: hidden; }
.modal-backdrop[hidden] { display: none !important; }
.modal { background: #fff; border-radius: 24px; padding: 1.3rem; width: min(560px, 100%); max-height: 92vh; overflow: auto; position: relative; z-index: 1; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-text { font-size: 1.1rem; }
.evolve, .levelup { text-align: center; display: grid; gap: .5rem; justify-items: center; }
.evolve-title, .levelup-title { font-size: 2rem; font-weight: 900; color: #E07A00; }
.evolve-anim { display: flex; align-items: center; justify-content: center; gap: .6rem; width: 100%; }
.evolve-from { width: 30%; opacity: .7; } .evolve-to { width: 55%; }
.evolve-arrow { font-size: 2rem; color: var(--muted); }
.evolve-name, .levelup-num { font-size: 1.2rem; font-weight: 800; margin: 0; }
.evolve-element { margin: 0; font-weight: 800; background: color-mix(in srgb, var(--el) 25%, #fff); border: 2px solid var(--el); border-radius: 999px; padding: .1rem 1rem; }
.sparkle { animation: sparkle 1.2s ease-out; }
@keyframes sparkle { 0% { transform: scale(.4); filter: brightness(2.2); } 70% { transform: scale(1.06); } 100% { transform: scale(1); filter: none; } }
.confetti { position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 3px; animation: fall 2.6s linear forwards; z-index: 0; pointer-events: none; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); } }
#toasts { position: fixed; /* below modals */ left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom)); z-index: 45; display: grid; gap: .4rem; width: min(92vw, 460px); pointer-events: none; }
.toast { background: #2E2A3B; color: #fff; border-radius: 14px; padding: .6rem 1rem; font-weight: 700; text-align: center; box-shadow: var(--shadow); transition: opacity .4s, transform .4s; }
.toast-reward { background: #1F8A5B; } .toast-level { background: #E07A00; }
.toast.out { opacity: 0; transform: translateY(8px); }
.error { color: var(--danger); }


/* ---------- 靈芽衝刺 (sprint_race): full-screen race while playing ---------- */
body.race-on { overflow: hidden; }
.race {
  position: fixed; inset: 0; z-index: 30; height: 100vh; height: 100dvh; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(96px, 1fr) auto auto auto;
  grid-template-areas: "hud" "track" "prog" "card" "pad";
  gap: clamp(6px, 1.2dvh, 12px);
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right), calc((100vw - 1000px) / 2))
           max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left), calc((100vw - 1000px) / 2));
  background: linear-gradient(180deg, #F7F3FF 0%, #EEE7FF 100%);
}
.race-hud { grid-area: hud; display: flex; align-items: center; gap: .6rem; min-width: 0; }
.race-ring { position: relative; width: clamp(46px, 7.5dvh, 66px); aspect-ratio: 1; flex: none; background: #fff; border-radius: 50%; box-shadow: var(--shadow); }
.race-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.race-ring circle { fill: none; stroke-width: 6; }
.ring-bg { stroke: #ECE6FB; }
.ring-fg { stroke: #8B5CF6; stroke-linecap: round; transition: stroke-dashoffset .1s linear; }
.race-ring.low .ring-fg { stroke: #F97316; }
.ring-num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: clamp(1.05rem, 3dvh, 1.5rem); color: #5B21B6; }
.race-count { background: #fff; border-radius: 999px; padding: .2rem .9rem; font-weight: 900; font-size: clamp(1.1rem, 3dvh, 1.5rem); color: #5B21B6; box-shadow: var(--shadow); white-space: nowrap; }
.race-count span { color: var(--ok); }
.race-quit { margin-left: auto; min-height: 40px; }
.race-track { grid-area: track; position: relative; min-height: 0; container-type: size; border-radius: 22px; overflow: hidden; box-shadow: var(--shadow);
  background: radial-gradient(ellipse 60px 22px at 18% 26%, #fff 70%, transparent 72%), radial-gradient(ellipse 80px 26px at 70% 18%, #fff 70%, transparent 72%),
              linear-gradient(180deg, #BFE3FF 0%, #E4F4FF 58%, #CDEFC4 58.2%, #BFE7B4 100%); }
.race-road { position: absolute; left: 0; right: 0; bottom: 10%; height: 30%; background: linear-gradient(180deg, #E6DAFB, #D5C4F6); border-top: 3px solid #fff; border-bottom: 3px solid #C4B0EE; }
.road-line { position: absolute; left: 0; right: 0; top: 50%; border-top: 3px dashed rgba(255,255,255,.9); }
.race-flag { position: absolute; bottom: 14%; height: 58%; width: 2px; transform: translateX(-50%); z-index: 1; font-size: clamp(14px, 3dvh, 26px); }
.flag-pole { position: absolute; left: 0; bottom: 0; width: 4px; height: 100%; background: #A78B6A; border-radius: 2px; }
.flag-cloth { position: absolute; left: 4px; top: 0; width: 0; height: 0; border-top: .7em solid transparent; border-bottom: .7em solid transparent; border-left: 1.4em solid #F472B6; transform-origin: left center; }
.flag-flag_big .flag-cloth { border-left-color: #60A5FA; border-top-width: .9em; border-bottom-width: .9em; border-left-width: 1.8em; }
.race-flag.reached .flag-cloth { animation: wave .6s ease-in-out 3; }
.finish-line { position: absolute; left: -7px; bottom: -8%; width: 14px; height: 108%; border-radius: 3px;
  background: repeating-conic-gradient(#2E2A3B 0 25%, #fff 0 50%) 0 0 / 14px 14px; box-shadow: 0 0 0 2px #fff; }
.flag-label { position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -2px); font-size: .75rem; font-weight: 800; background: rgba(255,255,255,.85); border-radius: 999px; padding: 0 .45rem; white-space: nowrap; }
.race-flag.reached .flag-label { background: #FFE9A8; }
.race-runner { position: absolute; bottom: 12%; height: min(66cqh, 24cqw); aspect-ratio: 1; transform: translateX(-50%); transition: left .35s cubic-bezier(.3, 1.4, .5, 1); z-index: 2; }
.race-shadow { z-index: 1; opacity: .42; filter: saturate(.2) brightness(1.2); transition: left .5s ease-out; }
.runner-tag { position: absolute; left: 50%; top: -2px; transform: translateX(-50%); font-size: .7rem; font-weight: 800; color: var(--muted); background: rgba(255,255,255,.8); border-radius: 999px; padding: 0 .4rem; white-space: nowrap; }
.sp-canvas.sp-run { background: none; border-radius: 0; overflow: visible; max-width: none; width: 100%; }
.race-me .sp-canvas { transform: rotate(4deg); transform-origin: 50% 90%; }
.race-me.hop .sp-canvas { animation: hop .38s ease-out; }
.race.past-finish .race-me .sp-inner { animation: runbounce .42s ease-in-out infinite; }
@keyframes hop { 0% { transform: rotate(4deg); } 40% { transform: translateY(-16%) rotate(12deg) scale(1.04, .96); } 100% { transform: rotate(4deg); } }
/* run frames (sprites.json run_frames): lean, squash and bob are drawn into the frames, so no CSS tilt/bounce;
   a correct answer still gives a short straight hop */
.race-runner .sp-canvas.sp-frames, .race-me .sp-canvas.sp-frames { transform: none; }
.race-runner .sp-canvas.sp-frames .sp-inner, .race.past-finish .race-me .sp-canvas.sp-frames .sp-inner { animation: none; }
.race-me.hop .sp-canvas.sp-frames { animation: hopframes .38s ease-out; }
@keyframes hopframes { 40% { transform: translateY(-12%); } }
@keyframes runbounce { 50% { transform: translateY(-7%) rotate(3deg); } }
@keyframes wave { 50% { transform: scaleX(.75) skewY(-8deg); } }
.race-progress { grid-area: prog; position: relative; height: 34px; margin: 0 14px; }
.race-bar { position: absolute; left: 0; right: 0; top: 4px; height: 12px; background: #DDD3F7; border-radius: 999px; overflow: hidden; }
.race-fill { height: 100%; width: 0; background: linear-gradient(90deg, #A78BFA, #7C3AED); border-radius: 999px; transition: width .35s; }
.race-mark { position: absolute; top: 0; transform: translateX(-50%); display: grid; justify-items: center; }
.race-mark i { width: 6px; height: 20px; border-radius: 3px; background: #fff; border: 2px solid #A78BFA; }
.race-mark b { font-size: .75rem; color: var(--muted); line-height: 1.1; }
.race-mark.reached i { background: #FACC15; border-color: #E0A800; }
.race-card { grid-area: card; justify-self: center; width: 100%; max-width: 720px; background: #fff; border-radius: 22px; box-shadow: var(--shadow);
  padding: clamp(.3rem, 1.4dvh, .9rem) .8rem; text-align: center; border: 3px solid transparent; }
.race-card.flash-ok { animation: okflash .35s ease-out; }
.race-card.is-wrong { border-color: #FCA5A5; background: #FFF6F6; }
@keyframes okflash { 0% { border-color: #34D399; background: #ECFDF5; } 100% { border-color: transparent; background: #fff; } }
.race-q { font-size: clamp(1.7rem, min(9vw, 6.2dvh), 3.4rem); font-weight: 900; line-height: 1.2; letter-spacing: .03em; color: #4C1D95; white-space: nowrap; }
.ans-box { display: inline-block; min-width: 2.3em; padding: 0 .25em; border: 3px solid #A78BFA; border-radius: 14px; color: #111; vertical-align: middle; line-height: 1.25; }
.ans-box.is-empty .caret { display: inline-block; width: 3px; height: .9em; background: #7C3AED; vertical-align: -.1em; animation: blink 1s steps(1) infinite; }
.ans-box.is-reveal { border-color: var(--ok); background: #D9F5E7; color: #146C45; }
@keyframes blink { 50% { opacity: 0; } }
.race-fb { margin: .1rem 0 0; font-size: .85rem; font-weight: 700; color: #9B2C2C; }
.race-pad { grid-area: pad; justify-self: center; width: 100%; max-width: 720px; height: clamp(196px, 38dvh, 380px);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); gap: clamp(6px, 1.1dvh, 12px); }
.key { font: inherit; font-weight: 900; font-size: clamp(1.4rem, 4.4dvh, 2.3rem); color: #3B0764; border: 0; border-radius: 18px; cursor: pointer; touch-action: manipulation;
  min-height: 44px; box-shadow: inset 0 -5px 0 rgba(0,0,0,.08), 0 3px 8px rgba(80,60,140,.12); -webkit-user-select: none; user-select: none; }
.key:active { transform: translateY(2px) scale(.98); box-shadow: inset 0 -2px 0 rgba(0,0,0,.08); }
.key.hit { animation: keyhit .16s ease-out; }
@keyframes keyhit { 40% { transform: translateY(2px) scale(.96); filter: brightness(.95); } }
.key:focus-visible { outline: 3px solid #7C3AED; outline-offset: 2px; }
.key-1 { background: #FFC4DD; } .key-2 { background: #FFD1A6; } .key-3 { background: #FFE990; }
.key-4 { background: #B9F2D0; } .key-5 { background: #B5EEF0; } .key-6 { background: #C7DFFF; }
.key-7 { background: #E2DAFF; } .key-8 { background: #CDBBFF; } .key-9 { background: #F6D2FF; }
.key-0 { background: #EEF0FF; grid-column: span 2; } .key-del { background: #9CC8FF; }
.race-banner { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); z-index: 5; pointer-events: none; background: #FFF7D6; color: #8A4B12;
  border: 3px solid #FACC15; border-radius: 999px; padding: .4rem 1.4rem; font-size: clamp(1.3rem, 4dvh, 2rem); font-weight: 900; white-space: nowrap; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
.race-banner.show { animation: bannerpop .5s cubic-bezier(.3, 1.6, .5, 1); }
.race-banner.big { background: linear-gradient(90deg, #FDE68A, #FBCFE8, #BFDBFE); color: #5B21B6; border-color: #fff; font-size: clamp(1.3rem, min(6.5vw, 5.5dvh), 2.6rem); max-width: 94vw; }
@keyframes bannerpop { 0% { transform: translateX(-50%) scale(.4); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }
.race-countdown { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background: rgba(247, 243, 255, .78); font-size: clamp(4rem, 22dvh, 9rem); font-weight: 900; color: #7C3AED; }
.race-countdown[hidden] { display: none; }
.race-countdown.pop { animation: bannerpop2 .6s ease-out; }
@keyframes bannerpop2 { 0% { transform: scale(1.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
/* small phones in landscape (e.g. 667x375): track + question on the left, number pad on the right */
@media (orientation: landscape) and (max-height: 560px) {
  .race { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "hud pad" "track pad" "prog pad" "card pad"; column-gap: 14px; }
  .race-pad { height: 100%; max-width: none; gap: 6px; }
  .key { font-size: clamp(1.2rem, 7dvh, 1.9rem); border-radius: 14px; }
  .race-q { font-size: clamp(1.4rem, min(5vw, 9dvh), 2.4rem); }
  .race-card { padding: .2rem .5rem; }
  .race-ring { width: clamp(40px, 12dvh, 54px); }
  .flag-label { font-size: .65rem; }
  .race-banner { top: 12%; }
}
/* intro + result */
.sprint-intro { display: grid; gap: .6rem; }
.sprint-how { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; font-weight: 700; }
.sprint-how li { background: #F4F1FF; border-radius: 14px; padding: .55rem .8rem; }
.sprint-flags { margin: 0; font-weight: 800; color: #5B21B6; text-align: center; }
.sprint-best { margin: 0; text-align: center; color: var(--muted); }
.sprint-start { min-width: 12rem; font-size: 1.3rem; }
.res-flags { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; }
.res-flag { background: #F1EEE8; border-radius: 999px; padding: .2rem .7rem; font-weight: 800; }
.res-flag.got { background: #FFF1C2; }
.res-flag small { color: var(--muted); }
.res-best { font-weight: 800; margin: .2rem 0; }
.res-best.new { color: #E07A00; }
.practice { background: #FFFBEF; border-radius: 16px; padding: .6rem .9rem; text-align: left; }
.practice h3 { margin: 0 0 .3rem; color: var(--ink); }
.practice ul { margin: 0; padding-left: 1.2rem; display: grid; gap: .25rem; }
.practice-none { font-weight: 700; color: var(--ok); }
.badge.rec { background: #FFE0F0; color: #9D2A6B; font-size: .75rem; vertical-align: middle; }
.mg-card.is-rec { box-shadow: 0 0 0 3px #F9A8D4 inset; }
.rec-card { display: flex; align-items: center; gap: .7rem; background: #F4F1FF; border-radius: 16px; padding: .6rem .8rem; margin-bottom: .7rem; flex-wrap: wrap; }
.rec-icon { font-size: 2rem; }
.rec-text { flex: 1 1 10rem; min-width: 0; }
/* parent: most-missed facts + table restriction */
.missed-list { list-style: none; counter-reset: m; padding: 0; margin: 0 0 .6rem; display: grid; gap: .5rem; }
.missed { counter-increment: m; background: #FBF8F2; border-radius: 14px; padding: .55rem .75rem; }
.missed-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.missed-head::before { content: counter(m); font-weight: 900; color: var(--muted); }
.missed-fact { font-weight: 900; font-size: 1.1rem; }
.missed-ans { color: var(--muted); font-weight: 700; }
.lvl { margin-left: auto; border-radius: 999px; padding: 0 .55rem; font-weight: 800; font-size: .8rem; background: #E7ECFF; white-space: nowrap; }
.lvl-1 { background: #FFE0E0; color: #9B2C2C; } .lvl-2 { background: #FFEBD1; color: #8A4B12; }
.missed-meta { display: flex; flex-wrap: wrap; gap: .2rem .8rem; margin-top: .2rem; }
.table-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: .4rem; }
.table-opt { display: flex; align-items: center; gap: .4rem; background: #FBF8F2; border-radius: 12px; padding: .3rem .6rem; min-height: 48px; font-weight: 700; cursor: pointer; }
.table-opt input { width: 24px; min-height: 24px; height: 24px; flex: none; }


/* ---------- 餵精靈: basket under the sprite (design_v0.5 §16, assets/feeding/README.md) ---------- */
.feed-stage { position: relative; }
.feed-stage .sp-lg { max-width: min(420px, 30dvh); }
.feed-stage.drop-ready .sp-canvas { box-shadow: 0 0 0 3px #FFE08A inset; }
.feed-stage.drop-over .sp-canvas { box-shadow: 0 0 0 5px #FFB938 inset; }
.feed-fx { position: absolute; pointer-events: none; object-fit: contain; z-index: 3; }
.fx-gold_burst { z-index: 0; transform-origin: 50% 50%; }
.sp-canvas > .sp-inner { z-index: 2; }
.sp-canvas > .sp-mood { z-index: 4; }
.feed-fly, .feed-ghost { position: fixed; z-index: 60; pointer-events: none; object-fit: contain; }
.feed-ghost { width: 72px; height: 72px; filter: drop-shadow(0 6px 8px rgba(0,0,0,.2)); }
.feed-stage[data-feeding="1"] .sp-mood { opacity: 0; transition: opacity .2s; }
.feed-gain { position: absolute; left: 50%; top: 6%; z-index: 5; pointer-events: none; font-weight: 900; font-size: 1.3rem; color: #5B7CFA;
  background: #fff; border-radius: 999px; padding: .1rem .8rem; box-shadow: var(--shadow); white-space: nowrap; }
.feed-gain.lucky { color: #B7791F; background: #FFF6D5; }
.basket-area { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "grow basket all" "hint hint hint";
  align-items: end; gap: .3rem .5rem; margin: .6rem 0 .2rem; padding: .5rem .5rem .3rem; background: #FFFBEF; border-radius: 18px; container-type: inline-size; }
.growing { grid-area: grow; display: grid; justify-items: center; gap: .15rem; text-align: center; }
.growing-ring { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(#7BC67E calc(var(--p) * 360deg), #E9E3D4 0); }
.growing-ring img { width: 44px; height: 44px; border-radius: 50%; background: #FFFBEF; padding: 3px; object-fit: contain; filter: saturate(.55) brightness(1.05); }
.growing-text { font-size: .78rem; font-weight: 800; color: var(--muted); line-height: 1.2; }
.basket { grid-area: basket; position: relative; width: clamp(120px, 46cqw, 220px); aspect-ratio: 1 / 0.82; cursor: pointer; }
.basket-img { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: auto; user-select: none; pointer-events: none; }
.basket-fruits { position: absolute; inset: 0; }
.fruit { all: unset; position: absolute; width: 30%; aspect-ratio: 1; cursor: grab; touch-action: none; border-radius: 50%; transform: translate(-50%, -50%); }
.fruit img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; filter: drop-shadow(0 3px 3px rgba(80,50,20,.25)); }
.fruit:focus-visible { outline: 3px solid #A9B8FF; }
.fruit:active { cursor: grabbing; }
.fruit.slot-0 { left: 50%; top: 14%; z-index: 3; } .fruit.slot-1 { left: 26%; top: 22%; z-index: 2; } .fruit.slot-2 { left: 74%; top: 22%; z-index: 2; }
.fruit.slot-3 { left: 38%; top: 33%; z-index: 1; } .fruit.slot-4 { left: 62%; top: 33%; z-index: 1; }
.basket-badge { position: absolute; right: 2%; top: 4%; z-index: 4; min-width: 2.1em; height: 2.1em; padding: 0 .45em; border-radius: 999px; display: grid; place-items: center;
  background: #E8573A; color: #fff; font-weight: 900; font-size: 1rem; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.basket-badge[hidden] { display: none; }
.basket-side { grid-area: all; display: grid; justify-items: center; align-self: center; }
.feed-all { padding: .45rem .6rem; font-size: 1rem; max-width: 100%; line-height: 1.2; text-align: center; display: grid; justify-items: center; }
.feed-all .fa-main { white-space: nowrap; } .feed-all .fa-n { font-size: .8rem; opacity: .9; }
.feed-all[hidden] { display: none; }
.feed-hint { grid-area: hint; margin: 0; text-align: center; color: var(--muted); }
/* small landscape phones (667x375): sprite + bubble on the left, level + basket on the right */
@media (orientation: landscape) and (max-height: 560px) {
  .sprite-card { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); column-gap: 1rem; align-items: start; }
  .sprite-card > * { grid-column: 2; }
  .sprite-card > .feed-stage { grid-column: 1; grid-row: 1 / span 3; }
  .sprite-card > .bubble { grid-column: 1; grid-row: 4 / span 3; margin-top: .4rem; }
  .sprite-card > .sprite-head { margin-bottom: 0; }
  .feed-stage .sp-lg { max-width: min(420px, 50dvh); }
  .sprite-card .basket-area { margin-top: .3rem; }
}

/* ---------- tablet ---------- */
@media (min-width: 760px) {
  #view { padding: 1.4rem 1.6rem calc(var(--nav-h) + 2rem); }
  .nav-btn { flex-direction: row; gap: .5rem; font-size: 1rem; }
  .home-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .hw-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .games-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .shop-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
  .shop-preview { position: sticky; top: calc(var(--top-h) + 1rem); }
  .play-grid { grid-template-columns: minmax(0, 1fr); max-width: 760px; margin: 0 auto; }
  .play-side { display: flex; align-items: center; gap: 1rem; text-align: left; }
  .play-side .sp-canvas { max-width: 150px; flex: none; margin: 0; }
  .play-side .bubble { flex: 1; }
  .play-side .bubble::before { display: none; }
  .qa-prompt { padding: 2rem .5rem; }
  .parent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .p-review { grid-column: 1 / -1; }
  .qa-choice { min-height: 130px; }
}
/* ---------- desktop: side navigation, wider multi-column panels ---------- */
@media (min-width: 1100px) {
  #app { display: grid; grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: auto 1fr; }
  #topbar { grid-column: 1 / -1; padding: .6rem 1.6rem; }
  #nav { position: sticky; top: var(--top-h); align-self: start; height: calc(100vh - var(--top-h)); flex-direction: column; justify-content: flex-start;
    gap: .4rem; padding: 1.2rem .8rem; border-top: 0; border-right: 1px solid var(--line); box-shadow: none; background: #FFFDF8; }
  .nav-btn { flex: none; justify-content: flex-start; padding: .7rem 1rem; font-size: 1.05rem; }
  #view { padding: 1.6rem 2rem 2rem; width: 100%; grid-column: 2; min-width: 0; }
  /* first-run setup has no nav: let the view span the full width instead of falling into the 220px nav column */
  #nav:empty ~ #view { grid-column: 1 / -1; }
  #toasts { bottom: 1.5rem; }
  .home-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .home-side { grid-template-columns: 1fr; }
  .play-grid { grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr); max-width: none; }
  .play-side { display: block; position: sticky; top: calc(var(--top-h) + 1rem); text-align: center; }
  .play-side .sp-canvas { max-width: 240px; margin: 0 auto; }
  .play-side .bubble::before { display: block; }
  .qa-choice { min-height: 120px; }
  .parent-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .p-review { grid-column: span 2; grid-row: span 2; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- 背包 + 吃小食 (treat, schema 0.5.1) - deliberately unlike fruit feeding ---------- */
.bag { margin: .75rem 0; padding: .6rem .7rem; border-radius: 16px; background: #F7F1FF; text-align: left; }
.bag-title { font-size: 1rem; margin: 0 0 .4rem; }
.bag-list { display: flex; flex-wrap: wrap; gap: .6rem; }
.bag-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .5rem; width: 100%; }
.bag-icon { position: relative; width: 48px; height: 48px; }
.bag-icon img { width: 100%; height: 100%; object-fit: contain; }
.bag-icon > span[aria-hidden] { font-size: 2rem; }
.bag-count { position: absolute; right: -6px; bottom: -4px; background: #6D4AFF; color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 800; padding: 0 .35rem; }
.bag-name { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.bag-item .btn { min-height: 44px; min-width: 64px; }
.treat-fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.treat-item { position: absolute; left: 50%; top: 105%; width: 26%; aspect-ratio: 1; transform: translate(-50%, -50%) scale(.6); opacity: 0;
  transition: top var(--move, 350ms) ease-out, transform var(--move, 350ms) ease-out, opacity var(--move, 350ms); }
.treat-item img, .treat-item span { width: 100%; height: 100%; object-fit: contain; display: block; font-size: 2.2rem; text-align: center; }
.treat-fx.at-mouth .treat-item { top: 64%; transform: translate(-50%, -50%) scale(1); opacity: 1; }
/* each bite takes a round chunk out of the cookie (a treat is nibbled, a fruit is gulped) */
.treat-fx[data-bite="1"] .treat-item { mask-image: radial-gradient(circle at 92% 18%, transparent 22%, #000 23%); }
.treat-fx[data-bite="2"] .treat-item { mask-image: radial-gradient(circle at 92% 18%, transparent 22%, #000 23%), radial-gradient(circle at 80% 72%, transparent 24%, #000 25%); mask-composite: intersect; transform: translate(-50%, -50%) scale(.85); }
.treat-fx[data-bite="3"] .treat-item { opacity: .35; transform: translate(-50%, -50%) scale(.5); }
.treat-crumbs i { position: absolute; left: 50%; top: 66%; width: 6px; height: 6px; border-radius: 2px; background: #C98B4A; opacity: 0; }
.treat-fx.nibbling .treat-crumbs i { animation: treat-crumb calc(var(--nibble, 360ms) * 1.2) ease-out infinite; }
.treat-crumbs i:nth-child(2) { --dx: -26px; animation-delay: 60ms !important; }
.treat-crumbs i:nth-child(3) { --dx: 24px; animation-delay: 120ms !important; }
.treat-crumbs i:nth-child(4) { --dx: -12px; animation-delay: 180ms !important; }
.treat-crumbs i:nth-child(5) { --dx: 14px; animation-delay: 240ms !important; }
@keyframes treat-crumb { 0% { opacity: 1; transform: translate(0, 0); } 100% { opacity: 0; transform: translate(var(--dx, 6px), 34px) rotate(90deg); } }
.sp-canvas.treat-nibbling .sp-inner { animation: treat-nibble var(--nibble, 360ms) ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes treat-nibble { 0%, 100% { transform: rotate(0) translateY(0); } 30% { transform: rotate(-3deg) translateY(2%); } 60% { transform: rotate(2deg) translateY(1%); } }
.treat-mood { position: absolute; left: 50%; top: 4%; transform: translateX(-50%); font-size: clamp(2rem, 18%, 3.5rem); animation: treat-mood-pop 600ms ease-out both; }
@keyframes treat-mood-pop { 0% { opacity: 0; transform: translate(-50%, 30%) scale(.4); } 70% { opacity: 1; transform: translate(-50%, -6%) scale(1.15); } 100% { transform: translate(-50%, 0) scale(1); } }
.sp-mood.sp-mood-hide { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .sp-canvas.treat-nibbling .sp-inner, .treat-fx.nibbling .treat-crumbs i, .treat-mood { animation: none; } }

/* ---------- parent account / cloud save / import ---------- */
.p-account h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem; }
.account-who { font-weight: 700; overflow-wrap: anywhere; }
.account-sync[data-status="offline"], .account-sync[data-status="error"], .account-sync[data-status="conflict"] { color: #9A5B00; }
.setup-restore { background: #F3EEFF; border-radius: 16px; padding: .8rem 1rem; margin: .6rem 0 1rem; }
.setup-restore h2 { font-size: 1.05rem; margin: 0 0 .3rem; }
.setup-restore .btn { margin-top: .3rem; }
.chooser h2, .import-confirm h2 { margin-top: 0; }
.chooser-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: .8rem; margin: .6rem 0; }
.chooser-opt { border: 2px solid var(--line); border-radius: 16px; padding: .6rem .8rem; display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.chooser-opt h3 { margin: 0; color: var(--ink); }
.chooser-opt .btn { margin-top: auto; }
.save-sum { list-style: none; margin: 0; padding: 0; font-size: .92rem; overflow-wrap: anywhere; }
.save-sum li { padding: .1rem 0; }
.warn-text { color: #9A5B00; }

/* signed-in delete-all: type-to-confirm step */
.btn.danger-btn { background: var(--danger); color: #fff; }
.delete-cloud input { font-size: 1.1rem; }
.consent-google { margin-top: .5rem; }

/* ---------- 功課 v0.5.2: subject + count entry, per-piece timer, speed bonus, parent times ---------- */
.hw-entry fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.hw-entry legend { font-weight: 700; margin-bottom: .35rem; padding: 0; }
.pick-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.pick { position: relative; cursor: pointer; }
.pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pick span { display: inline-flex; align-items: center; gap: .25rem; min-height: 44px; padding: .35rem .75rem; border-radius: 999px;
  background: #FBF8F2; border: 2px solid #E8E1D4; border-left: 5px solid var(--subj, #E8E1D4); font-weight: 700; white-space: nowrap; }
.pick-num span { min-width: 44px; justify-content: center; border-left-width: 2px; }
.pick input:checked + span { background: #FFF3C4; border-color: #E0A800; box-shadow: 0 0 0 2px rgba(224, 168, 0, .25); }
.pick input:focus-visible + span { outline: 3px solid #7C9CFF; outline-offset: 2px; }
.task-note { color: #6B6358; overflow-wrap: anywhere; }
.task.in_progress { border-color: #8FD3A8; background: #F1FBF5; } .task.paused { border-color: #E8E1D4; }
.badge.st-in_progress { background: #D8F5E3; color: #1E6B3A; } .badge.st-paused { background: #EEE; color: #555; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: .95rem; }
.timer.on { color: #1E6B3A; }
.speed-note { margin-top: .4rem; padding: .45rem .65rem; border-radius: 12px; background: #FFF6D6; font-weight: 800; color: #7A5200; }
.pending-fruit { display: block; font-weight: 600; font-size: .85rem; color: #6B5A2A; margin-top: .15rem; }
.badge.bonus { background: #FFF1B8; color: #7A5200; }
.ptiming { margin-top: .3rem; }
.table-wrap { overflow-x: auto; }
.times-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.times-table th, .times-table td { text-align: left; padding: .4rem .35rem; border-bottom: 1px solid #EFE9DE; vertical-align: top; }
.times-table thead th { font-size: .78rem; color: #6B6358; font-weight: 700; }
.times-table td { font-variant-numeric: tabular-nums; white-space: nowrap; }
.task .task-actions .btn { min-height: 44px; }
.ptiming .badge, .speed-note { white-space: normal; overflow-wrap: anywhere; }

/* ---------- v0.5.3 family account ---------- */
.pick-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip-btn { border: 2px solid var(--line, #e6dcc8); background: #fff; border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 700; min-height: 40px; cursor: pointer; }
.chip-btn:hover { border-color: #b9a5ff; }
.member-list, .log-list, .invite-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.member { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: #faf6ee; }
.member-main { min-width: 0; flex: 1 1 180px; }
.member-name { font-weight: 800; font-size: 1.05rem; }
.member-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.log-row { padding: 8px 10px; border-radius: 12px; background: #faf6ee; overflow-wrap: anywhere; }
.log-time { display: inline-block; min-width: 88px; }
.invite { max-width: 420px; }
.invite .qr { width: min(240px, 70vw); margin: 8px auto; background: #fff; padding: 6px; border-radius: 12px; }
.invite .qr svg { width: 100%; height: auto; display: block; }
.invite input[readonly] { font-size: 0.85rem; }
.invite-code { font-size: 2.2rem; font-weight: 800; letter-spacing: 0.12em; text-align: center; margin: 8px 0; }
.invite hr { border: 0; border-top: 1px dashed #e6dcc8; margin: 14px 0; }
.join-card { max-width: 560px; margin: 0 auto; }
.join-card .big-emoji { font-size: 3rem; text-align: center; margin: 0; }
.confirmed-by { margin-top: 6px; color: #1f7a4d; font-weight: 700; }
.center { text-align: center; }

/* v0.5.3 「遊戲更新咗，請重新載入。」 */
.stale-banner { position: sticky; top: 0; z-index: 60; display: flex; gap: .6rem; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: .55rem .8rem; background: #fff4d6; color: #5a3d00; border-bottom: 2px solid #f0c24b; font-size: .95rem; text-align: center; }

/* v0.5.4 day switcher (design §4.2) */
.day-pick { min-width: 0; flex: 1 1 12rem; }
.card-head .day-pick { flex: 1 1 10rem; }

/* ---------- dictation recall (glyphs are text; runes are animation only) ---------- */
.dict-form, .dict-game { display: grid; gap: .7rem; min-width: 0; }
.dict-input { font: inherit; width: 100%; min-height: 6.5rem; padding: .5rem .8rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); resize: vertical; }
.dict-words { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.dict-word { display: flex; align-items: center; gap: .35rem .6rem; flex-wrap: wrap; background: #F7F4EC; border-radius: 12px; padding: .35rem .55rem; min-width: 0; }
.dict-word b { font-size: 1.2rem; overflow-wrap: anywhere; }
.dict-top { display: flex; align-items: center; justify-content: space-between; gap: .4rem; flex-wrap: wrap; font-weight: 800; }
.dict-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.dict-runes { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.dict-rune { aspect-ratio: 1; max-height: 28px; border-radius: 50%; background: #EFE6D6; border: 2px solid #E2D3B8; justify-self: center; width: 100%; }
.dict-rune.is-lit { background: radial-gradient(circle at 40% 35%, #FFF6C9, #FFC14D); border-color: #E8A317; box-shadow: 0 0 8px #FFD56A; }
.dict-prompt { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .3rem; min-height: 4.4rem; padding: .6rem; background: #FFFBEF; border-radius: 20px; font-size: clamp(1.8rem, 8vw, 3rem); font-weight: 800; }
.dict-blank { min-width: 1.15em; min-height: 1.15em; border-radius: 14px; background: #FFF8E0; border: 3px solid #F0C14A; box-shadow: 0 0 16px #FFD56A; }
.dict-choices { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.dict-choice { font: inherit; font-weight: 800; font-size: clamp(1.6rem, 7vw, 2.4rem); min-height: 72px; border-radius: 999px; border: 3px solid transparent; color: var(--ink); cursor: pointer; touch-action: manipulation; }
.dict-choice.c0 { background: #FFD6E7; }
.dict-choice.c1 { background: #C9E4FF; }
.dict-choice.c2 { background: #FFF1B8; }
.dict-choice.c3 { background: #D4F5DE; }
.dict-choice.is-answer { box-shadow: 0 0 0 3px var(--ok); }
.dict-choice.is-picked { opacity: .55; }
.dict-slots, .dict-tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; min-width: 0; }
.dict-slot, .dict-tile { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font: inherit; font-weight: 800; font-size: 1.35rem; }
.dict-slot { border: 2px dashed #D9C7A2; background: #FFFBEF; }
.dict-slot.is-open { border-style: solid; border-color: #E8A317; box-shadow: 0 0 0 3px #FFE3A3; }
.dict-tile { border: 3px solid #E2D3B8; background: #F4EFE4; color: var(--ink); cursor: pointer; touch-action: manipulation; box-shadow: inset 0 -4px 0 rgba(80, 60, 20, .08); }
.dict-tile.is-used { visibility: hidden; }
.dict-tile.is-bounce { animation: dict-bounce .35s ease; }
.dict-feedback { min-height: 1.4em; margin: 0; text-align: center; font-weight: 800; }
@keyframes dict-bounce { 0% { transform: translateY(0); } 40% { transform: translateY(-14px); } 100% { transform: translateY(0); } }

/* ---------- v0.5.8 英文串字 (spell_order) ---------- */
.spell-board { display: grid; gap: .7rem; justify-items: center; min-width: 0; }
.spell-meaning { margin: 0; padding: .55rem 1rem; min-width: 60%; text-align: center; background: #FFFBEF; border-radius: 20px; font-size: clamp(1.7rem, 8vw, 2.6rem); font-weight: 900; line-height: 1.25; overflow-wrap: anywhere; }
.spell-hint { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: .15rem .3rem; font-size: clamp(1.25rem, 6vw, 1.7rem); font-weight: 800; letter-spacing: .02em; color: #5A4E3A; }
.spell-hint.none { font-size: .9rem; font-weight: 700; }
.sh-letter, .sh-blank, .sh-fixed { min-width: .75em; text-align: center; }
.sh-blank { color: #D08A00; }
.spell-slots, .spell-tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; min-width: 0; max-width: 100%; }
.spell-slot { width: 42px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 1.35rem; border: 2px dashed #D9C7A2; background: #FFFBEF; }
.spell-slot.is-filled { border-style: solid; border-color: #9CC9A9; background: #EEFAF1; }
.spell-slot.is-fixed { border: none; background: transparent; width: 18px; color: var(--muted); }
.spell-slot.is-space { width: 14px; }
.spell-slot.is-reveal { border-style: solid; border-color: #E8A317; background: #FFF3CF; }
.spell-slot.is-flash { animation: spell-flash .45s ease; }
@keyframes spell-flash { 0%, 100% { box-shadow: none; } 40% { box-shadow: 0 0 0 4px #FFC9A8; } }
.spell-tile { width: 50px; height: 52px; font-size: 1.45rem; }
.spell-tile:disabled:not(.is-used) { opacity: .5; cursor: default; }
.spell-empty { display: grid; gap: .7rem; text-align: center; }
.p-en-words { display: grid; gap: .55rem; min-width: 0; }
.p-en-words h2, .p-en-words h3, .p-en-words p { margin: 0; }
.en-word b { font-size: 1.15rem; }
.en-word-actions { display: flex; gap: .3rem; margin-left: auto; }
.en-edit-box { display: flex; gap: .4rem; width: 100%; }
.en-edit-box input, .en-pmeaning { font: inherit; flex: 1; min-width: 0; min-height: 44px; padding: .3rem .7rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
.en-preview { display: grid; gap: .55rem; min-width: 0; }
.en-prows { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.en-prow { display: grid; gap: .4rem; padding: .55rem .65rem; border-radius: 14px; background: #F7F4EC; border: 2px solid transparent; min-width: 0; }
.en-prow.tag-missing { background: #FFF4E8; border-color: #FFD3A8; }
.en-prow-head { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.en-prow-head b { font-size: 1.2rem; overflow-wrap: anywhere; }
.en-prow-x { margin-left: auto; }
.badge.dict { background: #DDF3FF; color: #0F5C85; }
.en-alts { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.en-alt { background: #EEF1FF; color: var(--primary); border: 2px solid #D5DDFF; }
.en-miss { color: #8A4B12; }
@media (max-width: 380px) { .spell-slot { width: 36px; height: 44px; } .spell-tile { width: 44px; height: 48px; } }

/* ---------- v0.5.8 忘記 PIN ---------- */
.gate-forgot { margin: .9rem 0 0; }
.link-btn { text-decoration: underline; text-underline-offset: 3px; color: var(--primary); }
.pin-reset { display: grid; gap: .8rem; text-align: center; }
.pin-reset h1, .pin-reset p { margin: 0; }
.pin-reset .form { text-align: left; }
.pin-reset .notice, .pin-reset .form-error { text-align: left; }
.pin-reset-wait { display: flex; align-items: center; justify-content: center; gap: .6rem; font-weight: 700; padding: .8rem 0; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #D9C7A2; border-top-color: var(--primary); animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }


/* v0.5.9 English word sets (parent tabs, preview lists) */
.ws-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; margin: .6rem 0 .8rem; }
.ws-tab { display: grid; gap: .1rem; text-align: left; padding: .5rem .6rem; border-radius: 14px; border: 2px solid var(--line); background: #FBF8F1; color: var(--ink); font: inherit; cursor: pointer; min-width: 0; }
.ws-tab.is-on { border-color: var(--primary); background: #EEF2FF; }
.ws-tab-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-tab .ws-feat { justify-self: start; font-size: .72rem; }
.ws-tab-date { font-size: .72rem; }
.ws-head { display: grid; gap: .4rem; margin-bottom: .4rem; }
.ws-head .row input { flex: 1; min-width: 0; }
.ws-summary { font-weight: 800; background: #EEF2FF; border-radius: 12px; padding: .5rem .7rem; }
.ws-rejected { background: #FFF1E6; border-radius: 12px; padding: .5rem .7rem; }
.ws-rejected p { margin: 0 0 .3rem; font-weight: 700; }
.ws-rejected ul { margin: 0; padding-left: 1.2rem; display: grid; gap: .15rem; }
.en-prow.is-bad { border-color: var(--danger); }
.ws-random { margin-top: 1rem; border-top: 2px dashed var(--line); padding-top: .8rem; }
.ws-switch { font-weight: 700; }
.ws-missed { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.ws-miss { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .45rem .6rem; border-radius: 12px; background: #F7F4EC; }
.ws-miss-pick select { font: inherit; margin-left: .3rem; }
@media (min-width: 720px) { .ws-tabs { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* v0.5.9 child set picker + word preview */
.set-cards { display: grid; gap: .7rem; margin: .6rem 0 1rem; }
.set-card { display: grid; gap: .25rem; text-align: left; padding: .8rem 1rem; border-radius: 18px; border: 2px solid var(--line); background: #F4F6FF; color: var(--ink); font: inherit; cursor: pointer; }
.set-card.is-featured { border-color: var(--secondary); background: #FFF8E1; }
.set-card-top { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: 1.1rem; }
.set-card-words { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-word-list { margin: .5rem 0 1rem; padding-left: 1.6rem; display: grid; gap: .35rem; max-height: 52vh; overflow-y: auto; }
.set-word-list li { padding: .3rem .4rem; border-bottom: 1px solid var(--line); }
.set-word-list li b { display: inline-block; min-width: 7.5rem; font-size: 1.1rem; margin-right: .6rem; }
.rw-words ul { list-style: none; padding: 0; display: grid; gap: .3rem; }

/* ---------- v0.5.9 part 3: styles (換精靈 / egg + BB picks / 精靈 shop) ---------- */
.skin-home { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.skin-change { align-self: center; }
.skin-card-home, .hatch-pick { border: 2px dashed #f3c76b; background: #fffaf0; border-radius: 16px; padding: 10px 12px; }
.skin-card-home h3, .hatch-pick h3 { margin: 0 0 4px; font-size: 1.05rem; }
.skin-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 8px; }
.skin-choice { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 44px; padding: 6px; border: 2px solid #eadfcb; border-radius: 14px; background: #fff; cursor: pointer; font: inherit; color: inherit; }
.skin-choice.is-on, .skin-choice:focus-visible { border-color: #5b7cfa; box-shadow: 0 0 0 3px rgba(91, 124, 250, .25); }
.skin-choice-name { font-weight: 700; font-size: .95rem; }
.skin-choice-sub { text-align: center; line-height: 1.25; }
.skin-thumb { display: block; width: 100%; max-width: 110px; aspect-ratio: 1 / 1; object-fit: contain; margin: 0 auto; }
.skin-thumb.is-locked { filter: grayscale(1); opacity: .45; }
.skin-thumb-none { display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 800; color: #b9a98c; background: #f6efe2; border-radius: 12px; max-width: 90px; }
.skin-notice { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 14px; background: #eef4ff; border: 1px solid #c9d7ff; }
.wardrobe h1 { margin-bottom: 4px; }
.wardrobe-preview { display: flex; justify-content: center; }
.skin-grid { list-style: none; padding: 0; margin: 10px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.skin-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px; border: 2px solid #eadfcb; border-radius: 16px; background: #fffdf8; text-align: center; min-width: 0; }
.skin-card.is-on { border-color: #22c55e; background: #f0fdf4; }
.skin-card.is-locked { background: #faf7f2; }
.skin-card .skin-how, .skin-card .skin-grows { margin: 0; overflow-wrap: anywhere; }
.skin-grows ul { margin: 2px 0 0; padding-left: 1.1em; text-align: left; }
.badge-on { background: #dcfce7; color: #166534; }
.egg-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.egg-opt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border: 2px solid #eadfcb; border-radius: 12px; cursor: pointer; min-height: 44px; }
.egg-opt { position: relative; }
.egg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; margin: 0; padding: 0; pointer-events: none; }
.egg-opt:has(input:focus-visible) { outline: 3px solid #A9B8FF; outline-offset: 2px; }
.egg-opt:has(input:checked) { border-color: #5b7cfa; background: #eef2ff; }
.egg-pic .skin-thumb { max-width: 64px; }
.egg-name { font-size: .85rem; font-weight: 700; }
.shop-skins { margin-bottom: 14px; }
.line-card.is-coming .item-img { opacity: .6; }
.line-card .bar { width: 100%; }
.evolve-style, .levelup-gift, .levelup-stars { font-weight: 700; margin: 4px 0; }
.line-card .badge, .skin-card .badge { white-space: normal; }

/* Line styles (growth/final cut-outs): their head offsets (skins.json slots_by_stage) put taller hats at the
   very top of the 512 canvas, and the idle bob lifts them 2.5% more, so .sp-canvas overflow:hidden cut the
   hat top. Here the top edge alone may show up to 16% above the box (sides/bottom keep the rounded clip),
   and a worn background item counter-bobs so it stays inside. Original looks are unchanged. */
.sp-canvas[data-skin^="skin_"] { overflow: visible; clip-path: inset(-16% 0 0 0 round 24px); }
.sp-canvas[data-skin^="skin_"] .sp-inner > .sp-background { animation: bob-counter 3s ease-in-out infinite; }
@keyframes bob-counter { 50% { transform: translateY(2.5%); } }

/* frames and bought backgrounds: canvas-sized, not inside the body scale or the bob */
.sp-cosmetic { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.sp-cosmetic-bg { z-index: 0; }
.sp-cosmetic-frame { z-index: 1; }
.shop-cosmetics { margin-bottom: 14px; }
.shop-cosmetics .item-img img { width: 72px; height: 72px; object-fit: contain; }

/* v0.5.10 spelling difficulty picker */
.diff-picker { margin: .8rem 0 1rem; text-align: center; }
.diff-label { margin: 0 0 .45rem; font-weight: 800; }
.diff-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; }
.diff-btn { min-width: 4.5rem; padding: .55rem 1rem; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 800; cursor: pointer; }
.diff-btn.is-on { border-color: var(--secondary); background: #FFF3C4; box-shadow: 0 0 0 2px rgba(255, 193, 7, .25); }
.ws-diff { margin: 1rem 0 .6rem; padding-top: .6rem; border-top: 1px dashed var(--line); }
.ws-diff .diff-picker { margin: .4rem 0 0; text-align: left; }
.ws-diff .diff-btns { justify-content: flex-start; }
.rw-gate { text-align: center; }

/* v0.5.11 我的檔案 */
.profile-card h1 { margin: 0 0 .4rem; font-size: 1.35rem; }
.profile-email-label { margin: .8rem 0 .2rem; font-weight: 700; }
.profile-email { margin: 0; padding: .65rem .9rem; border-radius: 14px; background: #F4F6FF; border: 2px solid var(--line); font-size: 1.05rem; font-weight: 700; word-break: break-all; }

/* v0.5.11 parent account email (visible after PIN) */
.account-email { margin: .35rem 0 .5rem; padding: .55rem .8rem; border-radius: 14px; background: #F4F6FF; border: 2px solid var(--line); font-size: 1.05rem; font-weight: 800; word-break: break-all; }
.p-account { order: -1; }

/* ---------- care v1 (design_v0.5.14) ---------- */
.care-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .4rem 0 .2rem; }
.care-bar .care-mood { margin-left: auto; font-weight: 700; }
.care-hint { margin: 0 0 .4rem; }

/* —— 小田 #/ranch (v0.5.14) —— */
.ranch-page h1 { margin: 0; font-size: 1.35rem; }
.ranch-page h2 { margin: 1rem 0 .5rem; font-size: 1.05rem; }
.plot-grid {
  list-style: none; padding: 0; margin: .6rem 0 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem;
}
.plot-card {
  background: linear-gradient(180deg, #e8f7e4, #f7fbf5);
  border: 2px solid #b7dfb0; border-radius: 16px; padding: .6rem;
  display: flex; flex-direction: column; gap: .4rem; min-width: 0;
}
.plot-art { position: relative; aspect-ratio: 1; display: grid; place-items: center; }
.plot-stage-img { width: 88%; height: 88%; object-fit: contain; }
.plot-seed-badge, .plot-fruit-badge {
  position: absolute; width: 36%; height: 36%; object-fit: contain;
  top: 8%; right: 8%; filter: drop-shadow(0 1px 2px rgba(0,0,0,.15));
}
.plot-meta { display: flex; flex-direction: column; gap: .15rem; }
.plot-idx { font-weight: 800; font-size: .9rem; }
.plot-actions .btn { flex: 1 1 auto; }
.seed-stock-list, .ranch-shop, .plot-basket-list, .plant-seed-list {
  list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem;
}
.seed-stock-list { flex-direction: row; flex-wrap: wrap; }
.seed-stock {
  display: flex; align-items: center; gap: .35rem;
  background: #fff8e8; border-radius: 999px; padding: .25rem .55rem;
  border: 1px solid #f0d9a0; font-size: .85rem;
}
.seed-stock img { width: 28px; height: 28px; object-fit: contain; }
.ranch-shop-row, .plot-basket-item {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  background: #fff; border: 1px solid #e6e0d4; border-radius: 14px; padding: .55rem .65rem;
}
.ranch-shop-row img, .plot-basket-item img { width: 48px; height: 48px; object-fit: contain; }
.ranch-shop-info { flex: 1 1 120px; min-width: 0; display: flex; flex-direction: column; }
.ranch-attr-pick { font-size: .9rem; border-radius: 8px; padding: .25rem .4rem; }
.plant-seed-list button { width: 100%; display: flex; align-items: center; gap: .5rem; justify-content: flex-start; }
@media (min-width: 700px) {
  .plot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* plant modal empty + scrollable seed list */
.plant-seed-list {
  max-height: min(50vh, 320px);
  overflow-y: auto;
  margin-bottom: .6rem;
}
.plant-seed-empty {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .75rem;
  padding: .35rem 0 .2rem;
}
.plant-seed-empty p {
  margin: 0;
  color: #6B6358;
  font-size: .95rem;
  line-height: 1.45;
  text-align: center;
}
.plant-seed-empty .btn { width: 100%; }

/* compact plots on phone so 6 plots + shop stay scrollable */
@media (max-width: 699px) {
  .plot-card { padding: .45rem; gap: .3rem; }
  .plot-art { aspect-ratio: 1.15; max-height: 110px; }
  .plot-stage-img { width: 82%; height: 82%; }
  .plot-seed-badge, .plot-fruit-badge { width: 32%; height: 32%; }
  .plot-idx { font-size: .82rem; }
  .plot-label { font-size: .75rem; line-height: 1.25; }
  .plot-actions .btn { font-size: .78rem; padding: .35rem .45rem; }
}

/* —— 地圖 hub #/map (v0.5.15) —— */
/* Ray square frame: .map-stage-inner inset 0 so hub purple fills square; cream only outside stage (page); contain = full disc＋rim; §3.3h Art PNG 05e7db00… */
.map-hub { display: flex; flex-direction: column; gap: .45rem; max-width: 640px; margin: 0 auto; width: 100%; }
.map-today { padding: .4rem .7rem; }
.map-today-toggle {
  appearance: none; border: 0; background: transparent; width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  font: inherit; font-weight: 800; cursor: pointer; padding: 0; color: inherit; text-align: left;
}
.map-today.is-collapsed .map-job-list { display: none; }
.map-job-list {
  list-style: none; margin: .45rem 0 0; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .6rem;
}
.map-job {
  display: flex; align-items: center; gap: .35rem;
  background: #F5F0E6; border-radius: 999px; padding: .28rem .65rem; font-weight: 700; font-size: .9rem;
}
.map-job.is-done { background: #E4F6EA; color: #1B7A4A; }
.map-job.is-done .map-job-check { animation: map-job-pop .28s ease-out; }
.map-job.is-optional:not(.is-done) { opacity: .85; }
.map-job-check { width: 1.1em; text-align: center; font-weight: 900; }
@keyframes map-job-pop { from { transform: scale(.6); opacity: .3; } to { transform: scale(1); opacity: 1; } }

.map-stage {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 18px; overflow: hidden;
  /* §3.3h / Ray ref: cream stage under plate; purple atmosphere from hub PNG fills square (inner inset 0) */
  background: #FFF7E8; box-shadow: 0 4px 14px rgba(80, 60, 20, .07); border: none;
  touch-action: manipulation;
  /* Large square stage; cap by remaining viewport under topbar+nav+compact today */
  max-width: min(100%, calc(100dvh - var(--nav-h) - var(--top-h) - 5.5rem));
  margin-inline: auto;
}
/* inset 0: hub plate full-bleed in square (purple corners); cream only outside .map-stage */
.map-stage-inner {
  position: absolute; inset: 0;
  /* children (bg/hotspots) fill stage — hotspot % stay aligned with art */
}
/* contain = full square plate + full circle visible (no crop of rim/buildings) */
.map-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
.map-center {
  position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%);
  width: 22%; height: 22%; object-fit: contain; pointer-events: none; z-index: 1;
}
.map-buildings { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.map-building {
  position: absolute; transform: translate(-50%, -50%);
  width: 32%; height: 32%; object-fit: contain;
  pointer-events: none; user-select: none;
  filter: drop-shadow(0 3px 6px rgba(40,30,10,.14));
}
/* Transparent tappable zones — names baked into bg; no pin icons / no label pills */
.map-hotspots { position: absolute; inset: 0; z-index: 3; }
.map-hotspot {
  position: absolute; transform: translate(-50%, -50%);
  appearance: none; border: 0; background: transparent; padding: 0;
  cursor: pointer; min-width: 72px; min-height: 48px; width: 24%; height: 14%;
  touch-action: manipulation; transition: transform .1s ease;
}
.map-hotspot:active, .map-hotspot.is-press { transform: translate(-50%, -50%) scale(.94); }
.map-hotspot:focus-visible {
  outline: 2px solid rgba(60,120,200,.55); outline-offset: 2px; border-radius: 12px;
}

.map-hint { text-align: center; margin: 0; }
@media (max-width: 480px) {
  .map-hub { gap: .35rem; }
  .map-stage { border-radius: 14px; max-width: min(100%, calc(100dvh - var(--nav-h) - var(--top-h) - 5rem)); }
  .map-hint { margin-top: .1rem; }
}
@media (min-width: 700px) {
  .map-hub { max-width: 680px; }
}

/* —— Slice A map walk (design_v0.5.17; Art concept A four-way) —— */
.map-hub--walk .map-stage { touch-action: none; }
.map-player {
  position: absolute; left: 50%; top: 52%;
  transform: translate(-50%, -78%);
  width: 18%; max-width: 72px; aspect-ratio: 1;
  z-index: 5; pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(40,30,10,.28));
}
.map-player--art {
  width: 22%; max-width: 88px;
}
.map-player-sprite {
  width: 100%; height: 100%; object-fit: contain;
  display: block; image-rendering: auto;
  user-select: none; -webkit-user-drag: none;
}
.map-player-bob {
  position: relative; width: 100%; height: 100%;
  animation: map-player-bob 1.1s ease-in-out infinite;
}
.map-player.is-walk .map-player-bob { animation-duration: .45s; }
.map-player--art .map-player-bob { animation: none; }
@keyframes map-player-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8%); }
}
.map-player-face {
  width: 100%; height: 100%; object-fit: contain;
  display: block; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #FFE9A8, #F4B84A 60%, #E0892A);
  border: 2px solid #fff; box-sizing: border-box;
}
.map-player-dot {
  display: block; width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #9BE7FF, #3BA7F0 55%, #1E6FBF);
  border: 2px solid #fff; box-sizing: border-box;
}
.map-player-badge {
  position: absolute; right: -6%; top: -6%;
  font-size: .55rem; font-weight: 900; line-height: 1;
  background: #FF6B6B; color: #fff; border-radius: 999px;
  padding: .15rem .28rem; border: 1.5px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.map-player.face-left .map-player-face,
.map-player.face-left .map-player-dot { transform: scaleX(-1); }
/* Art left frames are already flipped PNGs — do NOT scaleX again */
.map-hotspot.is-near {
  outline: 2px dashed rgba(60,140,220,.55); outline-offset: 2px; border-radius: 14px;
}
.map-enter {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  margin: .15rem auto 0; padding: .35rem .7rem;
  background: #FFFDF8; border: 1.5px solid #E8D9B8; border-radius: 999px;
  box-shadow: 0 2px 8px rgba(80,60,20,.08); max-width: 92%;
}
.map-enter[hidden] { display: none !important; }
.map-enter-label { font-weight: 800; font-size: .92rem; }
.map-enter-btn {
  appearance: none; border: 0; cursor: pointer;
  background: #3BA7F0; color: #fff; font: inherit; font-weight: 900;
  border-radius: 999px; padding: .35rem .9rem;
  box-shadow: 0 2px 0 #1E6FBF;
}
.map-enter-btn.is-press { transform: scale(.96); }
.map-stick {
  position: absolute; left: .6rem; bottom: calc(var(--nav-h) + .55rem);
  z-index: 6; width: 96px; height: 96px;
  /* stick sits over page chrome; map-hub is relative via stage parent — pin to view */
}
.map-hub--walk { position: relative; }
.map-hub--walk .map-stick {
  position: relative; left: auto; bottom: auto;
  margin: .15rem auto .1rem; width: 100px; height: 100px;
}
.map-stick-base {
  width: 100%; height: 100%; border-radius: 50%;
  background: rgba(40,50,70,.18); border: 2px solid rgba(255,255,255,.65);
  box-shadow: inset 0 2px 8px rgba(0,0,0,.12);
  touch-action: none; position: relative;
}
.map-stick-knob {
  position: absolute; left: 50%; top: 50%; width: 42%; height: 42%;
  margin: -21% 0 0 -21%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #D8E6F5 55%, #8FAFCF);
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.22);
  pointer-events: none; will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
  .map-player-bob { animation: none; }
}


/* gloss absorb weekly admin (#/admin/gloss-absorb) */
.gloss-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.gloss-table th, .gloss-table td { text-align: left; padding: .4rem .35rem; border-bottom: 1px solid #EFE9DE; vertical-align: middle; }
.gloss-table thead th { font-size: .78rem; color: #6B6358; font-weight: 700; }
.gloss-table input[data-testid=gloss-edit] { width: 6.5rem; max-width: 100%; }
.en-absorb-opt { display: flex; align-items: flex-start; gap: .4rem; margin: .5rem 0 .2rem; }

/* gloss absorb weekly report v0.2 */
.gloss-summary { display: flex; flex-wrap: wrap; gap: .5rem .9rem; margin: .5rem 0 .75rem; font-size: .86rem; }
.gloss-summary b { color: #3D3428; }
.gloss-report-sec { margin: .85rem 0; }
.gloss-report-sec h2 { font-size: 1rem; margin: 0 0 .35rem; }
.gloss-format-fold { margin: .75rem 0; font-size: .88rem; }
.gloss-format-fold summary { cursor: pointer; font-weight: 700; color: #6B6358; }
.p-gloss-absorb .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- math_unify v0.1: roll picker + presentation placeholders ---- */
.roll-picker { text-align: center; padding: .5rem 0 1rem; }
.roll-title { margin: 0 0 .4rem; font-size: 1.35rem; }
.roll-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; margin: 1rem 0; }
.roll-btn { min-height: 56px; font-weight: 800; font-size: 1.05rem; }
.badge.diff { background: #E0E7FF; color: #3730A3; font-size: .75rem; vertical-align: middle; }

.qa-present-run, .qa-present-cake { }
.qa-skin { margin: .35rem 0 .55rem; }
.qa-skin-label { margin: .25rem 0 0; font-size: .8rem; font-weight: 700; color: var(--muted); text-align: center; }
.qa-run-track { position: relative; height: 52px; border-radius: 14px; overflow: hidden;
  background: linear-gradient(180deg, #E8F5E9, #C8E6C9); box-shadow: inset 0 -2px 0 #A5D6A7; }
.qa-run-road { position: absolute; left: 0; right: 0; bottom: 8px; height: 14px;
  background: repeating-linear-gradient(90deg, #FFF 0 12px, #81C784 12px 24px); opacity: .85; }
.qa-run-me { position: absolute; bottom: 10px; width: 28px; height: 28px; border-radius: 50%;
  background: #7C3AED; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: left .35s ease; transform: translateX(-50%); }
.qa-run-me::after { content: '🏃'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 16px; }

.cake-tray { display: flex; flex-wrap: wrap; gap: .25rem; justify-content: center; padding: .35rem; }
.cake-piece { font-size: 1.25rem; line-height: 1; transition: transform .25s, opacity .25s; display: inline-block; }
.cake-piece.is-eaten { opacity: .35; transform: scale(.7) rotate(-12deg); filter: grayscale(.4); }
.qa-skin-cake .cake-tray { background: #FFF7ED; border-radius: 14px; border: 2px dashed #FDBA74; }

.race-present-cake .race-track { background: linear-gradient(180deg, #FFF7ED, #FFEDD5); }
.race-cake { display: flex; flex-direction: column; align-items: center; gap: .15rem; flex: 1; min-width: 0; }
.race-cake .cake-tray { max-width: 100%; }
.race-cake .cake-status { font-size: .7rem; font-weight: 700; color: #9A3412; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }


/* —— 成語薄玩 story_comprehension (local; HOLD 上) —— */
.sc { display: grid; gap: .75rem; min-width: 0; }
.sc-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; font-weight: 800; }
.sc-title { margin: 0; font-size: clamp(1.25rem, 4.5vw, 1.7rem); font-weight: 800; }
.sc-body {
  max-height: min(52vh, 420px); overflow: auto; -webkit-overflow-scrolling: touch;
  padding: .9rem 1rem; background: #FFFBEF; border-radius: 16px; line-height: 1.7;
  font-size: clamp(1rem, 3.6vw, 1.15rem); white-space: pre-wrap;
}
.sc-prompt {
  text-align: center; font-size: clamp(1.15rem, 4.2vw, 1.55rem); font-weight: 800;
  padding: 1rem .7rem; background: #FFFBEF; border-radius: 16px; line-height: 1.45;
}
.sc-choices { display: grid; gap: .65rem; }
.sc-choice {
  font: inherit; font-size: clamp(1rem, 3.8vw, 1.25rem); font-weight: 700;
  min-height: 56px; padding: .65rem .9rem; border-radius: 16px; border: 3px solid #DCE3FF;
  background: #fff; color: var(--ink); cursor: pointer; touch-action: manipulation; text-align: left;
}
.sc-choice:active { transform: scale(.98); }
.sc-choice.is-correct, .sc-choice.is-answer { background: #D9F5E7; border-color: var(--ok); }
.sc-choice.is-wrong { background: #FFE0E0; border-color: var(--danger); }
.sc-picker { display: grid; gap: .7rem; }
.sc-cards { display: grid; gap: .55rem; }
.sc-card {
  display: grid; gap: .2rem; text-align: left; padding: .75rem .9rem;
  border-radius: 16px; border: 2px solid var(--line); background: #fff; cursor: pointer;
  font: inherit; color: var(--ink);
}
.sc-card:active { transform: scale(.98); }
.sc-card-idiom { font-weight: 800; font-size: 1.15rem; }
.story-gloss {
  margin: .4rem 0 .6rem; padding: .7rem .9rem; border-radius: 14px;
  background: #EEF6FF; border: 2px solid #C9E0FF; text-align: center;
}
.story-gloss-idiom { margin: 0; font-size: 1.25rem; font-weight: 800; }
.story-gloss-meaning { margin: .25rem 0 0; }


/* —— 成語故事書翻頁 storybook (local; HOLD 上) —— */
.sc-book { gap: .55rem; }
.sc-book-title { font-size: clamp(.95rem, 3.4vw, 1.15rem); margin: 0; }
.sc-page { font-weight: 800; color: #5B6B9A; font-variant-numeric: tabular-nums; }
.sc-book-stage {
  display: grid; gap: .55rem; min-width: 0;
  touch-action: pan-y;
}
.sc-book-frame {
  margin: 0 auto; width: min(100%, 240px);
  max-height: min(30vh, 260px);
  aspect-ratio: 3 / 4;
  border-radius: 18px; overflow: hidden;
  background: #FFFBEF; border: 3px solid #E8D9B8;
  display: grid; place-items: center;
}
.sc-book-img {
  width: 100%; height: 100%;
  object-fit: contain; object-position: center;
  display: block; user-select: none; -webkit-user-drag: none;
  background: #FFFBEF;
}
.sc-book-missing { width: 100%; height: 100%; background: #F3EFE4; }
.sc-book-body {
  margin: 0; padding: .35rem .55rem;
  font-size: clamp(.82rem, 3vw, .95rem);
  line-height: 1.45; font-weight: 600;
  color: #3D4A63; text-align: left; white-space: pre-wrap;
}
.sc-book-dialogue {
  display: grid; gap: .2rem;
  margin: 0; padding: .45rem .65rem;
  background: #FFFBEF; border-radius: 14px;
}
.sc-book-speaker {
  font-size: clamp(.75rem, 2.8vw, .88rem);
  font-weight: 800; color: #C45C26;
  text-align: left; letter-spacing: .02em;
}
.sc-book-speaker.is-narrator { color: #6B7280; }
.sc-book-line {
  margin: 0; padding: 0;
  background: transparent; border-radius: 0;
  font-size: clamp(.9rem, 3.3vw, 1.05rem);
  line-height: 1.45; font-weight: 700;
  text-align: left; white-space: pre-wrap;
}
.sc-book-nav { margin-top: .1rem; }
.sc-book-nav .btn { min-height: 44px; padding: .45rem .7rem; font-size: .95rem; }
.sc-book-nav .btn-primary { flex: 1 1 auto; }
.sc-book-nav .btn[disabled] { opacity: .4; cursor: default; }
.btn.is-dim, .btn[disabled].is-dim, [data-testid=sc-start-quiz][disabled],
[data-testid=sc-start-quiz][aria-disabled="true"] {
  opacity: .45; filter: grayscale(.15); cursor: not-allowed;
}


/* Admin dedicated shell: no kid bottom padding / chrome */
body[data-admin-shell="1"] #view {
  padding-bottom: 1.5rem;
}
body[data-admin-shell="1"] #topbar .chips { display: none !important; }
body[data-admin-shell="1"] #nav { display: none !important; }
body[data-admin-shell="1"] #toasts {
  bottom: 1rem;
}
.sr-gate { max-width: 420px; margin: 1.5rem auto; }

/* —— Admin hub (#/admin) separate LOGIN entrance —— */
.admin-hub { max-width: 720px; margin: 0 auto; display: grid; gap: .65rem; }
.admin-hub-h2 { margin: .85rem 0 .25rem; font-size: 1.05rem; }
.admin-hub-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.admin-hub-row {
  display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; justify-content: space-between;
  padding: .65rem .75rem; border-radius: 14px; background: #FFFBEF; border: 1px solid var(--line);
}
.admin-hub-row-main { display: flex; flex-wrap: wrap; gap: .4rem .65rem; align-items: baseline; min-width: 0; }
.admin-hub-id { font-weight: 800; font-variant-numeric: tabular-nums; color: #5C5346; }
.admin-hub-idiom { font-weight: 800; font-size: 1.05rem; }
.admin-hub-tools { margin-top: .5rem; padding-top: .5rem; border-top: 1px dashed #D7CFC0; }
.admin-hub-google { display: grid; gap: .5rem; margin: .75rem 0 .25rem; }
.admin-hub-pin-fallback { margin-top: .85rem; padding-top: .5rem; border-top: 1px dashed #D7CFC0; }
.admin-hub-pin-fallback > summary { cursor: pointer; font-weight: 700; color: #5C5346; margin-bottom: .5rem; }
.admin-hub-deny { text-align: center; }


/* —— story review admin (#/admin/story-review/:id) —— */
.sr-admin { display: grid; gap: 1rem; min-width: 0; }
.sr-head-top { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.sr-pilot { display: inline-block; margin: 0 0 .35rem; padding: .15rem .55rem; border-radius: 999px; background: #FFF3CD; color: #7A5B00; font-size: .78rem; font-weight: 800; }
.sr-meta { margin: .2rem 0; font-size: 1.1rem; font-weight: 800; }
.sr-progress { text-align: right; font-size: .9rem; font-weight: 700; }
.sr-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.sr-list { display: grid; gap: 1rem; }
.sr-panel-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; align-items: baseline; margin-bottom: .65rem; }
.sr-panel-head h2 { margin: 0; font-size: 1.15rem; }
.sr-badges { display: flex; flex-wrap: wrap; gap: .35rem; }
.sr-badge { font-size: .75rem; font-weight: 800; padding: .2rem .5rem; border-radius: 999px; background: #F3F0EA; color: #5C5346; }
.sr-badge.is-pending { background: #F3F0EA; }
.sr-badge.is-pass { background: #D9F5E7; color: #146C43; }
.sr-badge.is-revise { background: #FFE8CC; color: #9A4D00; }
.sr-badge.is-done { background: #DCE3FF; color: #2F3A8F; }
.sr-panel-grid { display: grid; grid-template-columns: minmax(140px, 280px) minmax(0, 1fr); gap: .85rem; align-items: start; }
@media (max-width: 720px) {
  .sr-panel-grid { grid-template-columns: 1fr; }
}
.sr-art { background: #FFFBEF; border-radius: 16px; border: 1px solid var(--line); padding: .5rem; min-height: 140px; display: grid; place-items: center; }
.sr-art img { max-width: 100%; height: auto; border-radius: 12px; display: block; }
.sr-art-empty { color: var(--muted); font-size: .9rem; padding: 1.5rem .5rem; text-align: center; }
.sr-fields { display: grid; gap: .55rem; }
.sr-fields label { display: grid; gap: .25rem; font-size: .82rem; font-weight: 700; color: #6B6358; }
.sr-fields input, .sr-fields textarea {
  font: inherit; font-weight: 500; color: var(--ink); width: 100%;
  border: 2px solid #E7E0D4; border-radius: 12px; padding: .45rem .6rem; background: #fff;
}
.sr-fields textarea { resize: vertical; min-height: 2.6rem; }
.sr-gate-btns { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .25rem; }
.btn-ok { background: #DCE3FF; border-color: #A9B4F0; }
.sr-ai { margin-top: .85rem; padding: .75rem; border-radius: 14px; background: #F7F4EE; border: 1px dashed #D7CFC0; }
.sr-ai h3 { margin: 0 0 .45rem; font-size: .95rem; }
.sr-ai-log { max-height: 140px; overflow: auto; display: grid; gap: .35rem; margin-bottom: .5rem; }
.sr-ai-msg { font-size: .86rem; line-height: 1.4; background: #fff; border-radius: 10px; padding: .4rem .55rem; }
.sr-ai-msg.is-assistant { background: #EEF2FF; }
.sr-ai-compose { display: flex; flex-wrap: wrap; gap: .4rem; }
.sr-ai-compose input { flex: 1 1 12rem; font: inherit; border: 2px solid #E7E0D4; border-radius: 12px; padding: .4rem .55rem; }
.sr-ai-preview { margin: .4rem 0 0; font-size: .8rem; font-weight: 700; color: #9A4D00; }
.sr-ai-accepted { margin: .35rem 0 0; font-size: .8rem; font-weight: 800; color: #146C43; }
