/* =============================================================================
   LyChee Learning UX Upgrade (Scoped to #view-chat, #notebook-modal, #review-modal)
   Does NOT modify sidebar, pricing cards, checkout sheet, or account quota modal.
   ============================================================================= */

#view-chat,
#notebook-modal,
#review-modal {
  --ux-font-scale: 1;
  --ux-prose-size: 1.125rem;
  --ux-hanzi-target-size: 1.625rem;
  --ux-pinyin-size: 1.0625rem;
  --ux-reading-max-width: 720px;
}

html[data-ux-font-scale="medium"] #view-chat,
html[data-ux-font-scale="medium"] #notebook-modal,
html[data-ux-font-scale="medium"] #review-modal,
#view-chat[data-ux-font-scale="medium"],
#notebook-modal[data-ux-font-scale="medium"],
#review-modal[data-ux-font-scale="medium"] {
  --ux-font-scale: 1;
}

html[data-ux-font-scale="large"] #view-chat,
html[data-ux-font-scale="large"] #notebook-modal,
html[data-ux-font-scale="large"] #review-modal,
#view-chat[data-ux-font-scale="large"],
#notebook-modal[data-ux-font-scale="large"],
#review-modal[data-ux-font-scale="large"] {
  --ux-font-scale: 1.12;
}

html[data-ux-font-scale="xlarge"] #view-chat,
html[data-ux-font-scale="xlarge"] #notebook-modal,
html[data-ux-font-scale="xlarge"] #review-modal,
#view-chat[data-ux-font-scale="xlarge"],
#notebook-modal[data-ux-font-scale="xlarge"],
#review-modal[data-ux-font-scale="xlarge"] {
  --ux-font-scale: 1.25;
}

/* 1. Reading Column Width (680px - 760px) & Scoped Pedagogical Typography */
#view-chat .messages-inner {
  max-width: 740px;
}

#view-chat .message-row.assistant .message-body,
#view-chat .message-row.assistant .message-bubble,
#view-chat .correction-diff-card {
  max-width: 720px;
  width: 100%;
}

/* Vietnamese Explanation Prose: 18px desktop, 16-18px mobile, line-height 1.72 */
#view-chat .message-row.assistant .message-bubble,
#view-chat .message-row.assistant .msg-text,
#view-chat .message-row.assistant .md-list-item,
#view-chat .pedagogy-explanation-vi,
#view-chat .diff-explanation,
#notebook-modal .ux-prose-vi,
#review-modal .ux-prose-vi {
  font-size: calc(1.125rem * var(--ux-font-scale));
  line-height: 1.72;
  font-weight: 400;
  color: #f3f4f6;
  overflow-wrap: break-word;
}

#view-chat .message-row.assistant .msg-text p,
#view-chat .message-row.assistant .message-bubble p {
  margin: 0 0 0.75em 0;
}

#view-chat .message-row.assistant .msg-text p:last-child,
#view-chat .message-row.assistant .message-bubble p:last-child {
  margin-bottom: 0;
}

/* Target Chinese Sentence / Phrase: 26px (24-28px) desktop, 23px (22-24px) mobile */
#view-chat .target-chinese-sentence,
#view-chat .diff-sentence-line,
#view-chat .ux-hanzi-target,
#notebook-modal .notebook-entry-hanzi,
#review-modal .review-item-hanzi {
  font-family: var(--font-hanzi, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif);
  font-size: calc(1.625rem * var(--ux-font-scale));
  font-weight: 600;
  line-height: 1.45;
  color: #f8fafc;
  letter-spacing: 0.015em;
  overflow-wrap: break-word;
}

/* Single Focus Hanzi: 38px (36-44px) desktop, 34px (32-36px) mobile */
#view-chat .target-hanzi-single,
#view-chat .vocab-hanzi.is-single {
  font-family: var(--font-hanzi, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif);
  font-size: calc(2.375rem * var(--ux-font-scale));
  font-weight: 700;
  line-height: 1.25;
  color: #ffffff;
}

