:root {
  --bg: #1a1a1a;
  --surface: #262626;
  --surface-hover: #2f2f2f;
  --border: #383838;
  --accent: #d4a574;
  --accent-dim: rgba(212,165,116,0.15);
  --text: #ececec;
  --text-muted: #888;
  --text-dim: #555;
  --green: #4caf7d;
  --green-dim: rgba(76,175,125,0.15);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ── Navbar ── */
.nav {
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 32px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.nav-brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  transition: color .15s, background .15s;
}
.nav-links a:hover { color: var(--text); background: var(--surface); }
.nav-links a.active { color: var(--text); background: var(--surface); }
.nav-right { margin-left: auto; }

/* ── Layout ── */
.page { max-width: 900px; margin: 0 auto; padding: 32px 24px; }

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: center; gap: 8px; flex: 1; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

/* ── Search ── */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  flex: 1;
  max-width: 320px;
}
.search svg { color: var(--text-dim); flex-shrink: 0; }
.search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  padding: 8px 0;
  width: 100%;
}
.search input::placeholder { color: var(--text-dim); }

/* ── Filter pills ── */
.filter-pills { display: flex; gap: 6px; }
.pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .85; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #1a1a1a; }
.btn-ghost { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }

/* ── Per-page select ── */
.per-page {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
}
.per-page select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
}

/* ── Word table ── */
.word-table { width: 100%; border-collapse: collapse; }
.word-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.word-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.word-table tr:last-child td { border-bottom: none; }
.word-table tr:hover td { background: var(--surface-hover); }
.word-table tr { cursor: pointer; transition: background .1s; }

.w-word { font-weight: 500; font-size: 15px; }
.w-pos {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  margin-left: 6px;
  vertical-align: middle;
}
.w-def { color: var(--text-muted); font-size: 13px; max-width: 400px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-date { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.w-status {}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
}
.badge-exported { background: var(--green-dim); color: var(--green); }
.badge-pending { background: var(--surface); color: var(--text-dim); border: 1px solid var(--border); }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 12px;
}
.page-btns { display: flex; gap: 4px; }
.page-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  transition: all .15s;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #1a1a1a; font-weight: 600; }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ── Word detail ── */
.detail-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.detail-header h1 { font-size: 28px; font-weight: 600; margin-bottom: 6px; }
.detail-meta { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 13px; }
.detail-phonetic { color: var(--text-muted); }

.section { margin-bottom: 20px; }
.section-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.section-body { color: var(--text); font-size: 14px; line-height: 1.6; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.example-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 16px;
}
.example-en { font-style: italic; margin-bottom: 4px; }
.example-zh { color: var(--text-muted); font-size: 13px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all .15s;
}
.back-link:hover { color: var(--text); background: var(--surface); }

/* ── Stats cards ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-num { font-size: 26px; font-weight: 600; color: var(--accent); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Empty / loading ── */
.empty { text-align: center; padding: 60px 0; color: var(--text-dim); font-size: 13px; }
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 99;
  animation: fadeUp .2s ease;
}
.toast.ok { border-color: var(--green); }
.toast.err { border-color: #e05c5c; }
@keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

/* ── Updated bar ── */
.updated-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--text-dim);
}
.refresh-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color .15s;
}
.refresh-btn:hover { color: var(--accent); }

/* ── Page title ── */
.page-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Article list ── */
.article-grid { display: flex; flex-direction: column; gap: 12px; }
.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: border-color .15s;
}
.article-card:hover { border-color: var(--accent); }
.article-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.article-card-date { font-size: 11px; color: var(--text-dim); }
.article-card-words { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.article-card-preview { color: var(--text-muted); font-size: 13px; line-height: 1.6; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ── Word picker ── */
.word-picker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.word-picker-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.word-picker-title { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.word-picker-list { display: flex; flex-wrap: wrap; gap: 7px; min-height: 36px; }
.word-chip {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.word-chip:hover { background: var(--accent); color: #1a1a1a; }
.word-chip.selected { background: var(--accent); color: #1a1a1a; }

/* ── Article detail ── */
.article-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  font-size: 15px;
  line-height: 1.8;
  margin-bottom: 24px;
  color: var(--text);
}
.article-content mark {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 2px;
}

.questions-section { margin-bottom: 24px; }
.question-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.question-text { font-size: 14px; margin-bottom: 10px; }
.answer-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 72px;
  font-family: var(--font);
  margin-bottom: 8px;
}
.answer-input:focus { outline: none; border-color: var(--accent); }
.correction-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: 0 6px 6px 0;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre-wrap;
  margin-top: 8px;
}
