/* 猪咪教学 · 苹果风：留白、系统字体、圆角卡片、克制的色彩。OC 元素只出现在头像/地图/奖励/弹窗。 */
:root {
  --bg: #f2f2f7; --card: #ffffff; --text: #1c1c1e; --text2: #6e6e73; --text3: #aeaeb2;
  --line: #e5e5ea; --blue: #007aff; --green: #34c759; --orange: #ff9500; --red: #ff3b30; --pink: #ff6b9d; --purple: #af52de; --teal: #5ac8fa;
  --bubble-ai: #ffffff; --bubble-me: #007aff; --radius: 16px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --text: #f2f2f7; --text2: #98989d; --text3: #636366; --line: #2c2c2e; --bubble-ai: #2c2c2e; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
body { padding-top: var(--safe-t); }
button { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
h1 { font-size: 28px; font-weight: 700; margin: 8px 0 12px; letter-spacing: -0.3px; }
h2 { font-size: 20px; font-weight: 600; margin: 18px 0 8px; }
h3 { font-size: 16px; font-weight: 600; margin: 12px 0 6px; }
.muted { color: var(--text2); } .small { font-size: 13px; } .tiny { font-size: 12px; color: var(--text3); }
.page { max-width: 640px; margin: 0 auto; padding: 12px 16px calc(90px + var(--safe-b)); min-height: 100vh; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card.tap { cursor: pointer; transition: transform .1s; } .card.tap:active { transform: scale(.985); }
.row { display: flex; align-items: center; gap: 10px; } .row.between { justify-content: space-between; } .row.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 14px; padding: 13px 18px; font-size: 16px; font-weight: 600; background: var(--blue); color: #fff; cursor: pointer; transition: opacity .15s, transform .1s; }
.btn:active { transform: scale(.97); } .btn:disabled { opacity: .45; }
.btn.big { width: 100%; padding: 16px; font-size: 17px; }
.btn.secondary { background: var(--card); color: var(--blue); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--blue); padding: 8px 10px; }
.btn.danger { background: var(--red); } .btn.green { background: var(--green); } .btn.orange { background: var(--orange); } .btn.gray { background: var(--line); color: var(--text); }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line); color: var(--text2); }
.pill.blue { background: #e5f1ff; color: var(--blue); } .pill.green { background: #e3f8e8; color: #1e8f3e; } .pill.orange { background: #fff1de; color: #b36200; } .pill.red { background: #ffe5e3; color: #c0271d; } .pill.pink { background: #ffe6ef; color: #c2185b; } .pill.purple { background: #f1e4ff; color: #6f22b5; }
@media (prefers-color-scheme: dark) { .pill.blue{background:#0a2540} .pill.green{background:#0f2e18} .pill.orange{background:#3a2400} .pill.red{background:#3d0f0c} .pill.pink{background:#3d0f22} .pill.purple{background:#2a1040} }
input, textarea, select { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%; outline: none; }
input:focus, textarea:focus { border-color: var(--blue); }
label.field { display: block; margin: 10px 0; } label.field > span { display: block; font-size: 13px; color: var(--text2); margin-bottom: 4px; }
.switch { position: relative; width: 51px; height: 31px; flex: none; } .switch input { opacity: 0; width: 0; height: 0; }
.switch .k { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; } .switch .k::before { content: ""; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px; background: #fff; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + .k { background: var(--green); } .switch input:checked + .k::before { transform: translateX(20px); }
.list .item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); } .list .item:last-child { border-bottom: none; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.92); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 6px 0 calc(6px + var(--safe-b)); z-index: 20; }
@media (prefers-color-scheme: dark) { .nav { background: rgba(28,28,30,.92); } }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--text2); padding: 4px 10px; min-width: 60px; } .nav a.active { color: var(--blue); } .nav a .ic { font-size: 22px; line-height: 1; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 4px; }
.topbar .back { font-size: 17px; color: var(--blue); padding: 6px 0; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, #ffd6e7, #ffe9f2); display: flex; align-items: center; justify-content: center; font-size: 28px; overflow: hidden; flex: none; } .avatar img { width: 100%; height: 100%; object-fit: cover; }
.stat { text-align: center; padding: 8px 4px; } .stat b { display: block; font-size: 22px; font-weight: 700; } .stat span { font-size: 12px; color: var(--text2); }
.toast { position: fixed; left: 50%; top: calc(20px + var(--safe-t)); transform: translateX(-50%); background: rgba(28,28,30,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 100; max-width: 90vw; }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + var(--safe-b)); width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .6 } to { transform: none; opacity: 1 } }
.sheet.center { border-radius: 20px; margin: 0 16px 40vh; align-self: center; }
/* 聊天 */
.chat { display: flex; flex-direction: column; gap: 8px; padding: 8px 0 12px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 18px; font-size: 16px; line-height: 1.5; word-break: break-word; position: relative; }
.msg.ai { align-self: flex-start; background: var(--bubble-ai); border-bottom-left-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.msg.me { align-self: flex-end; background: var(--bubble-me); color: #fff; border-bottom-right-radius: 6px; }
.msg.sys { align-self: center; background: transparent; color: var(--text2); font-size: 13px; text-align: center; max-width: 95%; }
.msg.variant { border: 1.5px solid var(--purple); background: var(--card); align-self: stretch; max-width: 100%; }
.msg.card { background: linear-gradient(135deg, #fff5f9, #fff); border: 1px solid #ffd6e7; align-self: stretch; max-width: 100%; }
.msg.lesson { border-left: 4px solid var(--teal); align-self: stretch; max-width: 100%; background: var(--card); }
.msg .fb { position: absolute; right: -4px; bottom: -14px; display: flex; gap: 6px; } .msg .fb button { border: none; background: var(--card); border-radius: 999px; font-size: 11px; padding: 2px 8px; color: var(--text2); box-shadow: 0 1px 2px rgba(0,0,0,.1); } .msg .fb button.on { color: var(--blue); }
.msg img { max-width: 100%; border-radius: 10px; }
.typing { display: inline-block; width: 8px; height: 8px; background: var(--text3); border-radius: 50%; margin: 0 2px; animation: blink 1s infinite; } .typing:nth-child(2){animation-delay:.2s} .typing:nth-child(3){animation-delay:.4s}
@keyframes blink { 0%,80%,100%{opacity:.2} 40%{opacity:1} }
.composer { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding: 8px 10px calc(8px + var(--safe-b)); z-index: 30; }
.composer .inner { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.composer .line { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 44px; max-height: 120px; resize: none; border-radius: 22px; padding: 11px 14px; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--line); font-size: 20px; display: flex; align-items: center; justify-content: center; flex: none; cursor: pointer; }
.iconbtn.primary { background: var(--blue); color: #fff; }
.iconbtn.rec { background: var(--red); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(255,59,48,.5)} 100%{box-shadow:0 0 0 14px rgba(255,59,48,0)} }
.mathkeys { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0; } .mathkeys button { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 6px 10px; font-size: 15px; white-space: nowrap; }
.voicebar { width: 100%; padding: 14px; border-radius: 22px; background: var(--blue); color: #fff; font-weight: 600; text-align: center; user-select: none; -webkit-user-select: none; } .voicebar.on { background: var(--red); }
.problem-card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; font-size: 15px; }
.problem-card .thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; float: right; margin-left: 10px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; } .timer.over { color: var(--red); }
.pause-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 40px; text-align: center; }
.pause-overlay .big-ico { font-size: 80px; }
.progressbar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; } .progressbar i { display: block; height: 100%; background: var(--blue); border-radius: 3px; transition: width .3s; }
.kp { display: inline-block; margin: 3px 4px 3px 0; padding: 6px 10px; border-radius: 10px; font-size: 13px; background: var(--line); color: var(--text2); }
.kp.l1 { background: #fff1de; color: #b36200; } .kp.l2 { background: #e3f8e8; color: #1e8f3e; } .kp.l3 { background: #34c759; color: #fff; } .kp.fail { background: #ffe5e3; color: #c0271d; }
.chip { display: inline-block; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); margin: 4px 6px 4px 0; font-size: 14px; cursor: pointer; } .chip.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.katex { font-size: 1.05em; } .katex-display { margin: 6px 0; }
.center { text-align: center; } .mt { margin-top: 12px; } .mb { margin-bottom: 12px; }
.hero { background: linear-gradient(135deg, #ffe6ef 0%, #f3e8ff 60%, #e6f4ff 100%); border-radius: 20px; padding: 18px; margin: 8px 0 12px; }
@media (prefers-color-scheme: dark) { .hero { background: linear-gradient(135deg, #3a1a2a, #24163a, #0f2740); } }
.hero .name { font-size: 22px; font-weight: 700; }
.bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; } .bar > * { flex: none; }
table { width: 100%; border-collapse: collapse; font-size: 14px; } th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); } th { color: var(--text2); font-weight: 500; font-size: 12px; }
.tabs { display: flex; gap: 4px; background: var(--line); border-radius: 12px; padding: 3px; margin: 8px 0; } .tabs button { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 10px; font-size: 14px; color: var(--text2); } .tabs button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.md p { margin: 6px 0; } .md h1, .md h2, .md h3 { margin: 12px 0 6px; } .md ul, .md ol { padding-left: 20px; } .md code { background: var(--line); padding: 1px 5px; border-radius: 5px; font-size: 13px; } .md pre { background: var(--line); padding: 10px; border-radius: 10px; overflow: auto; font-size: 12px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; } @keyframes spin { to { transform: rotate(360deg) } }
.oc-bubble { position: relative; background: var(--card); border-radius: 16px; padding: 12px; margin-left: 12px; } .oc-bubble::before { content: ""; position: absolute; left: -8px; top: 18px; border: 8px solid transparent; border-right-color: var(--card); border-left: 0; }
.fade { animation: fade .25s ease-out; } @keyframes fade { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
.hidden { display: none !important; }
