
:root {
  --bg: #f6f7f4;
  --panel: #fff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #d9ddd5;
  --accent: #2f6f73;
  --accent-soft: #e3f0ec;
  --danger: #9f3a38;
  --gold: #b7791f;
  --side: #fbfbf8;
  --field: #fff;
  --link: #1d4e52;
  --header: rgba(246, 247, 244, 0.94);
}
[data-theme="dark"] {
  --bg: #111816;
  --panel: #18211f;
  --ink: #edf2ef;
  --muted: #a9b6b0;
  --line: #33413c;
  --accent: #7ab7aa;
  --accent-soft: #213732;
  --danger: #f0a29d;
  --gold: #e6c36a;
  --side: #141c1a;
  --field: #101715;
  --link: #8dc9bc;
  --header: rgba(17, 24, 22, 0.94);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111816;
    --panel: #18211f;
    --ink: #edf2ef;
    --muted: #a9b6b0;
    --line: #33413c;
    --accent: #7ab7aa;
    --accent-soft: #213732;
    --danger: #f0a29d;
    --gold: #e6c36a;
    --side: #141c1a;
    --field: #101715;
    --link: #8dc9bc;
    --header: rgba(17, 24, 22, 0.94);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", sans-serif;
}
button, input, select { font: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  border-radius: 7px;
  padding: 8px 11px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); color: var(--link); }
button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--link); }
.kp-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 320px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--side);
  padding: 18px;
}
.kp-brand { display: grid; gap: 4px; margin-bottom: 14px; }
.kp-brand strong { font-size: 20px; }
.kp-brand span, .kp-kicker, .kp-note, .card-meta { color: var(--muted); font-size: 13px; }
.kp-link {
  display: block;
  color: var(--link);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: var(--field);
  margin-bottom: 8px;
  font-weight: 700;
}
.kp-link:hover { background: var(--accent-soft); border-color: var(--accent); }
.kp-field { display: grid; gap: 6px; margin: 12px 0; }
.kp-field input, .kp-field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--ink);
  padding: 10px 12px;
}
.kp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.kp-actions button { flex: 1 1 120px; }
.kp-note { margin-top: 16px; }
.kp-main { margin-left: 320px; min-height: 100vh; }
.kp-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--header);
  backdrop-filter: blur(10px);
  padding: 20px clamp(20px, 4vw, 54px);
}
h1 { margin: 0; font-size: clamp(30px, 4vw, 44px); line-height: 1.1; letter-spacing: 0; }
.kp-metrics { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.kp-metrics div {
  min-width: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px 10px;
}
.kp-metrics strong { display: block; font-size: 20px; line-height: 1.1; }
.kp-metrics span { color: var(--muted); font-size: 12px; }
.review-panel, .card-list {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 44px) 0;
}
.card-list { padding-bottom: 80px; }
.study-card, .browse-card, .inspect-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(18px, 3vw, 30px);
}
.study-card.marked, .browse-card.marked, .inspect-card.marked {
  border-color: var(--gold);
  box-shadow: inset 4px 0 0 var(--gold);
}
.study-card { min-height: 380px; display: grid; gap: 18px; }
.browse-card { margin-bottom: 14px; }
.inspect-card { margin-bottom: 14px; }
.inspect-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(0, 1.4fr);
  gap: 16px;
}
.inspect-front, .inspect-back {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--side);
}
.inspect-front h2, .inspect-back h3 {
  margin: 0 0 10px;
  line-height: 1.35;
}
.inspect-front h2 { font-size: 20px; }
.inspect-back h3 { font-size: 15px; color: var(--muted); }
.card-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  background: var(--side);
}
.next-due {
  color: var(--muted);
  font-size: 14px;
}
.note-box {
  display: grid;
  gap: 7px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.note-box label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.note-box textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}
