/* pages/notes.css — trang Ghi chú & Ôn tập (templates/pages/notes.html). Bản vẽ: GCH_*, FC_*, FC_Q*.
   Chỉ dùng biến trong tokens.css. */

/* ── Chung ────────────────────────────────────────────────────────── */
.notes-page { max-width: 1060px; }
.notes-page .notes-h2 { margin: 32px 0 10px; }
.icon-btn {
  width: 32px; height: 32px; flex-shrink: 0; padding: 0;
  border: 0; border-radius: var(--r); background: none; color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }
.grow { flex-grow: 1; }
.tag-red { background: var(--red-bg); color: var(--red); }
.tag-violet { background: var(--violet-bg); color: var(--violet); }
.tag-btn { gap: 4px; border: 0; font: inherit; font-size: 13px; cursor: pointer; }
.code-tag {
  width: 30px; height: 20px; flex-shrink: 0; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-soft); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
}
.sec-label {
  margin: 0 0 10px; font-size: 13px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--reading);
}
.trans-row { display: flex; align-items: center; gap: 10px; min-height: 32px; flex-wrap: wrap; }
.trans-text { font-size: 16px; color: var(--ink); }
.trans-sub { font-size: 13px; color: var(--muted); }
.ex-sentence { margin: 0; font-size: 15px; line-height: 1.55; color: var(--muted); }
.ex-sentence.is-target { font-size: 17px; color: var(--ink); }
.ex-reading { margin: 4px 0 0; font-size: 12px; color: var(--faint); }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent);
  animation: notes-spin 0.8s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; flex-shrink: 0; }
@keyframes notes-spin { to { transform: rotate(360deg); } }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  height: 32px; padding: 0 14px; border: 0; border-radius: 999px;
  background: var(--bg-soft); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.pill .num { font-weight: 500; opacity: 0.7; }
.pill.is-on { background: var(--accent); color: var(--on-accent); }

/* ── Hộp đến hạn ôn ───────────────────────────────────────────────── */
.notes-callout { padding: 16px 18px; gap: 12px; flex-wrap: wrap; }
.notes-callout-main { display: flex; align-items: center; gap: 14px; flex: 1 1 280px; min-width: 0; }
.notes-callout-icon {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: var(--r-md);
  background: var(--bg); color: var(--accent); display: grid; place-items: center;
}
.notes-callout-text { flex-grow: 1; min-width: 0; }
.notes-callout-label { margin: 0; font-size: 13px; color: var(--muted); }
.notes-callout-title { margin: 2px 0; font-size: 16px; font-weight: 600; color: var(--ink); }
.notes-callout-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.notes-sec-btn { font-size: 14px; border-color: color-mix(in srgb, var(--accent) 16%, var(--bg)); }
.notes-sec-btn .icon { color: var(--muted); }
.notes-main-btn { font-size: 14px; padding: 0 16px; }
.notes-pill {
  height: 20px; padding: 0 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.22);
  font-size: 12px; display: inline-flex; align-items: center;
}

/* ── Thêm từ ──────────────────────────────────────────────────────── */
.notes-add { display: flex; gap: 8px; }
.notes-add-field {
  flex-grow: 1; min-width: 0; height: 44px; padding: 0 12px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); color: var(--faint);
}
.notes-add-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }
.notes-add-field input {
  flex-grow: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none;
  font: inherit; font-size: 15px; color: var(--ink);
}
.notes-add-btn { height: 44px; padding: 0 16px; border-radius: var(--r-md); font-size: 14px; gap: 8px; }
.notes-add-btn:disabled { opacity: 0.6; cursor: wait; }
.notes-add-hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

