:root {
  --bg: #F4F5F7; --surface: #FFFFFF; --ink: #15171C; --muted: #555B6B; --soft: #6B7180;
  --line: #E1E4EA; --line-strong: #C9CDD6; --track: #E4E6EC;
  --accent: #3D4FD6; --accent-ink: #2A39A8; --accent-soft: #E4E8FB; --accent-bg: #F3F5FE;
  --warn: #C2410C; --warn-ink: #9A3412; --warn-soft: #FDE8DC; --warn-bg: #FFF4ED;
  --good: #15803D; --good-soft: #DCFCE7; --good-ink: #166534;
  --gold: #F5B70A; --gold-soft: #FDF0C4;
  --neutral-soft: #ECEEF2; --neutral-ink: #3A3F4C; --key-used: #D5D8DF;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --body: Inter, system-ui, -apple-system, sans-serif;
  --serif: 'EB Garamond', Georgia, serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  --nav-h: 72px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
.hidden { display: none !important; }

/* ---------- layout */
.app { min-height: 100vh; }
.shell { display: flex; flex-direction: column; min-height: 100vh; }
.topbar { display: none; }
.main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 16px calc(var(--nav-h) + 32px); }
.main.narrow { max-width: 560px; }
.main.game { max-width: 520px; padding-bottom: calc(var(--nav-h) + 16px); }
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 6px 8px env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); display: flex; z-index: 20; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 500; color: var(--muted); text-decoration: none; min-height: 44px; border-radius: 10px; }
.nav a.on { color: var(--accent); font-weight: 600; }
.nav svg { width: 22px; height: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 20px; font-weight: 700; text-decoration: none; color: var(--ink); }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.brand .logo svg { width: 18px; height: 18px; }

@media (min-width: 900px) {
  .topbar { display: flex; position: sticky; top: 0; z-index: 20; height: 64px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); align-items: center; justify-content: space-between; gap: 16px; }
  .topbar .links { display: flex; gap: 4px; align-items: center; }
  .topbar .links a { height: 40px; padding: 0 14px; border-radius: 10px; color: var(--neutral-ink); font-weight: 500; font-size: 14px; display: flex; align-items: center; text-decoration: none; }
  .topbar .links a.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
  .topbar .user { margin-left: 12px; width: 36px; height: 36px; border-radius: 18px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; text-transform: uppercase; }
  .nav { display: none; }
  .main { padding: 32px 24px 48px; }
  .main.game { padding-bottom: 48px; }
}