.note-box.compact textarea { min-height: 64px; }
.highlight-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.highlight-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  padding: 2px 7px;
  font-size: 12px;
}
.highlight-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 190px;
}
.highlight-chip button {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  line-height: 1;
}
.user-highlight {
  background: #fff2a8;
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}
[data-theme="dark"] .user-highlight {
  background: #6f5f12;
}
.shortcut {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border: 1px solid currentColor;
  border-radius: 5px;
  margin-right: 6px;
  font-size: 12px;
  font-weight: 800;
}
.front {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.35;
}
.answer {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.answer.hidden { display: none; }
.answer p { margin: 0 0 10px; text-align: justify; }
.answer ul { margin: 0 0 10px; padding-left: 1.4em; }
.answer li { margin: 6px 0; }
.answer table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.answer td, .answer th { border: 1px solid var(--line); padding: 7px 8px; vertical-align: top; }
.answer .table-wrap { overflow-x: auto; }
.math-inline {
  font-family: "Times New Roman", Georgia, serif;
  font-style: italic;
  white-space: nowrap;
}
sub, sup { font-size: 0.72em; line-height: 0; }
.review-actions, .rating-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rating-actions button {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 2px 0;
  min-width: 130px;
  text-align: left;
}
.rating-actions button .next-due {
  grid-column: 2;
  font-size: 12px;
}
.rating-actions button[data-rating="again"] { border-color: #e5b8b5; color: var(--danger); }
.rating-actions button[data-rating="hard"] { border-color: #e8d6a8; color: var(--gold); }
.rating-actions button[data-rating="good"], .rating-actions button[data-rating="easy"] { border-color: #b9d6cb; color: var(--link); }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 70px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.kp-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--link);
  color: #fff;
  padding: 10px 14px;
  border-radius: 7px;
  opacity: 0;
  transform: translateY(8px);
  transition: 160ms ease;
  pointer-events: none;
}
.kp-toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 860px) {
  .kp-sidebar {
    position: sticky;
    top: 0;
    z-index: 8;
    width: auto;
    max-height: 44vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
  }
  .kp-brand { grid-template-columns: 1fr auto; align-items: center; margin-bottom: 8px; }
  .kp-brand strong { font-size: 18px; }
  .kp-link { display: inline-block; margin: 0 6px 8px 0; padding: 5px 8px; font-size: 13px; }
  .kp-field { margin: 8px 0; }
  .kp-field span, .kp-note { display: none; }
  .kp-field input, .kp-field select { padding: 7px 9px; }
  .kp-actions { gap: 6px; margin: 8px 0 0; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .kp-actions button { flex: 0 0 auto; padding: 5px 8px; font-size: 13px; white-space: nowrap; }
  .kp-main { margin-left: 0; }
  .kp-header { position: static; align-items: flex-start; flex-direction: column; gap: 10px; padding: 14px 16px; }
  .kp-kicker { display: none; }
  h1 { font-size: 26px; }
  .kp-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
  .kp-metrics div { min-width: 0; }
  .review-panel, .card-list { padding-top: 14px; }
  .study-card { min-height: 0; gap: 12px; }
  .study-card, .browse-card, .inspect-card { padding: 14px; }
  .review-actions, .rating-actions { gap: 6px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .rating-actions button, .review-actions button {
    flex: 0 0 auto;
    min-width: auto;
    min-height: 34px;
    padding: 5px 8px;
    font-size: 13px;
    white-space: nowrap;
  }
  .rating-actions button { grid-template-columns: auto auto; }
  .rating-actions button .next-due { display: none; }
  .note-box { gap: 6px; padding-top: 10px; }
  .note-box textarea { min-height: 58px; }
  .inspect-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  body { font-size: 15px; }
  .kp-sidebar { max-height: 38vh; }
  .kp-header { padding: 12px; }
  .review-panel, .card-list { padding: 16px 12px 0; }
  .kp-metrics { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .kp-metrics div { padding: 7px 8px; }
  .kp-metrics strong { font-size: 18px; }
  .front { font-size: 22px; }
  .card-meta { gap: 5px; }
  .badge { font-size: 12px; padding: 1px 6px; }
  .answer { padding-top: 12px; }
  .answer p { margin-bottom: 8px; }
  .shortcut { min-width: 18px; height: 18px; border-radius: 4px; font-size: 11px; margin-right: 4px; }
}
