/* 随身老师 · 墨色书香风格 */
:root {
  --bg: #171411;
  --bg2: #1f1b16;
  --card: #242019;
  --line: #3a3226;
  --ink: #ece3d0;
  --ink2: #b7ab90;
  --ink3: #8d8168;
  --red: #c2452f;
  --red2: #e0553a;
  --gold: #c9a25e;
  --green: #7d9c6d;
  --radius: 14px;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", "STSong", serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  min-height: 100vh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
body.no-scroll { overflow: hidden; }
main { max-width: 720px; margin: 0 auto; padding: 12px 14px 28px; }

#topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--bg) 82%, rgba(23,20,17,0));
  padding: 14px 16px 8px;
}
#topbar .logo { display: flex; align-items: center; gap: 12px; max-width: 720px; margin: 0 auto; }
#topbar h1 { font-size: 1.35rem; letter-spacing: 0.12em; font-weight: 700; }
#topbar p { font-size: 0.72rem; color: var(--ink3); letter-spacing: 0.08em; margin-top: 2px; }
.seal {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; flex: 0 0 42px;
  background: linear-gradient(135deg, var(--red2), var(--red));
  color: #f7e9d8; font-weight: 700; font-size: 1.3rem;
  border-radius: 9px; box-shadow: 0 2px 8px rgba(194,69,47,.35);
  user-select: none;
}
.seal.small { width: 26px; height: 26px; flex: 0 0 26px; font-size: 0.85rem; border-radius: 6px; }
.seal.big { width: 72px; height: 72px; font-size: 2.2rem; border-radius: 14px; margin: 0 auto 14px; }

