:root {
  --bg: #f6f1e7;
  --panel: #fffdf8;
  --card: #ffffff;
  --text: #3a3530;
  --text-dim: #8a8378;
  --accent: #b5651d;
  --accent-soft: #f3e2d0;
  --border: #e8e0d2;
  --ew: #1a6b5a;
  --ew-bg: #e5f3ef;
  --shadow: 0 2px 10px rgba(90, 70, 40, 0.08);
}
body[data-theme="light"] {
  --bg: #f4f5f7; --panel: #ffffff; --card: #ffffff; --text: #2b2f33;
  --text-dim: #878d94; --accent: #2f6fd6; --accent-soft: #e3edfb;
  --border: #e3e6ea; --ew: #1a6b8f; --ew-bg: #e3f2f8;
  --shadow: 0 2px 10px rgba(30, 40, 60, 0.07);
}
body[data-theme="dark"] {
  --bg: #1e2126; --panel: #262a31; --card: #2c313a; --text: #d8dce2;
  --text-dim: #8b919b; --accent: #d9a05b; --accent-soft: #3a3226;
  --border: #3a4049; --ew: #7fd4bc; --ew-bg: #24413a;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--text);
  transition: background 0.25s, color 0.25s;
  min-height: 100vh;
}

/* ── 顶栏 ─────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 600;
}
.brand h1 { font-size: 18px; font-weight: 600; }
.slogan { font-size: 12px; color: var(--text-dim); }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 8px 12px; cursor: pointer; font-size: 14px;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.off { opacity: 0.45; }

/* ── 布局 ─────────────────────────── */
.layout {
  display: grid; grid-template-columns: 340px 1fr; gap: 20px;
  max-width: 1200px; margin: 20px auto; padding: 0 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

/* ── 左侧面板 ─────────────────────── */
.panel { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; box-shadow: var(--shadow);
}
.card h2 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text); }
.samples { display: flex; gap: 8px; margin-bottom: 10px; }
.sample-btn {
  flex: 1; border: 1px solid var(--border); background: var(--panel);
  color: var(--text); border-radius: 8px; padding: 7px 4px; font-size: 12px; cursor: pointer;
}
.sample-btn:hover { border-color: var(--accent); color: var(--accent); }
#input-text {
  width: 100%; height: 150px; resize: vertical;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; font-size: 13px; line-height: 1.6;
  background: var(--panel); color: var(--text);
}
#input-text:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.input-actions { display: flex; gap: 10px; margin-top: 10px; }
.upload-btn {
  flex: 1; text-align: center; border: 1px dashed var(--border);
  border-radius: 10px; padding: 9px; font-size: 13px; cursor: pointer; color: var(--text-dim);
}
.upload-btn:hover { border-color: var(--accent); color: var(--accent); }
.primary-btn {
  flex: 1.4; border: none; border-radius: 10px; padding: 9px;
  background: var(--accent); color: #fff; font-size: 14px; cursor: pointer; font-weight: 500;
}
.primary-btn:hover { filter: brightness(1.08); }

.field { margin-bottom: 14px; }
.field > label { font-size: 13px; color: var(--text-dim); display: block; margin-bottom: 8px; }
.field.row { display: flex; align-items: center; justify-content: space-between; }
.hint { font-size: 11px; color: var(--text-dim); margin-top: 6px; }
.level-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 500; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.switch-label { font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.font-ctrl { display: flex; gap: 6px; }
.font-ctrl button {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 12px;
}

.stats { display: flex; gap: 10px; }
.stat {
  flex: 1; text-align: center; background: var(--panel);
  border-radius: 10px; padding: 10px 4px;
}
.stat b { display: block; font-size: 20px; color: var(--accent); }
.stat span { font-size: 11px; color: var(--text-dim); }

/* ── 阅读区 ───────────────────────── */
.reader-wrap { min-height: 60vh; }
.empty-state {
  text-align: center; padding: 90px 20px; color: var(--text-dim);
  background: var(--card); border: 1px dashed var(--border); border-radius: 16px;
}
.empty-icon { font-size: 46px; margin-bottom: 14px; }
.empty-state h2 { font-size: 18px; font-weight: 500; color: var(--text); margin-bottom: 10px; }
.empty-state p { font-size: 13px; line-height: 1.9; }

.reader {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px 48px; box-shadow: var(--shadow);
  font-size: var(--reader-fs, 18px); line-height: 2.1;
  letter-spacing: 0.02em; white-space: pre-wrap; word-break: break-word;
}
@media (max-width: 600px) { .reader { padding: 22px 18px; } }

.ew {
  color: var(--ew); background: var(--ew-bg);
  border-radius: 5px; padding: 0 4px; margin: 0 1px;
  cursor: pointer; font-weight: 500; font-style: normal;
  border-bottom: 1px dashed var(--ew);
  transition: background 0.15s;
  user-select: none;
}
.ew:hover { filter: brightness(0.96); }
.ew.revealed { background: transparent; border-bottom-color: transparent; color: inherit; font-weight: 400; }
.ew.revealed::after {
  content: attr(data-zh); font-size: 0.72em; color: var(--text-dim);
  margin-left: 4px; border-bottom: 1px dashed var(--text-dim);
}
.reader.show-all .ew::after {
  content: attr(data-zh); font-size: 0.72em; color: var(--text-dim);
  margin-left: 4px; opacity: 0.75;
}

/* ── 生词本 ───────────────────────── */
.notebook {
  position: fixed; top: 0; right: 0; width: 340px; max-width: 92vw; height: 100vh;
  background: var(--panel); border-left: 1px solid var(--border);
  box-shadow: -6px 0 24px rgba(0,0,0,0.12); z-index: 50;
  display: flex; flex-direction: column; padding: 18px;
}
.nb-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.nb-header h2 { font-size: 16px; }
.mini-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 8px; padding: 5px 12px; font-size: 12px; cursor: pointer; margin-left: 6px;
}
.nb-list { list-style: none; overflow-y: auto; flex: 1; }
.nb-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px;
}
.nb-list .en { color: var(--ew); font-weight: 500; }
.nb-list .zh { color: var(--text-dim); font-size: 13px; margin-left: 8px; }
.nb-list .del { cursor: pointer; color: var(--text-dim); border: none; background: none; font-size: 14px; }
.nb-empty { color: var(--text-dim); font-size: 13px; text-align: center; margin-top: 40px; line-height: 1.8; }

/* ── 其他 ─────────────────────────── */
.toast {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 22px;
  border-radius: 999px; font-size: 13px; z-index: 60; opacity: 0.95;
}
.footer {
  text-align: center; padding: 26px 0 34px; font-size: 12px; color: var(--text-dim);
}
