/* ───── Chat ───── */
.chat { padding-bottom: 24px; display: flex; flex-direction: column; min-height: calc(100vh - 260px); }
.chat-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; min-height: 36px; }
.quota { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.quota.low { color: var(--mid); font-weight: 600; }
.btn.small { padding: 6px 14px; font-size: 13px; font-weight: 500; }
.log { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 88%; padding: 11px 16px; border-radius: 18px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: var(--shadow); }
.msg.error .bubble { background: var(--ko-soft); color: var(--ko); border: 1px solid color-mix(in srgb, var(--ko) 30%, transparent); font-size: 14px; }
.bubble p { margin: 0 0 8px; }
.bubble > :last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 8px; padding-left: 22px; }
.bubble li + li { margin-top: 3px; }
.bubble code { font: 13.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.bubble.typing { color: var(--muted); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.welcome { margin-top: 20px; }
.welcome[hidden] { display: none; }
.chips { display: grid; gap: 8px; }
.chip { font: inherit; font-size: 14.5px; text-align: left; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer; transition: border-color .12s, background .12s; }
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.composer { position: sticky; bottom: 0; margin-top: auto; padding-top: 16px; padding-bottom: 8px; display: flex; gap: 8px; align-items: flex-end; background: linear-gradient(to top, var(--bg) 75%, transparent); }
.composer textarea { flex: 1; resize: none; min-height: 46px; max-height: 160px; border-radius: 14px; padding: 11px 14px; background: var(--surface); }
.btn.send { width: 46px; height: 46px; padding: 0; display: grid; place-items: center; border-radius: 14px; flex: none; }
.fine { margin: 4px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
textarea:disabled { opacity: .7; }

/* ───── Réviser ───── */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin: 20px 0 4px; }
.subnav a { font-size: 13.5px; font-weight: 500; color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 99px; padding: 4px 14px; background: var(--surface); }
.subnav a:hover { color: var(--accent); border-color: var(--accent); }

.deck-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 4px 0 14px; font-size: 14px; color: var(--muted); }
.deck-prog { flex: 1 1 140px; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; min-width: 100px; }
.deck-prog > div { height: 100%; background: var(--ok); border-radius: 99px; transition: width .25s; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; background: var(--surface); }
.seg button { font: inherit; font-size: 13px; padding: 4px 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.card3d { perspective: 1200px; }
.flash { position: relative; display: block; width: 100%; min-height: 260px; cursor: pointer; border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3, .7, .3, 1); }
.flash.flipped { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); padding: 24px 26px; display: flex; flex-direction: column; justify-content: center; gap: 10px; overflow: auto; }
.face.back { transform: rotateY(180deg); background: var(--accent-soft); border-color: transparent; justify-content: flex-start; }
.face .tag { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.face .term { font: 700 clamp(24px, 5vw, 32px)/1.2 Georgia, "Times New Roman", serif; }
.face .tap { font-size: 13px; color: var(--muted); margin-top: auto; }
.face p { margin: 0; }
.face .eg { font-size: 14.5px; color: var(--muted); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; justify-content: center; }
.card-actions .btn { padding: 9px 18px; font-size: 14.5px; }
.btn.ok { background: var(--ok); }
.btn.again { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.again:hover { border-color: var(--ko); color: var(--ko); opacity: 1; }
.deck-done { text-align: center; padding: 36px 20px; background: var(--surface); border: 1px dashed var(--line); border-radius: 18px; }
.deck-done h3 { margin: 0 0 6px; font: 700 22px Georgia, serif; }

.drill-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.drill-tabs button { font: inherit; font-size: 14px; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.drill-tabs button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.drill { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.drill-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 10px; }
.drill-text { font: 600 19px/1.5 Georgia, "Times New Roman", serif; margin: 0 0 16px; }
.drill-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.drill-opts button { font: inherit; font-size: 15px; padding: 9px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; transition: border-color .12s, background .12s; }
.drill-opts button:hover:not(:disabled) { border-color: var(--accent); }
.drill-opts button.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.drill-opts button.wrong { background: var(--ko-soft); border-color: var(--ko); color: var(--ko); }
.drill-opts button:disabled { cursor: default; }
.drill .why { margin-top: 14px; padding: 11px 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 15px; }
.drill .why.ok { border-left: 4px solid var(--ok); }
.drill .why.ko { border-left: 4px solid var(--ko); }
.drill-foot { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.drill-score { text-align: center; padding: 8px 0; }
.drill-score .big { font: 700 52px/1 Georgia, serif; font-variant-numeric: tabular-nums; }

.explorer { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); margin-top: 12px; }
.explorer h3 { margin: 0 0 4px; font-size: 17px; }
.explorer .src { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.dbar { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; align-items: center; width: 100%; text-align: left; font: inherit; color: inherit; background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 7px 8px; cursor: pointer; }
.dbar:hover { background: var(--bg); }
.dbar[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.dbar .name { font-size: 13.5px; line-height: 1.3; }
.dbar .bars { display: grid; gap: 3px; }
.dbar .b { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dbar .b span.fill { display: block; height: 10px; border-radius: 4px; min-width: 2px; transition: width .3s; }
.c1 { background: #8a8fa3; } .c2 { background: var(--accent); }
.read { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); font-size: 15px; min-height: 52px; }
.read strong { color: var(--accent); }
.pickers { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pickers button { font: inherit; font-size: 13.5px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; }
.pickers button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.label-sm { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.homo { display: grid; grid-template-columns: 110px 1fr 48px; gap: 6px 10px; align-items: center; font-size: 13.5px; }
.homo .track { height: 14px; background: var(--line); border-radius: 5px; overflow: hidden; }
.homo .track span { display: block; height: 100%; background: #8a8fa3; border-radius: 5px; transition: width .3s; }
.homo .track span.same { background: var(--ok); }
.homo .v { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; }
.stack { display: grid; gap: 14px; }
.stack .row2 { display: grid; grid-template-columns: 160px 1fr; gap: 10px; align-items: center; font-size: 13.5px; }
.stack .sbar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; background: var(--line); }
.stack .sbar span { display: grid; place-items: center; font-size: 12px; font-weight: 600; color: #fff; transition: width .3s; white-space: nowrap; }
.stack .sbar .g { background: var(--accent); } .stack .sbar .f { background: #d6568b; }
.reveal { margin-top: 12px; }
.reveal button { font: inherit; font-size: 14px; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; }
.reveal button:hover { border-color: var(--accent); }
.reveal .ans { margin-top: 10px; font-size: 15px; }

.acc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-top: 10px; overflow: hidden; }
.acc summary { cursor: pointer; padding: 14px 18px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 10px; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::before { content: "▸"; color: var(--accent); transition: transform .15s; display: inline-block; }
.acc[open] summary::before { transform: rotate(90deg); }
.acc .acc-body { padding: 0 18px 16px 38px; font-size: 15.5px; }
.acc ul { margin: 0 0 12px; padding-left: 18px; }
.acc li + li { margin-top: 4px; }
.acc .ask { font: inherit; font-size: 13.5px; padding: 5px 14px; border-radius: 99px; border: 1px solid var(--accent); color: var(--accent); background: transparent; text-decoration: none; display: inline-block; cursor: pointer; }
.acc .ask:hover { background: var(--accent-soft); }

@media (max-width: 560px) {
  .bubble { max-width: 94%; }
  .dbar { grid-template-columns: 1fr; }
  .stack .row2 { grid-template-columns: 1fr; gap: 4px; }
  .homo { grid-template-columns: 90px 1fr 42px; }
  .face { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .flash, .deck-prog > div, .dbar .b span.fill, .homo .track span, .stack .sbar span { transition: none; }
  .bubble.typing { animation: none; }
}