/* ── Tab ngôn ngữ + tìm kiếm ──────────────────────────────────────── */
.notes-views { display: flex; align-items: flex-end; gap: 18px; border-bottom: 1px solid var(--line); }
.notes-tabs { display: flex; gap: 18px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.notes-tab {
  height: 36px; padding: 0 2px; border: 0; background: none; white-space: nowrap;
  font: inherit; font-size: 14px; color: var(--muted); cursor: pointer;
}
.notes-tab:hover { color: var(--ink); }
.notes-tab[aria-selected="true"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--ink); }
.notes-tab-n { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--faint); }
.notes-search {
  margin: 0 0 4px auto; width: 240px; height: 32px; padding: 0 10px; flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: var(--r); color: var(--faint);
}
.notes-search:focus-within { border-color: var(--accent); }
.notes-search input {
  flex-grow: 1; min-width: 0; border: 0; outline: none; background: none;
  font: inherit; font-size: 13px; color: var(--ink);
}

/* ── Bảng từ đã lưu ───────────────────────────────────────────────── */
.notes-head, .nrow-main {
  display: grid; align-items: center;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.7fr) 120px 110px 104px;
}
.notes-head {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.7fr) 120px 110px 104px 40px;
  height: 34px; padding: 0 8px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.notes-table.is-empty .notes-head { display: none; }
