:root {
  --bg: #faf6ef;
  --card: #ffffff;
  --ink: #2c2a26;
  --muted: #7a7265;
  --terracotta: #9c4a3a;
  --terracotta-dark: #7d382c;
  --gold: #c8a15a;
  --gold-soft: #f3e8d3;
  --green: #3a7d44;
  --line: #e9e0d0;
  --shadow: 0 8px 24px rgba(60, 45, 30, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, #3a2b24 0%, #5a3a2e 55%, #7d382c 100%);
  color: #f7efe3;
  padding: 44px 24px 48px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(200,161,90,0.25), transparent 40%),
              radial-gradient(circle at 80% 80%, rgba(200,161,90,0.18), transparent 45%);
  pointer-events: none;
}
.hero-inner { position: relative; max-width: 860px; margin: 0 auto; }
.hero-badge {
  display: inline-block;
  font-size: 13px;
  letter-spacing: 0.5px;
  color: var(--gold);
  border: 1px solid rgba(200,161,90,0.5);
  padding: 5px 14px;
  border-radius: 100px;
  margin-bottom: 16px;
}
.hero h1 {
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: clamp(28px, 4.5vw, 44px);
  margin: 0 0 12px;
  font-weight: 700;
}
.hero-sub {
  font-size: 16px;
  color: #e8dccb;
  max-width: 640px;
  margin: 0 auto 22px;
}
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pill {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
}

/* ===== Tabs ===== */
.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 6px;
  background: rgba(250,246,239,0.92);
  backdrop-filter: blur(10px);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.tab {
  border: none;
  background: transparent;
  font-size: 15px;
  padding: 10px 18px;
  border-radius: 100px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  transition: all .18s;
}
.tab:hover { color: var(--terracotta); background: var(--gold-soft); }
.tab.active { background: var(--terracotta); color: #fff; }

main { max-width: 1040px; margin: 28px auto 60px; padding: 0 20px; }
.panel { display: none; }
.panel.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== Cards & buttons ===== */
.card, .setup-card, .section-head, .chat-wrap, .image-stage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.setup-card { padding: 28px; margin-bottom: 24px; }
.setup-head h2, .section-head h2 { margin: 0 0 6px; font-family: Georgia, "Songti SC", serif; font-size: 24px; }
.setup-head p, .section-head p { margin: 0; color: var(--muted); font-size: 14px; }
.section-head { padding: 22px 28px; margin-bottom: 20px; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--terracotta); color: #fff; }
.btn-primary:hover { background: var(--terracotta-dark); }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--terracotta); color: var(--terracotta); }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Setup / modes ===== */
.mode-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.mode input { display: none; }
.mode-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: all .15s;
  height: 100%;
}
.mode-box strong { font-size: 15px; }
.mode-box small { color: var(--muted); font-size: 12px; }
.mode input:checked + .mode-box {
  border-color: var(--terracotta);
  background: #fdf3ee;
  box-shadow: 0 0 0 3px rgba(156,74,58,0.08);
}
.setup-controls { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.control { display: flex; flex-direction: column; gap: 6px; }
.control label { font-size: 13px; color: var(--muted); font-weight: 500; }
.control select {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  min-width: 160px;
}
.setup-controls .btn { margin-left: auto; }

/* ===== Chat ===== */
.chat-wrap { overflow: hidden; }
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbf7f0;
}
.prof-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--gold-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  border: 1px solid var(--gold);
}
.chat-head strong { display: block; font-size: 15px; }
.chat-head small { color: var(--muted); font-size: 12px; }
.chat-actions { margin-left: auto; display: flex; gap: 8px; }

