/* 职场英语 · Work English — 样式 */
:root {
  --bg: #f5f6f8;
  --bg-elev: #ffffff;
  --bg-soft: #eef1f6;
  --text: #131a26;
  --text-dim: #5b6675;
  --text-faint: #8b95a3;
  --line: #e3e7ee;
  --accent: #2f6df6;
  --accent-soft: #e8f0ff;
  --good: #16a34a;
  --good-soft: #e8f7ee;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --bad: #dc2626;
  --bad-soft: #fdeced;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px -8px rgba(16, 24, 40, .12);
  --maxw: 760px;
  --tabh: 60px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1319;
    --bg-elev: #171d26;
    --bg-soft: #1e2531;
    --text: #e9edf3;
    --text-dim: #9aa5b4;
    --text-faint: #6b7686;
    --line: #273040;
    --accent: #6c9bff;
    --accent-soft: #1b2942;
    --good: #4ade80;
    --good-soft: #16301f;
    --warn: #fbbf24;
    --warn-soft: #33280f;
    --bad: #f87171;
    --bad-soft: #3a1d1f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  padding-bottom: calc(var(--tabh) + env(safe-area-inset-bottom, 0px));
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* ---------- 布局 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; font-weight: 700; }
.brand-text small { font-weight: 500; font-size: 11px; color: var(--text-faint); letter-spacing: .04em; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px; font-size: 13px;
  background: var(--bg-soft); color: var(--text-dim); border: 1px solid var(--line);
}
.view { max-width: var(--maxw); margin: 0 auto; padding: 18px 16px 28px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center; gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1 1 0; max-width: 120px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 0; border-radius: 10px;
  font-size: 11px; color: var(--text-faint);
}
.tabbar a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ---------- 通用组件 ---------- */
.page-title { font-size: 22px; font-weight: 800; margin: 4px 0 2px; }
.page-sub { color: var(--text-dim); font-size: 14px; margin: 0 0 16px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--text-dim); margin: 22px 0 10px; letter-spacing: .02em; }

.card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card.tappable { transition: transform .08s ease; }
.card.tappable:active { transform: scale(.985); }
.grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }
/* 数字统计始终两列，避免窄屏下堆叠 */
.grid.keep2 { grid-template-columns: 1fr 1fr; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-elev); cursor: pointer; font-weight: 600;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 14px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: default; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); font-size: 13px; }
.center { text-align: center; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb8 { margin-bottom: 8px; }

.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  background: var(--bg-soft); color: var(--text-dim); border: 1px solid var(--line);
}
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.progressbar { height: 8px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.progressbar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }

.stat { text-align: center; padding: 12px 6px; }
.stat b { display: block; font-size: 24px; font-weight: 800; }
.stat span { font-size: 12px; color: var(--text-faint); }

/* ---------- 句型卡 ---------- */
.phrase {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 12px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.phrase .en { font-size: 17px; font-weight: 650; line-height: 1.45; }
.phrase .zh { color: var(--text-dim); margin-top: 4px; }
.phrase .note { color: var(--text-faint); font-size: 13px; margin-top: 6px; }
.phrase .tools { display: flex; gap: 8px; margin-top: 10px; }
.iconbtn {
  border: 1px solid var(--line); background: var(--bg-soft); border-radius: 9px;
  padding: 6px 12px; cursor: pointer; font-size: 14px;
}
.iconbtn:active { transform: scale(.97); }
.phrase.learned { border-left: 3px solid var(--good); }

/* ---------- 复习卡 ---------- */
.review-stage { display: flex; flex-direction: column; min-height: 56vh; }
.flashcard {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 14px; padding: 26px 18px; cursor: pointer;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.flashcard .front { font-size: 24px; font-weight: 750; line-height: 1.4; }
.flashcard .back-zh { font-size: 18px; color: var(--text-dim); }
.flashcard .hint { color: var(--text-faint); font-size: 13px; }
.grade-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.grade-row .btn { flex-direction: column; padding: 12px 6px; }
.grade-row .btn small { font-weight: 500; font-size: 11px; opacity: .75; }

/* ---------- 对话 ---------- */
.bubble { display: flex; gap: 10px; margin-bottom: 14px; }
.bubble .avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; background: var(--bg-soft); color: var(--text-dim);
  border: 1px solid var(--line);
}
.bubble.b .avatar { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.bubble .body {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 4px 14px 14px 14px;
  padding: 10px 13px; box-shadow: var(--shadow); max-width: 86%;
}
.bubble.b .body { border-radius: 14px 4px 14px 14px; }
.bubble .en { font-weight: 600; }
.bubble.key .body { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.bubble .zh { color: var(--text-dim); font-size: 14px; margin-top: 3px; }
.bubble .who { font-size: 11px; font-weight: 700; color: var(--text-faint); letter-spacing: .03em; margin-bottom: 3px; }
.bubble.hidden-line .en, .bubble.hidden-line .zh { filter: blur(6px); }

/* ---------- 听写 ---------- */
.dict-input {
  width: 100%; min-height: 96px; resize: vertical;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  background: var(--bg-elev); color: var(--text); font: inherit;
}
.dict-input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.diff-ok { color: var(--good); font-weight: 650; }
.diff-miss { color: var(--bad); text-decoration: underline wavy var(--bad); }
.diff-extra { color: var(--text-faint); text-decoration: line-through; }

/* ---------- 图表 ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 96px; margin-top: 8px; }
.bars > div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.bars i { display: block; width: 100%; max-width: 34px; background: var(--accent); border-radius: 6px 6px 2px 2px; min-height: 3px; opacity: .9; }
.bars span { font-size: 10px; color: var(--text-faint); }

/* ---------- 邮件模板 ---------- */
.mail-body {
  white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px; line-height: 1.7; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 10px;
  overflow-x: auto;
}
.ph { background: var(--warn-soft); color: var(--warn); border-radius: 4px; padding: 0 3px; }

/* ---------- 其它 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabh) + 22px); transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 14px; z-index: 99; box-shadow: var(--shadow); max-width: 88vw;
}
.empty { text-align: center; color: var(--text-faint); padding: 40px 12px; }
.empty .big { font-size: 40px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list-plain li:last-child { border-bottom: 0; }
.kbd {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
  padding: 1px 6px; background: var(--bg-soft);
}
details.acc { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--bg-elev); margin-bottom: 10px; }
details.acc summary { cursor: pointer; font-weight: 600; }
details.acc[open] summary { margin-bottom: 8px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
select, input[type="text"], input[type="file"] {
  background: var(--bg-elev); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; font: inherit; max-width: 100%;
}
@media (min-width: 700px) {
  /* 宽屏：导航从底部移到顶部（DOM 中 nav 在 content 之后，用 flex order 提前） */
  #app { display: flex; flex-direction: column; }
  .topbar { order: 0; position: static; }
  .tabbar {
    order: 1; position: sticky; top: 0; bottom: auto;
    justify-content: center; border-top: 0; border-bottom: 1px solid var(--line);
  }
  .view { order: 2; padding-top: 26px; }
  body { padding-bottom: 0; }
  .tabbar a { flex-direction: row; gap: 6px; font-size: 13px; padding: 8px 14px; }
}
