/* ==========================================================================
   词库 v1.1 · 本地离线学习网站 v0.1 — 样式
   纯本地、无外部字体/CDN；阿拉伯语区域 dir=rtl / lang=ar，行高 ≥ 2.0。
   ========================================================================== */

:root {
  --ink: #23201b;
  --ink-2: #4d453a;
  --muted: #7c7264;
  --line: #ddd2c0;
  --line-strong: #c4b498;
  --paper: #fbf7ef;
  --paper-2: #f4ecdd;
  --card: #fffdf8;
  --bg: #eee6d8;
  --accent: #7a2e1e;
  --accent-2: #9c5a2e;
  --good: #2f6b4f;
  --good-bg: #e8f3ec;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --bad: #7d3b3b;
  --bad-bg: #f7e8e6;
  --shadow: 0 2px 10px rgba(60, 44, 24, 0.10);
  --radius: 12px;
  --font-ui: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Tahoma, sans-serif;
  --font-ar: "Amiri", "Scheherazade New", "Traditional Arabic", "Noto Naskh Arabic",
              "Sakkal Majalla", "Arial", serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 2.0; /* 契约要求 ≥ 2.0 */
}

button, input { font: inherit; color: inherit; }

/* ---------------------------------- 顶栏 --------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 22px;
  padding: 10px 20px;
  background: #2c251d;
  color: #f5eee1;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #f8e3bd;
}

.brand .sub {
  margin: 1px 0 0;
  font-size: 12px;
  color: #cdbfa9;
}

.brand .ver {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border: 1px solid #8e785a;
  border-radius: 4px;
  font-size: 11px;
  color: #e8d4b0;
}

.brand-ar {
  display: inline-block;
  margin-left: 10px;
  font-family: var(--font-ar);
  font-size: 15px;
  line-height: 2.0;
  color: #e0c9a4;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat {
  min-width: 72px;
  padding: 2px 12px;
  border: 1px solid #5c4d39;
  border-radius: 8px;
  background: #3a3025;
  text-align: center;
}

.stat .num {
  display: block;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  color: #f6d9a8;
}

.stat .lbl {
  display: block;
  font-size: 11px;
  line-height: 1.4;
  color: #bfae94;
}

.stat.ok { border-color: #3d6b52; background: #2d4237; }
.stat.ok .num { color: #b8e3c8; }
.stat.warn { border-color: #7a5c25; background: #443619; }
.stat.warn .num { color: #f2cc84; }
.stat.muted { opacity: 0.72; }

/* ---------------------------------- 布局 --------------------------------- */

.layout {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px 18px 42px;
}

/* ---------------------------------- 侧栏 --------------------------------- */

.side {
  position: sticky;
  top: 78px;
  flex: 0 0 300px;
  width: 300px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.side-block { padding: 8px 6px 12px; border-bottom: 1px dashed var(--line); }
.side-block:last-child { border-bottom: none; }

.side-title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.field-label {
  display: block;
  margin-bottom: 4px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fffdf8;
  line-height: 1.8;
}

.search:focus {
  outline: 2px solid #c9a86a;
  outline-offset: 1px;
}

.hint {
  margin: 6px 0 0;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--muted);
}

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Naked Mode 开关 */

