/* ============================================================
   style.css — English Trainer
   Thème sombre par défaut + thème clair (data-theme sur <html>).
   ============================================================ */

/* ---------- Variables de thème ---------- */
:root[data-theme="dark"] {
  --bg: #0f1420;
  --bg-2: #151b2b;
  --card: #1a2234;
  --card-2: #212b40;
  --border: #2b3550;
  --text: #e7ecf5;
  --muted: #93a0bd;
  --accent: #4dd6c1;
  --accent-2: #6c8cff;
  --accent-ink: #06231f;
  --ok: #38c172;
  --ok-bg: #10331f;
  --ko: #ff6b6b;
  --ko-bg: #3a1720;
  --hint: #f2c14e;
  --hint-bg: #33290e;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
:root[data-theme="light"] {
  --bg: #f2f5fb;
  --bg-2: #e9eef8;
  --card: #ffffff;
  --card-2: #f4f7fd;
  --border: #dde3ef;
  --text: #16203a;
  --muted: #61708f;
  --accent: #0ca697;
  --accent-2: #3d5bef;
  --accent-ink: #ffffff;
  --ok: #1a9c56;
  --ok-bg: #e4f6ea;
  --ko: #d63b4a;
  --ko-bg: #fbe6e8;
  --hint: #a9791a;
  --hint-bg: #fbf1d6;
  --shadow: 0 8px 24px rgba(30, 50, 90, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, var(--bg-2), var(--bg)) fixed;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; }
p { margin: 0 0 .8em; }
a { color: var(--accent-2); }
code { background: var(--card-2); padding: .1em .4em; border-radius: 5px; font-size: .9em; }
kbd {
  background: var(--card-2); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: .05em .45em; font-size: .85em; font-family: inherit;
}
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- En-tête ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.2rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .7rem; margin-right: auto; }
.brand .logo { font-size: 1.9rem; }
.brand h1 { font-size: 1.25rem; margin: 0; letter-spacing: .3px; }
.tagline { margin: 0; font-size: .8rem; color: var(--muted); }

.tabs { display: flex; gap: .35rem; background: var(--card); padding: .3rem; border-radius: 12px; border: 1px solid var(--border); }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: .5rem .9rem; border-radius: 9px; cursor: pointer;
  font-size: .92rem; font-weight: 600; transition: .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); }

.icon-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; font-size: 1.1rem;
}
.icon-btn:hover { border-color: var(--accent); }

/* ---------- Layout ---------- */
.app-main { max-width: 1120px; margin: 0 auto; padding: 1.4rem 1.2rem 3rem; }
.panel { display: none; animation: fade .25s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1.1rem;
}

.ex-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.1rem; align-items: start; }
.ex-col-side { position: sticky; top: 74px; }

