:root {
  --bg: #faf6ef;            /* crème papier */
  --bg-2: #f3ebdd;
  --card: #fffdf8;          /* blanc cassé */
  --text: #3a322e;          /* encre chaude */
  --text-2: #a2968a;
  --sep: rgba(90, 70, 55, 0.12);
  --accent: #e07a5f;        /* terracotta */
  --accent-press: #c25e44;
  --amber: #e9b44c;         /* ambre doux */
  --green: #7ca55f;         /* vert chaud (acquis/réussite) */
  --danger: #d1495b;
  --orange: #e2894a;
  --learn-bg: rgba(233, 180, 76, 0.30);  /* surlignage ambre */
  --learn-line: #d99a2b;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(90, 65, 40, 0.05), 0 12px 30px rgba(120, 90, 55, 0.10);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18130f;          /* brun très sombre chaud */
    --bg-2: #201a14;
    --card: #241d17;
    --text: #f3eadf;
    --text-2: #ab9d8d;
    --sep: rgba(210, 185, 155, 0.16);
    --accent: #e88a70;
    --accent-press: #f0a189;
    --green: #8fb573;
    --learn-bg: rgba(233, 180, 76, 0.20);
    --learn-line: #e9b44c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(1100px 480px at 100% -8%, rgba(224, 122, 95, 0.10), transparent 60%),
    radial-gradient(950px 460px at -5% 108%, rgba(233, 180, 76, 0.12), transparent 62%);
  background-attachment: fixed;
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(6px + var(--safe-t)) 16px 0;
}