.chat-log { max-height: 520px; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.bubble { max-width: 78%; padding: 14px 18px; border-radius: 16px; font-size: 15px; position: relative; }
.bubble .bubble-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; opacity: 0.75; }
.bubble.prof { align-self: flex-start; background: #f1e9dc; border-bottom-left-radius: 4px; }
.bubble.student { align-self: flex-end; background: #eaf2ea; border-bottom-right-radius: 4px; }
.bubble.zh { font-size: 13px; color: var(--muted); margin-top: 6px; padding-top: 6px; border-top: 1px dashed rgba(0,0,0,0.1); }

.feedback-card {
  align-self: stretch;
  background: #fdf8ef;
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 14px;
}
.feedback-card .grade {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; height: 42px;
  border-radius: 50%;
  font-weight: 800; font-size: 18px;
  margin-right: 12px;
  vertical-align: middle;
}
.grade-a { background: #e4f3e5; color: #2e7d32; border: 2px solid #2e7d32; }
.grade-b { background: #fdf3d8; color: #b07a1a; border: 2px solid #d8a92a; }
.grade-c { background: #fbe9e7; color: #c0392b; border: 2px solid #c0392b; }
.feedback-card .fb-main { display: flex; align-items: center; }
.feedback-card .fb-detail { margin-top: 10px; color: var(--muted); }
.feedback-card .fb-detail ul { margin: 6px 0; padding-left: 20px; }
.key-hit { color: #2e7d32; font-weight: 600; }
.key-miss { color: #c0392b; font-weight: 600; }

.chat-input { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-input textarea {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  resize: vertical;
  min-height: 52px;
  max-height: 160px;
  font-family: inherit;
}
.chat-input textarea:focus { outline: none; border-color: var(--terracotta); }
.mic-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 22px;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.mic-btn:hover { border-color: var(--terracotta); }
.mic-btn.recording { background: #c0392b; color: #fff; border-color: #c0392b; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(192,57,43,0.4);} 50% { box-shadow: 0 0 0 10px rgba(192,57,43,0);} }
.voice-status { padding: 0 20px 14px; font-size: 13px; color: var(--muted); min-height: 20px; }
.voice-status.error { color: #c0392b; }

/* ===== Library ===== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  padding: 7px 16px;
  border-radius: 100px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  transition: all .15s;
}
.chip:hover { color: var(--terracotta); }
.chip.active { background: var(--terracotta); color: #fff; border-color: var(--terracotta); }

.question-list { display: flex; flex-direction: column; gap: 12px; }
.q-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.q-card summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.q-card summary::-webkit-details-marker { display: none; }
.q-num {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--terracotta-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.q-card summary .q-it { flex: 1; font-size: 16px; font-weight: 600; }
.q-card summary .q-zh { font-size: 13px; color: var(--muted); margin-top: 2px; }
.q-card summary .q-cat { font-size: 12px; color: var(--gold); white-space: nowrap; }
.q-body { padding: 0 22px 22px; border-top: 1px solid var(--line); margin: 0 22px; }
.q-block { margin-top: 16px; }
.q-block h4 { margin: 0 0 6px; font-size: 13px; color: var(--terracotta); text-transform: uppercase; letter-spacing: .5px; }
.q-block p { margin: 0; }
.sample-it {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  background: #fbf7f0;
  padding: 14px 16px;
  border-radius: 10px;
  border-left: 3px solid var(--gold);
}
.sample-zh { color: var(--muted); font-size: 14px; }
.phrases-list { display: flex; flex-wrap: wrap; gap: 8px; }
.phrase-tag {
  background: var(--gold-soft);
  color: var(--terracotta-dark);
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 13px;
  font-family: Georgia, serif;
}
.q-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ===== Image ===== */
.image-stage { display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; overflow: hidden; }
.image-viewer { background: #2c2a26; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; min-height: 440px; }
.image-viewer img { max-width: 100%; max-height: 420px; object-fit: contain; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.image-caption { color: #e8dccb; margin-top: 16px; font-size: 14px; text-align: center; }
.image-side { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.art-questions h3, .art-sample h3 { margin: 0 0 8px; font-size: 15px; color: var(--terracotta); display: flex; align-items: center; gap: 8px; }
.art-questions ul { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.art-sample p { margin: 0; font-size: 14.5px; }
.art-sample p.it { font-family: Georgia, serif; background: #fbf7f0; padding: 14px 16px; border-radius: 10px; border-left: 3px solid var(--gold); }
.art-nav { margin-top: auto; display: flex; gap: 10px; justify-content: space-between; }

/* ===== Phrases / vocab ===== */
.sub-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.sub-tab {
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 18px;
  border-radius: 100px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
}
.sub-tab.active { background: var(--green); color: #fff; border-color: var(--green); }
.phrase-group { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.phrase-group h3 { margin: 0 0 12px; font-size: 17px; color: var(--terracotta-dark); }
.phrase-item { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.phrase-item:last-child { border-bottom: none; }
.phrase-item .it { flex: 1; font-family: Georgia, serif; font-size: 15.5px; }
.phrase-item .zh { flex: 1; color: var(--muted); font-size: 14px; }
.vocab-table { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.vocab-table table { width: 100%; border-collapse: collapse; }
.vocab-table th, .vocab-table td { text-align: left; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 14px; }
.vocab-table th { background: #fbf7f0; color: var(--terracotta-dark); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.vocab-table tr:last-child td { border-bottom: none; }
.vocab-table td.it { font-family: Georgia, serif; font-weight: 600; }

/* ===== Footer ===== */
footer {
  max-width: 1040px;
  margin: 0 auto 40px;
  padding: 0 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.foot-note { font-size: 12px; opacity: 0.75; }

/* ===== Responsive ===== */
@media (max-width: 760px) {
  .mode-row { grid-template-columns: 1fr; }
  .image-stage { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
  .tabs { flex-wrap: wrap; }
  .setup-controls .btn { margin-left: 0; }
}
