:root {
  --bg: #f5f6fb; --card: #ffffff; --text: #1d2033; --muted: #6b7088; --line: #e3e5ef;
  --pri: #4f46e5; --pri-2: #eef0ff; --ok: #059669; --warn: #d97706; --err: #dc2626; --shadow: 0 1px 3px rgba(20, 22, 50, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #12131c; --card: #1c1e2b; --text: #e8e9f2; --muted: #9a9db3; --line: #2c2f40; --pri: #818cf8; --pri-2: #262a4a; --ok: #34d399; --warn: #fbbf24; --err: #f87171; --shadow: none; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #12131c; --card: #1c1e2b; --text: #e8e9f2; --muted: #9a9db3; --line: #2c2f40; --pri: #818cf8; --pri-2: #262a4a; --ok: #34d399; --warn: #fbbf24; --err: #f87171; --shadow: none; color-scheme: dark; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
a { color: var(--pri); text-decoration: none; }
h1 { font-size: 1.5rem; margin: .4rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; color: var(--muted); font-weight: 600; }
header#top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 8px; align-items: center; font-weight: 700; color: var(--text); font-size: 1.1rem; }
#sync { font-size: .85rem; color: var(--ok); }
#sync.pending { color: var(--warn); }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px 24px; }
nav#nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav#nav a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 7px 0 6px; font-size: .7rem; color: var(--muted); }
nav#nav a span { font-size: 1.3rem; line-height: 1.2; filter: grayscale(1); opacity: .7; }
nav#nav a.on { color: var(--pri); font-weight: 600; }
nav#nav a.on span { filter: none; opacity: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 0 0 12px; box-shadow: var(--shadow); }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err, .errc { color: var(--err); }
.okc { color: var(--ok); font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; }
.row.center { justify-content: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.head h1 { margin: .4rem 0; }
.back { font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; background: var(--pri); color: #fff; font: inherit; font-weight: 600; padding: 10px 16px; cursor: pointer; min-height: 44px; }
:root[data-theme="dark"] .btn:not(.ghost) { color: #0f1020; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn:not(.ghost) { color: #0f1020; } }
.btn.ghost { background: var(--pri-2); color: var(--pri); }
.btn.big { font-size: 1.1rem; padding: 14px 22px; }
.btn.wide { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.link { background: none; border: 0; padding: 0; color: var(--pri); font: inherit; cursor: pointer; }
.link.danger { color: var(--err); }
.hero { text-align: center; padding: 22px 16px; }
.hero p { margin: .4rem 0 1rem; }
.big-num { font-size: 3rem; font-weight: 800; line-height: 1.1; color: var(--pri); }
.big-num small { font-size: 1.2rem; color: var(--muted); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
.stat { text-align: center; padding: 12px 6px; margin: 0; }
.stat b { display: block; font-size: 1.5rem; }
.stat span { font-size: .78rem; color: var(--muted); }
.list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: var(--text); }
.item.col { flex-direction: column; align-items: stretch; gap: 6px; }
.item small { display: block; color: var(--muted); font-size: .82rem; }
.item.paused { opacity: .55; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; }
.tic { flex: none; width: 24px; text-align: center; }
.badge { flex: none; background: var(--pri); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 700; }
.badge.warn { background: var(--warn); }
.badge.ok { background: var(--ok); }
.badge.soft { background: var(--pri-2); color: var(--pri); }
:root[data-theme="dark"] .badge:not(.soft) { color: #0f1020; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge:not(.soft) { color: #0f1020; } }
.pbar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.pbar i { display: block; height: 100%; background: var(--pri); border-radius: 99px; transition: width .3s; }
.week, .fc { display: flex; align-items: flex-end; gap: 6px; height: 100px; }
.week div, .fc div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.week i, .fc i { width: 70%; max-width: 26px; background: var(--pri); border-radius: 5px 5px 2px 2px; }
.week small, .fc small { font-size: .7rem; color: var(--muted); text-align: center; line-height: 1.2; margin-top: 3px; }
.fc { height: 130px; gap: 2px; }
.fc div, .week div { min-width: 0; }
.fc small { font-size: .62rem; }
.fc b { font-size: .7rem; color: var(--muted); }
.form label { display: block; font-weight: 600; font-size: .92rem; margin: 10px 0 4px; }
.form label.check { display: flex; gap: 10px; align-items: center; font-weight: 400; }
input, textarea, select { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 4px; }
input[type=checkbox] { width: 20px; height: 20px; margin: 0; accent-color: var(--pri); flex: none; }
input[type=range] { padding: 0; accent-color: var(--pri); }
input[type=file] { padding: 8px; }
input[type=search] { margin: 4px 0 12px; }
textarea { resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .92rem; cursor: pointer; margin: 0 !important; font-weight: 400 !important; }
.chip.on { background: var(--pri-2); border-color: var(--pri); color: var(--pri); font-weight: 600 !important; }
.chip.sw { width: 34px; height: 34px; padding: 0; }
.chip.sw.on { outline: 3px solid var(--text); outline-offset: 2px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); font: inherit; font-size: .88rem; padding: 8px 4px; border-radius: 9px; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
#cardform .t-qa, #cardform .t-qcm, #cardform .t-trous, #cardform .t-note { display: none; }
#cardform[data-type=qa] .t-qa, #cardform[data-type=qcm] .t-qcm, #cardform[data-type=trous] .t-trous, #cardform[data-type=note] .t-note { display: block; }
.choice { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.choice input[type=text] { margin: 0; }
.imgf { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0; }
.imgf img { max-height: 90px; border-radius: 8px; border: 1px solid var(--line); }
.imgf label.btn { margin: 0; font-weight: 600; }
pre.ex { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; white-space: pre-wrap; font-size: .85rem; }
code { background: var(--pri-2); border-radius: 5px; padding: 0 4px; font-size: .9em; }
.subhead h1 { margin: 0 0 4px; }
.subhead .row { margin-top: 10px; }
details.chap { margin: 12px 0; }
details.chap > summary { cursor: pointer; font-weight: 700; padding: 6px 2px; }
details.chap > summary small { color: var(--muted); font-weight: 400; margin-left: 6px; }
details.chap .list { margin-top: 6px; }
details.card > summary { cursor: pointer; }
.qhist { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.flash { min-height: 220px; padding: 20px 18px; }
.flash .meta { display: flex; justify-content: space-between; gap: 8px; font-size: .82rem; color: var(--muted); margin-bottom: 14px; }
.flash .q { font-size: 1.2rem; font-weight: 600; }
.flash .a { font-size: 1.1rem; margin-top: 12px; }
.flash hr { border: 0; border-top: 1px dashed var(--line); margin: 16px 0; }
.fimg { display: block; max-width: 100%; max-height: 50vh; margin: 12px auto 0; border-radius: 10px; }
.opts { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.opt { text-align: left; border: 2px solid var(--line); background: var(--bg); color: var(--text); border-radius: 12px; padding: 12px 14px; font: inherit; cursor: pointer; }
.opt.sel { border-color: var(--pri); background: var(--pri-2); }
.opt.good { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.opt.bad { border-color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent); }
.opt:disabled { cursor: default; color: var(--text); }
.hole { display: inline-block; width: auto; min-width: 4ch; max-width: 100%; padding: 2px 6px; margin: 0 2px; border-width: 0 0 2px; border-radius: 4px; border-color: var(--pri); font-weight: 600; }
.hole-r { font-weight: 700; padding: 0 3px; border-radius: 4px; }
.hole-r.good { color: var(--ok); }
.hole-r.bad { color: var(--err); }
.hole-r s { opacity: .7; font-weight: 400; }
.actions { margin: 12px 0; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 4px; }
.grades.two { grid-template-columns: 1fr 1fr; }
.gbtn { border: 0; border-radius: 12px; padding: 10px 4px; font: inherit; cursor: pointer; color: #fff; display: flex; flex-direction: column; align-items: center; min-height: 58px; justify-content: center; }
.gbtn small { opacity: .85; font-size: .78rem; }
.gbtn.g0 { background: #dc2626; } .gbtn.g1 { background: #d97706; } .gbtn.g2 { background: #059669; } .gbtn.g3 { background: #2563eb; }
.gbtn.sug { outline: 3px solid var(--text); outline-offset: 2px; }
.login { max-width: 420px; margin: 8vh auto; text-align: center; padding: 28px 20px; }
.login h1 { margin: .6rem 0 .3rem; }
#gbtn { display: flex; justify-content: center; margin: 18px 0 8px; min-height: 44px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--pri-2); font-size: 1.4rem; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
#toast { position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: #1d2033; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .92rem; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100vw - 32px); z-index: 10; }
#toast.on { opacity: 1; transform: translateX(-50%); }