/* ============================ HEADER ============================ */
.topbar {
  padding: 10px 4px 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.mascot {
  width: 46px; height: 46px; flex: 0 0 auto;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.12));
  animation: bob 4s ease-in-out infinite;
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.title-block { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; overflow: hidden; }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.brand { font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand b { color: var(--accent); }
.auth { margin-left: auto; flex: 0 0 auto; }
.login-btn {
  display: inline-block; padding: 9px 16px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  text-decoration: none; box-shadow: 0 4px 12px rgba(224, 122, 95, 0.32);
}
.login-btn:active { background: var(--accent-press); }
.avatar {
  width: 40px; height: 40px; padding: 0; border: none; border-radius: 50%;
  overflow: hidden; cursor: pointer; background: var(--accent); box-shadow: var(--shadow);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-fallback { display: grid; place-items: center; width: 100%; height: 100%; color: #fff; font-weight: 700; font-size: 18px; }

/* ============================ VIEWS ============================ */
.views { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; animation: viewIn 0.22s ease; }
.view.hidden { display: none; }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- Sélecteur de langues ---- */
.lang-bar { display: flex; align-items: center; gap: 8px; margin: 10px 0 12px; }
.lang {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 10px; background: var(--card); border: none; border-radius: 15px;
  color: var(--text); font-size: 16px; font-weight: 600; box-shadow: var(--shadow); cursor: default;
}
.lang .flag { font-size: 20px; }
.swap {
  flex: 0 0 auto; width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--card); border: none; border-radius: 50%; color: var(--accent);
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.4, 1.4, 0.5, 1), background 0.15s;
}
.swap:active { background: var(--bg); }
.swap.spin { transform: rotate(180deg); }

/* ---- Cartes traduction ---- */
.cards { flex: 1; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; display: flex; flex-direction: column; flex: 1; min-height: 120px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; min-height: 22px; }
.card-lang { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.03em; }

.text-in {
  flex: 1; width: 100%; border: none; outline: none; resize: none; background: transparent;
  color: var(--text); font: inherit; font-size: 23px; line-height: 1.35; letter-spacing: -0.01em;
}
.text-in::placeholder { color: var(--text-2); }
.text-out { flex: 1; font-size: 24px; line-height: 1.35; letter-spacing: -0.01em; color: var(--text); word-break: break-word; white-space: pre-wrap; }
.text-out.placeholder { color: var(--text-2); }
.text-out.loading { color: var(--text-2); }

/* pinyin ruby */
.text-out.ruby { line-height: 2.5; white-space: normal; }
.text-out ruby { ruby-position: under; ruby-align: center; margin: 0 1px; }
.text-out rt { font-size: 0.4em; font-weight: 500; color: var(--text-2); padding-top: 2px; }
.text-out .punct { color: var(--text-2); }

/* mots à apprendre */
ruby.learnable {
  cursor: pointer; background: var(--learn-bg); border-radius: 6px;
  box-shadow: inset 0 -2px 0 var(--learn-line); padding: 0 2px; transition: transform 0.1s;
}
ruby.learnable:active { transform: scale(0.94); }
ruby.adding { opacity: 0.5; }
ruby.added {
  background: rgba(124, 165, 95, 0.22); box-shadow: inset 0 -2px 0 var(--green);
  border-radius: 6px; padding: 0 2px;
}
.learn-tip { margin: 8px 0 0; font-size: 13px; color: var(--text-2); }
.hl-demo, .learn-tip .hl-demo {
  background: var(--learn-bg); box-shadow: inset 0 -2px 0 var(--learn-line);
  border-radius: 5px; padding: 0 4px; color: var(--text); font-weight: 600;
}

/* Toggle « capturer auto les mots surlignés » */
.auto-cap {
  display: flex; align-items: center; gap: 9px; width: 100%;
  margin: 12px 0 0; padding: 9px 12px; border: none; border-radius: 12px;
  background: var(--bg); color: var(--text-2); font-size: 13px; font-weight: 600;
  cursor: pointer; text-align: left; transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.auto-cap .ac-dot {
  flex: none; width: 38px; height: 22px; border-radius: 999px;
  background: var(--learn-line); position: relative; transition: background 0.2s;
}
.auto-cap .ac-dot::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.2s;
}
.auto-cap.on { color: var(--text); }
.auto-cap.on .ac-dot { background: var(--green); }
.auto-cap.on .ac-dot::after { transform: translateX(16px); }
.auto-cap .ac-label { flex: 1; }

/* Source chinoise annotée (ZH→FR) : rendu pinyin + mots capturables */
.source-render { color: var(--text); cursor: text; }
.source-render .punct { color: var(--text-2); }
#editSourceBtn { color: var(--accent); }

.dots span { display: inline-block; animation: blink 1.4s infinite both; font-size: 30px; line-height: 0; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

.icon-btn { border: none; background: transparent; color: var(--text-2); padding: 4px; display: grid; place-items: center; border-radius: 10px; cursor: pointer; }
.icon-btn:active { background: var(--bg); }
#speakBtn { color: var(--accent); }

/* ---- Micro ---- */
.mic-bar { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 0; }
.hint { margin: 0; font-size: 14px; color: var(--text-2); min-height: 18px; }
.mic {
  width: 68px; height: 68px; border-radius: 50%; border: none; background: var(--accent);
  color: #fff; display: grid; place-items: center; box-shadow: 0 6px 20px rgba(224, 122, 95, 0.38);
  cursor: pointer; transition: transform 0.12s ease, background 0.2s;
}
.mic:active { transform: scale(0.92); }
.mic.recording { background: var(--danger); animation: pulse 1.5s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.5); }
  70% { box-shadow: 0 0 0 18px rgba(255, 59, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}
.mic:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================ TAB BAR ============================ */
.tabbar {
  position: sticky; bottom: 0; margin: 0 -16px; padding: 8px 16px calc(8px + var(--safe-b));
  display: flex; gap: 4px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--sep);
}
.tab {
  flex: 1; position: relative; border: none; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; color: var(--text-2); font-size: 10.5px; font-weight: 600; border-radius: 14px;
  white-space: nowrap;
}
.tab-ico { font-size: 21px; line-height: 1; filter: grayscale(0.5); opacity: 0.7; transition: 0.15s; }
.tab.active { color: var(--accent); }
.tab.active .tab-ico { filter: none; opacity: 1; transform: translateY(-1px); }
.badge {
  position: absolute; top: 2px; right: 50%; margin-right: -22px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

/* ============================ OVERLAY / SHEET ============================ */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(4px); padding: 0;
}
.overlay.hidden { display: none; }
.sheet {
  width: 100%; max-width: 640px; background: var(--card);
  border-radius: 28px 28px 0 0; padding: 28px 22px calc(28px + var(--safe-b));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2); animation: slideUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-height: 92dvh; overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.assess-intro { text-align: center; padding: 8px 6px; }
.assess-emoji { font-size: 54px; }
.assess-intro h2 { margin: 8px 0 6px; font-size: 24px; font-weight: 800; }
.assess-intro p { margin: 0 0 22px; color: var(--text-2); font-size: 15px; line-height: 1.5; }
.assess-loading { text-align: center; padding: 40px 0; color: var(--text-2); }
.assess-loading p { margin-top: 8px; font-size: 14px; }

.btn-primary {
  display: inline-block; width: 100%; max-width: 320px; padding: 15px 20px; border: none;
  border-radius: 16px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 700;
  cursor: pointer; text-decoration: none; box-shadow: 0 6px 18px rgba(224, 122, 95, 0.32);
}
.btn-primary:active { background: var(--accent-press); transform: scale(0.98); }
.btn-primary.wide { max-width: none; }
.btn-outline {
  display: inline-block; width: 100%; max-width: 320px; margin-top: 10px;
  padding: 14px 20px; border: 1.5px solid var(--accent); border-radius: 16px;
  background: transparent; color: var(--accent); font-size: 16px; font-weight: 700; cursor: pointer;
}
.btn-outline:active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.btn-text { display: block; margin: 12px auto 0; background: none; border: none; color: var(--text-2); font-size: 15px; font-weight: 600; cursor: pointer; }

/* ---- Quiz ---- */
.quiz-progress { height: 6px; background: var(--sep); border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.quiz-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.quiz-count { font-size: 13px; color: var(--text-2); font-weight: 600; margin-bottom: 14px; }
.quiz-q { font-size: 22px; font-weight: 700; line-height: 1.35; margin-bottom: 20px; }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; }
.quiz-opt {
  padding: 16px 18px; border: 1.5px solid var(--sep); border-radius: 15px; background: var(--card);
  color: var(--text); font-size: 17px; font-weight: 500; text-align: left; cursor: pointer;
  transition: 0.12s;
}
.quiz-opt:active { border-color: var(--accent); background: rgba(224, 122, 95, 0.10); transform: scale(0.99); }

/* ============================ RÉVISION ============================ */
.empty { text-align: center; padding: 48px 16px; }
.empty-emoji { font-size: 56px; }
.empty h3 { margin: 10px 0 6px; font-size: 21px; font-weight: 800; }
.empty p { margin: 0 auto 20px; color: var(--text-2); font-size: 15px; line-height: 1.5; max-width: 300px; }

#view-review { justify-content: flex-start; padding-top: 10px; }
.flashcard {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px 22px; text-align: center; margin-bottom: 16px; min-height: 240px;
  display: flex; flex-direction: column; justify-content: center;
}
.fc-count { font-size: 13px; color: var(--text-2); font-weight: 600; margin-bottom: 18px; }
.fc-hanzi { font-size: 60px; font-weight: 600; letter-spacing: 2px; line-height: 1.1; }
.fc-back { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--sep); }
.fc-back.hidden { display: none; }
.fc-pinyin { font-size: 22px; color: var(--accent); font-weight: 600; }
.fc-trans { font-size: 20px; font-weight: 600; margin-top: 6px; }
.fc-example { margin-top: 16px; background: var(--bg); border-radius: 14px; padding: 12px 14px; }
.fc-ex-zh { font-size: 18px; }
.fc-ex-py { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.fc-ex-fr { font-size: 14px; color: var(--text-2); margin-top: 4px; font-style: italic; }

.fc-actions { margin-top: auto; }
.grades { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grade {
  padding: 15px; border: none; border-radius: 15px; font-size: 16px; font-weight: 700;
  color: #fff; cursor: pointer; transition: 0.12s;
}
.grade:active { transform: scale(0.97); }
.grade.again { background: var(--danger); }
.grade.hard { background: var(--orange); }
.grade.good { background: var(--green); }
.grade.easy { background: var(--accent); }

/* ============================ RARETÉ ============================ */
.rarity {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: #fff; background: var(--rc, #98a2b3);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--rc, #98a2b3) 45%, transparent);
  white-space: nowrap;
}

/* mots capturables / possédés */
ruby.tappable { cursor: pointer; }
ruby.owned.known { box-shadow: inset 0 -2px 0 rgba(124, 165, 95, 0.7); border-radius: 5px; padding: 0 1px; }
ruby.owned.learning { box-shadow: inset 0 -2px 0 rgba(217, 154, 43, 0.7); border-radius: 5px; padding: 0 1px; }
.word-owned { color: var(--text-2); font-weight: 600; font-size: 15px; padding: 4px 0 14px; }

/* ==================== FEUILLE MOT (capture) ==================== */
.word-card { text-align: center; padding: 2px 4px; }
.word-hanzi { font-size: 54px; font-weight: 600; letter-spacing: 2px; line-height: 1.1; }
.word-py { font-size: 22px; color: var(--accent); font-weight: 600; margin-top: 6px; }
.word-tags { display: flex; gap: 8px; justify-content: center; margin: 16px 0 18px; }
.hsk-tag {
  padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--sep); color: var(--text-2);
}
.geo-toggle {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; color: var(--text-2); margin-bottom: 16px; cursor: pointer;
}
.geo-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.word-added { color: var(--green); font-weight: 700; font-size: 16px; padding: 12px; }

/* ==================== TOGGLE MODE RÉVISION ==================== */
.mode-toggle {
  display: flex; gap: 6px; background: var(--sep); padding: 4px;
  border-radius: 14px; margin: 6px 0 14px;
}
.mode {
  flex: 1; border: none; background: transparent; padding: 10px; border-radius: 11px;
  font-size: 15px; font-weight: 600; color: var(--text-2); cursor: pointer;
}
.mode.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.mode-n {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 10px; background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700; margin-left: 5px;
}
.mode:not(.active) .mode-n { background: var(--text-2); }

.fc-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.fc-geo { margin-top: 12px; font-size: 13px; color: var(--text-2); }

/* ============================ TOAST ============================ */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: rgba(30, 30, 32, 0.95); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 60; opacity: 0; transition: 0.25s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-height: 620px) {
  .card { min-height: 92px; }
  .fc-hanzi { font-size: 48px; }
}

