/* Memora · estilos */
:root {
  --bg: #f6f4ef;
  --bg2: #efece4;
  --surface: #ffffff;
  --surface2: #f8f6f1;
  --line: #e4dfd3;
  --line2: #d6d0c1;
  --text: #1c1a24;
  --muted: #6d6878;
  --accent: #6b4dff;
  --accent2: #8b72ff;
  --accent-soft: #ece8ff;
  --ok: #138a5b;
  --ok-soft: #e1f4ea;
  --warn: #b26a00;
  --warn-soft: #fbefd9;
  --err: #c9343b;
  --err-soft: #fbe4e3;
  --c-new: #2f74d0;
  --c-learn: #d0602f;
  --c-due: #138a5b;
  --shadow: 0 1px 2px rgba(30, 25, 50, .05), 0 6px 24px rgba(30, 25, 50, .06);
  --shadow-lg: 0 20px 60px rgba(30, 25, 50, .18);
  --r: 16px;
  --r-sm: 10px;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --side: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12111a;
    --bg2: #0d0c13;
    --surface: #1b1a26;
    --surface2: #22212f;
    --line: #2d2b3d;
    --line2: #3a3850;
    --text: #ecebf3;
    --muted: #9c98b0;
    --accent: #8f78ff;
    --accent2: #a796ff;
    --accent-soft: #2a2450;
    --ok: #3ccf8e;
    --ok-soft: #173327;
    --warn: #f0a83a;
    --warn-soft: #3a2c14;
    --err: #ff6b70;
    --err-soft: #3d1c1f;
    --c-new: #5ea2ff;
    --c-learn: #ff8a57;
    --c-due: #3ccf8e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 30px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.55 var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body.has-modal { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-family: var(--serif); font-weight: 650; font-size: clamp(28px, 4vw, 40px); letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }
code, kbd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .86em; }
kbd { border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 6px; padding: 0 5px; opacity: .7; font-size: 11px; margin-left: 6px; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.ic.big { width: 40px; height: 40px; color: var(--accent); }
.muted { color: var(--muted); }
.sm { font-size: 13px; }
.pad { padding: 18px 4px; }
.center { text-align: center; justify-content: center; }
.mt { margin-top: 22px; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.err { color: var(--err); }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }
.boot-error { max-width: 640px; margin: 60px auto; padding: 24px; background: var(--err-soft); border-radius: var(--r); }

/* ---------- botões e campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px; padding: 9px 16px;
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: transform .08s, background .15s, border-color .15s, box-shadow .15s;
  background: var(--surface2); color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover:not(:disabled) { background: var(--accent2); }
.btn.ghost { background: transparent; border-color: var(--line2); }
.btn.ghost:hover { background: var(--surface2); }
.btn.danger { background: var(--err); color: #fff; }
.btn.lg { padding: 13px 22px; font-size: 15px; border-radius: 14px; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.on { color: #f2b200; }
.icon-btn.on .ic { fill: currentColor; }
.link { color: var(--accent); font-weight: 600; font-size: 14px; }
.fld { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.fld > span, .lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; border: 1px solid var(--line2); background: var(--surface); border-radius: 11px;
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
.hint { font-size: 13px; color: var(--muted); margin: -4px 0 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin: 4px 0 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600; background: var(--surface2); color: var(--muted); border: 1px solid var(--line);
}
.chip .ic { width: 12px; height: 12px; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.t-basic { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.chip.t-cloze { color: #0f8a8a; background: color-mix(in srgb, #12b5b5 14%, transparent); border-color: transparent; }
.chip.t-mcq { color: #b3478f; background: color-mix(in srgb, #d14fa6 13%, transparent); border-color: transparent; }
.chip.t-tf { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pg { display: inline-block; font: 600 11px/1.6 var(--sans); padding: 0 7px; border-radius: 6px; background: var(--surface2); color: var(--muted); border: 1px solid var(--line); vertical-align: 1px; }
.spin { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 7px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px; transition: width .35s ease; }
.bar.big { height: 10px; }
.bar.thin { height: 3px; border-radius: 0; }

/* ---------- layout */
#shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px;
  padding: 22px 16px; border-right: 1px solid var(--line); background: var(--bg2);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 650; font-size: 22px; padding: 4px 10px 18px; }
