/* StudyFlash — direction artistique inspirée de La Main Douce : lumière dorée de fin de journée, papier crème,
   terracotta et brun profond, ornements en trait fin (lune, étoiles, pointillés). */

:root {
  --paper: #f7ecdc;
  --paper-2: #fbf4ea;
  --surface: #fffaf3;
  --ink: #3a2619;
  --ink-2: #6b4f3a;
  --muted: #85664f;
  --line: #ead8c0;
  --line-2: #dcc3a3;
  --amber: #e2954b;
  --terracotta: #c0643a;
  --terracotta-d: #9c4c28;
  --gold: #e9b45c;
  --olive: #7c8450;
  --rose: #c98b7f;
  --danger: #b43c2e;
  --sunset: linear-gradient(135deg, #f6c37a 0%, #e9935a 55%, #c86a4a 100%);
  --shadow: 0 1px 2px rgba(90, 55, 30, .06), 0 6px 20px rgba(90, 55, 30, .08);
  --shadow-lg: 0 10px 40px rgba(90, 55, 30, .18);
  --radius: 18px;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: Lato, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.55 var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(246, 195, 122, .45), transparent 60%),
    radial-gradient(900px 400px at -10% 0%, rgba(233, 147, 90, .18), transparent 60%),
    var(--paper);
  background-attachment: fixed;
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--serif); font-variant-numeric: lining-nums; font-weight: 600; line-height: 1.15; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: clamp(2rem, 5vw, 2.7rem); }
h2 { font-size: 1.6rem; margin-top: 1.6em; }
a { color: var(--terracotta-d); }
img { max-width: 100%; }
[hidden] { display: none !important; }
kbd { font: 11px var(--sans); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; opacity: .55; margin-left: 8px; }

