/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--btn-h); padding: 0 var(--s5);
  border-radius: var(--radius-btn);
  font-size: 15px; font-weight: 600; line-height: 1;
  border: 1px solid transparent;
  transition: background var(--fast), color var(--fast), border-color var(--fast), transform var(--fast), box-shadow var(--fast);
  white-space: nowrap; user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }
.btn svg.icon { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 28%, transparent); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover:not(:disabled) { background: color-mix(in srgb, var(--primary-soft) 80%, var(--primary) 12%); }
.btn-outline { background: var(--card); color: var(--primary); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); }
.btn-ghost { color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--muted-soft); }
.btn-danger { background: var(--error-soft); color: var(--error); }
.btn-danger-solid { background: var(--error); color: #fff; }
.btn-success-solid { background: var(--success); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 var(--s3); font-size: 14px; border-radius: var(--radius-sm); }
.btn-lg { min-height: 52px; font-size: 16px; }
.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-grid; place-items: center;
  border-radius: 12px; color: var(--text);
  transition: background var(--fast), color var(--fast);
}
.icon-btn:hover:not(:disabled) { background: var(--muted-soft); }
.icon-btn:disabled { opacity: 0.35; }
.icon-btn.bordered { background: var(--card); border: 1px solid var(--border); }
.avatar-btn {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: var(--s4); }
.card + .card { margin-top: var(--s3); }

/* Card de continuidade */
.continue-card { display: grid; grid-template-columns: 76px 1fr; gap: var(--s3); padding: var(--s3); position: relative; }
.continue-thumb { position: relative; width: 76px; height: 76px; border-radius: 12px; overflow: hidden; background: var(--muted-soft); }
.continue-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.continue-card .label { font-size: var(--fs-xs); font-weight: 600; color: var(--primary); }
.continue-card h3 { font-size: 15px; }
.continue-card .btn { grid-column: 1 / -1; }
.continue-card .close { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; }

.welcome h1 { font-size: 22px; font-weight: 650; line-height: 1.3; }
.welcome p { font-size: 17px; font-weight: 600; }

/* Cards de matérias */
.subject-grid { display: grid; grid-template-columns: 1fr; gap: var(--s3); }
.subject-card {
  position: relative; display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s2) var(--s3) var(--s3);
  cursor: pointer; text-align: left; width: 100%;
  transition: border-color var(--fast), box-shadow var(--fast), transform var(--fast);
}
.subject-card:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); box-shadow: var(--shadow-md); }
.subject-card:active { transform: scale(0.995); }
.subject-icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c, var(--primary)) 14%, var(--card));
  color: var(--c, var(--primary));
}
.subject-icon svg.icon { width: 26px; height: 26px; }
.subject-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.subject-body h3 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-meta { font-size: var(--fs-xs); color: var(--text-2); }
.subject-progress { display: flex; align-items: center; gap: var(--s2); margin-top: 4px; }
.subject-progress .pct { font-size: 11px; color: var(--text-2); min-width: 30px; text-align: right; }
.subject-card .more { width: 40px; height: 40px; color: var(--text-2); }

/* Barra de progresso */
.progress { flex: 1; height: 6px; border-radius: 99px; background: var(--muted-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--primary)); transition: width var(--med) var(--ease); }

/* Estado vazio */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s3);
  padding: var(--s8) var(--s5);
}
.empty-illus {
  width: 84px; height: 84px; border-radius: 24px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); margin-bottom: var(--s2);
}
.empty-illus svg.icon { width: 40px; height: 40px; stroke-width: 1.5; }
.empty h2 { font-size: 20px; }
.empty p { color: var(--text-2); max-width: 340px; }
.empty .btn { margin-top: var(--s2); }
.empty.compact { padding: var(--s6) var(--s4); }
.empty.compact .empty-illus { width: 56px; height: 56px; border-radius: 16px; }
.empty.compact .empty-illus svg.icon { width: 26px; height: 26px; }
.empty.compact h2 { font-size: 16px; }