.notes-table.is-loading .notes-list { opacity: 0.5; }
.notes-list { margin: 0; padding: 0; list-style: none; }
.nrow {
  display: grid; grid-template-columns: minmax(0, 1fr) 40px; align-items: center;
  min-height: 52px; padding: 0 8px; border-bottom: 1px solid var(--line);
}
.nrow:hover, .nrow.is-selected { background: var(--bg-soft); }
.nrow-main {
  min-height: 52px; padding: 6px 0; border: 0; background: none; text-align: left;
  font: inherit; font-size: 14px; color: var(--text); cursor: pointer;
}
.nrow-word { display: flex; align-items: baseline; gap: 8px; min-width: 0; padding-right: 12px; flex-wrap: wrap; }
.nrow-word b { font-size: 17px; font-weight: 700; color: var(--accent); overflow-wrap: anywhere; }
.nrow-reading { font-size: 13px; color: var(--reading); white-space: nowrap; }
.nrow-mean {
  padding-right: 12px; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.nrow-date { color: var(--muted); }
.nrow-due-m, .nrow-chev { display: none; }
.nrow-tts { justify-self: end; }
.nrow-pending {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 8px;
  border-bottom: 1px solid var(--line); background: var(--callout); color: var(--accent); font-size: 14px;
}
.notes-empty {
  margin-top: 8px; padding: 48px 24px;
  border: 1px dashed var(--line); border-radius: var(--r-md);
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
}
.notes-empty p { margin: 0; }
.notes-empty-icon {
  width: 56px; height: 56px; border-radius: var(--r-lg); background: var(--bg-soft); color: var(--faint);
  display: grid; place-items: center;
}
.notes-empty-title { margin-top: 6px !important; font-size: 16px; font-weight: 600; color: var(--ink); }
.notes-empty-text { max-width: 420px; font-size: 14px; line-height: 1.6; color: var(--muted); }
.notes-empty-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.notes-more { display: flex; justify-content: center; padding-top: 16px; }

/* ── Xem nhanh (side peek) ────────────────────────────────────────── */
.peek {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
  width: 560px; max-width: 100vw; display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(15, 23, 42, 0.1);
}
.peek[hidden] { display: none; }
.peek-bar {
  height: 52px; flex-shrink: 0; padding: 0 14px; display: flex; align-items: center; gap: 4px;
  border-bottom: 1px solid var(--line);
}
.peek-bar .icon-btn { width: 36px; height: 36px; }
.peek-body { flex-grow: 1; overflow-y: auto; padding: 28px 36px 40px; }
.peek-word { margin: 0; font-size: 46px; font-weight: 900; line-height: 1.15; color: var(--accent); overflow-wrap: anywhere; }
.peek-reading { margin: 6px 0 0; font-size: 22px; color: var(--reading); }
.peek-props { margin-top: 18px; }
.peek-props .prop-name { width: 130px; }
.peek-meaning { margin: 0 0 24px; font-size: 19px; font-weight: 500; line-height: 1.5; color: var(--ink); }
.peek-trans { margin-bottom: 20px; }
.peek-ex { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.peek-ex .code-tag { margin-top: 3px; }
.peek-ex-text { flex-grow: 1; min-width: 0; }

/* ── Sửa ghi chú ──────────────────────────────────────────────────── */
.notes-edit { width: min(620px, calc(100vw - 32px)); }
.notes-edit-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.notes-edit-head .dialog-title { flex-grow: 1; }
.notes-edit-body { padding: 18px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-height: 65vh; overflow-y: auto; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field span { font-size: 13px; font-weight: 500; color: var(--muted); }
.field input, .field textarea {
  height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r);
  font: inherit; font-size: 15px; color: var(--ink); background: var(--bg);
}
.field textarea { height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.notes-edit-foot { margin: 0; padding: 14px 20px; border-top: 1px solid var(--line); }

/* ── Màn toàn trang: Ôn bài / Bài tập ─────────────────────────────── */
body.is-study-open { overflow: hidden; }
.study {
  position: fixed; inset: 0; z-index: 80; outline: none;
  display: flex; flex-direction: column; background: var(--stage);
}
.study[hidden] { display: none; }
.study[data-mode="quiz"] { background: var(--bg); }
.study-bar {
  height: 56px; flex-shrink: 0; padding: 0 20px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.study-x { width: 36px; height: 36px; }
.study-crumb { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.study-right { display: flex; align-items: center; gap: 12px; }
.study-count { font-size: 13px; color: var(--muted); white-space: nowrap; }
.study-progress { flex-grow: 0; width: 220px; height: 5px; border-radius: 3px; }
.study-gear.is-open { background: var(--callout); border-color: var(--accent-soft); color: var(--accent); }
.study-panel { padding: 20px 16px 0; flex-shrink: 0; max-height: 60vh; overflow-y: auto; }
.study-panel[hidden] { display: none; }
.study-body { flex-grow: 1; overflow-y: auto; padding: 0 20px 32px; }
.study-foot { flex-shrink: 0; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--bg); position: relative; }
.study-foot[hidden] { display: none; }
.study-foot-in { max-width: 760px; min-height: 48px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.study-center { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 120px 20px; text-align: center; }
.study-center p { margin: 0; }
.study-center-title { font-size: 16px; font-weight: 600; color: var(--ink); }
.study-page { max-width: 640px; margin: 0 auto; padding: 64px 0 24px; }
.study-page-center { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 110px; max-width: 520px; }
.study-badge { width: 56px; height: 56px; border-radius: var(--r-lg); display: grid; place-items: center; margin-bottom: 18px; }
.study-kicker { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.study-title { margin: 0 0 6px; font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.study-lead { margin: 0 0 24px; font-size: 15px; color: var(--muted); line-height: 1.5; }
.study-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.study-promo { margin-top: 36px; align-items: flex-start; text-align: left; flex-direction: row; }
.study-promo .icon { color: var(--accent); }
.study-promo p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--text); }
.study-promo a { font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 26px; text-align: left; }
.stat { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); }
.stat p { margin: 0; font-size: 13px; color: var(--muted); }
.stat b { display: block; margin-top: 4px; font-size: 24px; font-weight: 700; color: var(--ink); }
.stat .is-good { color: var(--green); }
.stat .is-bad { color: var(--red); }
.missed-row {
  display: flex; align-items: baseline; gap: 10px; min-height: 44px; padding: 10px 4px;
  border-top: 1px solid var(--line); font-size: 14px; color: var(--text); text-align: left;
}
.missed-row b { font-size: 17px; color: var(--accent); }
.missed-row .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.missed-row .tag { flex-shrink: 0; align-self: center; }

/* Bảng cài đặt ôn bài */
.fc-settings {
  width: min(760px, 100%); margin: 0 auto; background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
.fc-settings-head {
  height: 48px; padding: 0 8px 0 16px; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--line); color: var(--accent); font-size: 14px;
}
.fc-settings-head b { font-weight: 600; color: var(--ink); }
.fc-settings-body { padding: 16px; }
.fc-settings-label { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-align: left; }
.fc-settings-langs { margin-bottom: 16px; }
.fc-switches { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch-row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg);
  font: inherit; text-align: left; cursor: pointer;
}
.switch-row:hover { border-color: var(--faint); }
.switch-text { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.switch-text b { font-size: 14px; font-weight: 600; color: var(--ink); }
.switch-text span { font-size: 13px; color: var(--muted); }
.switch {
  position: relative; width: 36px; height: 20px; flex-shrink: 0; border-radius: 999px;
  background: color-mix(in srgb, var(--faint) 55%, var(--bg)); transition: background 0.15s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2); transition: left 0.15s;
}
.switch-row[aria-checked="true"] .switch { background: var(--accent); }
.switch-row[aria-checked="true"] .switch::after { left: 18px; }

/* Thẻ flashcard */
.fc-stage { max-width: 560px; margin: 0 auto; padding-top: 72px; }
.fc-stage.is-back { padding-top: 40px; }
.fc-stage:has(.listen-steps) { padding-top: 0; }
.fc-card {
  position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 8%, transparent); padding: 24px; cursor: pointer; outline: none;
  animation: notes-card-in 0.18s ease-out;
}
.fc-card:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft), 0 6px 16px color-mix(in srgb, var(--accent) 8%, transparent); }
.fc-card[data-swipe="good"] { border-color: var(--green); }
.fc-card[data-swipe="bad"] { border-color: var(--red); }
@keyframes notes-card-in { from { opacity: 0; transform: translateY(6px); } }
.fc-front { height: 380px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.fc-lang { position: absolute; top: 20px; left: 20px; }
.fc-say { position: absolute; top: 14px; right: 14px; }
.round-btn {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; padding: 0;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--bg)); background: var(--bg); color: var(--accent);
  display: grid; place-items: center; cursor: pointer;
}
.round-btn:hover { background: var(--callout); }
.round-btn-lg { width: 60px; height: 60px; }
.round-btn.is-fill { border: 0; background: var(--accent); color: var(--on-accent); }
.round-btn.is-fill:hover { background: var(--accent-hover); }
.fc-word { margin: 0; font-size: 50px; font-weight: 900; line-height: 1.1; color: var(--accent); text-align: center; overflow-wrap: anywhere; }
.fc-reading { margin: 0; font-size: 26px; color: var(--reading); text-align: center; }
.fc-reading-hidden, .fc-meaning-hidden {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border: 0; border-radius: 999px; background: var(--bg-soft); color: var(--muted); font: inherit; font-size: 13px;
}
.fc-meaning-hidden { margin: 12px 0 18px; cursor: pointer; }
.fc-flip-hint { position: absolute; left: 0; right: 0; bottom: 20px; margin: 0; text-align: center; font-size: 13px; color: var(--faint); }
.fc-help { margin: 22px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.fc-back { cursor: pointer; }
.fc-back-head { display: flex; align-items: flex-start; gap: 12px; }
.fc-back-word { flex-grow: 1; margin: 0; font-size: 22px; font-weight: 800; color: var(--accent); overflow-wrap: anywhere; }
.fc-back-word > span:not(.jf-words) { font-weight: 500; color: var(--reading); }
.fc-meaning { margin: 10px -6px 18px; padding: 2px 6px; border-radius: var(--r); font-size: 20px; font-weight: 500; line-height: 1.45; color: var(--ink); }
.fc-rule { height: 1px; border: 0; margin: 0 0 16px; background: var(--line); }
.fc-back .trans-text { font-size: 17px; }
.fc-ex-label { margin-top: 16px; }
.fc-examples { cursor: text; }
.fc-ex { padding: 10px 12px; margin: 0 -12px; border-radius: var(--r-md); }
.is-playing { background: var(--callout); box-shadow: inset 3px 0 0 var(--accent); }
.fc-foot-label { font-size: 13px; }
.fc-flip-btn { min-width: 140px; }

/* Nút chấm Nhớ / Không nhớ */
.review-bar { position: relative; flex-grow: 1; display: flex; align-items: center; justify-content: center; gap: 14px; }
.review-hint { position: absolute; left: 0; font-size: 13px; color: var(--muted); max-width: 170px; }
.review-btn {
  width: 220px; height: 56px; border-radius: 12px; border: 1.5px solid; cursor: pointer; font: inherit;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.review-btn span { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; }
.review-btn small { font-size: 12px; opacity: 0.8; }
.review-btn.is-bad { background: var(--bg); border-color: color-mix(in srgb, var(--red) 35%, var(--bg)); color: var(--red); }
.review-btn.is-bad:hover { background: var(--red-bg); }
.review-btn.is-good { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.review-btn.is-good:hover { background: var(--accent-hover); }

/* Nghe rảnh tay */
.listen-steps {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 24px 0 18px; overflow-x: auto; scrollbar-width: none;
}
.listen-step { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--faint); white-space: nowrap; }
.listen-step.is-done { color: var(--accent); }
.listen-step.is-now {
  height: 30px; padding: 0 12px; gap: 6px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-weight: 600;
}
.listen-sep { width: 18px; height: 1px; flex-shrink: 0; background: var(--line); }
.study-foot-in:has(.listen-foot) { max-width: none; }
.listen-foot { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; }
.listen-desc { margin: 0; max-width: 360px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.listen-transport { display: flex; align-items: center; gap: 18px; }
.listen-side { display: flex; align-items: center; justify-content: flex-end; gap: 12px; font-size: 13px; }
.listen-gear { height: 44px; font-size: 14px; }
.listen-gear[aria-expanded="true"] { background: var(--callout); border-color: var(--accent-soft); color: var(--accent); }
.listen-pop {
  position: absolute; left: 50%; bottom: calc(100% + 12px); transform: translateX(-50%); z-index: 5;
  width: min(460px, calc(100vw - 32px)); padding: 6px 18px 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
}
.listen-pop[hidden] { display: none; }
.listen-pop-title { margin: 8px 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.listen-pop-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  min-height: 48px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; color: var(--text);
}
.listen-pop .pill { height: 30px; min-width: 34px; padding: 0 10px; }
.listen-speed { display: flex; align-items: center; gap: 10px; }
.listen-speed input { width: 160px; accent-color: var(--accent); }
.select {
  width: 180px; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg); font: inherit; font-size: 13px; color: var(--ink);
}
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--bg-soft); }
.seg-btn {
  height: 30px; padding: 0 14px; border: 0; border-radius: 999px; background: none;
  font: inherit; font-size: 13px; color: var(--muted); cursor: pointer;
}
.seg-btn.is-on { background: var(--bg); color: var(--accent); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1); }

