/* 肥嘟嘟左卫门主题 · 视觉层
   只改观感，不动任何业务类名和接口；加载顺序在 style.css 之后，靠同名变量覆盖。 */

:root {
  --ink: #4a3038;
  --muted: #7b6167;
  --line: #f1ddd9;
  --accent: #e0698b;
  --green: #4c9a7c;
  --bg: #fff6f2;
  --red: #cf4f4a;
  --amber: #c2813a;
  --pork-skin: #ffd9e0;
  --pork-rose: #f4aebd;
  --pork-cream: #fffaf6;
  --pork-gold: #f4c25a;
  --shadow-soft: 0 10px 28px rgba(120, 63, 78, .10);
  --shadow-lift: 0 16px 40px rgba(120, 63, 78, .16);
  --radius: 16px;
}

body {
  background:
    radial-gradient(1200px 600px at 12% -10%, #ffe6ec 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 8%, #fff1dc 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- 侧栏 ---------- */
.sidebar {
  background: linear-gradient(180deg, #fffaf7 0%, #fff4f1 100%);
  border-right: 1px solid var(--line);
}
.brand {
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand::before {
  content: "";
  width: 30px; height: 30px;
  flex: 0 0 auto;
  background: url("/assets/mascot.svg") center/contain no-repeat;
  filter: drop-shadow(0 3px 6px rgba(224, 105, 139, .28));
}
.brand small { color: var(--muted); }
.nav a {
  border-radius: 12px;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav a:hover { background: #fff0f3; color: var(--ink); transform: translateX(2px); }
.nav a.active {
  background: linear-gradient(135deg, #ffd7e1, #ffeaf0);
  box-shadow: inset 0 0 0 1px #f2b9c8, 0 4px 12px rgba(224, 105, 139, .14);
  color: #8f3350;
  font-weight: 650;
  position: relative;
}
.nav a.active::before {
  content: "";
  position: absolute;
  left: -12px; top: 50%;
  width: 4px; height: 22px;
  border-radius: 4px;
  background: var(--accent);
  transform: translateY(-50%);
}

/* ---------- 卡片 / 标题 ---------- */
.card {
  border-radius: var(--radius);
  border: 1px solid #ecd8d4;
  background: #fffdfb;
  box-shadow: 0 8px 22px rgba(120, 63, 78, .09), 0 1px 0 #fff inset;
  transition: box-shadow .25s ease, transform .25s ease;
}
.card:hover { box-shadow: var(--shadow-lift); }
h1 { letter-spacing: -.4px; }
h2 { letter-spacing: -.2px; }
.page-head h1::after {
  content: "";
  display: block;
  width: 46px; height: 4px;
  margin-top: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--pork-gold));
}

/* ---------- 指标卡 ---------- */
.stat {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: radial-gradient(120% 120% at 100% 0%, #fff3f6 0%, #fffdfb 55%);
  box-shadow: var(--shadow-soft);
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.stat strong { color: var(--ink); }

/* ---------- 按钮 ---------- */
button {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
button:hover { border-color: var(--pork-rose); background: #fff7f9; }
button:active { transform: scale(.97); }
button.primary {
  background: linear-gradient(135deg, #ec7a99, #d95d80);
  border-color: #d95d80;
  box-shadow: 0 8px 18px rgba(217, 93, 128, .28);
}
button.primary:hover {
  background: linear-gradient(135deg, #ef87a3, #dd6a8b);
  box-shadow: 0 10px 22px rgba(217, 93, 128, .34);
}
button.danger { color: var(--red); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 选项：选中像盖章 ---------- */
.option {
  border-radius: 14px;
  background: #fff;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.option:hover { border-color: var(--pork-rose); box-shadow: 0 6px 16px rgba(224, 105, 139, .12); transform: translateY(-1px); }
.option:has(input:checked) {
  border-color: var(--accent);
  background: linear-gradient(135deg, #fff2f5, #fff8f9);
  box-shadow: 0 8px 20px rgba(224, 105, 139, .18);
  animation: pop .28s cubic-bezier(.34, 1.56, .64, 1);
}
.option input { accent-color: var(--accent); }

/* ---------- 判卷动画 ---------- */
.result {
  border-radius: 14px;
  border-left-width: 4px;
  background: linear-gradient(135deg, #eef8f2, #f7fdfa);
  animation: rise .34s cubic-bezier(.22, 1, .36, 1);
  position: relative;
  overflow: hidden;
}
.result.wrong { background: linear-gradient(135deg, #fdeeee, #fff7f6); }
.verdict {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px dashed #dfeeE6;
}
.result.wrong .verdict { border-bottom-color: #f0d2d2; }
.verdict-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #57b18d, #3f8f6e);
  color: #fff;
  font-size: 22px;
  box-shadow: 0 8px 18px rgba(76, 154, 124, .3);
  animation: stamp .46s cubic-bezier(.2, 1.5, .4, 1) .05s backwards;
}
.verdict-mark::before { content: "✓"; }
.result.wrong .verdict-mark {
  background: linear-gradient(135deg, #e0696a, #c84642);
  box-shadow: 0 8px 18px rgba(207, 79, 74, .28);
}
.result.wrong .verdict-mark::before { content: "✕"; }
.verdict-body h3 {
  font-size: 34px;
  font-weight: 750;
  line-height: 1.1;
  margin: 0;
  letter-spacing: -1px;
  color: #1f6a4c;
  font-variant-numeric: tabular-nums;
}
.result.wrong .verdict-body h3 { color: #9e2f2b; }
.verdict-body h3:has(+ .verdict-line) { margin-bottom: 2px; }
.verdict-line {
  margin: 5px 0 0;
  font-size: 14.5px;
  color: #5b4147;
  letter-spacing: .1px;
}
.verdict-line b { color: var(--ink); }

/* 选项判卷标记 */
/* 答对的那一项：即使被选中，也用绿色盖住选中态的粉色 */
.option.correct,
.option.correct:has(input:checked) {
  border-color: #85c9ad;
  background: linear-gradient(135deg, #eafaf2, #f6fffa);
  box-shadow: 0 6px 16px rgba(76, 154, 124, .14);
}
.option.chosen-wrong,
.option.chosen-wrong:has(input:checked) {
  border-color: #e5a3a0;
  background: linear-gradient(135deg, #fdeeee, #fff7f6);
}
.option.correct input { accent-color: var(--green); }
.option.chosen-wrong input { accent-color: var(--red); }
.opt-flag {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
  animation: rise .3s ease .1s backwards;
}
.opt-flag.ok { background: #d9f2e6; color: #2f7a5d; }
.opt-flag.bad { background: #fbe0df; color: #b23c38; }

/* 解析分区标签 */
.ana-label {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 8px;
  border-radius: 6px;
  background: #fff1f4;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  vertical-align: 1px;
}
.source .ana-label { background: #f6f1ea; color: #8f6f3f; }
.analysis { color: #3d2c31; line-height: 1.68; }
.source {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed #e3efe9;
  font-size: 13px;
  color: #7b6167;
}
.result.wrong .source { border-top-color: #f0d2d2; }
.result::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 12% 0%, rgba(255, 255, 255, .75), transparent 55%);
  pointer-events: none;
}

/* ---------- 进度条 ---------- */
progress {
  height: 8px;
  border-radius: 99px;
  background: #ffe9ee;
}
progress::-webkit-progress-bar { background: #ffe9ee; border-radius: 99px; }
progress::-webkit-progress-value {
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--pork-gold));
  transition: width .6s cubic-bezier(.22, 1, .36, 1);
}

/* ---------- 考试导航按钮 ---------- */
.numbers button {
  border-radius: 12px;
  transition: transform .14s ease, background .14s ease;
}
.numbers button.done { background: #eaf7f0; border-color: #b6ddc9; }
.numbers button.active {
  background: linear-gradient(135deg, #ec7a99, #d95d80);
  border-color: #d95d80;
  color: #fff;
  transform: scale(1.06);
}

/* ---------- 徽标 / 提示 ---------- */
.badge { border-radius: 999px; padding: 3px 10px; }
.badge.green { background: #e6f6ee; color: #2f7a5d; }
.badge.amber { background: #fdf2e0; color: #a86a22; }
.badge.red { background: #fdeaea; color: #b23c38; }
.notice { border-radius: 12px; background: #fff8e8; border-left-color: var(--pork-gold); }

/* ---------- 登录页 ---------- */
.login { border-radius: 22px; box-shadow: var(--shadow-lift); position: relative; }
.login::before {
  content: "";
  position: absolute;
  inset: -70px -40px auto auto;
  width: 190px; height: 190px;
  background: url("/assets/mascot.svg") center/contain no-repeat;
  opacity: .92;
  animation: float 5.5s ease-in-out infinite;
  pointer-events: none;
}
.login h1 { margin-top: 6px; }

/* ---------- 页面进入 ---------- */
.main > * { animation: fadeUp .3s ease both; }

/* ---------- 撒花瓣（答对） ---------- */
.pork-petal {
  position: fixed;
  width: 10px; height: 10px;
  border-radius: 60% 40% 55% 45%;
  background: linear-gradient(135deg, #ffc9d6, #f490ab);
  pointer-events: none;
  z-index: 60;
  animation: petal 1.5s ease-out forwards;
}

/* ---------- 加载骨架 ---------- */
.loading { color: var(--muted); }
.loading::after {
  content: "";
  display: block;
  width: 120px; height: 6px;
  margin: 14px auto 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #ffe3ea 0%, #fff1f4 50%, #ffe3ea 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

/* ---------- 动效关键帧 ---------- */
@keyframes pop { 0% { transform: scale(.985); } 55% { transform: scale(1.012); } 100% { transform: scale(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes stamp {
  0% { transform: scale(.2) rotate(-24deg); opacity: 0; }
  60% { transform: scale(1.18) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-9px) rotate(2deg); } }
@keyframes petal {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx, 20px), 70vh) rotate(320deg); opacity: 0; }
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes wag {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}

/* 得分数字滚动时的轻微跳动 */
.score-roll { display: inline-block; animation: wag .5s ease; }

/* 判卷中的遮罩：只在提交那一瞬间出现 */
.judging {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 250, 247, .78);
  border-radius: 14px;
  z-index: 5;
  font-size: 14px;
  color: var(--muted);
}
.judging::after {
  content: "";
  width: 46px; height: 46px;
  margin-left: 10px;
  border-radius: 50%;
  border: 3px solid #ffe0e7;
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 无障碍：系统要求减少动效时全部关掉 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* 手机端补丁：主题不改变触控尺寸，只把阴影收轻一点 */
@media (max-width: 650px) {
  .card { box-shadow: 0 6px 18px rgba(120, 63, 78, .08); }
  .login::before { inset: -46px -14px auto auto; width: 130px; height: 130px; }
  .tabbar { background: #fffaf7; }
  .tabbar a.active { background: linear-gradient(135deg, #ffe3ea, #fff0f3); }
}

/* ---------- 首页「接下来」四宫格 ---------- */

.next-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.next-tile {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto 12px;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #fff7f9, #fffdfb);
  text-decoration: none;
  color: var(--ink);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.next-tile:hover {
  transform: translateY(-2px);
  border-color: var(--pork-rose);
  box-shadow: 0 10px 22px rgba(224, 105, 139, .15);
  text-decoration: none;
}
.next-ico {
  width: 34px; height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: #fff0f4;
  color: var(--accent);
  font-size: 16px;
  line-height: 1;
}
.next-body b { display: block; font-size: 14.5px; font-weight: 650; }
.next-body small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.next-count {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.4px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.next-count small { font-size: 11.5px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.next-go { color: #e0ccd2; font-size: 13px; transition: transform .2s ease, color .2s ease; }
.next-tile:hover .next-go { color: var(--accent); transform: translateX(3px); }

/* 指标卡：数字同字号、说明同灰度 */
.stat strong {
  font-size: 28px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat small { font-size: 12.5px; color: #8d7178; }
.stat a {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  background: #ffe1e8;
  color: #b8435f;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.stat a:hover { background: #ffd2dd; text-decoration: none; }

@media (max-width: 650px) {
  .next-grid { grid-template-columns: 1fr; }
  .next-tile { padding: 12px 13px; }
}


/* ---------- 学习包：笔记体与记忆卡 ---------- */
.brief-body {
  margin-top: 12px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdfb;
  line-height: 1.75;
}
.brief-body h2, .brief-body h3 { font-size: 17px; margin: 18px 0 6px; }
.brief-body h2:first-child, .brief-body h3:first-child { margin-top: 0; }
.brief-body h3 { color: #8f3350; }
.brief-body ul { margin: 6px 0 10px; padding-left: 20px; }
.brief-body li { margin: 4px 0; }
.brief-body table { font-size: 13.5px; }

.flash-wrap { display: grid; gap: 12px; margin-top: 12px; }
.flash {
  perspective: 1200px;
  cursor: pointer;
  min-height: 190px;
}
.flash-inner {
  position: relative;
  width: 100%;
  min-height: 190px;
  transition: transform .55s cubic-bezier(.22, 1, .36, 1);
  transform-style: preserve-3d;
}
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 22px 24px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(150deg, #fff7f9, #fffdfb);
  box-shadow: 0 10px 24px rgba(120, 63, 78, .10);
  backface-visibility: hidden;
}
.flash-back {
  transform: rotateY(180deg);
  background: linear-gradient(150deg, #f3fbf7, #fbfffd);
  border-color: #cfe9dc;
}
.flash-face p { margin: 0; font-size: 17px; line-height: 1.65; }
.flash-front p { font-weight: 600; }
.flash-hint { font-size: 12px; color: var(--muted); }
.flash-actions { gap: 10px; }
.flash-done { padding: 18px; text-align: center; }
.card-list { display: grid; gap: 8px; margin-top: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.conn-item.ok-flash { animation: flashOk .9s ease; }
.conn-item.bad-flash { animation: flashBad .9s ease; }
@keyframes flashOk { 0% { background: #e7f8ef; } 100% { background: transparent; } }
@keyframes flashBad { 0% { background: #fdeaea; } 100% { background: transparent; } }

@media (max-width: 650px) {
  .flash-face { padding: 18px; }
  .flash-face p { font-size: 16px; }
}

/* 表单里需要占更宽的一列（CSP 禁止行内 style） */
.grow { flex: 2 1 260px; }

/* ---------- AI 老师：首页入口与缓存标记 ---------- */
.ai-home .row { flex-wrap: wrap; gap: 10px; }
.ai-cached {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  background: #fff6e6;
  border: 1px solid #f3dcb4;
  font-size: 12.5px;
  color: #8a6320;
}
.ai-cached button { padding: 2px 9px; font-size: 12px; }

.ai-home-hint small { display: block; line-height: 1.5; margin-bottom: 8px; }

/* ---------- 提示条：手机上也要读完 ---------- */
#toast {
  white-space: normal;
  line-height: 1.55;
  text-align: left;
  max-width: min(92vw, 620px);
  padding: 12px 16px;
  font-size: 14px;
  border-radius: 12px;
  word-break: break-word;
}
@media (max-width: 650px) {
  #toast {
    left: 12px; right: 12px; bottom: calc(78px + env(safe-area-inset-bottom));
    transform: none; max-width: none;
  }
}

/* ---------- AI 设置：一条连接一张卡 ---------- */
.ai-status {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff7f9;
  border: 1px solid var(--line);
}
.ai-status-line { display: flex; gap: 10px; font-size: 14px; }
.ai-status-line strong { flex: 0 0 64px; color: var(--ink); }
.conn-list { display: grid; gap: 12px; margin-top: 12px; }
.conn-item {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdfb;
}
.conn-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; }
.conn-addr {
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.conn-field { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 10px; }
.conn-field label { font-size: 13.5px; color: var(--ink); }
.conn-field input, .conn-field select { width: 100%; }
.conn-meta { display: grid; gap: 4px; font-size: 12.8px; color: var(--muted); }
.conn-meta .ok { color: #2f7a5d; }
.conn-meta .bad { color: #b23c38; }
.conn-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.conn-btns button.small, button.small { padding: 7px 14px; font-size: 13.5px; min-height: 38px; }
.ai-head-actions { display: flex; align-items: center; gap: 8px; }
.ai-history-note {
  margin: 6px 0 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f6f1ea;
  color: #8a6a3a;
  font-size: 12.5px;
}
@media (max-width: 650px) {
  .conn-field { grid-template-columns: 1fr; gap: 4px; }
  .conn-btns button.small { flex: 1 1 42%; }
  .ai-head-actions button.tiny { padding: 6px 10px; }
}

/* AI 连接卡：手机也够得着（44px），危险操作和常用操作分开 */
.conn-btns button.small { min-height: 44px; padding: 9px 14px; }
.conn-btns button.danger { margin-left: auto; }
.conn-edit { background: #fff8f0; border-color: #f0dcbb; }

/* ---------- AI 抽屉：先讲清楚在聊什么 ---------- */
.ai-context {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--line);
  background: #fffaf7;
  max-height: 34vh;
  overflow: auto;
}
.ai-ctx-label {
  font-size: 12px;
  color: var(--accent);
  font-weight: 650;
  letter-spacing: .2px;
}
.ai-ctx-stem {
  margin-top: 4px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
  font-weight: 600;
}
.ai-ctx-options {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  font-size: 13px;
  color: #5b4147;
}
.ai-ctx-note { margin-top: 4px; font-size: 12.5px; color: var(--muted); }

/* ---------- 模拟卷与进度页 ---------- */
.mock-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.mock-form label { display: grid; gap: 4px; font-size: 13px; color: var(--ink); }
.mock-form input { width: 110px; }
.mock-paper { margin-top: 14px; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: #fffaf7; }
.mock-list { display: grid; gap: 8px; margin: 10px 0; }
.mock-list summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.mock-list .ai-ctx-options { margin: 6px 0; }

.section-title { font-size: 15px; margin: 18px 0 6px; }

/* ---------- 手机：AI 抽屉接近全屏 ---------- */
@media (max-width: 650px) {
  .ai-drawer { height: 94dvh; }
  .ai-context { max-height: 26vh; }
}

/* ---------- 打印 ---------- */
@media print {
  .sidebar, .tabbar, .page-head button, #toast { display: none !important; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