/* ---------- Listas ---------- */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); min-height: 56px; width: 100%;
  text-align: left; border-bottom: 1px solid var(--border);
  transition: background var(--fast);
}
.list-row:last-child { border-bottom: 0; }
button.list-row:hover, a.list-row:hover { background: var(--muted-soft); }
.list-row .icon-lead {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; background: var(--muted-soft); color: var(--text-2);
}
.list-row .icon-lead.plain { background: none; width: 24px; }
.list-row .title { font-weight: 600; font-size: 15px; color: var(--text); }
.list-row .sub { font-size: var(--fs-small); color: var(--text-2); }
.list-row .trail { color: var(--text-2); font-size: var(--fs-small); display: flex; align-items: center; gap: 4px; flex: none; }
.list-row .trail svg.icon { width: 18px; height: 18px; }

.status-dot { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; }
.status-dot svg.icon { width: 20px; height: 20px; stroke-width: 2.2; }
.status-dot.ok { background: var(--success-soft); color: var(--success); }
.status-dot.pending { background: var(--warning-soft); color: var(--warning); }
.status-dot.again { background: var(--error-soft); color: var(--error); }
.status-dot.new { background: var(--muted-soft); color: var(--text-2); }
.status-text { font-size: var(--fs-xs); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.status-text.ok { color: var(--success); }
.status-text.pending { color: var(--warning); }
.status-text.again { color: var(--error); }
.status-text.new { color: var(--text-2); }
.status-text::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Chips / segmentado ---------- */
.chips { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 var(--s4);
  border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--card); color: var(--text-2); font-size: 14px; font-weight: 500;
  transition: all var(--fast);
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.segmented { display: flex; padding: 3px; background: var(--muted-soft); border-radius: 12px; gap: 2px; }
.segmented button {
  flex: 1; min-height: 38px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--text-2);
  transition: all var(--fast);
}
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

/* ---------- Formulários ---------- */
.form { display: flex; flex-direction: column; gap: var(--s4); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-size: 14px; font-weight: 600; }
.field .hint { font-size: var(--fs-xs); color: var(--text-2); }
.input, .textarea, .select {
  width: 100%; min-height: var(--field-h);
  padding: 0 var(--s4);
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  background: var(--card); color: var(--text); font-size: 16px;
  transition: border-color var(--fast), box-shadow var(--fast);
}
.textarea { padding: var(--s3) var(--s4); min-height: 108px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--text-2) 75%, transparent); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); outline: none; }
.input.invalid { border-color: var(--error); }
.field-error { font-size: var(--fs-xs); color: var(--error); }
.input-sm { min-height: 40px; font-size: 14px; padding: 0 var(--s3); border-radius: var(--radius-sm); }
.search { position: relative; }
.search svg.icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-2); width: 18px; height: 18px; pointer-events: none; }
.search .input { padding-left: 38px; }

.swatches { display: flex; flex-wrap: wrap; gap: var(--s3); }
.swatch {
  width: 40px; height: 40px; border-radius: 50%; background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
  display: grid; place-items: center; color: #fff;
  transition: transform var(--fast);
}
.swatch svg.icon { width: 18px; height: 18px; stroke-width: 2.6; opacity: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--c); }
.swatch[aria-pressed="true"] svg.icon { opacity: 1; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: var(--s2); }
.icon-choice {
  aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--border); background: var(--card);
  display: grid; place-items: center; color: var(--text-2);
  transition: all var(--fast);
}
.icon-choice svg.icon { width: 24px; height: 24px; }
.icon-choice[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

.range-row { display: flex; align-items: center; gap: var(--s3); }
.range-row output { min-width: 52px; text-align: right; font-size: var(--fs-small); color: var(--text-2); font-variant-numeric: tabular-nums; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 28px; background: transparent; min-width: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: var(--muted-soft); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 99px; background: var(--muted-soft); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--primary); box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--card); border: 2px solid var(--primary); }

.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--border); transition: background var(--fast); }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--fast) var(--ease); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Estatísticas ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; gap: var(--s2); }
.stats b { display: block; font-size: 19px; font-weight: 700; }
.stats span { font-size: var(--fs-xs); color: var(--text-2); }
.stats > div + div { border-left: 1px solid var(--border); }