.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.switch-ui {
  display: inline-block;
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 12px;
  background: #cfc2ac;
  transition: background 0.15s ease;
  flex: 0 0 40px;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fffdf8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.switch input:checked + .switch-ui { background: var(--accent-2); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid #c9a86a; outline-offset: 2px; }
.switch-label { font-size: 13px; }

/* 状态筛选 */

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.chip {
  padding: 3px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fffdf8;
  cursor: pointer;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink-2);
}

.chip:hover { border-color: var(--accent-2); color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff7ea; }

/* 课程导航 */

#lessons { display: flex; flex-direction: column; gap: 3px; }

.lesson-btn {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "no ar count" "no zh count";
  align-items: center;
  column-gap: 8px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  line-height: 1.75;
}

.lesson-btn:hover { background: var(--paper-2); }
.lesson-btn.active { background: #f1e5cf; border-color: var(--line-strong); }

.lesson-no { grid-area: no; font-size: 11.5px; color: var(--accent-2); font-weight: 700; white-space: nowrap; }
.lesson-ar {
  grid-area: ar;
  font-family: var(--font-ar);
  font-size: 16px;
  color: var(--ink);
  text-align: right;
}
.lesson-zh { grid-area: zh; font-size: 11.5px; color: var(--muted); }
.lesson-count {
  grid-area: count;
  min-width: 30px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e9dfcc;
  font-size: 11.5px;
  color: var(--ink-2);
  text-align: center;
}

.side-note ul { margin: 4px 0 0; padding-inline-start: 18px; }
.side-note li { font-size: 11.5px; color: var(--muted); line-height: 1.85; }

/* ---------------------------------- 主区 --------------------------------- */

.main { flex: 1 1 auto; min-width: 0; }

.lesson-head {
  margin: 0 0 14px;
  padding: 14px 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.lesson-head h2 {
  margin: 0;
  font-size: 20px;
  color: var(--accent);
  line-height: 1.8;
}

.lesson-head .muted { margin: 2px 0 0; font-size: 12.5px; }

.muted { color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 12px;
}

/* ---------------------------------- 词卡 --------------------------------- */

.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  break-inside: avoid;
}

.card.status-pending { border-color: #e0c98f; background: #fffcf4; }
.card.status-rejected { display: none; }

.card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 11.5px;
  color: var(--muted);
}

.badge {
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.9;
  border: 1px solid transparent;
}

.badge-verified { color: var(--good); background: var(--good-bg); border-color: #b9d6c4; }
.badge-pending { color: var(--warn); background: var(--warn-bg); border-color: #e0c98f; }
.badge-rejected { color: var(--bad); background: var(--bad-bg); border-color: #d9b3ae; }

.entry-id { font-family: Consolas, "Courier New", monospace; font-size: 11px; color: #9a8d7b; }
.page { margin-left: auto; }

.naked-tag {
  padding: 0 7px;
  border-radius: 999px;
  border: 1px dashed var(--line-strong);
  background: var(--paper-2);
  color: var(--accent-2);
  font-size: 11px;
}

.word-row {
  display: flex;
  align-items: center;
  gap: 10px;
  direction: ltr;
}

.word {
  flex: 1 1 auto;
  min-width: 0;
  direction: rtl;
  text-align: right;
  font-family: var(--font-ar);
  font-size: 26px;
  line-height: 2.2; /* 阿语行高 ≥ 2.0 */
  color: #1f1a14;
  word-break: break-word;
}

.verb-forms {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
  margin: 0;
}

.verb-form {
  flex: 1 1 28%;
  min-width: 66px;
  padding: 4px 5px;
  border-radius: 6px;
  background: var(--paper-2);
  text-align: center;
}

.verb-form dt { color: var(--muted); font-size: 11px; }
.verb-form dd { margin: 0; }
.verb-form dd[lang="ar"] {
  font-family: var(--font-ar);
  font-size: 22px;
  line-height: 2;
  overflow-wrap: anywhere;
}
.verb-form .verb-form-pending { color: var(--warn); font-size: 12px; line-height: 44px; }

.fields { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }

.pos {
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 11.5px;
  line-height: 1.9;
  white-space: nowrap;
}

.meaning { font-size: 15px; color: var(--ink); }

.pending-note {
  padding: 3px 10px;
  border: 1px dashed #e0c98f;
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 12px;
  line-height: 1.9;
}

.morph { font-size: 12px; color: var(--ink-2); line-height: 1.9; }

.sentence {
  margin-top: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfaf3;
}

.sentence-row { display: flex; align-items: flex-start; gap: 8px; direction: ltr; }

.sentence-ar {
  flex: 1 1 auto;
  margin: 0;
  direction: rtl;
  text-align: right;
  font-family: var(--font-ar);
  font-size: 18px;
  line-height: 2.1;
  color: #2a241d;
}

.sentence-zh { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }

.card-meta { margin-top: auto; font-size: 11.5px; }

/* 音频按钮 */

.audio-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.audio-btn:hover { background: #eadcc3; }
.audio-btn.loading { background: #fff1cf; color: var(--warn); cursor: progress; }
.audio-btn.playing { background: var(--accent); border-color: var(--accent); color: #fff7ea; }
.audio-btn.error { background: var(--bad-bg); border-color: #d9b3ae; color: var(--bad); }
.audio-btn.disabled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  color: #b6a894;
  cursor: default;
  background: transparent;
  font-size: 12px;
}

/* ---------------------------------- 空状态 / 页脚 --------------------------------- */

.empty {
  margin: 40px auto;
  padding: 26px;
  max-width: 520px;
  text-align: center;
  background: var(--paper);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-2);
}

.link-btn {
  margin-top: 8px;
  padding: 5px 14px;
  border: 1px solid var(--accent-2);
  border-radius: 999px;
  background: transparent;
  color: var(--accent-2);
  cursor: pointer;
}

.link-btn:hover { background: var(--paper-2); }

.footer {
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px 22px 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.9;
}

.footer p { margin: 3px 0; }

/* ---------------------------------- 响应式 --------------------------------- */

@media (max-width: 1000px) {
  .layout { flex-direction: column; padding: 12px; }
  .side {
    position: static;
    width: 100%;
    flex: 1 1 auto;
    max-height: none;
  }
  .cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .stats { justify-content: flex-start; }
}

@media (max-width: 560px) {
  body { font-size: 14px; }
  .topbar { padding: 9px 12px; }
  .brand h1 { font-size: 16px; }
  .stat { min-width: 60px; padding: 1px 8px; }
  .stat .num { font-size: 15px; }
  .word { font-size: 23px; }
  .cards { grid-template-columns: 1fr; }
  .lesson-head { padding: 11px 14px; }
}

@media print {
  .topbar, .side, .empty, .footer { display: none; }
  .layout { display: block; padding: 0; }
  .card { break-inside: avoid; }
}