/* Pinyin Line: 17px (16-18px) desktop, 16px mobile, WCAG AA #93c5fd on dark card */
#view-chat .target-pinyin-line,
#view-chat .vocab-pinyin,
#view-chat .pinyin-subtext,
#view-chat .ux-pinyin-line,
#notebook-modal .notebook-entry-pinyin,
#review-modal .review-item-pinyin {
  font-size: calc(1.0625rem * var(--ux-font-scale));
  font-weight: 500;
  line-height: 1.45;
  color: #93c5fd;
  letter-spacing: 0.01em;
}

/* Vietnamese Meaning Line: 17px (16-18px) desktop, 16px mobile */
#view-chat .vocab-meaning,
#view-chat .ux-meaning-line,
#notebook-modal .notebook-entry-meaning,
#review-modal .review-item-meaning {
  font-size: calc(1.0625rem * var(--ux-font-scale));
  font-weight: 400;
  line-height: 1.55;
  color: #e2e8f0;
}

/* Section & Badge Labels: >= 14px (0.875rem) */
#view-chat .pedagogy-label,
#view-chat .correction-category-badge,
#view-chat .diff-row-label,
#view-chat .ux-badge-label,
#notebook-modal .ux-badge-label,
#review-modal .ux-badge-label {
  font-size: calc(0.875rem * var(--ux-font-scale));
  line-height: 1.4;
  font-weight: 600;
}

@media (max-width: 768px) {
  #view-chat .message-row.assistant .message-bubble,
  #view-chat .message-row.assistant .msg-text,
  #view-chat .message-row.assistant .md-list-item,
  #view-chat .pedagogy-explanation-vi,
  #view-chat .diff-explanation,
  #notebook-modal .ux-prose-vi,
  #review-modal .ux-prose-vi {
    font-size: calc(1.0625rem * var(--ux-font-scale));
    line-height: 1.68;
  }

  #view-chat .target-chinese-sentence,
  #view-chat .diff-sentence-line,
  #view-chat .ux-hanzi-target,
  #notebook-modal .notebook-entry-hanzi,
  #review-modal .review-item-hanzi {
    font-size: calc(1.4375rem * var(--ux-font-scale));
    line-height: 1.45;
  }

  #view-chat .target-hanzi-single,
  #view-chat .vocab-hanzi.is-single {
    font-size: calc(2.125rem * var(--ux-font-scale));
  }

  #view-chat .target-pinyin-line,
  #view-chat .vocab-pinyin,
  #view-chat .pinyin-subtext,
  #view-chat .ux-pinyin-line,
  #notebook-modal .notebook-entry-pinyin,
  #review-modal .review-item-pinyin,
  #view-chat .vocab-meaning,
  #view-chat .ux-meaning-line,
  #notebook-modal .notebook-entry-meaning,
  #review-modal .review-item-meaning {
    font-size: calc(1rem * var(--ux-font-scale));
  }
}

/* 2. Independent Pinyin & Meaning Visibility Toggles (0 AI calls) */
html[data-ux-hide-pinyin="true"] #view-chat .target-pinyin-line:not(.is-revealed),
html[data-ux-hide-pinyin="true"] #view-chat .vocab-pinyin:not(.is-revealed),
html[data-ux-hide-pinyin="true"] #view-chat .pinyin-subtext:not(.is-revealed),
html[data-ux-hide-pinyin="true"] #view-chat .ux-pinyin-line:not(.is-revealed),
html[data-ux-hide-pinyin="true"] #view-chat .practice-stem-pinyin:not(.is-revealed),
html[data-ux-hide-pinyin="true"] #view-chat .practice-choice-pinyin:not(.is-revealed),
html[data-ux-hide-pinyin="true"] #notebook-modal .notebook-entry-pinyin:not(.is-revealed),
html[data-ux-hide-pinyin="true"] #review-modal .review-item-pinyin:not(.is-revealed) {
  display: none !important;
}