/* ---------- type */
h1 { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -.3px; }
h2 { margin: 0; font-family: var(--display); font-size: 20px; font-weight: 700; }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.pre { white-space: pre-line; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .t { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.back { display: inline-flex; align-items: center; gap: 6px; height: 40px; font-size: 15px; font-weight: 500; text-decoration: none; margin-bottom: 6px; }
.back svg { width: 20px; height: 20px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 24px 0 10px; font-size: 15px; font-weight: 600; }

/* ---------- components */
.btn { height: 48px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { color: #fff; filter: brightness(1.06); }
.btn.dark { background: var(--ink); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }
.btn.ghost:hover { color: var(--ink); background: #FAFBFC; }
.btn.danger { background: var(--surface); color: var(--warn-ink); border: 1px solid var(--line-strong); }
.btn.small { height: 38px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); text-decoration: none; flex-shrink: 0; }
.icon-btn svg { width: 20px; height: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.chip { display: inline-flex; align-items: center; flex-shrink: 0; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--neutral-soft); color: var(--neutral-ink); white-space: nowrap; }
.chip.due { background: var(--warn-soft); color: var(--warn-ink); }
.chip.ok { background: var(--accent-soft); color: var(--accent-ink); }
.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 3px; width: 0; transition: width .3s; }
label.lbl { font-size: 13px; color: var(--muted); font-weight: 500; }
.field { display: flex; flex-direction: column; gap: 6px; }
input[type=text], input[type=password], select, textarea { width: 100%; min-height: 46px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; font-size: 16px; background: var(--surface); }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(61,79,214,.35); outline-offset: 1px; }
.err { color: var(--warn-ink); font-size: 14px; min-height: 18px; margin: 0; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* ---------- auth */
.auth { max-width: 420px; margin: 0 auto; padding: 72px 24px 32px; display: flex; flex-direction: column; gap: 28px; }
.auth .logo-big { width: 52px; height: 52px; border-radius: 14px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.auth .logo-big svg { width: 28px; height: 28px; }
.auth h1 { font-size: 34px; margin-top: 12px; }
.seg { display: flex; background: var(--track); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 500; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- topics */
.hero { background: var(--ink); color: #fff; border-radius: 16px; padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.hero .n { font-family: var(--display); font-size: 26px; font-weight: 700; }
.hero .l { font-size: 13px; color: #B9BECB; }
.hero .btn { background: #fff; color: var(--ink); }
.tile { display: flex; flex-direction: column; gap: 12px; text-decoration: none; color: var(--ink); }
.tile:hover { color: var(--ink); border-color: var(--line-strong); }
.tile .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.tile .name { font-size: 17px; font-weight: 600; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; }
.list-item .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.list-item .txt span { overflow-wrap: anywhere; }
.list-item .acts { display: flex; gap: 6px; align-items: center; }
.layout-2 { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.layout-2 > .wide { flex: 999 1 420px; min-width: 0; }
.layout-2 > .side { flex: 1 1 300px; min-width: 0; }

/* ---------- review */
.review-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.review-top .p { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.flash { width: 100%; min-height: 360px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: 0 8px 24px rgba(21,23,28,.06); padding: 28px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; cursor: pointer; gap: 20px; }
.flash .side { font-size: 12px; font-weight: 600; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.flash .q { font-family: var(--display); font-size: 26px; font-weight: 700; line-height: 1.25; white-space: pre-line; overflow-wrap: anywhere; }
.flash .a { font-size: 19px; color: var(--accent-ink); white-space: pre-line; line-height: 1.45; overflow-wrap: anywhere; }
.flash hr { border: 0; height: 1px; background: var(--line); margin: 16px 0; }
.answer-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.btn.miss { height: 60px; border: 2px solid var(--warn); background: var(--warn-bg); color: var(--warn-ink); }
.btn.hit { height: 60px; }
.done-box { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 48px 16px; }
.done-box .ok { width: 72px; height: 72px; border-radius: 36px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.done-box .ok svg { width: 36px; height: 36px; }

/* ---------- settings */
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; border: 2px solid var(--line); cursor: pointer; background: var(--surface); }
.opt.on { border-color: var(--accent); background: var(--accent-bg); }
.opt input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.opt b { display: block; font-size: 15px; }
.opt span { font-size: 13px; color: var(--muted); line-height: 1.4; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 15px; font-weight: 600; margin-bottom: 10px; padding: 0; }

/* ---------- vocab */
.games { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .games { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.game-tile { padding: 14px; min-height: 116px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); }
.game-tile:hover { color: var(--ink); border-color: var(--line-strong); }
.game-tile .tag { align-self: flex-start; font-size: 11px; font-weight: 700; letter-spacing: .5px; padding: 3px 8px; border-radius: 6px; }
.tag.t1 { background: var(--warn); color: #fff; } .tag.t2 { background: var(--ink); color: #fff; } .tag.t3 { background: var(--gold); color: var(--ink); } .tag.t4 { background: var(--accent); color: #fff; }
.game-tile b { font-size: 15px; }
.game-tile span.d { font-size: 12px; color: var(--muted); line-height: 1.35; }
.fiche-item { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--ink); padding: 12px 14px; }
.fiche-item:hover { color: var(--ink); border-color: var(--line-strong); }
.fiche-item .mot { font-family: var(--serif); font-size: 21px; font-weight: 600; }
.fiche-title { font-family: var(--serif); font-size: 40px; font-weight: 600; line-height: 1.05; margin: 0; }
.fiche-forms { font-family: var(--serif); font-style: italic; font-size: 18px; color: var(--muted); }
.acc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.acc > button { width: 100%; min-height: 50px; padding: 0 14px; border: 0; background: transparent; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; text-align: left; cursor: pointer; }
.acc > button .grow { flex: 1; }
.acc > button .sign { font-size: 18px; color: var(--muted); width: 16px; text-align: center; }
.acc .body { padding: 0 16px 16px 16px; font-size: 15px; line-height: 1.55; color: #2B2F38; white-space: pre-line; overflow-wrap: anywhere; }
.acc .body.empty-f { color: var(--soft); font-style: italic; }
@media (min-width: 900px) { .acc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; } }
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; width: 14px; flex-shrink: 0; }
.tl-dot { width: 14px; height: 14px; border-radius: 7px; background: var(--accent); margin-top: 3px; flex-shrink: 0; }
.tl-line { flex: 1; width: 2px; background: var(--line-strong); min-height: 14px; }
.tl-body { padding-bottom: 14px; display: flex; flex-direction: column; gap: 2px; }
.tl-date { font-size: 12px; font-weight: 700; color: var(--accent-ink); letter-spacing: .5px; text-transform: uppercase; }
.quote { font-family: var(--serif); font-style: italic; font-size: 24px; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
.quote mark { font-style: normal; font-weight: 600; background: var(--gold-soft); padding: 0 4px; border-radius: 4px; color: inherit; }
.choice { min-height: 52px; padding: 10px 14px; border-radius: 12px; text-align: left; font-weight: 500; font-size: 15px; line-height: 1.35; cursor: pointer; border: 1px solid var(--line); background: var(--surface); width: 100%; }
.choice.good { border: 2px solid var(--accent); background: var(--accent-bg); color: var(--accent-ink); }
.choice.bad { border: 2px solid var(--warn); background: var(--warn-bg); color: var(--warn-ink); }
.choice.dim { color: var(--soft); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { height: 36px; padding: 0 14px; border-radius: 999px; font-weight: 600; font-size: 13px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--neutral-ink); cursor: pointer; }
.pill.on { border-color: var(--ink); background: var(--ink); color: #fff; }

/* ---------- mot mystère */
.clue { padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px dashed var(--line-strong); display: flex; gap: 8px; align-items: baseline; }
.clue .k { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; flex-shrink: 0; }
.clue .v { font-family: var(--serif); font-size: 18px; }
.grid-word { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 14px 0 8px; --cell: 46px; }
.grid-word .r { display: flex; gap: 5px; }
.cell { width: var(--cell); height: var(--cell); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 700; font-size: calc(var(--cell) * .5); border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.cell.ok { background: var(--good); color: #fff; border-color: var(--good); }
.cell.mid { background: var(--gold); color: var(--ink); border-color: var(--gold); border-radius: 999px; }
.cell.no { background: var(--track); color: var(--muted); border-color: var(--track); }
.cell.typed { border: 2px solid var(--ink); }
.cell.hint { color: var(--soft); }
.kb { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; user-select: none; }
.kb .kr { display: flex; gap: 4px; justify-content: center; }
.key { flex: 1 1 0; max-width: 44px; height: 52px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-weight: 600; font-size: 17px; padding: 0; cursor: pointer; touch-action: manipulation; }
.key.wide { max-width: 76px; flex: 1.8 1 0; font-size: 14px; }
.key.enter { background: var(--accent); color: #fff; border-color: var(--accent); }
.key.del { background: var(--key-used); border-color: var(--key-used); }
.key.ok { background: var(--good); color: #fff; border-color: var(--good); }
.key.mid { background: var(--gold); border-color: var(--gold); }
.key.no { background: var(--key-used); color: var(--neutral-ink); border-color: var(--key-used); }
.msg { text-align: center; color: var(--muted); font-size: 14px; min-height: 20px; margin: 4px 0; }

/* ---------- editor */
.editor-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.sub-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) 44px; gap: 8px; align-items: start; }
@media (max-width: 560px) { .sub-row { grid-template-columns: 100px minmax(0, 1fr) 44px; } }
.cit-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: #FAFBFC; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table.preview { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 13px; }
table.preview th, table.preview td { padding: 8px 10px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
table.preview th { color: var(--muted); font-weight: 600; border-top: 0; }
table.preview .clip { max-width: 260px; min-width: 140px; white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.paste-zone { min-height: 140px; border: 2px dashed var(--line-strong); border-radius: 14px; background: var(--surface); padding: 18px; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); cursor: text; }
.paste-zone:focus { outline: 3px solid rgba(61,79,214,.35); border-color: var(--accent); }

/* ---------- v2 : Mailmo */
.chip.win { background: var(--good-soft); color: var(--good-ink); }
.chip svg { margin-right: 3px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; flex-wrap: wrap; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.import-banner { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; background: var(--accent-bg); border-color: var(--accent-soft); }
.import-banner .stack { flex: 1 1 320px; }
.import-sources { align-items: stretch; }
@media (max-width: 700px) { .import-sources { grid-template-columns: 1fr; } }
.link-card { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); }
.link-card:hover { color: var(--ink); border-color: var(--line-strong); }
.link-card > span { display: flex; flex-direction: column; gap: 2px; }
.link-card svg { color: var(--accent); flex-shrink: 0; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
.h-sec { margin: 26px 0 12px; }
.prog h3 { margin: 2px 0 0; font-size: 22px; font-weight: 600; line-height: 1.2; }
.prog h3:not(.serif) { font-family: var(--display); font-size: 17px; }
.prog-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; }
.prog p { margin: 6px 0 0; line-height: 1.5; }
.prog .gram { font-size: 14px; background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.works { margin: 10px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; }
.user-item { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); }
.user-item:hover { color: var(--ink); border-color: var(--line-strong); }
.avatar { width: 44px; height: 44px; border-radius: 22px; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; text-transform: uppercase; flex-shrink: 0; }
.warn-txt { color: var(--warn-ink); }
.dim-row td { opacity: .6; }
.admin-table { min-width: 860px; }
.admin-table td { vertical-align: middle; }