/* ==================== BANDE STATS (série + objectif) ==================== */
.stats-strip { display: flex; gap: 10px; margin: 2px 4px 6px; }
.stat-chip, .stat-goal {
  display: flex; align-items: center; gap: 9px; border: none; cursor: pointer;
  background: var(--card); box-shadow: var(--shadow); border-radius: 15px;
  padding: 8px 13px; color: var(--text); transition: transform 0.1s;
}
.stat-chip:active, .stat-goal:active { transform: scale(0.97); }
.stat-chip { flex: 0 0 auto; }
.sc-ico { font-size: 21px; }
.stat-chip.cold .sc-ico { filter: grayscale(1); opacity: 0.5; }
.sc-body, .goal-body { display: flex; flex-direction: column; line-height: 1.05; align-items: flex-start; }
.sc-n { font-size: 18px; font-weight: 800; }
.sc-l, .goal-l { font-size: 10.5px; color: var(--text-2); font-weight: 600; }
.stat-goal { flex: 1; }
.goal-ring { width: 34px; height: 34px; flex: none; transform: rotate(-90deg); }
.goal-ring .gr-bg { fill: none; stroke: var(--sep); stroke-width: 4; }
.goal-ring .gr-fg {
  fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 100.5; stroke-dashoffset: 100.5; transition: stroke-dashoffset 0.6s ease;
}
.stat-goal.done .gr-fg { stroke: var(--green); }
.goal-top { font-size: 15px; font-weight: 800; }
.goal-top b { color: var(--accent); }
.stat-goal.done .goal-top b { color: var(--green); }

