/* 青心学堂·英语口语：沿用青心学堂的清爽笔记本风，主色换成天蓝色，跟随手机深色模式 */
:root {
  --bg: #f5f9fd;
  --card: #ffffff;
  --text: #1d2a36;
  --muted: #6a7c8c;
  --line: #e1e9f1;
  --primary: #2f8fd8;
  --primary-soft: #e2f0fb;
  --primary-text: #ffffff;
  --me: #2f8fd8;
  --me-text: #ffffff;
  --warn-bg: #fff6e0;
  --warn-text: #7a5a00;
  --help-bg: #eaf7ee;
  --help-text: #1f6b3a;
  --danger: #d4534b;
  --rec: #e5484d;
  --shadow: 0 1px 3px rgba(30, 50, 70, 0.08), 0 4px 14px rgba(30, 50, 70, 0.05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121c26;
    --card: #1b2733;
    --text: #e3ecf4;
    --muted: #91a4b6;
    --line: #2a3a49;
    --primary: #5aaef0;
    --primary-soft: #1e3a52;
    --primary-text: #0d1822;
    --me: #3b8fd0;
    --me-text: #ffffff;
    --warn-bg: #3a3220;
    --warn-text: #f1d58a;
    --help-bg: #1d3626;
    --help-text: #a6e0b8;
    --danger: #f07c74;
    --rec: #ff6b6f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: center; gap: 6px; height: 48px; padding: 0 8px; max-width: 720px; margin: 0 auto; }
.brand { display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; flex: 1; }
.icon-btn { border: 0; background: none; font-size: 30px; line-height: 1; padding: 0 8px 4px; cursor: pointer; color: var(--primary); min-width: 44px; }
.text-btn { border: 0; background: none; color: var(--primary); font-weight: 600; cursor: pointer; padding: 8px; text-decoration: none; font-size: 15px; white-space: nowrap; }
.back-home { font-size: 14px; }

main { max-width: 720px; margin: 0 auto; padding: 0 16px 24px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 16px; width: 100%;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text);
}
.btn:active { transform: scale(0.99); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.ghost { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn.small { width: auto; min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin: 14px 0; }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.card.warn { background: var(--warn-bg); color: var(--warn-text); }
.card ol { padding-left: 1.3em; margin: 6px 0 0; }
.card p { margin: 4px 0; }

/* ---------- 首页 ---------- */
.hero { padding: 22px 2px 6px; }
.hero h1 { margin: 0 0 6px; font-size: 26px; }
.hero-text { margin: 0; color: var(--muted); font-size: 15px; }
.hero-text b { color: var(--text); }
.quota { margin: 10px 0 0; font-size: 14px; color: var(--primary); font-weight: 600; }
.scene-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 18px; }
.scene-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  padding: 14px; border-radius: var(--radius); border: 0; background: var(--card); box-shadow: var(--shadow);
  cursor: pointer; min-height: 132px; -webkit-tap-highlight-color: transparent;
}
.scene-card:active { transform: scale(0.98); }
.scene-card .emoji { width: 46px; height: 46px; border-radius: 12px; background: var(--primary-soft); display: grid; place-items: center; font-size: 26px; }
.scene-card .name { font-size: 17px; font-weight: 700; margin-top: 4px; }
.scene-card .intro { font-size: 13px; color: var(--muted); line-height: 1.45; }
.scene-card .go { margin-top: auto; font-size: 13px; font-weight: 700; color: var(--primary); }
.scene-card.wide { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: center; gap: 12px; }
.scene-card.wide .text { flex: 1; display: flex; flex-direction: column; }
.scene-card.wide .go { margin: 0; }
.home-links { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }

/* ---------- 聊天页 ---------- */
#view-chat { display: flex; flex-direction: column; min-height: calc(100dvh - 49px - env(safe-area-inset-top)); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.chat-head-main { flex: 1; min-width: 0; }
.chat-title { font-weight: 700; font-size: 17px; }
.chat-role { font-size: 13px; color: var(--muted); }
.avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--primary-soft); display: grid; place-items: center; font-size: 21px; }
.avatar.big { width: 46px; height: 46px; font-size: 26px; }