.card {
  background: linear-gradient(180deg, var(--card), #211d17);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}

.greet { font-size: 0.95rem; line-height: 1.9; color: var(--ink2); border-left: 3px solid var(--gold); }
.greet b { color: var(--red2); font-size: 1.1em; }

.start-zone { text-align: center; padding: 18px 0 6px; }
.btn-one {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 168px; height: 168px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #2c2720, #1c1914 70%);
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 6px rgba(201,162,94,.12), 0 10px 30px rgba(0,0,0,.45);
  color: var(--ink); cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  font-family: var(--serif);
}
.btn-one:active { transform: scale(.96); box-shadow: 0 0 0 8px rgba(201,162,94,.2), 0 6px 20px rgba(0,0,0,.5); }
.btn-one .one {
  font-size: 4.4rem; line-height: 1; font-weight: 700;
  color: var(--red2); text-shadow: 0 2px 12px rgba(224,85,58,.4);
}
.btn-one .one-label { font-size: 1.05rem; letter-spacing: 0.3em; margin: 4px 0 2px; padding-left: 0.3em; }
.btn-one .one-sub { font-size: 0.72rem; color: var(--ink3); letter-spacing: 0.05em; }

.quick-fields { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.qf-label { color: var(--ink3); font-size: 0.8rem; }
.quick-fields button {
  background: var(--card); color: var(--ink2);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 6px 14px; font-size: 0.82rem; cursor: pointer;
  font-family: var(--serif); letter-spacing: 0.1em;
}
.quick-fields button:active { background: #2e2920; color: var(--red2); border-color: var(--red); }

.stats { display: flex; gap: 10px; align-items: stretch; }
.stat { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 12px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: none; }
.stat.grow { flex: 1; align-items: flex-start; padding-left: 14px; }
.stat b { font-size: 1.7rem; color: var(--gold); line-height: 1.2; }
.stat span { font-size: 0.72rem; color: var(--ink3); }
.dist { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.dist-chip { background: rgba(201,162,94,.12); color: var(--gold); border-radius: 4px; padding: 2px 8px; font-size: 0.72rem; }

.section-title { display: flex; align-items: center; justify-content: space-between; margin: 20px 2px 10px; }
.section-title h2 { font-size: 1.1rem; letter-spacing: 0.15em; }
.section-title span { color: var(--ink3); font-size: 0.78rem; }

.recent-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-bottom: 8px; cursor: pointer;
}
.recent-item:active { background: #2a251d; }
.recent-main { flex: 1; min-width: 0; }
.recent-main h4 { font-size: 0.92rem; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-main p { font-size: 0.76rem; color: var(--ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--ink3); font-size: 1.3rem; }

.chip {
  display: inline-block; flex: 0 0 auto;
  background: rgba(194,69,47,.14); color: #e08d78;
  border-radius: 4px; padding: 2px 8px; font-size: 0.72rem; letter-spacing: 0.06em;
}

.tip { background: rgba(201,162,94,.06); border-color: rgba(201,162,94,.25); color: var(--ink2); font-size: 0.82rem; line-height: 1.85; }
.tip b { color: var(--gold); }
.empty { text-align: center; padding: 34px 10px; color: var(--ink3); font-size: 0.85rem; line-height: 1.9; }
.empty.small { padding: 20px 10px; }
.empty-icon {
  width: 52px; height: 52px; line-height: 52px; margin: 0 auto 12px;
  border: 1px dashed var(--line); border-radius: 50%; color: var(--ink3);
}

.map-title { text-align: center; padding: 10px 0 16px; }
.map-title h2 { font-size: 1.3rem; letter-spacing: 0.3em; margin-bottom: 6px; }
.map-title p { color: var(--ink3); font-size: 0.8rem; }
.map-h { font-size: 0.95rem; color: var(--gold); letter-spacing: 0.1em; margin-bottom: 12px; }
.map-item { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.map-item:last-child { border-bottom: none; }
.map-item b { color: var(--ink); }
.map-item p { font-size: 0.84rem; line-height: 1.85; color: var(--ink2); margin-top: 4px; }
.map-item i { color: var(--gold); font-style: normal; }
.map-item u { color: var(--red2); text-decoration: none; border-bottom: 1px solid var(--red); }
.chain { text-align: center; line-height: 2.2; font-size: 0.92rem; }
.chain span { color: var(--ink3); font-size: 0.75rem; display: inline-block; margin: 0 6px; }
.chain-note { color: var(--ink3); font-size: 0.8rem; line-height: 1.8; text-align: center; margin-top: 8px; }
.lvl-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.lvl-table th, .lvl-table td { border: 1px solid var(--line); padding: 9px 10px; text-align: left; line-height: 1.7; }
.lvl-table th { color: var(--gold); background: rgba(201,162,94,.07); }
.lvl-table b { color: var(--red2); }

.note-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.note-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.note-head h4 { flex: 1; font-size: 0.92rem; }
.note-del {
  background: none; border: 1px solid var(--line); color: var(--ink3);
  border-radius: 6px; padding: 3px 10px; font-size: 0.75rem; cursor: pointer;
  font-family: var(--serif);
}
.note-text { font-size: 0.85rem; line-height: 1.9; color: var(--ink2); }

.form-card label { display: block; font-size: 0.8rem; color: var(--ink3); margin: 14px 0 6px; }
.form-card label:first-child { margin-top: 0; }
.form-card input, .form-card select {
  width: 100%; background: #1a1712; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font-size: 0.9rem; font-family: var(--sans);
  outline: none;
}
.form-card input:focus, .form-card select:focus { border-color: var(--gold); }
.hint { font-size: 0.75rem; color: var(--ink3); line-height: 1.7; margin-top: 6px; }
.hint.free { color: var(--green); }
.temp-val { float: right; color: var(--gold); }
input[type=range] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 3px; background: var(--line); border: none !important; padding: 0 !important; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--red); border: 2px solid #f7e9d8; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; align-items: center; }
.btn-main {
  flex: 1; background: linear-gradient(135deg, var(--red2), var(--red));
  color: #f7e9d8; border: none; border-radius: 10px;
  padding: 12px; font-size: 0.95rem; letter-spacing: 0.2em; cursor: pointer;
  font-family: var(--serif);
}
.btn-main:active { opacity: .85; }
.btn-mini {
  background: rgba(194,69,47,.16); color: #e08d78;
  border: 1px solid rgba(194,69,47,.4); border-radius: 8px;
  padding: 7px 14px; font-size: 0.8rem; cursor: pointer; font-family: var(--serif);
}
.btn-mini.ghost { background: none; color: var(--ink2); border-color: var(--line); }
.danger-btn { background: rgba(194,69,47,.12); color: #d98a77; }
.steps { padding-left: 20px; font-size: 0.84rem; line-height: 2; color: var(--ink2); }
.steps b { color: var(--gold); }

#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: rgba(23,20,17,.96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(8px);
}
#tabbar button {
  flex: 1; background: none; border: none; color: var(--ink3);
  padding: 9px 0 7px; font-size: 0.72rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: var(--serif); letter-spacing: 0.1em;
}
#tabbar button.active { color: var(--red2); }
.tab-ico {
  width: 24px; height: 24px; line-height: 24px; border-radius: 50%;
  font-size: 0.7rem; text-align: center;
  border: 1px solid currentColor; opacity: .75;
}
#tabbar button.active .tab-ico { background: var(--red); border-color: var(--red); color: #f7e9d8; opacity: 1; }

.view { display: none; }
.view.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.lesson {
  position: fixed; inset: 0; z-index: 40;
  background: var(--bg);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .28s ease;
}
.lesson.open { transform: none; }
.lesson-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 8px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.lesson-head .back, .lesson-head .next {
  background: none; border: none; color: var(--ink2); font-size: 0.85rem;
  cursor: pointer; font-family: var(--serif); padding: 4px 6px;
}
.lesson-head .next { color: var(--red2); }
.lesson-title { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.95rem; letter-spacing: 0.2em; }
.lesson-state { text-align: center; font-size: 0.72rem; color: var(--ink3); padding: 6px 10px 10px; }
.chat {
  flex: 1; overflow-y: auto; padding: 10px 14px 16px;
  max-width: 720px; width: 100%; margin: 0 auto;
  -webkit-overflow-scrolling: touch;
}
.bubble { display: flex; gap: 8px; margin-bottom: 16px; align-items: flex-start; }
.bubble.student { justify-content: flex-end; }
.teacher-avatar {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--red2), var(--red));
  color: #f7e9d8; text-align: center; line-height: 34px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(194,69,47,.3); user-select: none;
}
.bubble-body {
  max-width: calc(100% - 60px);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 4px 14px 14px 14px; padding: 11px 14px;
  font-size: 0.9rem; line-height: 1.85; word-break: break-word;
}
.bubble.student .bubble-body {
  background: #2a241c; border-color: rgba(201,162,94,.35);
  border-radius: 14px 4px 14px 14px;
  max-width: 82%;
}
.bubble-body.error { color: #e08d78; border-color: rgba(194,69,47,.5); }

.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head h3 { font-size: 0.98rem; flex: 1; }
.stamp {
  font-style: normal; width: 26px; height: 26px; line-height: 26px; text-align: center;
  background: var(--red); color: #f7e9d8; border-radius: 6px; font-size: 0.8rem;
}
.scene, .questions, .answer-block, .comment { margin-bottom: 10px; }
.scene i, .questions i, .answer-block i, .comment i {
  font-style: normal; color: var(--gold); font-size: 0.75rem;
  display: block; margin-bottom: 5px; letter-spacing: 0.1em;
}
.scene p { font-size: 0.88rem; color: var(--ink2); line-height: 1.9; }
.q-item { display: flex; gap: 8px; padding: 6px 0; align-items: flex-start; }
.q-item i {
  font-style: normal; flex: 0 0 20px; width: 20px; height: 20px; line-height: 20px;
  text-align: center; background: rgba(201,162,94,.15); color: var(--gold);
  border-radius: 50%; font-size: 0.75rem; margin-top: 2px;
}
.q-item span { font-size: 0.88rem; line-height: 1.75; }
.hint {
  font-size: 0.78rem; color: var(--ink3); border-left: 2px solid var(--line);
  padding: 4px 10px; line-height: 1.7;
}

.review .comment { background: rgba(194,69,47,.07); border-radius: 10px; padding: 10px 12px; font-size: 0.87rem; line-height: 1.85; }
.review .comment i { color: #e08d78; }
.answer-block { background: rgba(201,162,94,.07); border: 1px solid rgba(201,162,94,.22); border-radius: 10px; padding: 12px; }
.answer-block p { font-size: 0.88rem; line-height: 1.95; color: var(--ink); }
.note { color: var(--gold); font-size: 0.82rem; text-align: right; margin-top: 6px; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; }

.typing { display: inline-flex; align-items: center; gap: 4px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
.typing em { font-style: normal; font-size: 0.76rem; color: var(--ink3); margin-left: 6px; }
@keyframes blink { 0%,100% { opacity: .25; } 50% { opacity: 1; } }
.stream-body { min-height: 1.5em; white-space: pre-wrap; }

.lesson-foot {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--bg);
  max-width: 720px; width: 100%; margin: 0 auto;
}
.btn-skip {
  flex: 0 0 auto; background: none; border: 1px dashed var(--line); color: var(--ink3);
  border-radius: 10px; padding: 11px 8px; font-size: 0.72rem; cursor: pointer;
  font-family: var(--serif); line-height: 1.3; max-width: 58px;
}
#lesson-input {
  flex: 1; background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; font-size: 0.92rem; line-height: 1.5;
  resize: none; outline: none; font-family: var(--serif);
  max-height: 120px; min-height: 44px;
}
#lesson-input:focus { border-color: var(--gold); }
#lesson-input:disabled { opacity: .5; }
.send {
  flex: 0 0 46px; width: 46px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--red2), var(--red));
  color: #f7e9d8; border: none; font-size: 0.95rem; cursor: pointer;
  font-family: var(--serif); letter-spacing: 0.1em;
}
.send:disabled { opacity: .5; }

.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.62); display: none; align-items: flex-end; justify-content: center; }
.modal.open { display: flex; animation: fadein .2s ease; }
.modal-panel {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; width: 100%; max-width: 720px;
  max-height: 86vh; overflow-y: auto; padding: 18px 18px calc(20px + env(safe-area-inset-bottom));
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { font-size: 1rem; letter-spacing: 0.15em; }
.modal-body .card-head { margin-bottom: 10px; }
.onboard-panel { text-align: center; border-radius: 18px; margin: 0 12px 12px; }
.onboard-panel h3 { font-size: 1.15rem; letter-spacing: 0.2em; margin-bottom: 10px; }
.onboard-panel > p { font-size: 0.86rem; color: var(--ink2); line-height: 1.9; text-align: left; margin-bottom: 10px; }
.onboard-panel .steps { text-align: left; }
.onboard-panel .btn-row { justify-content: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  background: rgba(40,35,28,.97); color: var(--ink);
  border: 1px solid var(--gold); border-radius: 10px;
  padding: 10px 18px; font-size: 0.84rem; z-index: 80;
  opacity: 0; pointer-events: none; transition: all .25s ease;
  max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 760px) {
  #tabbar { max-width: 720px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
}