/* ==================== FEUILLE PROFIL / PROGRESSION ==================== */
.profile-head { text-align: center; }
.profile-avatar {
  width: 66px; height: 66px; border-radius: 50%; overflow: hidden; margin: 0 auto 8px;
  background: var(--accent); box-shadow: var(--shadow);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar .avatar-fallback { font-size: 28px; }
.profile-name { font-size: 21px; font-weight: 800; margin: 0; }
.profile-sub { font-size: 13px; color: var(--text-2); margin: 3px 0 0; }
.profile-cards { display: flex; gap: 10px; margin: 16px 0 4px; }
.pcard { flex: 1; background: var(--bg); border-radius: 14px; padding: 13px 8px; text-align: center; }
.pc-big { font-size: 25px; font-weight: 800; line-height: 1; }
.pc-big.fire { color: var(--accent); }
.pc-big.grn { color: var(--green); }
.pc-l { font-size: 11px; color: var(--text-2); font-weight: 600; margin-top: 4px; }
.prog-title { font-size: 12.5px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; margin: 18px 4px 10px; }
.lvl-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.lvl-tag { flex: 0 0 42px; font-size: 12px; font-weight: 800; color: var(--text-2); }
.lvl-bar { flex: 1; height: 9px; background: var(--sep); border-radius: 999px; overflow: hidden; }
.lvl-fill { height: 100%; background: linear-gradient(90deg, var(--amber), var(--accent)); border-radius: 999px; transition: width 0.6s ease; }
.lvl-num { flex: 0 0 auto; font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 128px; text-align: right; }
.lvl-num .rd { color: var(--green); font-weight: 700; }
.lvl-num .gm { color: var(--learn-line); font-weight: 700; }

/* ==================== BADGES / PROGRESSION LECTURE ==================== */
.rg-count { text-transform: none; letter-spacing: 0; font-weight: 700; color: var(--text-2); margin-left: auto; }
.rg-bar { height: 6px; background: var(--sep); border-radius: 999px; margin: 0 4px 10px; overflow: hidden; }
.rg-fill { height: 100%; background: var(--green); border-radius: 999px; transition: width 0.5s; }
.read-item.is-read { opacity: 0.7; }
.ri-badge { flex: none; font-size: 15px; }
.ri-badge.read { color: var(--green); }
.ri-badge.reading { color: var(--learn-line); }

/* ==================== LECTEUR : bouton terminé ==================== */
.reader-finish { margin-top: 18px; text-align: center; }
.reader-finish .btn-primary.is-done { background: var(--green); box-shadow: 0 6px 18px rgba(124, 165, 95, 0.32); pointer-events: none; }

/* ==================== SENS DU MOT (feuille) ==================== */
.word-meaning { margin: 10px 0 2px; min-height: 22px; }
.word-meaning .dots span { font-size: 20px; }
.wm-trans { font-size: 18px; font-weight: 600; color: var(--text); }
.wm-trans.muted { color: var(--text-2); font-weight: 500; font-size: 15px; }
.wm-ex { margin-top: 12px; background: var(--bg); border-radius: 14px; padding: 11px 14px; text-align: left; }
.wm-ex-zh { font-size: 17px; color: var(--text); }
.wm-ex-py { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.wm-ex-fr { font-size: 13.5px; color: var(--text-2); margin-top: 4px; font-style: italic; }

/* ==================== LECTURE ==================== */
.read-intro { padding: 6px 2px 8px; }
.read-intro h2 { margin: 0 0 4px; font-size: 22px; }
.read-intro p { margin: 0; font-size: 14px; color: var(--text-2); line-height: 1.4; }
.read-group { margin-top: 18px; }
.read-group-h {
  font-size: 13px; font-weight: 700; color: var(--text-2); text-transform: uppercase;
  letter-spacing: 0.04em; margin: 0 4px 8px; display: flex; align-items: center; gap: 8px;
}
.read-reco {
  text-transform: none; letter-spacing: 0; background: var(--green); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
}
.read-list { display: flex; flex-direction: column; gap: 8px; }
.read-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: none; border-radius: 16px; padding: 12px 14px;
  cursor: pointer; box-shadow: var(--shadow); transition: transform 0.1s;
}
.read-item:active { transform: scale(0.985); }
.ri-ico { font-size: 26px; flex: none; }
.ri-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ri-title { font-size: 17px; font-weight: 600; color: var(--text); }
.ri-sub { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-arrow { color: var(--text-2); font-size: 22px; flex: none; }

/* lecteur */
.reader-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.btn-back { background: none; border: none; color: var(--accent); font-size: 15px; font-weight: 600; cursor: pointer; padding: 4px 0; }
.reader-tools { display: flex; gap: 8px; }
.tool {
  background: var(--bg); border: none; border-radius: 999px; padding: 7px 12px;
  font-size: 13px; font-weight: 700; color: var(--text-2); cursor: pointer; transition: 0.12s;
}
.tool.on { background: var(--accent); color: #fff; }
.reader-title { margin: 8px 0 2px; font-size: 22px; }
.reader-sub { font-size: 13px; color: var(--text-2); margin-bottom: 14px; }
.reader-text {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 16px; font-size: 21px; color: var(--text);
}
.reader-text.ruby { line-height: 2.6; }
.reader-text ruby { ruby-position: under; ruby-align: center; margin: 0 1px; }
.reader-text rt { font-size: 0.42em; font-weight: 500; color: var(--text-2); padding-top: 2px; }
.reader-text.no-py { line-height: 2; }
.reader-text.no-py rt { display: none; }
.reader-text .punct { color: var(--text-2); }
.rd-para { margin: 0 0 12px; }
.rd-para:last-child { margin-bottom: 0; }
.rd-space { height: 10px; }
.reader-fr { margin-top: 14px; background: var(--bg); border-radius: 16px; padding: 14px 16px; }
.reader-fr.hidden { display: none; }
.reader-fr-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); margin-bottom: 8px; }
.reader-fr p { margin: 0 0 8px; font-size: 15px; line-height: 1.5; color: var(--text); }
.reader-fr p:last-child { margin-bottom: 0; }

/* ==================== GRAMMAIRE : leçon ==================== */
.lesson-sec {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 14px;
}
.ls-h { margin: 0 0 6px; font-size: 17px; font-weight: 800; }
.ls-p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.55; color: var(--text); }
.ls-struct {
  display: inline-block; margin: 0 0 12px; padding: 7px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent-press); font-size: 14px; font-weight: 700; letter-spacing: 0.01em;
}
@media (prefers-color-scheme: dark) { .ls-struct { color: var(--accent); } }
.ls-ex { background: var(--bg); border-radius: 14px; padding: 11px 14px; margin-bottom: 10px; }
.ls-ex:last-child { margin-bottom: 0; }
.ls-ex-zh { font-size: 20px; line-height: 2.4; }
.ls-ex-zh ruby { ruby-position: under; ruby-align: center; margin: 0 1px; }
.ls-ex-zh rt { font-size: 0.42em; font-weight: 500; color: var(--text-2); padding-top: 2px; }
.lesson.no-py .ls-ex-zh { line-height: 1.7; }
.lesson.no-py .ls-ex-zh rt { display: none; }
.ls-ex-zh .punct { color: var(--text-2); }
.ls-ex-fr { font-size: 13.5px; color: var(--text-2); font-style: italic; margin-top: 6px; }