.messages { flex: 1; padding: 14px 0 200px; display: flex; flex-direction: column; gap: 14px; }
.messages.readonly { padding-bottom: 24px; }
.msg { display: flex; gap: 8px; align-items: flex-start; max-width: 100%; }
.msg.me { flex-direction: row-reverse; }
.msg-col { display: flex; flex-direction: column; gap: 6px; max-width: calc(100% - 50px); min-width: 0; }
.msg.me .msg-col { align-items: flex-end; }
.bubble { padding: 10px 14px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); font-size: 17px; line-height: 1.5; overflow-wrap: anywhere; }
.msg.ai .bubble { border-top-left-radius: 6px; }
.msg.me .bubble { background: var(--me); color: var(--me-text); border-top-right-radius: 6px; }
.heard-label { font-size: 12px; color: var(--muted); }
.zh { font-size: 15px; color: var(--muted); padding: 0 4px; }
.msg-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 99px;
  padding: 5px 12px; font-size: 14px; cursor: pointer; min-height: 34px; -webkit-tap-highlight-color: transparent;
}
.chip:active { background: var(--primary-soft); }
.chip.on { border-color: var(--primary); color: var(--primary); }
.tip-card, .help-card { border-radius: 12px; padding: 10px 12px; font-size: 15px; line-height: 1.5; }
.tip-card { background: var(--warn-bg); color: var(--warn-text); }
.help-card { background: var(--help-bg); color: var(--help-text); }
.tip-card .label, .help-card .label { font-weight: 700; display: block; margin-bottom: 2px; }
.tip-card .wrong { text-decoration: line-through; opacity: 0.8; }
.tip-card .better, .help-card .en { font-weight: 700; font-size: 16px; }
.tip-card .why { display: block; font-size: 13px; margin-top: 4px; opacity: 0.9; }
.say-btn { border: 0; background: none; cursor: pointer; font-size: 18px; padding: 0 4px; vertical-align: -2px; }
.thinking { color: var(--muted); font-size: 15px; display: flex; align-items: center; gap: 8px; }
.dots::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.dock-status { font-size: 14px; color: var(--muted); min-height: 22px; text-align: center; }
.hold-btn {
  width: 96px; height: 96px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--primary); color: var(--primary-text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 40%, transparent);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, background 0.15s;
}
.hold-icon { font-size: 30px; line-height: 1; pointer-events: none; }
.hold-text { font-size: 13px; font-weight: 700; pointer-events: none; }
.hold-btn.recording { background: var(--rec); transform: scale(1.12); box-shadow: 0 0 0 10px color-mix(in srgb, var(--rec) 22%, transparent); }
.hold-btn:disabled { opacity: 0.45; cursor: default; }
.mock-say { font-size: 13px; padding: 2px 8px; }

/* ---------- 错句本 / 历史记录 ---------- */
.page-title { margin: 20px 0 4px; font-size: 22px; }
.page-tip { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.day-label { margin: 18px 2px 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.mistake { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin: 8px 0; }
.mistake .wrong { color: var(--muted); text-decoration: line-through; font-size: 15px; }
.mistake .better { font-weight: 700; font-size: 17px; margin-top: 2px; }
.mistake .why { font-size: 13px; color: var(--muted); margin-top: 4px; }
.mistake .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.mistake .scene-tag { font-size: 12px; color: var(--muted); }
.history-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 0; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; margin: 8px 0; cursor: pointer; text-decoration: none; color: var(--text);
}
.history-item .main { flex: 1; min-width: 0; }
.history-item .title { font-weight: 700; }
.history-item .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item .go { color: var(--primary); font-size: 22px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* ---------- 弹窗和提示 ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 18px; padding: 20px 18px 16px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); }
.modal-card h3 { margin: 0 0 4px; font-size: 20px; }
.modal-tip { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.modal-card input {
  width: 100%; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  padding: 0 14px; font-size: 18px; text-align: center; outline: none;
}
.modal-card input:focus { border-color: var(--primary); }
.modal-error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(170px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  max-width: calc(100% - 32px); background: rgba(20, 30, 40, 0.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px; text-align: center;
}