html[data-ux-hide-meaning="true"] #view-chat .vocab-meaning:not(.is-revealed),
html[data-ux-hide-meaning="true"] #view-chat .ux-meaning-line:not(.is-revealed),
html[data-ux-hide-meaning="true"] #view-chat .practice-choice-meaning:not(.is-revealed),
html[data-ux-hide-meaning="true"] #notebook-modal .notebook-entry-meaning:not(.is-revealed),
html[data-ux-hide-meaning="true"] #review-modal .review-item-meaning:not(.is-revealed) {
  display: none !important;
}

/* 3. Topbar Display & Notebook Controls (44x44px touch targets) */
.ux-topbar-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
}

.ux-topbar-btn,
.ux-display-toggle-btn,
.ux-font-scale-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0.3rem 0.6rem;
  border-radius: 10px;
  border: 1px solid #64748b;
  background: var(--bg-subtle, #171717);
  color: #f1f5f9;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  box-sizing: border-box;
}

.ux-topbar-btn:hover,
.ux-display-toggle-btn:hover,
.ux-font-scale-btn:hover {
  border-color: #60a5fa;
  background: #222222;
}

.ux-topbar-btn:focus-visible,
.ux-display-toggle-btn:focus-visible,
.ux-font-scale-btn:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

.ux-display-toggle-btn[aria-pressed="true"],
.ux-font-scale-btn[aria-pressed="true"],
.ux-font-scale-btn.active {
  background: rgba(96, 165, 250, 0.18);
  border-color: #60a5fa;
  color: #bfdbfe;
}

.ux-notebook-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(225, 29, 72, 0.22);
  border: 1px solid rgba(251, 113, 133, 0.45);
  color: #fecdd3;
  font-size: 0.8125rem;
  font-weight: 700;
}

.ux-display-popover-wrap {
  position: relative;
}

.ux-display-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 85;
  width: min(320px, calc(100vw - 24px));
  background: #1b1b1b;
  border: 1px solid #64748b;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.65);
  display: none;
  flex-direction: column;
  gap: 0.65rem;
}

.ux-display-popover.open {
  display: flex;
}

.ux-display-popover[hidden] {
  display: none !important;
}

.ux-display-group-label,
.ux-popover-section-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 0.2rem;
}

.ux-segmented-group,
.ux-font-scale-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.ux-toggle-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.ux-toggle-row-btn {
  min-height: 44px;
  width: 100%;
  padding: 0.45rem 0.75rem;
  border-radius: 9px;
  border: 1px solid #64748b;
  background: #141414;
  color: #f1f5f9;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
}

.ux-toggle-row-btn[aria-pressed="true"] strong {
  color: #34d399;
}

.ux-toggle-row-btn[aria-pressed="false"] strong {
  color: #94a3b8;
}

/* 4. Correction Diff Card: All 5 Categories + Safe Neutral Fallback */
#view-chat .correction-diff-card {
  background: #1c1c1c;
  border: 1px solid #64748b;
  border-left: 4px solid #94a3b8;
  border-radius: 12px;
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  color: #f3f4f6;
}

#view-chat .correction-diff-card.category-wrong {
  border-left-color: #f87171;
}

#view-chat .correction-diff-card.category-correct,
#view-chat .correction-diff-card.category-valid_variant,
#view-chat .correction-diff-card.category-alt_valid {
  border-left-color: #34d399;
}

#view-chat .correction-diff-card.category-more_natural {
  border-left-color: #60a5fa;
}

#view-chat .correction-diff-card.category-needs_context,
#view-chat .correction-diff-card.category-neutral_review {
  border-left-color: #fbbf24;
}

#view-chat .correction-category-badge.cat-wrong {
  background: rgba(248, 113, 113, 0.16);
  border: 1px solid rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

#view-chat .correction-category-badge.cat-correct,
#view-chat .correction-category-badge.cat-valid_variant,
#view-chat .correction-category-badge.cat-alt_valid {
  background: rgba(52, 211, 153, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.5);
  color: #a7f3d0;
}

#view-chat .correction-category-badge.cat-more_natural {
  background: rgba(96, 165, 250, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.5);
  color: #bfdbfe;
}

#view-chat .correction-category-badge.cat-needs_context,
#view-chat .correction-category-badge.cat-neutral_review {
  background: rgba(251, 191, 36, 0.16);
  border: 1px solid rgba(251, 191, 36, 0.5);
  color: #fde68a;
}