/* ==================== IA : PANDA TUTEUR ==================== */
#view-ia { min-height: 0; }
#iaBody { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ia-hero {
  text-align: center; padding: 8px 0 4px; flex: none;
  transition: padding 0.25s ease;
}
.ia-panda {
  width: 168px; height: auto; margin: 0 auto;
  filter: drop-shadow(0 8px 18px rgba(120, 90, 55, 0.18));
  animation: bob 4s ease-in-out infinite;
  transition: width 0.25s ease;
}
.ia-hero.small { padding: 2px 0 0; }
.ia-hero.small .ia-panda { width: 76px; }
.panda-arm { transform-origin: 138px 146px; animation: wave 1.5s ease-in-out infinite; }
@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  40% { transform: rotate(30deg); }
  60% { transform: rotate(18deg); }
  80% { transform: rotate(32deg); }
}
.ia-hello h2 { margin: 6px 0 4px; font-size: 23px; font-weight: 800; }
.ia-hello p { margin: 0 auto; max-width: 340px; font-size: 14.5px; line-height: 1.5; color: var(--text-2); }
.ia-hello b { color: var(--accent); }

.chat-list {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column;
  gap: 10px; padding: 10px 2px; -webkit-overflow-scrolling: touch;
}
.bubble {
  max-width: 86%; padding: 11px 15px; font-size: 15.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; animation: bubbleIn 0.22s ease;
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.bubble.user {
  align-self: flex-end; background: var(--accent); color: #fff;
  border-radius: 19px 19px 5px 19px; box-shadow: 0 4px 14px rgba(224, 122, 95, 0.25);
}
.bubble.panda {
  align-self: flex-start; background: var(--card); color: var(--text);
  border-radius: 19px 19px 19px 5px; box-shadow: var(--shadow);
}
.bubble.panda.typing { color: var(--text-2); }
.bubble.panda .dots span { font-size: 22px; }
.bubble .bz { white-space: normal; }
.bubble ruby { ruby-position: under; ruby-align: center; margin: 0 1px; line-height: 2.2; }
.bubble rt { font-size: 0.45em; font-weight: 500; color: var(--text-2); padding-top: 1px; }

.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 6px 0 12px; flex: none; }
.chip {
  border: 1.5px solid var(--sep); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 9px 14px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; box-shadow: var(--shadow); transition: 0.12s;
}
.chip:active { border-color: var(--accent); color: var(--accent); transform: scale(0.97); }