/* ── Bài tập từ ghi chú ───────────────────────────────────────────── */
.qz-page { max-width: 680px; padding-top: 48px; display: flex; flex-direction: column; gap: 14px; }
.qz-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qz-word { font-size: 13px; color: var(--faint); }
.qz-zone { display: flex; flex-direction: column; gap: 14px; }
.qz-question { margin: 0; font-size: 15px; line-height: 1.6; color: var(--text); white-space: pre-line; }
.qz-question.is-big { font-size: 20px; font-weight: 600; color: var(--ink); }
.qz-hint { margin: 0 0 4px; font-size: 13px; color: var(--faint); }
.qz-sentences {
  padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 20px; line-height: 2.2; color: var(--ink); margin-bottom: 6px;
}
.qz-blank {
  display: inline-block; min-width: 72px; margin: 0 4px; padding: 0 6px; border: 0; background: none;
  border-bottom: 2px solid color-mix(in srgb, var(--faint) 60%, var(--bg));
  font: inherit; line-height: 1.5; color: var(--faint); text-align: center; cursor: pointer;
}
.qz-blank.is-filled { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.qz-blank.is-ok { color: var(--green); border-bottom-color: var(--green); font-weight: 700; cursor: default; }
.qz-blank.is-bad { color: var(--red); border-bottom-color: var(--red); font-weight: 700; cursor: default; }
.qz-bank { display: flex; flex-wrap: wrap; gap: 8px; }
.qz-chip {
  min-height: 44px; padding: 6px 18px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); font: inherit; font-size: 17px; color: var(--ink); cursor: pointer;
}
.qz-chip:hover:not(:disabled) { border-color: var(--accent); }
.qz-chip.is-used { opacity: 0.4; text-decoration: line-through; cursor: default; }
.qz-chip.is-placed { border-color: transparent; border-radius: var(--r-md); background: var(--blue-bg); color: var(--blue); }
.qz-build {
  min-height: 60px; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px;
  border: 1.5px dashed var(--line); border-radius: var(--r-md);
}
.qz-build.is-ok { border: 1.5px solid var(--green); }
.qz-build.is-bad { border: 1.5px solid var(--red); }
.qz-options { display: flex; flex-direction: column; gap: 10px; }
.qz-option {
  width: 100%; min-height: 50px; padding: 10px 14px; display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); font: inherit; text-align: left; cursor: pointer;
}
.qz-option:hover:not(:disabled) { border-color: var(--faint); }
.qz-letter {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: var(--r); background: var(--bg-soft); color: var(--muted);
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
}
.qz-option-text { flex-grow: 1; font-size: 16px; line-height: 1.5; color: var(--ink); }
.qz-option.is-sel { border-color: var(--accent); background: var(--callout); }
.qz-option.is-sel .qz-letter { background: var(--accent); color: var(--on-accent); }
.qz-option.is-ok { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.qz-option.is-ok .qz-letter { background: var(--green); color: var(--on-accent); }
.qz-option.is-bad { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.qz-option.is-bad .qz-letter { background: var(--red); color: var(--on-accent); }
.qz-option.is-dim .qz-option-text, .qz-option.is-dim .qz-letter { color: var(--faint); }
.qz-option:disabled { cursor: default; }
.qz-match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qz-cell {
  --link: var(--accent);
  min-height: 56px; padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--bg);
  font: inherit; font-size: 15px; font-weight: 500; color: var(--ink); text-align: left; cursor: pointer;
}
.qz-cell.jp { font-size: 19px; font-weight: 700; }
.qz-cell > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.qz-cell.is-sel { border-color: var(--accent); background: var(--callout); color: var(--accent); }
.qz-cell.is-link { border-color: var(--link); color: var(--text); }
.qz-cell.link-0 { --link: var(--blue); background: var(--blue-bg); }
.qz-cell.link-1 { --link: var(--violet); background: var(--violet-bg); }
.qz-cell.link-2 { --link: var(--amber); background: var(--amber-bg); }
.qz-cell.link-3 { --link: var(--green); background: var(--green-bg); }
.qz-cell.is-ok { border-color: var(--green); background: var(--green-bg); }
.qz-cell.is-bad { border-color: var(--red); background: var(--red-bg); }
.qz-cell:disabled { cursor: default; }
.qz-num {
  width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; background: var(--link); color: var(--on-accent);
  display: grid; place-items: center; font-family: var(--font); font-size: 12px; font-weight: 700;
}
.qz-fix { margin-top: 2px; font-family: var(--font); font-size: 12px; font-weight: 500; color: var(--green); }
.qz-feedback { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); border: 1px solid; }
.qz-feedback .icon { margin-top: 1px; }
.qz-feedback.is-ok { background: var(--green-bg); border-color: color-mix(in srgb, var(--green) 25%, var(--bg)); color: var(--green); }
.qz-feedback.is-bad { background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 25%, var(--bg)); color: var(--red); }
.qz-feedback-title { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.qz-feedback-text { margin: 0; font-size: 14px; line-height: 1.6; color: var(--text); }
.qz-status { font-size: 13px; }
.qz-more { margin-bottom: 16px; }
.qz-more > .icon { color: var(--accent); }
.qz-reset-box { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--r-md); }
.qz-reset-box p { margin: 0; }