/* Neutral / Suggestion Span Highlights (Never red on non-wrong categories) */
.diff-span-suggestion {
  background: rgba(96, 165, 250, 0.2);
  border: 1px solid #60a5fa;
  color: #bfdbfe;
  border-radius: 6px;
  padding: 0 0.35rem;
  font-weight: 700;
}

.diff-span-context {
  background: rgba(251, 191, 36, 0.18);
  border: 1px dashed #fbbf24;
  color: #fde68a;
  border-radius: 6px;
  padding: 0 0.35rem;
  font-weight: 700;
}

.ux-multi-errors-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.ux-multi-error-item {
  font-size: calc(0.95rem * var(--ux-font-scale));
  line-height: 1.55;
  color: #f3f4f6;
}

/* Card Action Bar & Inline Self-Try ("Tự thử một câu") */
.ux-card-actions-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ux-card-action-btn,
.ux-btn-primary,
.ux-btn-secondary {
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  border-radius: 9px;
  border: 1px solid #64748b;
  background: #242424;
  color: #f3f4f6;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ux-card-action-btn:hover,
.ux-btn-primary:hover,
.ux-btn-secondary:hover {
  background: #2e2e2e;
  border-color: #60a5fa;
}

.ux-card-action-btn.is-primary,
.ux-btn-primary {
  background: rgba(96, 165, 250, 0.16);
  border-color: rgba(96, 165, 250, 0.55);
  color: #bfdbfe;
}

.ux-card-action-btn.is-saved {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.5);
  color: #a7f3d0;
}

.ux-self-try-box {
  margin-top: 0.5rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: rgba(96, 165, 250, 0.08);
  border: 1px solid rgba(96, 165, 250, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.ux-self-try-box[hidden] {
  display: none !important;
}

.ux-self-try-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.ux-self-try-input {
  flex: 1 1 220px;
  min-height: 44px;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  border: 1px solid #64748b;
  background: #141414;
  color: #f8fafc;
  font-size: 1rem;
  font-family: inherit;
}

.ux-self-try-feedback {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.55;
}

.ux-self-try-feedback.is-ok {
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: #d1fae5;
}

.ux-self-try-feedback.is-retry {
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fef3c7;
}

/* 5. Compact Secondary Action Menu ("Thêm ▾") & Pedagogical Feedback Popover */
.ux-more-actions-wrap {
  position: relative;
  display: inline-block;
}

.ux-more-actions-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 75;
  min-width: 230px;
  background: #1e1e1e;
  border: 1px solid #64748b;
  border-radius: 10px;
  padding: 0.4rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ux-more-actions-menu[hidden] {
  display: none !important;
}

.ux-more-menu-item {
  min-height: 44px;
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}

.ux-more-menu-item:hover {
  background: #2a2a2a;
  color: #ffffff;
}

/* 6. Durable "Sổ tay của tôi" Modal & Save Preview Popover & Undo Toast */
#notebook-modal .modal-dialog,
#review-modal .modal-dialog {
  max-width: 720px;
  width: min(720px, calc(100vw - 24px));
  max-height: 88vh;
  padding: 1.25rem 1.35rem;
  background: #181818;
  border: 1px solid #64748b;
  border-radius: 14px;
  color: #f3f4f6;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow: hidden;
}

.ux-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid #2d2d2d;
}

.ux-modal-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.ux-modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.ux-sync-status-badge,
.ux-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid rgba(148, 163, 184, 0.45);
  color: #cbd5e1;
}

.ux-sync-status-badge.is-synced,
.ux-sync-badge.is-synced {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.45);
  color: #a7f3d0;
}

.ux-notebook-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.ux-notebook-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ux-notebook-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}