.brand.big { font-size: 30px; justify-content: center; padding: 0 0 6px; }
.logo {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #c25cff); color: #fff; font: 700 17px var(--sans);
}
.brand.big .logo { width: 46px; height: 46px; font-size: 22px; border-radius: 14px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: var(--muted); font-weight: 550; }
.side nav a:hover { background: var(--surface2); color: var(--text); }
.side nav a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.side nav a.on .ic { color: var(--accent); }
.side-foot { margin-top: auto; }
#main { padding: 34px clamp(16px, 4vw, 48px) 80px; max-width: 1240px; width: 100%; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-weight: 600; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.eyebrow a:hover { color: var(--accent); }
.editable { cursor: text; }
.editable:hover { text-decoration: underline dotted var(--line2); text-underline-offset: 6px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.panel > h2 { margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.empty { text-align: center; padding: 40px 16px; }
.empty h3, .empty h2 { margin: 12px 0 6px; }
.empty .btn { margin-top: 12px; }
.big-empty { padding: 90px 16px; }

/* ---------- painel */
.hero-card {
  display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 26px 28px; border-radius: 22px; margin-bottom: 18px; color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, #8b6cff 0%, #5b3df0 45%, #2b1c86 100%);
  box-shadow: 0 18px 50px rgba(91, 61, 240, .35);
}
.hero-card .muted { color: rgba(255, 255, 255, .78); }
.hero-num { font: 650 64px/1 var(--serif); letter-spacing: -.02em; }
.hero-card .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, .35); }
.hero-card .btn.ghost:hover { background: rgba(255, 255, 255, .12); }
.hero-card .btn.primary { background: #fff; color: #3a22c4; box-shadow: none; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpis.mini { grid-template-columns: repeat(3, minmax(0, 120px)); justify-content: center; margin: 20px 0; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.kpi span { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi span .ic { color: #f07a2a; width: 16px; height: 16px; }
.kpi b { font: 650 28px/1.15 var(--serif); }
.kpi small { color: var(--muted); font-size: 12px; }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.deck-tile {
  display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
}
.deck-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.deck-name { font-weight: 650; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.deck-counts { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; font-weight: 600; }
.c-new { color: var(--c-new); }
.c-learn { color: var(--c-learn); }
.c-due { color: var(--c-due); }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); gap: 3px; overflow-x: auto; padding-bottom: 6px; }
.heat i, .heat-leg i { width: 13px; height: 13px; border-radius: 3px; background: var(--surface2); display: inline-block; border: 1px solid var(--line); }
.heat i.e { visibility: hidden; }
.heat .l1, .heat-leg .l1 { background: color-mix(in srgb, var(--accent) 25%, var(--surface)); border-color: transparent; }
.heat .l2, .heat-leg .l2 { background: color-mix(in srgb, var(--accent) 50%, var(--surface)); border-color: transparent; }
.heat .l3, .heat-leg .l3 { background: color-mix(in srgb, var(--accent) 75%, var(--surface)); border-color: transparent; }
.heat .l4, .heat-leg .l4 { background: var(--accent); border-color: transparent; }
.heat-leg { display: flex; align-items: center; gap: 3px; margin-top: 8px; justify-content: flex-end; }
.fc { display: flex; align-items: flex-end; gap: 8px; height: 150px; }
.fc-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.fc-col i { width: 100%; max-width: 34px; background: linear-gradient(180deg, var(--accent2), var(--accent)); border-radius: 6px 6px 3px 3px; min-height: 2px; }
.fc-n { font-size: 12px; font-weight: 600; color: var(--muted); }
.fc-l { font-size: 11px; color: var(--muted); }

