:root {
  --bg: #f7f3ec;
  --surface: #fffdf9;
  --surface-2: #f3ecdf;
  --line: #e8ddc9;
  --ink: #3b3022;
  --ink-2: #6b5c47;
  --ink-3: #9b8c75;
  --gold: #a9782f;
  --gold-dark: #8a5f22;
  --gold-soft: #f7ecd8;
  --teal: #4a7c70;
  --teal-soft: #eaf3ef;
  --red: #b25542;
  --red-soft: #fbeeea;
  --shadow: 0 8px 26px rgba(120, 90, 40, .08);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px; line-height: 1.65;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--ink-3); font-size: 13px; font-weight: 400; }
.good { color: var(--teal); }
.bad { color: var(--red); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--gold); background: var(--gold); color: #fff;
  border-radius: 11px; padding: 11px 22px; font-weight: 600;
  transition: background .18s, transform .18s, opacity .18s;
}
.btn:hover:not(:disabled) { background: var(--gold-dark); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.wide { width: 100%; }
.btn.sm { padding: 8px 15px; font-size: 13px; border-radius: 9px; }
.btn.ghost { background: transparent; color: var(--gold); }
.btn.ghost:hover:not(:disabled) { background: var(--gold-soft); }
.link-btn {
  border: 0; background: transparent; color: var(--gold-dark);
  font-size: 13px; padding: 4px 6px; border-radius: 6px;
}
.link-btn:hover { background: var(--gold-soft); }

/* 自建版登录表单 */
.login-field { margin: 12px 0; }
.login-field input {
  width: 100%; box-sizing: border-box; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 14px;
}
.login-field input:focus { outline: 2px solid var(--gold-soft); border-color: var(--gold); }

/* 登录 */
.login-view {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: radial-gradient(circle at 50% 18%, #fdf8ee 0%, #eee2cd 100%);
  z-index: 50;
}
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  max-width: 430px; width: 100%; padding: 40px 34px; text-align: center; box-shadow: var(--shadow);
}
.login-mark {
  width: 60px; height: 60px; margin: 0 auto 18px; border-radius: 18px;
  background: var(--gold); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
}
.login-card h1 { font-size: 22px; margin: 0 0 6px; }
.login-card .sub { color: var(--ink-2); font-size: 13px; margin: 0 0 24px; }
.login-feature {
  text-align: left; background: var(--gold-soft); border-radius: 12px;
  padding: 14px 18px; font-size: 13px; color: var(--ink-2); line-height: 2; margin-bottom: 24px;
}
.login-feature span { display: block; }
.error-text { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 12px; }
.login-foot { color: var(--ink-3); font-size: 12px; margin: 18px 0 0; }

/* 顶栏与导航 */
.topbar {
  position: sticky; top: 0; z-index: 30; background: rgba(247, 243, 236, .93);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  padding: 11px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--gold-dark); white-space: nowrap; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--gold);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.brand small { color: var(--ink-3); font-size: 11px; font-weight: 400; margin-left: 6px; }
.user-area { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--gold-soft);
  color: var(--gold-dark); display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-name { color: var(--ink-2); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs {
  position: sticky; top: 53px; z-index: 29; display: flex; gap: 6px;
  background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 18px 0;
}
.tab-btn {
  border: 0; background: transparent; color: var(--ink-2); padding: 9px 18px 11px;
  font-weight: 600; border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--gold-dark); border-bottom-color: var(--gold); }
.main { max-width: 880px; margin: 0 auto; padding: 20px 18px 70px; }
.panel { animation: fade .2s ease; }
@keyframes fade { from { opacity: .4; } to { opacity: 1; } }