.ux-filter-chip,
.ux-nb-filter-chip {
  min-height: 44px;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #64748b;
  background: #202020;
  color: #cbd5e1;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.ux-filter-chip.active,
.ux-nb-filter-chip.active {
  background: rgba(96, 165, 250, 0.18);
  border-color: #60a5fa;
  color: #bfdbfe;
}

.ux-notebook-search,
.ux-notebook-search-input {
  flex: 1 1 220px;
  min-height: 44px;
  padding: 0.45rem 0.8rem;
  border-radius: 9px;
  border: 1px solid #64748b;
  background: #121212;
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.95rem;
}

/* Honest Progress Counters Bar (4 separate metrics) */
.ux-progress-counters-grid,
.ux-notebook-counters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

@media (max-width: 560px) {
  .ux-progress-counters-grid,
  .ux-notebook-counters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.ux-counter-box {
  background: #202020;
  border: 1px solid #2e2e2e;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ux-counter-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.ux-counter-label {
  font-size: 0.875rem;
  color: #cbd5e1;
  line-height: 1.35;
}

.ux-notebook-list-scroll {
  flex: 1;
  min-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-right: 0.25rem;
}

.ux-notebook-entry-card {
  background: #202020;
  border: 1px solid #323232;
  border-radius: 11px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ux-notebook-entry-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ux-notebook-entry-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ux-entry-icon-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #383838;
  background: #171717;
  color: #e2e8f0;
  font-size: 0.875rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  cursor: pointer;
}

.ux-entry-icon-btn:hover {
  border-color: #60a5fa;
  color: #ffffff;
}

/* Legacy Import & Recovery Banners */
.ux-notebook-banner {
  padding: 0.75rem 0.95rem;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fde68a;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Undo Toast */
.ux-undo-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  color: #f8fafc;
  font-size: 0.95rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ux-undo-toast[hidden] {
  display: none !important;
}

/* 7. Pricing Note Collapsible Details ("Xem cách tính lượt") */
.pricing-shared-lines p {
  margin: 0.35rem 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #e2e8f0;
}

.pricing-quota-details {
  margin-top: 0.65rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #333333;
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
}

.pricing-quota-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: #93c5fd;
  min-height: 36px;
  display: flex;
  align-items: center;
}

.pricing-quota-details-body {
  margin-top: 0.45rem;
  font-size: 0.88rem;
  line-height: 1.6;
  color: #cbd5e1;
}

/* 8. 320px Mobile Reflow & Reduced Motion */
@media (max-width: 640px) {
  #view-chat .chat-topbar,
  #view-chat .chat-header {
    height: auto !important;
    min-height: 54px;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  #view-chat .topbar-right,
  #view-chat .header-right {
    flex-wrap: wrap;
    gap: 0.3rem;
  }
}

@media (max-width: 420px) {
  .ux-topbar-controls {
    gap: 0.25rem;
    flex-wrap: wrap;
  }
  .ux-topbar-btn {
    padding: 0.25rem 0.45rem;
    font-size: 0.8125rem;
  }
  #notebook-modal .modal-dialog,
  #review-modal .modal-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 92vh;
    max-height: 92vh;
    margin: auto 0 0 0;
    border-radius: 16px 16px 0 0;
    padding: 1rem 0.85rem;
  }
}

@media (max-width: 360px) {
  #view-chat .ux-topbar-controls {
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  #view-chat .correction-diff-card,
  #view-chat .inline-card {
    padding: 0.75rem 0.65rem;
  }
  #view-chat .ux-card-actions-bar {
    flex-direction: column;
    align-items: stretch;
  }
  #view-chat .ux-card-action-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  #view-chat *,
  #notebook-modal *,
  #review-modal * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* =============================================================================
   9. Pinyin & Meaning Toggle Buttons (Next-Action Labels + Accessible States)
   ============================================================================= */