.chat-bar {
  flex: none; display: flex; align-items: flex-end; gap: 8px;
  background: var(--card); border-radius: 22px; box-shadow: var(--shadow);
  padding: 8px 8px 8px 16px; margin: 4px 0 10px;
}
.chat-input {
  flex: 1; border: none; outline: none; resize: none; background: transparent;
  color: var(--text); font: inherit; font-size: 15.5px; line-height: 1.4;
  max-height: 120px; padding: 8px 0;
}
.chat-input::placeholder { color: var(--text-2); }
.chat-send {
  flex: none; width: 40px; height: 40px; border: none; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  cursor: pointer; box-shadow: 0 4px 12px rgba(224, 122, 95, 0.32); transition: 0.12s;
}
.chat-send:active { background: var(--accent-press); transform: scale(0.93); }
.chat-clear { margin: 0 auto 8px; flex: none; }

/* ==================== PREMIUM (paywall) ==================== */
.paywall { text-align: center; padding: 2px 4px; }
.pw-emoji { font-size: 46px; }
.paywall h2 { margin: 6px 0 6px; font-size: 24px; font-weight: 800; }
.pw-msg { margin: 0 auto 16px; max-width: 320px; font-size: 14.5px; line-height: 1.5; color: var(--text-2); }
.pw-features { display: flex; flex-direction: column; gap: 8px; margin: 0 auto 16px; max-width: 300px; }
.pw-f {
  background: var(--bg); border-radius: 12px; padding: 10px 14px;
  font-size: 14px; font-weight: 600; text-align: left;
}
.pw-prices { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; }
.pw-price {
  position: relative; flex: 1; max-width: 150px; background: var(--bg);
  border: 1.5px solid var(--sep); border-radius: 16px; padding: 14px 8px 12px;
  display: flex; flex-direction: column; line-height: 1.2;
}
.pw-price b { font-size: 19px; }
.pw-price span { font-size: 12px; color: var(--text-2); font-weight: 600; }
.pw-price.best { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--bg)); }
.pw-badge {
  position: absolute; top: -9px; right: 10px; background: var(--accent); color: #fff !important;
  font-size: 10.5px !important; font-weight: 800; padding: 2px 8px; border-radius: 999px;
}
.paywall .btn-primary:disabled { opacity: 0.65; cursor: default; }
.pw-note { margin: 10px auto 0; max-width: 300px; font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.pw-link {
  border: none; background: none; padding: 0; color: var(--accent);
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline;
}

/* quota chat + textes verrouillés */
.chat-quota { flex: none; text-align: center; font-size: 12.5px; color: var(--text-2); font-weight: 600; margin: -4px 0 10px; }
.chat-quota b { color: var(--accent); }
.read-item.is-locked { opacity: 0.62; }
.ri-badge.lock { font-size: 14px; }

/* ===================== SPLASH (écran de chargement) ===================== */
#splash {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(circle at 50% 30%, rgba(233, 180, 76, 0.10), transparent 55%);
  transition: opacity 0.5s ease;
}
#splash.out { opacity: 0; pointer-events: none; }
.sp-inner { display: flex; flex-direction: column; align-items: center; animation: spIn 0.6s ease; }
.sp-panda { width: 150px; height: auto; animation: spBob 2.4s ease-in-out infinite; }
.sp-title { margin: 14px 0 2px; font-size: 30px; letter-spacing: 0.3px; }
.sp-sub { margin: 0 0 22px; color: var(--text-2); font-size: 14px; font-weight: 600; }
.sp-bar {
  width: 190px; height: 8px; border-radius: 999px; background: var(--bg-2);
  overflow: hidden; box-shadow: inset 0 1px 2px rgba(90, 65, 40, 0.10);
}
#spFill {
  display: block; height: 100%; width: 6%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--amber), var(--accent));
  background-size: 200% 100%; animation: spShimmer 1.3s linear infinite;
  transition: width 0.35s ease;
}
.sp-tip { margin: 12px 0 0; font-size: 13px; color: var(--text-2); font-weight: 600; min-height: 18px; }
.sp-hanzi {
  position: absolute; font-size: 28px; font-weight: 700; color: var(--accent);
  opacity: 0; animation: spFloat 5.5s ease-in-out infinite; user-select: none; pointer-events: none;
}
@keyframes spIn { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes spBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes spShimmer { from { background-position: 0 0; } to { background-position: -200% 0; } }
@keyframes spFloat {
  0% { opacity: 0; transform: translateY(16px) rotate(-4deg); }
  25% { opacity: 0.16; }
  75% { opacity: 0.13; }
  100% { opacity: 0; transform: translateY(-30px) rotate(4deg); }
}

/* paywall : cartes de prix cliquables (Stripe branché) */
button.pw-price { font: inherit; color: inherit; cursor: pointer; transition: transform 0.12s ease, border-color 0.12s ease; }
button.pw-price:not(:disabled):active { transform: scale(0.96); }
button.pw-price:not(:disabled):hover { border-color: var(--accent); }
button.pw-price:disabled { cursor: default; }
.profile-premium {
  margin: -6px 0 12px; font-size: 13.5px; font-weight: 700; color: var(--amber);
}
