:root {
  --bg: #FFF4E8;
  --bg2: #FFE9D6;
  --card: #FFFFFF;
  --ink: #4A3428;
  --ink-soft: #8C7262;
  --peach: #FF8E6E;
  --peach-deep: #F2694A;
  --butter: #FFD36E;
  --mint: #8FD9B6;
  --pink: #FFB8C6;
  --danger: #E5574F;
  --radius: 22px;
  --shadow: 0 10px 28px rgba(186, 110, 70, .16), 0 2px 6px rgba(186, 110, 70, .10);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: ui-rounded, "SF Pro Rounded", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body {
  background:
    radial-gradient(circle at 12% 8%, #FFE0CC 0 90px, transparent 91px),
    radial-gradient(circle at 92% 22%, #FFF0C2 0 60px, transparent 61px),
    radial-gradient(circle at 80% 96%, #FFE3EA 0 120px, transparent 121px),
    var(--bg);
  background-attachment: fixed;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding: calc(var(--safe-t) + 18px) 18px calc(var(--safe-b) + 96px); }
.view { animation: viewIn .38s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------- 通用 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 700; font-size: 16px;
  cursor: pointer; transition: transform .12s, box-shadow .2s, background .2s; user-select: none;
}
.btn:active { transform: scale(.95); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: linear-gradient(180deg, #FF9C7E, var(--peach-deep)); color: #fff; box-shadow: 0 6px 0 #D9573A, 0 10px 18px rgba(242, 105, 74, .3); }
.btn.primary:active { box-shadow: 0 2px 0 #D9573A; transform: translateY(4px); }
.btn.ghost { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 2px #F5D9C6; }
.btn.danger { background: #FFECEA; color: var(--danger); }
.btn.big { width: 100%; padding: 15px; font-size: 18px; }
.icon-btn { border: 0; background: #FFF1E6; border-radius: 999px; padding: 8px 12px; font-size: 20px; cursor: pointer; transition: transform .12s; }
.icon-btn:active { transform: scale(.9); }
.icon-btn.small { font-size: 14px; padding: 6px 12px; color: var(--ink-soft); font-weight: 600; }
.label { display: block; font-size: 14px; color: var(--ink-soft); font-weight: 700; margin: 10px 0 6px; }
input[type=password], input[type=search], .sheet input, .sheet textarea {
  width: 100%; border: 2px solid #F5D9C6; background: #FFFBF7; border-radius: 16px; padding: 13px 15px; font-size: 17px; outline: none; transition: border .2s, box-shadow .2s;
}
input:focus, textarea:focus { border-color: var(--peach); box-shadow: 0 0 0 4px rgba(255, 142, 110, .18); }
.sheet .label input, .sheet .label textarea { margin-top: 6px; color: var(--ink); font-weight: 500; }
.err { color: var(--danger); font-size: 14px; margin: 10px 0 0; text-align: center; }
.top { margin: 4px 0 18px; }
.top h2 { font-size: 26px; margin: 0 0 6px; letter-spacing: .5px; }
.top .sub { margin: 0; color: var(--ink-soft); }
.hl { background: linear-gradient(transparent 60%, var(--butter) 60%); padding: 0 2px; }
.count { font-size: 15px; color: var(--ink-soft); font-weight: 600; }
.spacer { flex: 1; }
.actions { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* ---------- 吉祥物：小相机 ---------- */
.mascot { position: relative; width: 132px; height: 104px; margin: 30px auto 10px; background: linear-gradient(180deg, #FFA889, var(--peach)); border-radius: 34px 34px 38px 38px; box-shadow: 0 10px 0 #E9714F, 0 18px 30px rgba(242, 105, 74, .3); }
.mascot::before { content: ""; position: absolute; left: 26px; top: -14px; width: 40px; height: 22px; border-radius: 12px 12px 4px 4px; background: #FF9E80; }
.mascot-lens { position: absolute; left: 50%; top: 50%; width: 68px; height: 68px; transform: translate(-50%, -46%); border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 7px #FFE3D6; }
.eye { position: absolute; top: 27px; width: 9px; height: 13px; border-radius: 50%; background: var(--ink); animation: blink 4s infinite; }
.eye.l { left: 20px; } .eye.r { right: 20px; }
.blush { position: absolute; top: 62px; width: 16px; height: 9px; border-radius: 50%; background: var(--pink); opacity: .9; }
.blush.l { left: 12px; } .blush.r { right: 12px; }
.mascot-flash { position: absolute; right: 16px; top: 12px; width: 14px; height: 14px; border-radius: 50%; background: var(--butter); box-shadow: 0 0 0 4px rgba(255, 211, 110, .35); animation: flash 2.4s infinite; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes flash { 0%, 80%, 100% { box-shadow: 0 0 0 4px rgba(255, 211, 110, .35); } 88% { box-shadow: 0 0 0 14px rgba(255, 211, 110, 0); } }
.bob { animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }

/* ---------- 登录 ---------- */
.login-wrap { text-align: center; padding-top: 6vh; }
.brand { font-size: 40px; margin: 22px 0 4px; letter-spacing: 4px; color: var(--peach-deep); text-shadow: 0 3px 0 #FFE0CC; }
.tagline { color: var(--ink-soft); line-height: 1.6; margin: 0 0 26px; }
.login-card { text-align: left; }
.login-card .btn { margin-top: 18px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- 拍照 ---------- */
.hello { line-height: 1.35; }
.due-pill { display: inline-block; margin-top: 6px; background: #E7F8EF; color: #2F8A5F; border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 14px; cursor: pointer; }
.snap-empty { display: flex; flex-direction: column; align-items: center; padding-top: 6vh; }
.shutter { position: relative; width: 190px; height: 190px; display: grid; place-items: center; cursor: pointer; }
.shutter-ring { position: absolute; inset: 0; border-radius: 50%; border: 4px dashed #FFC2A8; animation: spin 18s linear infinite; }
.shutter-core { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: radial-gradient(circle at 35% 30%, #FFB79E, var(--peach-deep)); box-shadow: 0 10px 0 #D9573A, 0 20px 36px rgba(242, 105, 74, .35); transition: transform .15s; animation: breathe 2.6s ease-in-out infinite; }
.shutter:active .shutter-core { transform: scale(.92) translateY(6px); box-shadow: 0 4px 0 #D9573A; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.04); } }
.hint { color: var(--ink-soft); margin: 26px 0 16px; }

.word-card { background: var(--card); border-radius: 28px; box-shadow: var(--shadow); padding: 18px 18px 20px; position: relative; overflow: hidden; }
.word-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 230px; background: repeating-linear-gradient(45deg, #FFF6EE 0 14px, #FFF0E4 14px 28px); }
.sticker-stage { position: relative; height: 250px; margin: -18px -18px 4px; display: grid; place-items: center; }
.sticker-stage > img { max-width: 78%; max-height: 210px; filter: drop-shadow(0 8px 12px rgba(120, 70, 40, .22)); animation: stickerIn .6s cubic-bezier(.2, 1.4, .4, 1) both; transform-origin: 50% 80%; }
/* 原图（抠图中 / 抠图失败 / 点选主体）：明确是照片，不加描边，不旋转 */
.photo-wrap { position: relative; max-width: 86%; max-height: 220px; border-radius: 14px; overflow: hidden; box-shadow: 0 4px 14px rgba(120, 70, 40, .18); line-height: 0; }
.photo-wrap img { max-width: 100%; max-height: 220px; display: block; }
.photo-wrap.busy img { filter: saturate(.6) brightness(1.05); }
.photo-wrap.busy::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.55) 50%, transparent 70%); background-size: 250% 100%; animation: scan 1.4s linear infinite; }
@keyframes scan { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.photo-wrap.picking { cursor: crosshair; outline: 3px dashed var(--peach); outline-offset: -3px; }
.tap-dot { position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #FF6B8B; border: 3px solid #fff; transform: translate(-50%, -50%); box-shadow: 0 2px 8px rgba(0,0,0,.25); animation: pop .3s; }
.seg-status { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,.94); color: var(--ink); font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; box-shadow: 0 2px 10px rgba(0,0,0,.08); white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis; }
.seg-status.warn { background: #FFF2CF; color: #8A5B00; white-space: normal; text-align: center; }
.seg-tools { display: flex; gap: 8px; justify-content: center; margin: 0 0 8px; }
.chip { border: 0; background: #FFF1E6; color: var(--peach-deep); font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-family: inherit; }
.chip.on { background: var(--peach-deep); color: #fff; }

/* 我的 */
.set-card { margin-bottom: 14px; }
.set-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.set-head h3 { margin: 0; font-size: 18px; }
.set-head .sub { margin: 2px 0 0; font-size: 13px; }
.set-ico { font-size: 26px; line-height: 1; }
.set-rows { background: #FFF8EF; border-radius: 14px; padding: 4px 12px; margin-bottom: 12px; }
.set-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; border-bottom: 1px dashed #F3DCC8; }
.set-row:last-child { border-bottom: 0; }
.set-row b.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.set-card > .btn { width: 100%; }
.set-card .actions { display: flex; gap: 10px; }
.set-card .actions .btn { flex: 1; text-align: center; }
.foot { text-align: center; color: #B39A8A; font-size: 12px; margin: 10px 0 30px; }
.dot-badge { position: absolute; top: 6px; right: calc(50% - 18px); width: 9px; height: 9px; border-radius: 50%; background: var(--butter, #FFC94D); border: 2px solid #fff; }
.mini .thumb img.photo, .face img.photo { transform: none; border-radius: 10px; filter: none; box-shadow: 0 2px 8px rgba(0,0,0,.12); }

@keyframes stickerIn { from { transform: scale(.3) rotate(-14deg); opacity: 0; } to { transform: scale(1) rotate(-3deg); opacity: 1; } }
.thinking { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; }
.thinking span { width: 10px; height: 10px; border-radius: 50%; background: var(--peach); animation: dot 1s infinite ease-in-out; }
.thinking span:nth-child(2) { animation-delay: .15s; background: var(--butter); }
.thinking span:nth-child(3) { animation-delay: .3s; background: var(--mint); }
.thinking p { width: 100%; text-align: center; margin: 6px 0 0; color: var(--ink-soft); font-size: 14px; }
@keyframes dot { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.word-body { position: relative; animation: viewIn .4s .05s both; }
.word-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.word { font-size: 38px; margin: 6px 0 0; letter-spacing: .5px; font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", "Nunito", system-ui, sans-serif; word-break: break-word; }
.ipa { font-family: "Charis SIL", "Doulos SIL", "Gentium Plus", "Lucida Sans Unicode", "Segoe UI", "Noto Sans", system-ui, sans-serif; color: var(--ink-soft); font-size: 17px; margin: 2px 0 0; letter-spacing: .3px; }
.ipa[hidden] { display: none; }
.zh { font-size: 20px; margin: 2px 0 12px; color: var(--peach-deep); font-weight: 700; }
.example { background: #FFF8EF; border-left: 4px solid var(--butter); border-radius: 12px; padding: 10px 12px; margin: 0 0 10px; line-height: 1.5; font-size: 16px; }
.mock-tag { color: #B39A8A; font-size: 12px; margin: 10px 0 0; }
.pop { animation: pop .45s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 词本 ---------- */
.search { margin-top: 8px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mini { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 10px 10px 12px; text-align: center; position: relative; cursor: pointer; animation: pop .4s both; transition: transform .15s; }
.mini:active { transform: scale(.96); }
.mini .thumb { height: 110px; display: grid; place-items: center; background: repeating-linear-gradient(45deg, #FFF8F1 0 10px, #FFF3E8 10px 20px); border-radius: 14px; }
.mini img { max-width: 88%; max-height: 100px; transform: rotate(-3deg); filter: drop-shadow(0 4px 6px rgba(120, 70, 40, .2)); }
.mini .w { font-weight: 800; font-size: 18px; margin-top: 8px; word-break: break-word; }
.mini .z { color: var(--ink-soft); font-size: 14px; }
.mini .ipa { font-size: 13px; margin: 0; }
.mini .lvl { position: absolute; top: 8px; right: 8px; font-size: 11px; font-weight: 700; background: #fff; border-radius: 999px; padding: 2px 8px; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.mini .spk { position: absolute; top: 6px; left: 6px; font-size: 16px; padding: 4px 8px; }
.empty { text-align: center; color: var(--ink-soft); padding: 50px 0; }
.empty-emoji { font-size: 54px; animation: bob 3s ease-in-out infinite; }

/* ---------- 复习 ---------- */
.flash { perspective: 1200px; }
.flash-inner { position: relative; transition: transform .6s cubic-bezier(.3, 1.3, .5, 1); transform-style: preserve-3d; min-height: 420px; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--card); border-radius: 28px; box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.face.back { transform: rotateY(180deg); }
.face img { max-width: 70%; max-height: 220px; transform: rotate(-3deg); filter: drop-shadow(0 8px 12px rgba(120, 70, 40, .22)); }
.face .back-thumb { max-height: 130px; max-width: 50%; margin-bottom: 4px; }
.face .q { color: var(--ink-soft); margin-top: 18px; }
.face .word { font-size: 40px; }
.face .example { text-align: left; width: 100%; }
.grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.grade .btn { padding: 14px 6px; flex-direction: column; gap: 2px; font-size: 16px; }
.grade small { font-weight: 500; opacity: .8; font-size: 12px; }
.g-again { background: #FFE6E3; color: #C9453C; }
.g-hard { background: #FFF2CF; color: #9A6B00; }
.g-good { background: #DDF5E8; color: #237A50; }
.progress { height: 10px; background: #FFE7D6; border-radius: 999px; overflow: hidden; margin-bottom: 16px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--butter), var(--peach)); border-radius: 999px; transition: width .4s; }
.done { text-align: center; padding: 40px 10px; }
.done .big-emoji { font-size: 70px; animation: bob 2.4s infinite; }

/* ---------- 底部导航 ---------- */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 12px); width: min(92vw, 420px); display: flex; background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-radius: 26px; box-shadow: 0 10px 30px rgba(186, 110, 70, .22); padding: 6px; z-index: 10; }
.tab { flex: 1; border: 0; background: transparent; padding: 8px 0 6px; border-radius: 20px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 700; color: var(--ink-soft); cursor: pointer; position: relative; transition: background .2s, color .2s; }
.tab .ti { font-size: 22px; transition: transform .25s cubic-bezier(.2, 1.6, .4, 1); }
.tab.active { background: #FFEEE3; color: var(--peach-deep); }
.tab.active .ti { transform: translateY(-2px) scale(1.15); }
.badge { position: absolute; top: 4px; right: calc(50% - 26px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--peach-deep); color: #fff; font-size: 11px; font-style: normal; display: grid; place-items: center; }

/* ---------- 弹窗 & 提示 ---------- */
.sheet { border: 0; border-radius: 26px; padding: 22px; width: min(92vw, 440px); background: #fff; box-shadow: 0 20px 60px rgba(80, 40, 20, .3); color: var(--ink); }
.sheet::backdrop { background: rgba(74, 52, 40, .35); backdrop-filter: blur(3px); }
.sheet[open] { animation: pop .3s cubic-bezier(.2, 1.3, .4, 1); }
.sheet h3 { margin: 0 0 6px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 100px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600; z-index: 20; animation: toastIn .3s cubic-bezier(.2, 1.4, .4, 1); white-space: nowrap; }
@keyframes toastIn { from { transform: translate(-50%, 20px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.no-img { font-size: 34px; opacity: .5; }