.btn-toggle-pinyin,
.btn-toggle-meaning {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  min-height: 30px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid var(--border-color, #334155);
  background: var(--bg-subtle, #1e293b);
  color: var(--text-main, #f1f5f9);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-toggle-pinyin.is-active,
.btn-toggle-pinyin[aria-pressed="true"] {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.14);
  color: #e0f2fe;
}

.btn-toggle-pinyin.is-inactive,
.btn-toggle-pinyin[aria-pressed="false"] {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.65);
  color: #cbd5e1;
}

.btn-toggle-meaning.is-active,
.btn-toggle-meaning[aria-pressed="true"] {
  border-color: rgba(16, 185, 129, 0.55);
  background: rgba(16, 185, 129, 0.14);
  color: #d1fae5;
}

.btn-toggle-meaning.is-inactive,
.btn-toggle-meaning[aria-pressed="false"] {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.65);
  color: #cbd5e1;
}

.btn-toggle-pinyin:disabled,
.btn-toggle-meaning:disabled,
.btn-toggle-pinyin.is-disabled,
.btn-toggle-meaning.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-toggle-pinyin:focus-visible,
.btn-toggle-meaning:focus-visible,
.btn-open-lesson-exercise:focus-visible,
.lex-choice-btn:focus-visible,
.lex-match-card:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

/* =============================================================================
   10. Post-Lesson Tutor Exercise Flow (0 Token AI · Local Deterministic)
   ============================================================================= */
.lesson-exercise-cta-box {
  margin-top: 0.75rem;
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.38);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.88), rgba(30, 41, 59, 0.75));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.lesson-exercise-cta-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lesson-exercise-cta-helper {
  font-size: 0.78rem;
  color: #93c5fd;
  font-weight: 500;
}

.btn-open-lesson-exercise {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0.45rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(56, 189, 248, 0.55);
  background: #0284c7;
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-open-lesson-exercise:hover:not(:disabled) {
  background: #0369a1;
}

.lesson-exercise-panel {
  margin-top: 0.75rem;
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  background: #111827;
  color: #f8fafc;
  max-width: 100%;
  box-sizing: border-box;
}

.lex-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.lex-progress-bar {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
  margin-bottom: 0.85rem;
}

.lex-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #10b981);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.lex-choices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.55rem;
  margin: 0.75rem 0;
}

.lex-choice-btn {
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #f8fafc;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.lex-choice-btn.is-selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.18);
}

.lex-choice-btn.is-correct {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.2);
  color: #d1fae5;
}

.lex-choice-btn.is-wrong {
  border-color: #f43f5e;
  background: rgba(244, 63, 94, 0.18);
  color: #ffe4e6;
}

.lex-matching-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 0.75rem 0;
}

@media (max-width: 480px) {
  .lex-matching-columns {
    grid-template-columns: 1fr;
  }
}

.lex-match-col {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.lex-match-card {
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #f8fafc;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.lex-match-card.is-active-source {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.18);
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.25);
}

.lex-match-card.is-paired {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
}

.lex-match-card.is-correct {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.2);
}

.lex-match-card.is-wrong {
  border-color: #f43f5e;
  background: rgba(244, 63, 94, 0.18);
}

/* =============================================================================
   11. Driver.js Onboarding Popover & Contextual Help Banner
   ============================================================================= */
.driver-popover.lychee-driver-popover {
  background: #0f172a !important;
  color: #f8fafc !important;
  border: 1px solid rgba(56, 189, 248, 0.5) !important;
  border-radius: 14px !important;
  padding: 1rem !important;
  max-width: min(360px, calc(100vw - 24px)) !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.65) !important;
}

.driver-popover.lychee-driver-popover .driver-popover-title {
  color: #7dd3fc !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
}

.driver-popover.lychee-driver-popover .driver-popover-description {
  color: #e2e8f0 !important;
  font-size: 0.88rem !important;
  line-height: 1.55 !important;
}

.driver-popover.lychee-driver-popover .driver-popover-footer button {
  background: #1e293b !important;
  color: #f8fafc !important;
  border: 1px solid #475569 !important;
  border-radius: 8px !important;
  padding: 5px 11px !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  text-shadow: none !important;
}

.driver-popover.lychee-driver-popover .driver-popover-footer .driver-popover-next-btn {
  background: #0284c7 !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
}

.ux-contextual-help-banner {
  position: fixed;
  bottom: 78px;
  right: 16px;
  left: auto;
  max-width: min(380px, calc(100vw - 32px));
  z-index: 9985;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  background: #0f172a;
  border: 1px solid rgba(56, 189, 248, 0.55);
  color: #f1f5f9;
  font-size: 0.82rem;
  line-height: 1.48;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

