:root {
  --bg: #f6f4ef; --surface: #ffffff; --surface-2: #efece4; --line: #dcd7cc;
  --text: #1d1b18; --muted: #6b665c; --accent: #7a2e2e; --accent-ink: #fff;
  --ok: #2f6b3f; --ok-bg: #e4f0e6; --bad: #a23a2c; --bad-bg: #f6e3df; --warn: #8a6a12; --warn-bg: #f5ecd2;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --serif: "Charter", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614; --surface: #211f1c; --surface-2: #2a2824; --line: #3a3732;
    --text: #ece8e0; --muted: #a39d92; --accent: #d78a7a; --accent-ink: #1b1918;
    --ok: #8fcf9d; --ok-bg: #1f3325; --bad: #f0a093; --bad-bg: #3a221e; --warn: #e3c26a; --warn-bg: #3a321b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 24px; padding: 10px 24px; flex-wrap: wrap; }
.brand { font-weight: 500; letter-spacing: .02em; white-space: nowrap; }
.brand .mark { color: var(--accent); font-family: var(--serif); font-size: 20px; }
nav { display: flex; gap: 2px; overflow-x: auto; }
nav button { background: none; border: 0; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); white-space: nowrap; }
nav button:hover { background: var(--surface-2); color: var(--text); }
nav button.on { background: var(--text); color: var(--bg); }

main { max-width: 980px; margin: 0 auto; padding: 28px 24px 80px; }
h1 { font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1.2; margin: 0 0 6px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 28px 0 10px; }
h3 { margin: 0 0 6px; font-size: 17px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 9px 16px; border-radius: 8px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 5px 10px; font-size: 13px; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.accent { background: var(--accent); color: var(--accent-ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input[type=date], input[type=number], select, textarea, input[type=text] {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--text); }
textarea { width: 100%; min-height: 90px; resize: vertical; }
.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.weekdays label { display: flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text); }

/* Hoje */
.hero { display: grid; gap: 16px; grid-template-columns: 1fr; }
.daylabel { color: var(--muted); font-size: 14px; }
.topic { border-left: 3px solid var(--accent); padding: 4px 0 4px 14px; }
.topic .t { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.topic details { margin-top: 6px; }
.topic summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.topic .full { font-family: var(--serif); font-size: 15px; margin-top: 6px; color: var(--text); }
.steps { display: grid; gap: 8px; }
.steps label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.steps input { margin-top: 4px; accent-color: var(--accent); }
.sync { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sync.ok::before { content: "● "; color: var(--ok); }
.sync.saving::before { content: "● "; color: var(--warn); }
.sync.error { color: var(--bad); }
.vgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.vcard { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); border-radius: 8px; }
.vcard img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.vcard:hover .vt { color: var(--accent); }
.vt { font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vch { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.videos a:not(.vcard) { color: var(--accent); }
.vtopic + .vtopic { border-top: 1px solid var(--line); padding-top: 14px; }
.leiseca a { color: var(--accent); white-space: nowrap; }
.leiseca label:has(input:checked) b { text-decoration: line-through; opacity: .6; }
.quizcta { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface-2); border-radius: var(--radius); padding: 16px 18px; }

/* Cronograma */
.week { margin-bottom: 18px; }
.daycell { display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--line); cursor: pointer; }
.daycell:hover { background: var(--surface-2); }
.daycell:last-child { border-bottom: 0; }
.daycell .d { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.daycell .d b { color: var(--text); display: block; font-size: 15px; }
.daycell.today { box-shadow: inset 3px 0 0 var(--accent); }
.daycell .ts { font-size: 14px; }
.daycell .ts .subj { color: var(--muted); font-size: 12px; }
.list { padding: 0; overflow: hidden; }

/* Questão */
.qwrap { display: grid; gap: 14px; }
.qhead { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stem { font-family: var(--serif); font-size: 17px; line-height: 1.6; white-space: pre-line; }
.opts { display: grid; gap: 8px; }
.opt { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: start; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; cursor: pointer;
  font-family: var(--serif); font-size: 16px; line-height: 1.5; }
.opt:hover:not(:disabled) { border-color: var(--muted); }
.opt .L { font-family: var(--sans); font-weight: 700; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); font-size: 13px; }
.opt.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.opt.sel .L { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.right .L { background: var(--ok); color: var(--surface); border-color: var(--ok); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .L { background: var(--bad); color: var(--surface); border-color: var(--bad); }
.opt.struck .txt { text-decoration: line-through; opacity: .45; }
.opt:disabled { cursor: default; }
.strike { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 4px; border-radius: 4px; }
.strike:hover { background: var(--surface-2); }
.feedback { padding: 12px 14px; border-radius: 10px; font-weight: 500; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.feedback.warn { background: var(--warn-bg); color: var(--warn); }
.qnav { display: flex; flex-wrap: wrap; gap: 4px; }
.qnav button { width: 32px; height: 30px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); font-size: 12px; cursor: pointer; font-variant-numeric: tabular-nums; }
.qnav button.cur { outline: 2px solid var(--accent); }
.qnav button.ans { background: var(--surface-2); }
.qnav button.r { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.qnav button.w { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Desempenho */
.stat { padding: 16px 18px; }
.stat .v { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-size: 13px; }
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 220px 1fr 90px; gap: 12px; align-items: center; font-size: 14px; }
.bar .track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar .track i { display: block; height: 100%; border-radius: 99px; }
.bar .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .2s;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; pointer-events: none; z-index: 20; }
#toast.on { opacity: 1; transform: translateX(-50%); }

@media (max-width: 640px) {
  .top { padding: 8px 16px; gap: 8px; }
  main { padding: 20px 16px 60px; }
  h1 { font-size: 24px; }
  .bar { grid-template-columns: 1fr 70px; }
  .bar .track { grid-column: 1 / -1; grid-row: 2; }
  .daycell { grid-template-columns: 70px 1fr; }
  .daycell > :last-child { grid-column: 2; }
  .stem { font-size: 16px; }
}