/* ---------------------------------------------------------------- en-tête */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)); padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(251, 244, 234, .82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.logged-out .topbar { display: none; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font: 600 1.45rem var(--serif); }
.brand svg { width: 28px; height: 28px; fill: none; stroke: var(--terracotta); stroke-width: 1.3; stroke-linejoin: round; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { min-height: 44px; display: inline-flex; align-items: center; padding: 7px 12px; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-weight: 700; font-size: .92rem; white-space: nowrap; }
.nav a:hover { background: var(--paper); }
.nav a.active { background: var(--ink); color: var(--paper-2); }
.nav .nav-cta { background: var(--terracotta); color: #fff; }
.nav .nav-cta { background: var(--terracotta-d); }
.nav .nav-cta:hover, .nav .nav-cta.active { background: #833e1f; color: #fff; }
.nav .icon-btn { min-width: 44px; min-height: 44px; }
:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 2px; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--terracotta); color: #fff; font-size: .75rem; text-align: center; margin-left: 2px; }
.nav a.active .badge { background: var(--gold); color: var(--ink); }
@media (max-width: 560px) {
  .brand span { display: none; }
  .nav a { padding: 7px 9px; font-size: .86rem; }
}

/* ---------------------------------------------------------------- mise en page */
main { padding: 24px 16px 80px; }
.page { max-width: 1040px; margin: 0 auto; }
.loading { text-align: center; color: var(--muted); padding: 80px 0; font-family: var(--serif); font-size: 1.3rem; font-style: italic; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .88rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.actions, .doc-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 8px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.crumbs { margin-bottom: 4px; font-weight: 700; font-size: .9rem; }
.crumbs a { text-decoration: none; }
.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); margin: 16px 0; }
.notice { background: #fff3df; border: 1px solid #f1cf9a; color: #7a4a17; padding: 12px 16px; border-radius: 12px; margin: 12px 0; font-size: .92rem; }
.status { color: var(--ink-2); font-size: .9rem; min-height: 1.4em; }

/* Séparateur ornemental (trait fin, croissant et points) */
.page > h2::after, .ornament {
  content: ''; display: block; height: 14px; margin-top: 8px; max-width: 220px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 14'%3E%3Cg fill='none' stroke='%23c0643a' stroke-width='.9'%3E%3Cpath d='M0 7h92M128 7h92' stroke-dasharray='1 5' stroke-linecap='round'/%3E%3Cpath d='M113 2.5a4.6 4.6 0 1 0 0 9 5.6 5.6 0 0 1 0-9z'/%3E%3C/g%3E%3Cg fill='%23c0643a'%3E%3Ccircle cx='100' cy='7' r='1.2'/%3E%3Ccircle cx='121' cy='7' r='1.2'/%3E%3C/g%3E%3C/svg%3E") left center / contain no-repeat;
}

/* ---------------------------------------------------------------- boutons et champs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font: 700 .92rem var(--sans); text-decoration: none;
  cursor: pointer; transition: background .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: #fff; box-shadow: var(--shadow); }
.ico { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; }
.ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.hero-btn .icon .ico { width: 24px; height: 24px; }
.drop-head strong .ico { color: var(--terracotta); margin-right: 4px; vertical-align: -2px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.primary { background: var(--terracotta-d); border-color: var(--terracotta-d); color: #fff; }
.btn.primary:hover { background: #833e1f; }
.btn.small { padding: 5px 12px; font-size: .82rem; }
.btn.link, button.link { border: 0; background: none; padding: 0; color: var(--terracotta-d); font: 700 .82rem var(--sans); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.btn.big { padding: 13px 26px; font-size: 1rem; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, .5); box-shadow: none; }
.btn.danger { color: var(--danger); }
.icon-btn { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 1rem; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--paper); color: var(--ink); }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: .88rem; color: var(--ink-2); margin-bottom: 14px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; margin-top: 28px; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  font: 400 1rem var(--sans); color: var(--ink); width: 100%;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(192, 100, 58, .35); border-color: var(--terracotta); }
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { accent-color: var(--terracotta); width: 17px; height: 17px; }

.chips, .radios { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { flex-direction: row; align-items: center; gap: 7px; margin: 0; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 700; color: var(--ink-2); }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.chip:has(input:focus-visible) { outline: 2px solid var(--terracotta); outline-offset: 2px; }
.chip.disabled { opacity: .45; cursor: not-allowed; }
.chip:has(input:checked) span::after { content: ' ✓'; }
.chip-all { align-self: center; font-size: .82rem; color: var(--muted); margin-left: 4px; }
.filter-label { font-weight: 700; font-size: .85rem; color: var(--ink-2); margin: 10px 0 2px; }
.chip::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); opacity: .9; }
.chip:has(input:checked) { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
.chip:has(input:checked)::before { background: var(--c, var(--gold)); box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }

/* ---------------------------------------------------------------- dialogues */
dialog { border: 0; border-radius: 22px; padding: 26px; width: min(560px, calc(100vw - 24px)); background: var(--paper-2); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(58, 38, 25, .45); backdrop-filter: blur(3px); }
dialog h2 { margin-top: 0; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch[aria-pressed=true] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--paper-2) inset; }

dialog.progress { text-align: center; width: min(760px, calc(100vw - 24px)); }
dialog.progress .preview { text-align: left; max-height: 50vh; overflow: auto; margin-top: 12px; background: #fff; border-radius: 12px; padding: 0 18px; font-size: .85rem; }
dialog.progress .preview:empty { display: none; }
.spinner {
  width: 54px; height: 54px; margin: 8px auto 4px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 54 54'%3E%3Cg fill='none' stroke='%23c0643a' stroke-width='1.2' stroke-linecap='round'%3E%3Ccircle cx='27' cy='27' r='22' stroke-dasharray='2 6'/%3E%3Cpath d='M31 15a12 12 0 1 0 8.5 20.5A10 10 0 0 1 31 15z' fill='%23f6c37a' fill-opacity='.35'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  animation: spin 6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; transition: .25s; z-index: 100;
  background: var(--ink); color: var(--paper-2); padding: 12px 20px; border-radius: 999px; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); font-weight: 700; font-size: .92rem; }
.toast.error { background: var(--danger); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- connexion */
.login { max-width: 360px; margin: 12vh auto 0; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0; font-size: 3rem; }
.login p { color: var(--ink-2); margin: 0 0 16px; font-family: var(--serif); font-style: italic; font-size: 1.2rem; }
.logo-big { width: 92px; height: 92px; margin: 0 auto; border-radius: 50%; background: var(--sunset); box-shadow: var(--shadow-lg);
  font-size: 0; position: relative; }
.logo-big::after { content: ''; position: absolute; inset: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke='%23fff' stroke-width='1.2' stroke-linejoin='round'%3E%3Cpath d='M19 5a11 11 0 1 0 8 18.5A9 9 0 0 1 19 5z'/%3E%3Cpath d='M23 9l.8 2.2L26 12l-2.2.8L23 15l-.8-2.2L20 12l2.2-.8z'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat; }

/* ---------------------------------------------------------------- accueil */
.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 8px; }
.hero-btn { display: flex; align-items: center; gap: 14px; padding: 20px; border-radius: var(--radius); text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.hero-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.hero-btn.primary { background: linear-gradient(135deg, #e39a58 0%, #d47a48 55%, #b35a38 100%); color: #fff; border: 0; text-shadow: 0 1px 2px rgba(90, 40, 20, .3); }
.hero-btn.primary small { color: rgba(255, 255, 255, .9); }
.hero-btn strong { display: block; font: 600 1.35rem var(--serif); }
.hero-btn small { display: block; color: var(--muted); font-size: .85rem; }
.hero-btn .icon { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; border: 1px solid currentColor; opacity: .85; }
.hero-btn .icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }

.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.subject-card { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 2px; min-height: 140px; padding: 18px 18px 16px 24px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; cursor: pointer; font: inherit; text-align: left; }
.subject-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 7px; background: var(--c); }
.subject-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.subject-card .code { font-size: .78rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: color-mix(in srgb, var(--c) 70%, var(--ink)); }
.subject-card .name { font: 600 1.4rem/1.15 var(--serif); flex: 1; }
.subject-card .meta { font-size: .82rem; color: var(--muted); }
.subject-card .meta b { color: var(--terracotta); }
.subject-card.add { align-items: center; justify-content: center; border-style: dashed; background: transparent; box-shadow: none; color: var(--ink-2); }
.subject-card.add::before { display: none; }
.subject-card.add .plus { font: 300 2.4rem/1 var(--serif); }
.subject-card.add .name { flex: none; font-size: 1.15rem; }

/* ---------------------------------------------------------------- matière */
.subject-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 22px 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-left: 8px solid var(--c); box-shadow: var(--shadow); }
.subject-head h1 { margin: 0; }
.subject-head .code { font-weight: 900; color: color-mix(in srgb, var(--c) 70%, var(--ink)); letter-spacing: .06em; text-transform: uppercase; font-size: .85rem; }
.course-list { display: flex; flex-direction: column; gap: 8px; }
.course-row { display: grid; grid-template-columns: 170px 1fr auto; gap: 12px; align-items: center; padding: 14px 18px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.course-row:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.course-row .date { color: var(--muted); font-size: .85rem; }
.course-row .title { font: 600 1.2rem var(--serif); }
.course-row .state { font-size: .8rem; color: var(--olive); font-weight: 700; }
@media (max-width: 640px) { .course-row { grid-template-columns: 1fr; gap: 2px; } }
.tag { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: .78rem; font-weight: 900; }

/* ---------------------------------------------------------------- nouveau cours / sources */
.course-form { display: flex; flex-direction: column; gap: 14px; }
.drop { border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 16px 18px; background: rgba(255, 250, 243, .7); transition: .15s; }
.drop.over { border-color: var(--terracotta); background: #fff; }
.drop-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.drop-head strong { display: block; font: 600 1.25rem var(--serif); }
.drop-head small { color: var(--muted); }
.file-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.file-list:empty { display: none; }
.file-item { position: relative; display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px; font-size: .78rem; }
.file-item img { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; }
.file-item .ext { height: 110px; display: grid; place-items: center; background: var(--paper); border-radius: 8px; font-weight: 900; color: var(--terracotta); }
.file-item .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .fsize { color: var(--muted); }
.file-item .icon-btn { position: absolute; top: 10px; right: 10px; background: rgba(255, 255, 255, .9); }
.sources { margin-top: 40px; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { position: relative; width: 96px; text-decoration: none; }
.thumb img { width: 96px; height: 128px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumb-pdf { display: grid; place-items: center; width: 96px; height: 128px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--terracotta-d); font-weight: 900; }
.thumb span { position: absolute; bottom: 6px; left: 6px; background: var(--ink); color: #fff; font-size: .7rem; padding: 0 6px; border-radius: 6px; }
.source-files { padding-left: 0; list-style: none; }
.source-files li { padding: 6px 0; display: flex; gap: 8px; align-items: center; }
.source-files li small { color: var(--muted); }
.source-files .icon-btn { min-width: 40px; min-height: 40px; }
.add-sources { margin-top: 16px; }
details.more { position: relative; }
details.more > summary { list-style: none; font-size: 1.2rem; line-height: 1; padding: 9px 16px; }
details.more > summary::-webkit-details-marker { display: none; }
.more-menu { position: absolute; z-index: 5; right: 0; top: calc(100% + 6px); min-width: 240px; display: flex; flex-direction: column; align-items: stretch;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; }
.more-menu .btn { justify-content: flex-start; border-radius: 10px; }
.more-menu { max-width: calc(100vw - 32px); }
details.more > summary { min-width: 44px; min-height: 44px; }
@media (max-width: 560px) {
  .doc-toolbar .btn { padding: 8px 12px; font-size: .86rem; }
}
.add-sources summary { cursor: pointer; font-weight: 700; color: var(--terracotta-d); margin-bottom: 12px; }
.add-sources .drop { margin-bottom: 10px; }

/* ---------------------------------------------------------------- documents (cours, fiches) */
.doc { background: #fffdf9; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow);
  padding: clamp(20px, 5vw, 56px) clamp(18px, 6vw, 72px); margin: 16px 0; font-size: 1rem; line-height: 1.65; }
.doc h1 { font-size: 2.3rem; margin-bottom: .2em; }
.doc h1 + p em { color: var(--muted); }
.doc h2 { font-size: 1.65rem; margin: 1.6em 0 .5em; padding-bottom: .2em; border-bottom: 1px solid var(--line); color: var(--terracotta-d); }
.doc h3 { font-size: 1.3rem; margin: 1.3em 0 .4em; }
.doc h4 { font: 700 1rem var(--sans); margin: 1em 0 .3em; }
.doc strong { color: #2a1a10; }
.doc blockquote { margin: 1em 0; padding: 10px 16px; background: #fdf1e2; border-left: 4px solid var(--amber); border-radius: 0 10px 10px 0; }
.doc blockquote p { margin: .3em 0; }
.doc table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: .92rem; display: block; overflow-x: auto; }
.doc th, .doc td { border: 1px solid var(--line-2); padding: 7px 10px; text-align: left; vertical-align: top; }
.doc th { background: #f8e6cf; }
.doc ul, .doc ol { padding-left: 1.4em; }
.doc li { margin: .2em 0; }
.doc hr { border: 0; border-top: 1px dashed var(--line-2); margin: 2em 0; }
.md-editor { font: 14px/1.6 ui-monospace, Consolas, monospace; min-height: 60vh; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.split .doc { margin: 0; max-height: 75vh; overflow: auto; padding: 24px; font-size: .9rem; }
.tabs { display: none; gap: 6px; margin-bottom: 8px; }
.tab { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 7px 16px; font: 700 .88rem var(--sans); color: var(--ink-2); cursor: pointer; }
.tab.on { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
@media (max-width: 800px) {
  .tabs { display: flex; }
  .split { grid-template-columns: 1fr; }
  .split .doc { display: none; max-height: none; }
  .split.show-preview .doc { display: block; }
  .split.show-preview .md-editor { display: none; }
}

/* ---------------------------------------------------------------- flashcards */
.fcard {
  --c: #c0643a;
  position: relative; overflow: hidden; aspect-ratio: 1.55; width: 100%;
  background: #fffdf9; border-radius: 16px; border: 1px solid var(--line);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 22%, #fff), var(--shadow);
  padding: 34px 18px 16px 58px; display: flex; color: var(--ink);
}
.fcard-tag { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); max-width: 88%;
  background: var(--c); background: color-mix(in srgb, var(--c) 80%, #3a2619); color: #fff; font: 900 .7rem var(--sans); padding: 3px 12px; border-radius: 999px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fcard-side { position: absolute; left: 14px; top: 34px; bottom: 14px; width: 30px; border-radius: 10px;
  background: var(--c); background: color-mix(in srgb, var(--c) 80%, #3a2619); display: flex; align-items: center; justify-content: center; }
.fcard-side span { writing-mode: vertical-rl; transform: rotate(180deg); color: #fff; font: 700 .7rem var(--sans); white-space: nowrap; overflow: hidden; max-height: 100%; }
.fcard-mark { position: absolute; inset: 0 6% 0 40px; display: grid; place-items: center end; font: 700 7rem/1 var(--serif);
  color: color-mix(in srgb, var(--gold) 20%, transparent); pointer-events: none; }
.q-recall { font: italic 500 .95rem/1.3 var(--serif); color: var(--ink-2); margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px dashed var(--line-2); }
.fcard-body { position: relative; flex: 1; overflow: auto; }
.front-text { display: flex; align-items: center; justify-content: center; text-align: center;
  font: 600 clamp(1.15rem, 2.6vw, 1.55rem)/1.25 var(--serif); color: var(--ink); }
.back-text { font-size: .88rem; line-height: 1.45; align-self: center; }
.back-text ul { padding-left: 1.1em; margin: 0; }
.back-text li::marker { color: var(--c); content: '◗ '; }
.back-text p { margin: .3em 0; }

.card-list { display: flex; flex-direction: column; gap: 22px; margin-top: 12px; }
.card-row .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: 860px; }
.card-row .fcard .front-text { font-size: 1.15rem; }
.card-row .fcard .back-text { font-size: .8rem; }
.card-meta .icon-btn { min-width: 44px; min-height: 44px; }
.answer-m { display: none; }
.card-meta { display: flex; gap: 12px; align-items: center; justify-content: flex-end; font-size: .8rem; color: var(--muted); margin-top: 8px; }
@media (max-width: 700px) {
  .card-row .pair { grid-template-columns: 1fr; }
  .card-row .fcard.back { display: none; }
  .card-row .fcard { aspect-ratio: auto; min-height: 130px; padding: 32px 14px 14px 50px; }
  .card-row .fcard-side { left: 10px; width: 26px; }
  .card-row .fcard-mark { font-size: 4.5rem; }
  .answer-m { display: block; background: #fffdf9; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-top: 8px; font-size: .9rem; }
  .answer-m summary { cursor: pointer; font-weight: 700; color: var(--terracotta-d); }
  .answer-m ul { padding-left: 1.1em; margin: 6px 0 0; }
}
.filters { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }

/* ---------------------------------------------------------------- révision */
.review-setup { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.review { max-width: 680px; margin: 0 auto; }
.review-progress .btn { margin-left: 4px; }
.review-progress { display: flex; align-items: center; gap: 12px; font-size: .85rem; color: var(--muted); font-weight: 700; margin-bottom: 18px; }
.review-progress .bar { flex: 1; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.review-progress .bar div { height: 100%; background: var(--sunset); transition: width .3s; }
.flip { perspective: 1400px; cursor: pointer; }
.flip-inner { display: grid; transition: transform .55s cubic-bezier(.3, .7, .3, 1); transform-style: preserve-3d; }
.flip-inner > .fcard { grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip-inner > .fcard.back { transform: rotateY(180deg); }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip.flipped { cursor: default; }
.review .fcard { aspect-ratio: 1.45; }
.review .back-text { font-size: 1rem; }
.review-actions { display: flex; gap: 8px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }
.rate { flex-direction: column; gap: 0; min-width: 120px; border-width: 2px; }
.rate small { font-weight: 400; color: var(--muted); }
.rate kbd { display: none; }
@media (hover: hover) { .rate kbd { display: inline; margin: 2px 0 0; } }
.rate.again { border-color: #d98a7a; } .rate.again:hover { background: #fbe9e4; }
.rate.hard { border-color: #e5b36c; } .rate.hard:hover { background: #fdf1de; }
.rate.good { border-color: #9fae6c; } .rate.good:hover { background: #f1f4e3; }
.rate.easy { border-color: #7fb0a5; } .rate.easy:hover { background: #e7f3f0; }
@media (max-width: 560px) { .rate { min-width: calc(50% - 6px); } }
.review-end { text-align: center; padding: 40px 0; }
.ornament.center { margin: 0 auto 16px; background-position: center; }

/* ---------------------------------------------------------------- impression */
#print-area { display: none; }
@media print {
  @page { size: A4; margin: 16mm 15mm 18mm;
    @bottom-center { content: counter(page) ' / ' counter(pages); font: 8pt Lato, sans-serif; color: #85664f; } }
  .q-recall { display: none; }
  .doc[data-subject]::before { content: attr(data-subject); display: block; margin-bottom: 5mm; font: 700 7.5pt Lato, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #85664f; }
  body { background: #fff; }
  body[data-print] > *:not(#print-area) { display: none !important; }
  body[data-print] #print-area { display: block; }
  .doc { background: #fff; border: 0; box-shadow: none; padding: 0; margin: 0; font-size: 10.5pt; line-height: 1.5; }
  .doc h1 { font-size: 22pt; } .doc h2 { font-size: 15pt; break-after: avoid; } .doc h3 { font-size: 12.5pt; break-after: avoid; }
  .doc blockquote, .doc table, .doc tr { break-inside: avoid; }
  .doc table { display: table; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  @page cards { margin: 16mm 15mm; }
  .card-page { page: cards; width: 180mm; height: 263mm; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(4, 1fr); gap: 0; break-after: page; margin: 0 auto; }
  .card-cell { padding: 3mm; border: .2mm dashed #ccc; display: flex; }
  .card-cell:empty { border-color: transparent; }
  .card-cell .fcard { aspect-ratio: auto; height: 100%; box-shadow: 0 0 0 1.4mm color-mix(in srgb, var(--c) 22%, #fff); border-radius: 4mm; padding: 9mm 5mm 4mm 15mm; }
  .card-cell .fcard-side { left: 4mm; top: 9mm; bottom: 4mm; width: 7mm; border-radius: 2.5mm; }
  .card-cell .fcard-side span { font-size: 6.5pt; }
  .card-cell .fcard-tag { font-size: 6.5pt; top: 2.5mm; }
  .card-cell .fcard-mark { font-size: 70pt; }
  .card-cell .front-text { font-size: 13pt; }
  .card-cell .back-text { font-size: 8pt; overflow: hidden; }
}