/* ---------- Contrôles ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.control-group { display: flex; flex-direction: column; gap: .4rem; }
.control-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 700; }

.segmented { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: 11px; padding: .25rem; gap: .2rem; }
.segmented button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: .45rem .8rem; border-radius: 8px; font-weight: 600; font-size: .9rem; transition: .15s;
}
.segmented.small button { padding: .4rem .65rem; font-size: .82rem; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.segmented button.is-disabled { opacity: .35; cursor: not-allowed; }

.select {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: .55rem .7rem; font-size: .92rem; min-width: 240px; font-family: inherit;
}
.select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* ---------- Carte d'exercice ---------- */
.exercise { padding: 1.4rem 1.4rem 1.2rem; }
.ex-badges { display: flex; gap: .5rem; margin-bottom: 1rem; }
.badge { font-size: .74rem; font-weight: 700; padding: .3rem .7rem; border-radius: 20px; letter-spacing: .02em; }
.badge-tense { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.badge-form { background: color-mix(in srgb, var(--accent-2) 22%, transparent); color: var(--accent-2); border: 1px solid color-mix(in srgb, var(--accent-2) 40%, transparent); }

.ex-prompt { min-height: 84px; margin-bottom: 1rem; }
.prompt-sentence { font-size: 1.5rem; font-weight: 500; letter-spacing: .2px; }
.prompt-fr { font-size: 1.5rem; font-weight: 600; }
.prompt-instr { margin-top: .7rem; color: var(--muted); font-size: .95rem; }
.prompt-instr b { color: var(--text); }
.form-lbl { color: var(--accent-2); font-weight: 700; }
.blank {
  display: inline-block; min-width: 90px; text-align: center; color: var(--accent);
  border-bottom: 2px dashed var(--accent); font-weight: 700; letter-spacing: 2px;
}
.tokens { display: flex; flex-wrap: wrap; gap: .6rem; }
.token {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px;
  padding: .55rem .8rem; font-size: 1.12rem; display: flex; flex-direction: column;
}
.token em { color: var(--muted); font-size: .82rem; font-style: normal; }
.tk-lbl { font-size: .64rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; margin-bottom: .1rem; }

.answer-input {
  width: 100%; background: var(--bg-2); border: 1.5px solid var(--border); color: var(--text);
  border-radius: 12px; padding: .85rem 1rem; font-size: 1.15rem; font-family: inherit;
}
.answer-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.answer-input:disabled { opacity: .8; }

.ex-actions { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--border); background: var(--card-2); color: var(--text);
  padding: .65rem 1.1rem; border-radius: 11px; cursor: pointer; font-weight: 700; font-size: .95rem;
  font-family: inherit; transition: .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border: 0; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn.small { padding: .45rem .75rem; font-size: .84rem; }

/* ---------- Feedback ---------- */
.feedback { min-height: 1.2rem; border-radius: 12px; font-size: 1rem; }
.feedback:not(:empty) { padding: .8rem 1rem; margin-top: .2rem; }
.feedback-ok { background: var(--ok-bg); border: 1px solid var(--ok); color: var(--text); }
.feedback-ko { background: var(--ko-bg); border: 1px solid var(--ko); color: var(--text); }
.feedback-hint { background: var(--hint-bg); border: 1px solid var(--hint); color: var(--text); }
.feedback .model { font-weight: 700; color: var(--accent); }
.feedback-ko .model { color: var(--text); }
.fb-note, .fb-formula { margin-top: .5rem; font-size: .9rem; color: var(--muted); }
.fb-note { color: var(--text); }

/* Correctif détaillé : ta réponse / phrase corrigée */
.fb-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .6rem; margin-top: .6rem; }
.fb-lbl {
  flex: 0 0 auto; font-size: .68rem; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.fb-yours { color: var(--muted); }
.fb-full { font-size: 1.08rem; font-weight: 600; line-height: 1.5; }

.diff-bad, .diff-good { border-radius: 5px; padding: .05em .3em; }
.diff-bad {
  background: color-mix(in srgb, var(--ko) 26%, transparent);
  text-decoration: line-through; text-decoration-color: var(--ko); text-decoration-thickness: 2px;
}
.diff-good {
  background: color-mix(in srgb, var(--ok) 24%, transparent);
  color: var(--ok); font-weight: 800;
}

/* Diagnostic : le temps réellement employé */
.fb-diag {
  margin-top: .8rem; padding: .7rem .9rem;
  border-left: 3px solid var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
  border-radius: 0 10px 10px 0;
}
.fb-diag-head { font-size: .95rem; }
.fb-diag-why { margin-top: .25rem; font-size: .85rem; color: var(--muted); }
.fb-diag-ex { font-size: 1rem; font-weight: 600; color: var(--accent-2); }

/* ---------- Options ---------- */
.options summary { cursor: pointer; font-weight: 700; color: var(--muted); }
.options summary:hover { color: var(--text); }
.options-body { margin-top: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.ai-box { display: flex; flex-direction: column; gap: .6rem; }
.check { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.reset-row { display: flex; gap: .6rem; flex-wrap: wrap; }

/* ---------- Stats ---------- */
.stats h3 { font-size: 1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: .6rem 0 1rem; }
.stat { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: .6rem .3rem; text-align: center; }
.stat-num { display: block; font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.stat-lbl { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.per-tense-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: .5rem; }
.per-tense { display: flex; flex-direction: column; gap: .45rem; }
.pt-row { display: grid; grid-template-columns: 1fr 70px auto; align-items: center; gap: .5rem; font-size: .82rem; }
.pt-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-bar { background: var(--bg-2); border-radius: 6px; height: 8px; overflow: hidden; border: 1px solid var(--border); }
.pt-fill { display: block; height: 100%; }
.pt-fill.good { background: var(--ok); }
.pt-fill.mid { background: var(--hint); }
.pt-fill.low { background: var(--ko); }
.pt-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.tip { font-size: .9rem; }

/* ---------- Panneaux de référence ---------- */
.panel-intro { margin-bottom: 1.2rem; }
.panel-intro h2 { font-size: 1.5rem; }
.panel-intro p { color: var(--muted); max-width: 70ch; }
.ref-nav { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.2rem; }
.chip {
  text-decoration: none; background: var(--card); border: 1px solid var(--border);
  color: var(--muted); padding: .35rem .7rem; border-radius: 20px; font-size: .82rem; font-weight: 600;
}
.chip:hover { color: var(--text); border-color: var(--accent); }

.ref-card { scroll-margin-top: 80px; }
.ref-head { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; }
.ref-head h3 { font-size: 1.25rem; color: var(--accent); margin: 0; }
.ref-fr { color: var(--muted); font-size: .9rem; }
.formula {
  background: var(--bg-2); border: 1px dashed var(--border); border-radius: 10px;
  padding: .5rem .8rem; margin: .7rem 0; font-family: "Consolas", monospace; font-size: .92rem;
}
.examples { display: flex; flex-direction: column; gap: .4rem; margin: .8rem 0; }
.ex { padding: .5rem .7rem; border-radius: 9px; background: var(--bg-2); font-size: 1rem; }
.tag { font-size: .66rem; font-weight: 800; text-transform: uppercase; padding: .12rem .45rem; border-radius: 6px; margin-right: .5rem; letter-spacing: .04em; }
.tag-aff { background: var(--ok-bg); color: var(--ok); }
.tag-neg { background: var(--ko-bg); color: var(--ko); }
.tag-q { background: var(--hint-bg); color: var(--hint); }

.ref-block { margin-top: .9rem; }
.ref-block h4 { font-size: .95rem; color: var(--text); }
.ref-block ul { margin: .3rem 0; padding-left: 1.2rem; }
.ref-block li { margin: .25rem 0; }
.ref-block s { color: var(--ko); }
.ref-intro { color: var(--muted); }
.signals { display: flex; flex-wrap: wrap; gap: .35rem; }
.signal { background: var(--card-2); border: 1px solid var(--border); border-radius: 7px; padding: .2rem .5rem; font-size: .82rem; color: var(--accent); }
.ref-mistakes { background: color-mix(in srgb, var(--ko) 8%, transparent); border-radius: 10px; padding: .7rem .9rem; }
.ref-fr-note {
  margin-top: 1rem; padding: .7rem .9rem; border-left: 3px solid var(--accent-2);
  background: var(--bg-2); border-radius: 0 10px 10px 0; font-size: .92rem;
}
.ref-text b { color: var(--text); }
em { color: var(--accent); font-style: italic; }
.ref-mistakes em, .ref-fr-note em, .examples em, .prompt-instr em { color: var(--accent); }

/* ---------- Footer ---------- */
.app-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1.5rem; border-top: 1px solid var(--border); }

/* ============================================================
   HABITUDES
   ============================================================ */

/* Bannière in-app */
.hb-banner {
  display: flex; align-items: center; gap: .6rem;
  background: color-mix(in srgb, var(--hint) 14%, transparent);
  border: 1px solid var(--hint); border-radius: 12px;
  padding: .75rem 1rem; margin-bottom: 1rem;
  font-size: .9rem; color: var(--hint);
}
.hb-banner.hb-banner-ok {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  border-color: var(--ok); color: var(--ok);
}

/* Hero */
.habits-hero { text-align: center; padding: 1.5rem 1.2rem; }
.habits-date { font-size: .9rem; color: var(--muted); text-transform: capitalize; margin-bottom: .8rem; }
.habits-streak { display: flex; align-items: center; justify-content: center; gap: .45rem; margin-bottom: .9rem; }
.streak-fire { font-size: 2rem; }
.streak-num { font-size: 2.8rem; font-weight: 900; color: var(--accent); line-height: 1; }
.streak-label { font-size: .9rem; color: var(--muted); }
.streak-best { font-size: .78rem; color: var(--muted); margin-left: .3rem; }
.habits-progress { max-width: 340px; margin: 0 auto; }
.hb-prog-bar { height: 8px; background: var(--bg-2); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); margin-bottom: .4rem; }
.hb-prog-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 8px; transition: width .4s ease; }
.hb-prog-text { font-size: .82rem; }

/* Liste habitudes */
.habits-list { display: flex; flex-direction: column; gap: .65rem; margin-bottom: 1.1rem; }

.hb-item { padding: 0; overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.hb-item.hb-done { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }

.hb-check-btn {
  width: 100%; display: flex; align-items: center; gap: .85rem;
  background: none; border: none; color: var(--text); cursor: pointer;
  padding: 1rem 1.1rem; text-align: left; -webkit-tap-highlight-color: transparent;
}
.hb-check-btn:active { opacity: .7; }

.hb-icon { font-size: 1.6rem; flex-shrink: 0; }
.hb-info { flex: 1; display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.hb-label { font-weight: 600; font-size: 1rem; }
.hb-cat { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }

.hb-check-mark { font-size: 1.5rem; color: var(--border); flex-shrink: 0; transition: color .2s; }
.hb-done .hb-check-mark { color: var(--ok); }
.hb-done .hb-label { text-decoration: line-through; opacity: .55; }

.hb-tab-link { margin: 0 1.1rem .9rem; display: block; }

/* Journal flash */
.hb-journal { max-height: 0; overflow: hidden; transition: max-height .3s ease; }
.hb-journal.hb-journal-open { max-height: 180px; }
.hb-journal-input {
  display: block; width: 100%; min-height: 80px; box-sizing: border-box;
  background: var(--bg-2); border: 0; border-top: 1px solid var(--border);
  color: var(--text); padding: .85rem 1.1rem;
  font-family: inherit; font-size: .95rem; resize: vertical;
}
.hb-journal-input:focus { outline: none; background: var(--card-2); }

/* Grille hebdo */
.hb-week { display: flex; flex-direction: column; gap: .3rem; overflow-x: auto; padding-bottom: .2rem; }
.hb-week-row { display: flex; align-items: center; gap: .28rem; }
.hb-week-header { margin-bottom: .15rem; }
.hb-week-day-lbl { width: 32px; flex-shrink: 0; font-size: .72rem; color: var(--muted); font-weight: 700; }
.hb-week-today .hb-week-day-lbl { color: var(--accent); }
.hb-week-cell { width: 28px; height: 28px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .78rem; border-radius: 7px; }
.hb-week-icon { font-size: .95rem; }
.hb-dot { background: var(--bg-2); border: 1px solid var(--border); color: var(--muted); }
.hb-dot-done { background: color-mix(in srgb, var(--ok) 18%, transparent); border-color: color-mix(in srgb, var(--ok) 50%, transparent); color: var(--ok); font-weight: 700; }
.hb-dot-miss { opacity: .35; }
.hb-week-today .hb-dot:not(.hb-dot-done) { border-color: var(--accent); }
.hb-week-fire { font-size: .85rem; margin-left: .15rem; }

/* Notifications */
.hb-notif-controls { display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-end; margin: .8rem 0 .6rem; }
.hb-notif-times { display: flex; gap: .5rem; flex-wrap: wrap; }
.hb-time-label { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; color: var(--muted); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.hb-time-input { min-width: 0 !important; width: 108px; }
.hb-notif-status { margin-top: .4rem; }
.btn-notif-ok { background: linear-gradient(135deg, var(--ok), var(--accent)); color: #fff; border: 0; }

/* Install card */
.hb-install-card strong { color: var(--text); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .ex-layout { grid-template-columns: 1fr; }
  .ex-col-side { position: static; }
  .brand h1 { font-size: 1.1rem; }
  .tabs { order: 3; width: 100%; justify-content: center; }
}
@media (max-width: 560px) {
  .app-header { padding: .6rem .8rem; }
  .app-main { padding: 1rem .8rem 2.5rem; }
  .prompt-sentence, .prompt-fr { font-size: 1.25rem; }
  .controls { gap: .9rem; }
  .select { min-width: 0; width: 100%; }
  .tab { padding: .45rem .6rem; font-size: .82rem; }
}
