[hidden] { display: none !important; }
:root {
  --bg: #fff8ec; --panel: #fff; --border: #f0e2c4; --text: #2b2620; --muted: #8a8272;
  --accent: #ef7d3b; --accent2: #3b8fef; --good: #2e9e5b; --bad: #e2574c;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: "Fredoka", system-ui, sans-serif; }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
.brand { font-size: 24px; margin: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.kid { background: #fff; border: 2px solid var(--border); border-radius: 999px; padding: 8px 14px; font: inherit; cursor: pointer; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 2px solid var(--border); background: #fff; border-radius: 12px; padding: 8px 12px; font: inherit; cursor: pointer; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.card { background: var(--panel); border: 2px solid var(--border); border-radius: 18px; padding: 18px; margin-bottom: 14px; }
.card h2, .card h3 { margin: 0 0 8px; }
.hero-card { background: linear-gradient(135deg, #fff, #fff1dc); }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
label { display: block; margin: 10px 0; font-weight: 500; }
input[type=text], input[type=password], select {
  width: 100%; padding: 12px 14px; font: inherit; font-size: 16px; border-radius: 12px; border: 2px solid var(--border); background: #fff; margin-top: 6px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.btn { background: var(--accent); color: #fff; border: none; border-radius: 12px; padding: 12px 18px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.big { width: 100%; font-size: 20px; padding: 16px; margin-top: 8px; }
.btn.ghost { background: #fff; color: var(--text); border: 2px solid var(--border); }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: none; color: var(--accent2); font: inherit; cursor: pointer; text-decoration: underline; }
.error { color: var(--bad); font-size: 14px; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.chip { border: 2px solid var(--border); background: #fff; border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 14px; cursor: pointer; }
.chip.on { border-color: var(--accent); background: #fff1e6; }
.grid-acts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.act { background: #fff; border: 2px solid var(--border); border-radius: 16px; padding: 14px; text-align: left; font: inherit; cursor: pointer; }
.act:hover { border-color: var(--accent); }
.act .e { font-size: 30px; display: block; }
.act .lv { color: var(--muted); font-size: 12px; }
.act.other { opacity: .7; }
.banner { border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.gold { background: #fff4c7; border: 2px solid #f3d36b; }
.banner.blue { background: #e4f1ff; border: 2px solid #a9cdf5; }
.banner .grow { flex: 1; min-width: 200px; }
.pending { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #f3ead8; flex-wrap: wrap; }
.pending .t { flex: 1; min-width: 180px; }
.fb { display: flex; gap: 6px; flex-wrap: wrap; }
.fb button { border: 2px solid var(--border); background: #fff; border-radius: 10px; padding: 6px 10px; font: inherit; cursor: pointer; }
.fb button.on { border-color: var(--good); background: #e9f8ef; }
.filelabel { display: inline-block; background: #fff; border: 2px dashed var(--border); border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.filelabel input { display: none; }
.refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin: 10px 0; }
.refs div { position: relative; }
.refs img { width: 100%; height: 90px; object-fit: contain; border: 2px solid var(--border); border-radius: 10px; background: #fff; }
.refs button { position: absolute; top: 4px; right: 4px; border: none; border-radius: 8px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }
.seg { display: flex; gap: 6px; margin: 10px 0; }
.seg button { border: 2px solid var(--border); background: #fff; border-radius: 10px; padding: 8px 12px; font: inherit; cursor: pointer; }
.seg button.on { border-color: var(--accent); background: #fff1e6; }
.filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.filters select { width: auto; margin: 0; }
.check { display: flex; gap: 6px; align-items: center; margin: 0; }
.hist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.hcard { background: #fff; border: 2px solid var(--border); border-radius: 14px; padding: 10px; cursor: pointer; font: inherit; text-align: left; }
.hcard .thumb { height: 120px; display: flex; align-items: center; justify-content: center; font-size: 54px; background: #fbf6ec; border-radius: 10px; overflow: hidden; }
.hcard .thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.hcard .ht { font-size: 13px; margin-top: 6px; line-height: 1.25; max-height: 3.75em; overflow: hidden; }
.hcard .hm { font-size: 12px; color: var(--muted); margin-top: 4px; }
.res { display: inline-block; font-size: 12px; border-radius: 999px; padding: 1px 8px; background: #f3ead8; }
.res.facile, .res.reussi { background: #e1f5e9; color: #1d7a45; }
.res.difficile { background: #fde7e5; color: #b5382e; }
.lettergrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.lt { border-radius: 10px; text-align: center; padding: 8px 0; font-family: Andika, sans-serif; font-size: 22px; background: #f2f0ea; color: #b3ad9f; }
.lt.b0 { background: #ffe7d6; color: #c25a1e; }
.lt.b1, .lt.b2 { background: #fff3c4; color: #8a6d00; }
.lt.b3, .lt.b4 { background: #dff3e6; color: #1d7a45; }
.lt.b5 { background: #2e9e5b; color: #fff; }
.lt.cursive { font-family: 'Playwrite FR Trad', cursive; font-size: 16px; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -2px; background: var(--c); }
.statrow { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stat { background: #fbf6ec; border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 26px; }
.bar { height: 14px; background: #f1e8d6; border-radius: 999px; overflow: hidden; margin: 8px 0; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #f7b267, #ef7d3b); }
.overlay { position: fixed; inset: 0; background: rgba(43,38,32,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.busy-box { background: #fff; border-radius: 20px; padding: 28px; text-align: center; max-width: 340px; margin: 16px; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 6px solid #f3e6cf; border-top-color: var(--accent); margin: 0 auto 12px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #fff; color: var(--text); border: 2px solid var(--good); border-radius: 12px; padding: 10px 16px; z-index: 60; max-width: 90vw; font-size: 15px; box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.toast.bad { border-color: var(--bad); color: var(--bad); }

/* viewer */
.viewer { position: fixed; inset: 0; background: #ece6da; z-index: 40; display: flex; flex-direction: column; }
.viewer-bar { display: flex; gap: 8px; padding: 10px 12px; background: #fff; border-bottom: 2px solid var(--border); flex-wrap: wrap; align-items: center; }
.viewer-bar .spacer { flex: 1; }
.viewer-feedback { padding: 8px 12px; background: #fffaf0; border-bottom: 2px solid var(--border); font-size: 14px; }
.viewer-feedback .fbrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.viewer-feedback .hardrow { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sheet-scroller { flex: 1; overflow: auto; padding: 16px; }
.sheet-holder { margin: 0 auto; transform-origin: top left; }
.answers-off .answer { display: none; }

/* the printable sheet: real inches */
.sheet { width: 8.5in; height: 11in; background: #fff; box-shadow: 0 4px 20px rgba(0,0,0,.15); position: relative; padding: 0.45in 0.5in 0.4in; display: flex; flex-direction: column; overflow: hidden; color: #222; }
.sheet.landscape { width: 11in; height: 8.5in; }
.sh-head { flex: none; margin-bottom: 0.12in; }
.sh-title { font-family: Fredoka, sans-serif; font-size: 19pt; font-weight: 600; line-height: 1.2; }
.sh-meta { display: flex; justify-content: space-between; font-family: Fredoka, sans-serif; font-size: 11pt; color: #666; margin-top: 0.08in; }
.sh-body { flex: 1; width: 100%; min-height: 0; }
.sh-foot { flex: none; display: flex; justify-content: space-between; font-family: Fredoka, sans-serif; font-size: 9.5pt; color: #8a8a8a; margin-top: 0.08in; border-top: 1px solid #eee; padding-top: 0.06in; }
.sh-self b { font-size: 13pt; font-weight: 400; }
.sheet.bare { padding: 0.4in; align-items: center; justify-content: center; }
.bare-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.diploma { padding: 0.35in; }
.dip-frame { flex: 1; border: 10px double #e0a93b; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-family: Fredoka, sans-serif; padding: 0.2in; }
.dip-stars { color: #e0a93b; font-size: 22pt; letter-spacing: 8px; }
.dip-title { font-size: 46pt; font-weight: 700; letter-spacing: 6px; }
.dip-sub { font-size: 20pt; }
.dip-img { max-height: 2.9in; max-width: 60%; margin: 0.1in 0; }
.dip-line { font-size: 15pt; color: #555; }
.dip-name { font-family: Andika, sans-serif; font-size: 40pt; font-weight: 700; margin: 0.05in 0; }
.dip-sign { display: flex; gap: 1in; margin-top: 0.2in; font-size: 12pt; color: #666; }

@media print {
  html, body { background: #fff; margin: 0; padding: 0; height: auto; }
  .wrap { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .sheet { height: 10.96in !important; }
  .sheet.landscape { height: 8.46in !important; }
  body > *:not(#app), #app > *:not(.viewer) { display: none !important; }
  .viewer { position: static; display: block; background: #fff; }
  .viewer-bar, .viewer-feedback { display: none !important; }
  .sheet-scroller { padding: 0; overflow: visible; }
  .sheet-holder { transform: none !important; width: auto !important; height: auto !important; }
  .sheet { box-shadow: none; page-break-after: avoid; break-after: avoid; }
  .answer { display: none !important; }
}
@media (max-width: 560px) {
  .brand { font-size: 19px; }
  .tabs button { padding: 7px 9px; font-size: 14px; }
}