/* ---------- Avisos ---------- */
.banner {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4); border-radius: var(--radius-btn);
  background: var(--warning-soft); color: var(--text); font-size: 14px;
  margin-bottom: var(--s4);
}
.banner svg.icon { color: var(--warning); margin-top: 1px; }
.banner.info { background: var(--primary-soft); }
.banner.info svg.icon { color: var(--primary); }
.banner.error { background: var(--error-soft); }
.banner.error svg.icon { color: var(--error); }
.banner .btn { margin-top: var(--s2); }

/* ---------- Página da matéria ---------- */
.room-card { overflow: hidden; }
.room-preview { position: relative; aspect-ratio: 16 / 9; background: var(--muted-soft); }
.room-preview img { width: 100%; height: 100%; object-fit: cover; }
.room-preview .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-2); }
.room-card-body { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s4); }
.room-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }

/* Ilustração de sala vazia (CSS) */
.illus-room { position: absolute; inset: 0; background: linear-gradient(#EDEEF5 0 62%, #D9DBE7 62%); }
:root[data-theme="dark"] .illus-room { background: linear-gradient(#2A2C3E 0 62%, #222433 62%); }
.illus-room::before { content: ''; position: absolute; left: 22%; right: 22%; top: 18%; bottom: 38%; background: color-mix(in srgb, var(--card) 70%, transparent); box-shadow: inset 0 0 0 1px var(--border); }
.illus-room::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 38%; background: linear-gradient(90deg, transparent 22%, rgba(0,0,0,.04) 22% 78%, transparent 78%); clip-path: polygon(22% 0, 78% 0, 100% 100%, 0 100%); }

/* Escolha de sala */
.room-options { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.room-option { position: relative; overflow: hidden; text-align: left; transition: border-color var(--fast), box-shadow var(--fast); }
.room-option .thumb { aspect-ratio: 4 / 3; background: var(--muted-soft); position: relative; }
.room-option .thumb img { width: 100%; height: 100%; object-fit: cover; }
.room-option .name { padding: var(--s3); font-weight: 600; font-size: 14px; }
.room-option[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.room-option .check {
  position: absolute; right: 8px; bottom: calc(var(--s3) * 2 + 20px); width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff; display: none; place-items: center; box-shadow: 0 0 0 2px var(--card);
}
.room-option .check svg.icon { width: 15px; height: 15px; stroke-width: 3; }
.room-option[aria-pressed="true"] .check { display: grid; }
.empty-room-card { display: grid; grid-template-columns: 110px 1fr; gap: var(--s3); padding: var(--s3); }
.empty-room-card .thumb { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1; }
.empty-room-card .btn { grid-column: 1 / -1; }

.loading-spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }

/* ---------- Painel inferior / modal ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: var(--overlay);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in var(--fast) ease-out;
}
.sheet {
  width: 100%; max-height: 92dvh;
  background: var(--card); color: var(--text);
  border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: sheet-up var(--med) var(--ease);
  padding-bottom: var(--safe-b);
}
.sheet.full { height: 100dvh; max-height: 100dvh; border-radius: 0; }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 8px auto 0; flex: none; }
.sheet.full .sheet-handle { display: none; }
.sheet-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s3) var(--s2) var(--s5); flex: none; }
.sheet.full .sheet-head { padding-top: calc(var(--s3) + var(--safe-t)); }
.sheet-head h2 { flex: 1; font-size: 19px; min-width: 0; }
.sheet-body { padding: var(--s2) var(--s5) var(--s5); overflow-y: auto; overscroll-behavior: contain; flex: 1; }
.sheet-foot { display: flex; gap: var(--s3); padding: var(--s3) var(--s5) var(--s4); border-top: 1px solid var(--border); flex: none; }
.sheet-foot .btn { flex: 1; }
.sheet-message { color: var(--text-2); }
.action-list { display: flex; flex-direction: column; margin: 0 calc(-1 * var(--s5)); }
.action-list button { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s5); min-height: 54px; font-weight: 500; text-align: left; }
.action-list button:hover { background: var(--muted-soft); }
.action-list button.danger { color: var(--error); }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 200;
  bottom: calc(var(--nav-h) + var(--safe-b) + var(--s4));
  display: flex; flex-direction: column; gap: var(--s2); align-items: center;
  pointer-events: none; width: min(92vw, 420px);
}
.toast {
  display: flex; align-items: center; gap: var(--s2);
  padding: 10px var(--s4); border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-md); animation: pop-in var(--med) var(--ease);
  pointer-events: auto; max-width: 100%;
}
.toast svg.icon { width: 18px; height: 18px; flex: none; }
.toast.success svg.icon { color: #6FD3A6; }
.toast.error { background: var(--error); color: #fff; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all var(--med); }

/* ---------- Conceito ---------- */
.concept-view { display: flex; flex-direction: column; gap: var(--s4); }
.concept-view .object-tag { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-small); color: var(--text-2); }
.concept-view .object-tag svg.icon { width: 16px; height: 16px; }
.concept-block { padding-top: var(--s3); border-top: 1px solid var(--border); }
.concept-block h4 { font-size: 14px; font-weight: 650; margin-bottom: 4px; }
.concept-block p { color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.concept-answer {
  padding: var(--s3) var(--s4); border-radius: var(--radius-btn);
  background: var(--success-soft); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere;
  animation: rise-in var(--med) var(--ease);
}
.concept-answer b { display: block; color: var(--success); font-size: 13px; margin-bottom: 2px; }
.keywords { display: flex; flex-wrap: wrap; gap: 6px; }
.keywords span { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.concept-actions { display: flex; flex-direction: column; gap: var(--s3); }
.reviewed-flash { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--success); font-weight: 600; font-size: 14px; animation: rise-in var(--med) var(--ease); }

/* ---------- Revisão ---------- */
.review-toolbar { display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s4); }
.review-cta {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + var(--s3)); margin-top: var(--s4); z-index: 5;
}
.session { display: flex; flex-direction: column; height: 100dvh; padding: calc(var(--s3) + var(--safe-t)) var(--gutter) calc(var(--s4) + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.session-top { display: flex; align-items: center; gap: var(--s3); }
.session-top .count { flex: 1; text-align: center; font-weight: 600; font-size: 14px; }
.session-progress { height: 4px; border-radius: 4px; background: var(--muted-soft); margin: var(--s3) 0 var(--s5); overflow: hidden; }
.session-progress span { display: block; height: 100%; background: var(--primary); transition: width var(--med) var(--ease); }
.session-card {
  flex: 1; display: flex; flex-direction: column; gap: var(--s4); padding: var(--s5);
  overflow-y: auto; min-height: 0;
}
.session-card .q { font-size: 20px; font-weight: 650; line-height: 1.35; text-align: center; margin: auto 0; overflow-wrap: anywhere; }
.session-card .ctx { text-align: center; font-size: var(--fs-small); color: var(--text-2); }
.session-answer { display: flex; flex-direction: column; gap: var(--s3); animation: rise-in var(--med) var(--ease); }
.session-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-top: var(--s4); }
.session-actions .btn { min-height: 92px; flex-direction: column; border-radius: 16px; font-size: 15px; }
.session-actions .btn svg.icon { width: 26px; height: 26px; stroke-width: 2.4; }
.session-done { text-align: center; }

/* ---------- Configurações ---------- */
.settings-group { margin-bottom: var(--s5); }
.settings-group > h2 { font-size: 15px; font-weight: 650; margin: 0 0 var(--s2) var(--s1); }
.settings-row-control { display: flex; align-items: center; gap: var(--s2); }
.settings-row-control .select { min-height: 38px; width: auto; font-size: 14px; padding: 0 var(--s3); }

/* ---------- Menu contextual ---------- */
.kbd { display: inline-block; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); font-size: 12px; font-family: inherit; }