/* ---------- materiais */
.drop {
  border: 2px dashed var(--line2); border-radius: 20px; padding: 40px 20px; text-align: center; cursor: pointer;
  background: var(--surface); margin-bottom: 18px; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop h3 { margin: 12px 0 6px; }
.drop p { max-width: 560px; margin: 0 auto; }
.up { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.up.need-pw { border-color: var(--warn); }
.up-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.up-size { white-space: nowrap; }
.up-title { border: 0 !important; background: transparent !important; box-shadow: none !important; font-weight: 600; padding: 2px 4px !important; }
.up-status { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.up-status.ok { color: var(--ok); }
.up-status.err { color: var(--err); }
.up-status.warn { color: var(--warn); }
.up-pw { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.up-pw input[type=password] { max-width: 260px; }
.up-pw .check { margin: 0; }
.mat-list { display: flex; flex-direction: column; }
.mat { display: flex; align-items: center; gap: 14px; padding: 14px 6px; border-bottom: 1px solid var(--line); }
.mat:last-child { border-bottom: 0; }
.mat:hover .mat-title { color: var(--accent); }
.mat-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.mat-body { flex: 1; min-width: 0; }
.mat-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
.gen-layout { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 18px; align-items: start; }
.gen-form { position: sticky; top: 20px; }
.chips-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { cursor: pointer; }
.pick input { display: none; }
.pick span { display: inline-block; padding: 7px 13px; border-radius: 99px; border: 1px solid var(--line2); font-size: 13px; font-weight: 600; color: var(--muted); }
.pick input:checked + span { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.seg label { cursor: pointer; }
.seg input { display: none; }
.seg span { display: flex; flex-direction: column; padding: 11px 13px; border: 1px solid var(--line2); border-radius: 12px; height: 100%; }
.seg small { color: var(--muted); font-size: 12px; }
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.gen-progress { margin-top: 14px; }
.gen-progress p { margin: 8px 0 0; }
.gen-out .clist, #genList { max-height: none; }

/* ---------- lista de cards */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.filters select { width: auto; }
.bulk { display: flex; gap: 10px; align-items: center; padding: 10px 12px; margin-bottom: 10px; border-radius: 12px; background: var(--accent-soft); font-weight: 600; font-size: 14px; }
.crow { display: flex; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); align-items: flex-start; animation: fadeIn .3s ease; }
.crow:last-child { border-bottom: 0; }
.crow.susp { opacity: .5; }
.crow .sel { margin-top: 4px; }
.crow-main { flex: 1; min-width: 0; }
.crow-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.crow-front { font-weight: 600; overflow-wrap: anywhere; }
.crow-back { color: var(--muted); margin-top: 4px; font-size: 14px; overflow-wrap: anywhere; }
.crow-act { display: flex; gap: 2px; flex: none; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.cloze { display: inline-block; min-width: 3.5em; text-align: center; padding: 0 6px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.cloze.on { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }

/* ---------- menu suspenso */
.menu { position: relative; }
.menu-pop {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 250px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px;
}
.menu.open .menu-pop { display: block; }
.menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.menu-pop button:hover { background: var(--surface2); }
.menu-pop button.danger { color: var(--err); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- resumos e tutor */
.sum-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.sum-item { display: flex; flex-direction: column; align-items: flex-start; text-align: left; border: 1px solid var(--line); background: var(--surface2); border-radius: 11px; padding: 10px 12px; cursor: pointer; }
.sum-item:hover { border-color: var(--accent); }
.prose { line-height: 1.7; overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { font-family: var(--sans); margin: 1.3em 0 .5em; }
.prose h2 { font-size: 19px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 16px; }
.prose > :first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: 3px 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line2); padding: 7px 10px; text-align: left; }
.prose th { background: var(--surface2); }
.prose blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.prose code { background: var(--surface2); padding: 1px 5px; border-radius: 5px; }
.streaming::after { content: '▍'; animation: blink 1s steps(2) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }
.chat { display: flex; flex-direction: column; height: calc(100vh - 260px); min-height: 480px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 12px; }
.chat-empty { text-align: center; margin: auto; max-width: 420px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: min(760px, 90%); padding: 11px 15px; border-radius: 16px; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.msg.assistant .bubble { background: var(--surface2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.chat-sugs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; }
.chip-btn { border: 1px solid var(--line2); background: transparent; border-radius: 99px; padding: 6px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; color: var(--muted); }
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.chat-form { display: flex; gap: 10px; align-items: flex-end; }
.chat-form textarea { resize: none; min-height: 46px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.page-text { white-space: pre-wrap; font: 14px/1.7 var(--sans); background: var(--surface2); border-radius: 12px; padding: 18px; margin: 0; max-height: 70vh; overflow-y: auto; }
.pg-in { width: 74px !important; display: inline-block; padding: 5px 8px !important; }

/* ---------- estudo */
body.focus-mode .side { display: none; }
body.focus-mode #shell { grid-template-columns: 1fr; }
body.focus-mode #main { max-width: 860px; margin: 0 auto; padding-top: 16px; }
.study-top { display: flex; align-items: center; gap: 12px; padding: 6px 0 10px; }
.study-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.study-counts { display: flex; gap: 12px; font-weight: 700; font-size: 15px; }
.study-counts span { min-width: 18px; text-align: center; }
.timer { font: 650 18px var(--sans); font-variant-numeric: tabular-nums; }
.timer.low { color: var(--err); }
.study-stage { padding-top: 22px; }
.flash {
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 38px); animation: cardIn .28s ease;
}
.flash.starred { border-color: color-mix(in srgb, #f2b200 55%, var(--line)); }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.flash-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.flash-meta .sp { flex: 1; }
.q { font: 500 clamp(20px, 2.6vw, 26px)/1.45 var(--serif); overflow-wrap: anywhere; }
.flash-back { margin-top: 22px; padding-top: 22px; border-top: 1px dashed var(--line2); animation: fadeIn .25s ease; }
.a { font: 500 19px/1.55 var(--serif); }
.a p { margin: 0 0 .5em; }
.expl { margin-top: 14px; padding: 14px 16px; background: var(--surface2); border-radius: 12px; font-size: 14.5px; }
.mnem { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--text); font-size: 14.5px; }
.mnem .ic { color: var(--warn); }
.ai-zone { margin-top: 14px; }
.ai-text { margin: 12px 0; padding: 14px 16px; border: 1px solid var(--accent-soft); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); border-radius: 12px; font-size: 14.5px; }
.opts { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; text-align: left; width: 100%; padding: 13px 15px; border-radius: 13px;
  border: 1px solid var(--line2); background: var(--surface); cursor: pointer; font-size: 15.5px; transition: border-color .15s, background .15s;
}
.opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--err); background: var(--err-soft); }
.opt-letter { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--surface2); font-weight: 700; font-size: 13px; }
.tf { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.tfb { justify-content: center; font-weight: 600; padding: 16px; }
.tfb b { color: var(--accent); }
.type-ans { margin-top: 20px; font-size: 15px; }
.study-actions { margin-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.typing-toggle { margin: 0; }
.reveal { min-width: 260px; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; }
.rbtn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line2); background: var(--surface); font-weight: 650; transition: transform .1s, box-shadow .15s;
}
.rbtn:hover { transform: translateY(-2px); }
.rbtn .ri { font-size: 12px; color: var(--muted); font-weight: 500; }
.rbtn kbd { margin: 4px 0 0; }
.rbtn.again { color: var(--err); }
.rbtn.hard { color: var(--warn); }
.rbtn.good { color: var(--ok); }
.rbtn.easy { color: var(--c-new); }
.rbtn.sug { box-shadow: 0 0 0 2px currentColor inset; background: color-mix(in srgb, currentColor 8%, var(--surface)); }
.grade { width: 100%; padding: 12px 14px; border-radius: 12px; background: var(--surface2); font-size: 14px; }
.grade ul { margin: 6px 0 0; padding-left: 1.2em; }
.grade.g-correta { background: var(--ok-soft); }
.grade.g-parcial { background: var(--warn-soft); }
.grade.g-incorreta { background: var(--err-soft); }
.finish { text-align: center; padding: 30px 0; }
.finish h2 { font: 650 30px var(--serif); margin: 12px 0 4px; }
.score-ring {
  --p: 0; width: 140px; height: 140px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface2) 0);
}
.score-ring b { display: grid; place-items: center; width: 112px; height: 112px; border-radius: 50%; background: var(--bg); font: 650 32px var(--serif); }
.review-list { text-align: left; margin-top: 26px; display: flex; flex-direction: column; gap: 8px; }
.rv { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 10px 14px; }
.rv summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.rv-n { flex: none; width: 26px; height: 26px; display: inline-grid; place-items: center; border-radius: 8px; font-weight: 700; font-size: 13px; }
.rv.rv-ok .rv-n { background: var(--ok-soft); color: var(--ok); }
.rv.rv-err .rv-n { background: var(--err-soft); color: var(--err); }
.rv.rv-blank .rv-n { background: var(--surface2); color: var(--muted); }
.quiz-setup { max-width: 760px; }

/* ---------- estatísticas */
.stack { display: flex; height: 18px; border-radius: 99px; overflow: hidden; background: var(--surface2); }
.stack i, .legend i { display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.s-new { background: var(--c-new); }
.s-learn { background: var(--c-learn); }
.s-young { background: color-mix(in srgb, var(--c-due) 55%, var(--surface)); }
.s-mature { background: var(--c-due); }
.hard { margin: 0; padding-left: 1.3em; }
.hard li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.hard li a { display: block; }
.hard li a:hover { color: var(--accent); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 13px; }
.cfg { max-width: 860px; }

/* ---------- modal e toasts */
.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(14, 12, 24, .55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; animation: fadeIn .15s; }
.modal { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 24px; width: min(480px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.modal.wide { width: min(720px, 100%); }
.modal h3 { margin-bottom: 14px; font-size: 19px; }
.modal p { margin: 0 0 16px; }
.opts-edit { margin-bottom: 14px; }
.opt-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.opt-row .opt-in { flex: 1; }
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500; opacity: 0; transform: translateY(10px); transition: all .25s; }
.toast.in { opacity: 1; transform: none; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.err { background: var(--err); color: #fff; }

/* ---------- acesso */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(80% 60% at 50% 0%, var(--accent-soft), var(--bg)); }
.auth-card { width: min(400px, 100%); background: var(--surface); border-radius: 24px; padding: 34px 30px; box-shadow: var(--shadow-lg); text-align: center; }
.auth-card .fld { text-align: left; }
.auth-card p { margin: 6px 0 22px; }

/* ---------- responsivo */
@media (max-width: 1020px) {
  .gen-layout { grid-template-columns: 1fr; }
  .gen-form { position: static; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  #shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 50; flex-direction: row;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line);
  }
  .side .brand, .side-foot { display: none; }
  .side nav { flex-direction: row; justify-content: space-around; width: 100%; }
  .side nav a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 4px; flex: 1; text-align: center; }
  .side nav a.on { box-shadow: none; background: transparent; color: var(--accent); }
  #main { padding: 22px 16px 100px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .hero-num { font-size: 48px; }
  .rate { grid-template-columns: repeat(2, 1fr); }
  .crow-act { flex-direction: column; }
  .chat { height: calc(100vh - 300px); }
  .seg { grid-template-columns: 1fr; }
  body.focus-mode #main { padding-bottom: 30px; }
  .kpis.mini { grid-template-columns: repeat(3, 1fr); }
}
@media print {
  .side, .study-top { display: none; }
}

/* ---------- geração em lote */
.bulkbar .check { margin: 0; }
.mat-row { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.mat-row:last-child { border-bottom: 0; }
.mat-row .mat { flex: 1; min-width: 0; border-bottom: 0; }
.mat-sel { display: grid; place-items: center; width: 34px; align-self: stretch; cursor: pointer; flex: none; }
.up-all { border-color: var(--accent); background: var(--accent-soft); }
.batch-form [hidden] { display: none !important; }
#batchDock {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; width: min(380px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 14px 16px;
}
#batchDock .dock-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
#batchDock .dock-ttl { display: flex; flex-direction: column; min-width: 0; }
#batchDock .dock-list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 260px; overflow-y: auto; display: none; }
#batchDock.open .dock-list { display: block; }
#batchDock .dock-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
#batchDock .dock-list small { grid-column: 1 / -1; color: var(--muted); }
#batchDock .dock-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
#batchDock .dock-t a:hover { color: var(--accent); }
#batchDock .dock-s { color: var(--muted); white-space: nowrap; }
#batchDock .st-ok .dock-s { color: var(--ok); }
#batchDock .st-erro .dock-s, #batchDock .st-erro small { color: var(--err); }
#batchDock .st-parcial .dock-s { color: var(--warn); }
#batchDock .st-gerando .dock-s { color: var(--accent); }

/* ---------- provas */
.ex-discs { margin: 0 0 14px; }
.ex-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 14px; max-height: 520px; overflow-y: auto; }
.ex-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ex-table th { position: sticky; top: 0; background: var(--surface2); text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; z-index: 1; }
.ex-table td { padding: 6px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.ex-table tr.done td { opacity: .6; }
.ex-table .ex-in { padding: 5px 8px; font-size: 13px; border-radius: 8px; min-width: 140px; }
.ex-table .ex-gab { min-width: 0; width: 84px; text-transform: uppercase; text-align: center; }
.ex-qh { margin: 16px 0 6px; font-weight: 650; font-size: 13px; color: var(--accent); letter-spacing: .02em; }
.ex-qh:first-child { margin-top: 0; }

@media (max-width: 760px) {
  #batchDock { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .ex-table .ex-in { min-width: 110px; }
}

[hidden] { display: none !important; }