/* 学习页 */
.hero {
  background: linear-gradient(135deg, #fffdf8, #f6ead4); border: 1px solid var(--line);
  border-radius: 18px; padding: 26px 26px 22px; box-shadow: var(--shadow); margin-bottom: 26px;
}
.hero-kicker { color: var(--gold); font-size: 12px; font-weight: 700; letter-spacing: 2px; }
.hero h2 { font-size: 22px; margin: 6px 0 8px; }
.hero p { color: var(--ink-2); margin: 0; font-size: 14px; }
.hero-stats { display: flex; gap: 12px; margin-top: 18px; }
.hero-stats div { flex: 1; background: rgba(255, 255, 255, .7); border-radius: 11px; padding: 10px 14px; }
.hero-stats b { display: block; font-size: 21px; color: var(--gold-dark); line-height: 1.2; }
.hero-stats span { font-size: 12px; color: var(--ink-3); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 12px; }
.section-head h3 { font-size: 16px; margin: 0; }
.head-actions { display: flex; align-items: center; gap: 10px; }

.lesson-list { display: grid; gap: 9px; }
.lesson { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.lesson-head {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; cursor: pointer; user-select: none;
}
.lesson-head:hover { background: var(--surface-2); }
.lesson-icon {
  width: 28px; height: 28px; flex: none; border-radius: 8px; background: var(--gold-soft);
  color: var(--gold-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.lesson-title { flex: 1; font-weight: 600; font-size: 14px; }
.lesson-arrow { color: var(--ink-3); transition: transform .2s; font-size: 13px; }
.lesson.open .lesson-arrow { transform: rotate(180deg); }
.lesson-body { display: none; padding: 0 16px 16px 56px; color: var(--ink-2); font-size: 14px; }
.lesson.open .lesson-body { display: block; }
.lesson-body p { margin: 8px 0; }
.lesson-body b { color: var(--ink); }
.callout {
  background: var(--gold-soft); border-left: 3px solid var(--gold);
  border-radius: 8px; padding: 10px 14px; margin: 10px 0; font-size: 13px;
}
.steps { margin: 8px 0; padding-left: 20px; }
.steps li { margin-bottom: 7px; }
.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }

.quiz-list { display: grid; gap: 10px; }
.quiz-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; }
.quiz-q { font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.quiz-options { display: grid; gap: 7px; }
.option {
  text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 9px;
  padding: 9px 12px; color: var(--ink-2); font-size: 13px;
}
.option:hover:not(:disabled) { border-color: var(--gold); }
.option.correct { border-color: var(--teal); background: var(--teal-soft); color: var(--teal); }
.option.wrong { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.quiz-why { font-size: 13px; color: var(--ink-2); margin-top: 9px; }
.cta-row { display: flex; justify-content: center; margin-top: 26px; }

/* 陪练设置 */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card-head h3 { margin: 0 0 4px; font-size: 17px; }
.card-head p { margin: 0; }
.pill {
  display: inline-block; background: var(--surface-2); color: var(--ink-2);
  border-radius: 99px; padding: 4px 11px; font-size: 12px; white-space: nowrap;
}
.pill.gold { background: var(--gold-soft); color: var(--gold-dark); }
.field { margin-top: 20px; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 9px; }
.field-label .muted { margin-left: 6px; }
.choice-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.choice-card {
  border: 1px solid var(--line); background: #fff; border-radius: 11px;
  padding: 11px 12px; text-align: left; min-height: 66px;
}
.choice-card:hover { border-color: var(--gold); }
.choice-card.selected { border-color: var(--gold); background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold); }
.choice-name { display: block; font-weight: 600; font-size: 13px; }
.choice-meta { display: block; color: var(--ink-3); font-size: 11px; margin-top: 3px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.select {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 10px 12px; color: var(--ink); outline: none;
}
.select:focus, .composer textarea:focus { border-color: var(--gold); }
.setup-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 22px; }
.hint-box { background: var(--teal-soft); color: var(--teal); border-radius: 9px; padding: 9px 13px; font-size: 12px; flex: 1; }

/* 对话 */
.live-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.live-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.chat-hint-row { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 6px; }
.tip-body {
  background: var(--gold-soft); border-radius: 9px; padding: 10px 13px;
  font-size: 12px; color: var(--ink-2); margin-bottom: 10px;
}
.chat-box {
  height: min(52vh, 460px); min-height: 300px; overflow-y: auto;
  background: #fbf8f2; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg.customer { align-self: flex-start; }
.msg.tech { align-self: flex-end; align-items: flex-end; }
.who { font-size: 11px; color: var(--ink-3); margin: 0 4px 3px; }
.bubble {
  background: #fff; border: 1px solid var(--line); border-radius: 12px 12px 12px 3px;
  padding: 9px 13px; white-space: pre-wrap; word-break: break-word; font-size: 14px;
}
.msg.tech .bubble { background: var(--gold); border-color: var(--gold); color: #fff; border-radius: 12px 12px 3px 12px; }
.typing { align-self: flex-start; color: var(--ink-3); font-size: 12px; padding: 4px; }
.retry-line { align-self: flex-start; }
.composer { margin-top: 12px; }
.composer textarea {
  width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; padding: 10px 12px; outline: none; line-height: 1.5;
}
.composer-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 8px; }
.composer-actions .muted { margin-right: auto; }

/* 复盘报告 */
.report-hero { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.score-ring {
  width: 84px; height: 84px; flex: none; border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--pct) * 1%), var(--surface-2) 0);
  display: flex; align-items: center; justify-content: center;
}
.score-ring::before {
  content: ''; position: absolute; width: 68px; height: 68px; border-radius: 50%; background: var(--surface);
}
.score-ring span { position: relative; font-size: 27px; font-weight: 700; color: var(--gold-dark); }
.score-ring.fail { background: conic-gradient(var(--red) calc(var(--pct) * 1%), var(--surface-2) 0); }
.score-ring.fail span { color: var(--red); }
.report-title h3 { margin: 0 0 5px; font-size: 18px; }
.report-title p { margin: 0; color: var(--ink-2); font-size: 13px; }
.report-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 15px; margin-bottom: 12px; }
.report-box h4 { margin: 0 0 12px; font-size: 14px; color: var(--gold-dark); }
.dim-row { margin-bottom: 11px; }
.dim-top { display: flex; justify-content: space-between; font-size: 13px; }
.dim-score { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dim-bar { height: 6px; background: var(--surface-2); border-radius: 99px; margin: 5px 0 3px; overflow: hidden; }
.dim-fill { height: 100%; background: var(--teal); border-radius: 99px; }
.dim-comment { font-size: 12px; color: var(--ink-3); }
.fb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fb-block { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; }
.fb-block h4 { margin: 0 0 6px; font-size: 13px; color: var(--gold-dark); }
.fb-block ul { margin: 0; padding-left: 17px; font-size: 13px; color: var(--ink-2); }
.fb-block li { margin-bottom: 4px; }
.suggestion { background: var(--teal-soft); color: var(--teal); border-radius: 10px; padding: 11px 14px; font-size: 13px; }
.redline-box { background: var(--red-soft); border: 1px solid #efc9bf; color: var(--red); border-radius: 10px; padding: 11px 14px; font-size: 13px; margin-bottom: 12px; }
.replay { margin-top: 12px; }
.replay summary { cursor: pointer; font-size: 13px; color: var(--gold-dark); font-weight: 600; }
.replay .mini-msg { font-size: 13px; color: var(--ink-2); border-bottom: 1px dashed var(--line); padding: 6px 0; }
.replay .mini-msg b { color: var(--ink); }
.report-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 16px; }
.save-note { font-size: 12px; color: var(--red); margin-top: 8px; }

/* 成绩 */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; }
.stat-card span { display: block; font-size: 12px; color: var(--ink-3); }
.stat-card b { font-size: 22px; color: var(--gold-dark); line-height: 1.4; font-variant-numeric: tabular-nums; }
.filter-group { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-btn { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; font-size: 12px; color: var(--ink-2); }
.filter-btn.active { border-color: var(--gold); background: var(--gold-soft); color: var(--gold-dark); }
.history-list { display: grid; gap: 9px; }
.hist-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 16px; cursor: pointer;
}
.hist-item:hover { border-color: var(--gold); }
.hh { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ht { font-weight: 600; font-size: 14px; }
.hs { font-weight: 700; font-variant-numeric: tabular-nums; }
.hs.ok { color: var(--teal); }
.hs.bad { color: var(--red); }
.hd { color: var(--ink-3); font-size: 12px; margin-top: 3px; }
.empty { text-align: center; color: var(--ink-3); background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 34px 16px; font-size: 13px; }

/* 弹层与提示 */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(40, 30, 18, .45); }
.modal-card {
  position: relative; background: var(--surface); border-radius: 16px; width: min(640px, 100%);
  max-height: 86vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { overflow-y: auto; padding: 18px 20px 24px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 80; display: none; max-width: min(90vw, 520px); text-align: center;
}

@media (max-width: 640px) {
  .main { padding: 16px 13px 60px; }
  .topbar, .tabs { padding-left: 13px; padding-right: 13px; }
  .tabs { top: 53px; }
  .tab-btn { flex: 1; padding: 9px 4px 11px; }
  .hero { padding: 20px 18px; }
  .hero h2 { font-size: 19px; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-row, .fb-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .setup-foot { flex-direction: column; align-items: stretch; }
  .lesson-body { padding-left: 16px; }
  .user-name { display: none; }
  .card { padding: 17px; }
  .chat-box { height: 50vh; }
}