/* Nút "Tra từ" nổi khi bôi chọn chữ */
.lookup-fab {
  position: fixed; z-index: 90; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  display: grid; place-items: center; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.lookup-fab[hidden] { display: none; }

/* ── Điện thoại ───────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .notes-callout { flex-direction: column; align-items: stretch; padding: 16px; }
  .notes-callout-main { flex: none; align-items: flex-start; gap: 12px; }
  .notes-callout-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .notes-callout-actions .btn { height: 44px; padding: 0 10px; white-space: normal; text-align: center; line-height: 1.2; }
  .notes-main-btn { grid-column: 1 / -1; order: -1; }
  .notes-add-field, .notes-add-btn { height: 48px; }
  .notes-add-btn { padding: 0 12px; }
  .notes-views { flex-direction: column; align-items: stretch; gap: 4px; }
  .notes-search { order: -1; width: 100%; height: 44px; margin: 0 0 4px; border-radius: var(--r-md); padding: 0 12px; }
  .notes-search input { font-size: 16px; }
  .notes-tab { height: 44px; }
  .notes-head { display: none; }
  .nrow { grid-template-columns: minmax(0, 1fr); padding: 0 2px; }
  .nrow-main {
    grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "word due chev" "mean due chev";
    column-gap: 10px; row-gap: 3px; min-height: 64px; padding: 10px 0;
  }
  .nrow-word { grid-area: word; padding-right: 0; }
  .nrow-word b { font-size: 18px; }
  .nrow-mean { grid-area: mean; padding-right: 0; -webkit-line-clamp: 1; }
  .nrow-lang, .nrow-due, .nrow-date, .nrow-tts { display: none; }
  .nrow-due-m { display: block; grid-area: due; }
  .nrow-chev { display: block; grid-area: chev; color: var(--faint); }
  .notes-more .btn { height: 44px; }
  .peek { width: 100vw; border-left: 0; }
  .peek-body { padding: 22px 20px 40px; }
  .peek-word { font-size: 38px; }
  .peek-props .prop-name { width: 110px; }
  .notes-edit-body { grid-template-columns: 1fr; }

  .study-bar { height: 52px; padding: 0 12px; gap: 8px; }
  .study-crumb { display: none; }
  .study-right { margin-left: auto; gap: 8px; }
  .study-progress { width: 90px; }
  .study-gear span { display: none; }
  .study-gear { padding: 0 10px; }
  .study-panel { padding: 12px 12px 0; }
  .fc-switches { grid-template-columns: 1fr; }
  .study-body { padding: 0 16px 24px; }
  .study-foot { padding: 12px 16px 16px; }
  .fc-stage, .fc-stage.is-back { padding-top: 16px; }
  .fc-front { height: 440px; }
  .fc-word { font-size: 46px; }
  .fc-meaning { font-size: 19px; }
  .fc-back .trans-text { font-size: 16px; }
  .fc-foot-label { display: none; }
  .fc-flip-btn { width: 100%; height: 52px; }
  .review-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .review-hint { display: none; }
  .review-btn { width: 100%; }
  .listen-foot { grid-template-columns: auto 1fr auto; gap: 8px; }
  .listen-desc { display: none; }
  .listen-transport { justify-content: center; gap: 14px; }
  .listen-side { order: -1; }
  .listen-side .muted { display: none; }
  .listen-gear { width: 48px; height: 48px; padding: 0; border-radius: 50%; }
  .listen-gear span { display: none; }
  .listen-steps { justify-content: flex-start; gap: 6px; padding: 14px 0 12px; }
  .listen-sep { width: 10px; }
  .listen-speed input { width: 120px; }
  .study-page { padding-top: 40px; }
  .study-page-center { padding-top: 64px; }
  .study-title { font-size: 28px; }
  .qz-page { padding-top: 24px; }
  .qz-sentences { padding: 14px 16px; font-size: 18px; }
  .qz-match { gap: 8px; }
  .qz-cell { padding: 8px 12px; font-size: 14px; }
  .qz-cell.jp { font-size: 17px; }
  .qz-more, .qz-reset-box { flex-direction: column; align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  .fc-card { animation: none; }
  .spinner { animation-duration: 2s; }
  .switch, .switch::after { transition: none; }
}
