.study-session-backdrop {
  position: fixed;
  /* O escurecimento cobre a tela inteira; o teclado do iOS/Android (visualViewport, acompanhado pelo app.js) entra como
     espaçamento da caixa. Antes o fundo era recortado e sobrava uma faixa clara entre o drawer e o teclado. */
  inset: 0;
  z-index: calc(var(--z-drawer) + 8);
  display: grid;
  place-items: center;
  padding: calc(20px + var(--study-vvtop, 0px)) 20px calc(20px + var(--study-vvbottom, 0px));
  overflow: hidden;
  background: rgba(2, 4, 12, 0.74);
  backdrop-filter: blur(11px);
  animation: study-session-backdrop-in 180ms ease-out both;
}

.study-session-drawer [hidden] { display: none !important; }

/* ==========================================================================
   BC-5 — drawer compacto (registro-A.html, versão 3 de 16/10/2026): modal em retrato de 448 px no computador, quase a
   largura toda no celular, rodapé com Salvar sempre visível, uma linha fina entre as seções e sem rótulos óbvios.
   As cores vêm de variáveis locais (--sd-*) que o tema claro redefine mais abaixo.
   ========================================================================== */
.study-session-drawer {
  --study-accent: #8b5cf6;
  --study-accent-rgb: 139, 92, 246;
  --sd-ink: var(--ink);
  --sd-text: var(--text-secondary);
  --sd-muted: var(--muted);
  --sd-faint: var(--text-muted);
  --sd-hair: rgba(148, 163, 184, 0.14);
  --sd-line: rgba(148, 163, 184, 0.22);
  --sd-field: #070a16;
  --sd-track: rgba(30, 41, 59, 0.9);
  --sd-chip: rgba(139, 92, 246, 0.1);
  --sd-elev: #12162a;
  --sd-border: rgba(139, 92, 246, 0.28);
  --sd-primary-ink: #c4b5fd;
  --sd-danger: #fb7185;
  --sd-save: #7c3aed;
  --sd-display: "Bahnschrift", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(448px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(var(--study-vvheight, 100dvh) - 32px);
  overflow: hidden;
  border: 1px solid var(--sd-border);
  border-radius: 14px;
  background: var(--drawer-1);
  color: var(--sd-ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  /* backwards: anima a entrada e não deixa transform depois. Com "both" o último quadro (translateY(0) scale(1)) ficava
     aplicado para sempre, e o iOS não troca a palavra em digitação pela sugestão do teclado em campo dentro de transform. */
  animation: study-session-drawer-in 240ms cubic-bezier(.22, .75, .2, 1) backwards;
}

.study-session-drawer--revisao { --study-accent: #3b82f6; --study-accent-rgb: 59, 130, 246; }
.study-session-drawer--questoes { --study-accent: #e247c8; --study-accent-rgb: 226, 71, 200; }

/* Cabeçalho de uma linha: título, tipo, fechar. */
.study-session-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 6px 4px 6px 16px;
  border-bottom: 1px solid var(--sd-hair);
}
.study-session-heading { flex: 1; min-width: 0; }
.study-session-heading h2 { margin: 0; overflow: hidden; font: 650 16px/1.2 var(--sd-display); letter-spacing: 0; text-overflow: ellipsis; white-space: nowrap; }

.study-session-type {
  --study-selector-accent: var(--study-accent);
  --study-selector-accent-rgb: var(--study-accent-rgb);
  position: relative;
  flex: none;
  color: var(--sd-ink);
}

.study-session-type--teoria {
  --study-selector-accent: #22c55e;
  --study-selector-accent-rgb: 34, 197, 94;
}

.study-session-type--simulado {
  --study-selector-accent: #facc15;
  --study-selector-accent-rgb: 250, 204, 21;
}

.study-session-type-trigger {
  position: relative;
  display: inline-flex;
  max-width: 168px;
  height: 32px;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 10px;
  border: 1px solid rgba(var(--study-selector-accent-rgb), 0.6);
  border-radius: 8px;
  background: rgba(var(--study-selector-accent-rgb), 0.12);
  color: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.study-session-type-trigger::before { content: ""; position: absolute; inset: -6px -2px; }
.study-session-type-trigger:hover,
.study-session-type[data-expanded="true"] .study-session-type-trigger {
  border-color: rgba(var(--study-selector-accent-rgb), 0.9);
  background: rgba(var(--study-selector-accent-rgb), 0.2);
}
.study-session-type-trigger:focus-visible {
  outline: 2px solid rgba(var(--study-selector-accent-rgb), 0.4);
  outline-offset: 2px;
}
.study-session-type-trigger:disabled { cursor: default; opacity: 1; }
.study-session-type-icon { display: grid; flex: none; width: 16px; height: 16px; place-items: center; color: var(--study-selector-accent); }
.study-session-type-icon svg { width: 16px; height: 16px; }
.study-session-type-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.study-session-type-chevron { display: grid; flex: none; width: 14px; height: 14px; place-items: center; color: var(--sd-muted); pointer-events: none; }
.study-session-type-chevron svg { width: 14px; height: 14px; }
.study-session-type-menu {
  position: absolute;
  z-index: 12;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  min-width: 200px;
  gap: 3px;
  padding: 5px;
  border: 1px solid rgba(var(--study-selector-accent-rgb), 0.52);
  border-radius: 9px;
  background: #090d1b;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.48);
}
.study-session-type-option {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 18px;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 450;
  text-align: left;
  cursor: pointer;
}
.study-session-type-option[data-study-type="teoria"] { --study-option-accent: #22c55e; }
.study-session-type-option[data-study-type="revisao"] { --study-option-accent: #3b82f6; }
.study-session-type-option[data-study-type="questoes"] { --study-option-accent: #e247c8; }
.study-session-type-option[data-study-type="simulado"] { --study-option-accent: #facc15; }
.study-session-type-option:hover,
.study-session-type-option:focus-visible,
.study-session-type-option.is-selected {
  background: color-mix(in srgb, var(--study-option-accent), transparent 86%);
  color: #f8fafc;
}
.study-session-type-option:focus-visible { outline: 1px solid color-mix(in srgb, var(--study-option-accent), transparent 38%); }
.study-session-type-option-icon,
.study-session-type-option-check { display: grid; place-items: center; }
.study-session-type-option-icon svg { width: 20px; height: 20px; color: var(--study-option-accent); }
.study-session-type-option-check svg { width: 16px; height: 16px; color: var(--study-option-accent); }

.study-session-close {
  display: grid;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--sd-muted);
  cursor: pointer;
}
.study-session-close svg { width: 14px; height: 14px; }
.study-session-close:hover,
.study-session-close:focus-visible { color: var(--sd-ink); }
.study-session-close:focus-visible { outline: 2px solid var(--sd-border); outline-offset: -2px; }

.study-session-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 16px;
  scrollbar-width: none;
}
.study-session-body::-webkit-scrollbar { display: none; }

/* Seções separadas por linha fina, sem moldura nem fundo. */
.study-session-date,
.study-session-subject,
.study-session-section { padding: 10px 0; border-bottom: 1px solid var(--sd-hair); }
.study-session-body > :last-child { border-bottom: 0; }

/* Cartão de tempo: o "cartão-postal" do drawer, na cor do tipo; fechado mostra só o tempo. */
.study-session-time-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  margin: 12px 0 0;
  padding: 12px 14px;
  overflow: hidden;
  border: 1px solid rgba(var(--study-accent-rgb), 0.55);
  border-radius: 12px;
  background:
    radial-gradient(ellipse at 50% 135%, rgba(var(--study-accent-rgb), 0.32), transparent 62%),
    radial-gradient(circle at 20% 20%, rgba(var(--study-accent-rgb), 0.1) 0 1px, transparent 1.5px),
    linear-gradient(160deg, rgba(24, 10, 58, 0.72), rgba(7, 10, 19, 0.92));
  background-size: auto, 38px 38px, auto;
  box-shadow: inset 0 0 24px rgba(var(--study-accent-rgb), 0.1);
  text-align: center;
}
.study-session-time-card::after {
  content: "";
  position: absolute;
  top: 58%;
  right: 4%;
  left: 4%;
  height: 240%;
  border: 1px solid rgba(var(--study-accent-rgb), 0.2);
  border-radius: 50%;
  pointer-events: none;
}
.study-session-time-card > * { position: relative; z-index: 1; }
.study-session-time-label { display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--sd-text); font-weight: 650; font-size: 10.5px; line-height: 1.2; letter-spacing: .22em; text-transform: uppercase; }
.study-session-time-label svg { width: 14px; height: 14px; color: var(--study-accent); }
.study-session-time-open { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0; border: 0; background: none; color: var(--sd-ink); cursor: pointer; }
.study-session-time-open strong { font: 600 26px/1 var(--sd-display); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.study-session-time-open > span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: rgba(var(--study-accent-rgb), 0.14); color: var(--study-accent); }
.study-session-time-open > span svg { width: 14px; height: 14px; }
.study-session-time-open:focus-visible { outline: 2px solid var(--study-accent); outline-offset: 2px; border-radius: 8px; }

/* Ao editar: rodas (toque) ou campos (mouse e teclado) + atalhos + OK, dentro do próprio cartão. */
.study-session-time-edit { display: grid; justify-items: center; gap: 8px; width: 100%; padding-top: 2px; }
.study-session-wheels { display: none; grid-template-columns: repeat(2, 92px); justify-content: center; align-items: center; gap: 12px; }
.study-session-wheel-wrap { position: relative; height: 108px; }
.study-session-wheel-wrap::before { content: ""; position: absolute; top: 36px; right: 0; left: 0; height: 36px; border-radius: 8px; background: rgba(var(--study-accent-rgb), 0.16); box-shadow: inset 0 0 0 1px rgba(var(--study-accent-rgb), 0.35); pointer-events: none; }
.study-session-wheel-wrap > i { position: absolute; top: 36px; right: 10px; display: grid; height: 36px; place-items: center; color: var(--sd-muted); font-weight: 600; font-size: 12px; font-style: normal; pointer-events: none; }
.study-session-wheel {
  position: relative;
  height: 108px;
  padding-block: 36px;
  overflow-y: auto;
  border-radius: 8px;
  outline: 0;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
  mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
}
.study-session-wheel::-webkit-scrollbar { display: none; }
.study-session-wheel:focus-visible { box-shadow: 0 0 0 2px var(--study-accent); }
.study-session-wheel b { display: grid; place-items: center; height: 36px; padding-right: 26px; color: var(--sd-muted); font: 500 20px var(--sd-display); font-variant-numeric: tabular-nums; scroll-snap-align: center; }
.study-session-wheel b.on { color: var(--sd-ink); font-weight: 650; }
.study-session-typein { display: flex; align-items: center; justify-content: center; gap: 8px; }
.study-session-num { display: inline-flex; width: auto; height: 44px; align-items: baseline; gap: 4px; padding: 0 10px; border: 1px solid var(--sd-line); border-radius: 9px; background: var(--sd-field); cursor: text; }
.study-session-num:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }
.study-session-drawer .study-session-num input,
.study-session-drawer .study-session-num input:focus { width: 3ch; height: 42px; padding: 0; border: 0; outline: 0; background: none; box-shadow: none; color: var(--sd-ink); font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; text-align: right; }
.study-session-num span { color: var(--sd-muted); font-size: 12.5px; font-weight: 400; }
.study-session-time-quick { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 10px; padding-bottom: 2px; }
.study-session-time-chips { display: inline-flex; gap: 4px; }
.study-session-time-chip { position: relative; min-width: 36px; height: 32px; padding: 0 7px; border: 1px solid rgba(var(--study-accent-rgb), 0.35); border-radius: 8px; background: rgba(var(--study-accent-rgb), 0.06); color: var(--sd-text); font-weight: 600; font-size: 12.5px; font-variant-numeric: tabular-nums; cursor: pointer; }
.study-session-time-chip::before { content: ""; position: absolute; inset: -6px -3px; }
.study-session-time-chip[aria-pressed="true"] { border-color: var(--study-accent); background: rgba(var(--study-accent-rgb), 0.2); color: var(--sd-ink); }
.study-session-time-ok { height: 44px; padding: 0 16px; border: 0; border-radius: 9px; background: var(--study-accent); color: #fff; font-weight: 650; font-size: 13.5px; cursor: pointer; }
.study-session-keyhint { margin: 0; color: var(--sd-faint); font-size: 11px; }
.study-session-keyhint kbd { padding: 1px 5px; border: 1px solid var(--sd-line); border-radius: 4px; color: var(--sd-text); font-weight: 600; font-size: 10.5px; }
/* Toque (celular e tablet): rodas, sem teclado. Mouse e teclado: campos de horas e minutos. */
@media (pointer: coarse) {
  .study-session-wheels { display: grid; }
  .study-session-typein,
  .study-session-keyhint { display: none; }
}

/* Data: segmentado; o campo de data só aparece em "Outro dia". */
.study-session-date { display: grid; gap: 8px; }
.study-session-date-presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 3px; border-radius: 10px; background: var(--sd-track); }
.study-session-date-presets button { position: relative; height: 34px; border: 0; border-radius: 8px; background: none; color: var(--sd-muted); font-weight: 600; font-size: 12.5px; cursor: pointer; }
.study-session-date-presets button::before { content: ""; position: absolute; inset: -5px 0; }
.study-session-date-presets button.active { background: var(--sd-elev); color: var(--sd-ink); box-shadow: 0 0 0 1px var(--sd-border); }
.study-session-date-input { position: relative; display: none; }
.study-session-date-input.active { display: block; }
.study-session-date-value { display: none; pointer-events: none; }
.study-session-drawer .study-session-date-input input { display: block; box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; height: 44px; min-height: 44px; margin: 0; padding: 0 12px; border: 1px solid var(--sd-line); border-radius: 9px; background: var(--sd-field); color: var(--sd-ink); font-size: 16px; line-height: normal; text-align: center; -webkit-appearance: none; appearance: none; }
.study-session-drawer .study-session-date-input input::-webkit-date-and-time-value { width: 100%; margin: 0; min-height: 1.4em; text-align: center; }
.study-session-drawer .study-session-date-input input::-webkit-datetime-edit { display: inline-flex; justify-content: center; width: 100%; padding: 0; }
/* No toque, o texto central independe da caixa interna do iOS; o input mantém foco e calendário nativos. */
@media (pointer: coarse) {
  .study-session-date-value { display: grid; place-items: center; box-sizing: border-box; height: 44px; border: 1px solid var(--sd-line); border-radius: 9px; background: var(--sd-field); color: var(--sd-ink); font-size: 16px; }
  .study-session-drawer .study-session-date-input input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
  .study-session-date-input:focus-within .study-session-date-value { border-color: var(--primary); outline: 2px solid var(--primary); outline-offset: 2px; }
}

/* Assunto: busca de disciplina; "Tópico ou subtópico" só depois de escolhida (campo desabilitado = escondido). */
.study-session-subject { display: grid; gap: 8px; }
.study-session-subject.is-searching { position: relative; z-index: 4; }
.study-session-subject-search { position: relative; z-index: 1; display: grid; gap: 8px; min-width: 0; isolation: isolate; }
.study-session-search-group { position: relative; }
.study-session-search-group:has(input:disabled) { display: none; }
.study-session-search-field { display: flex; height: 44px; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--sd-line); border-radius: 9px; background: var(--sd-field); color: var(--sd-muted); font-weight: 400; }
.study-session-search-field:focus-within { border-color: var(--primary); }
.study-session-search-field svg { flex: none; width: 14px; height: 14px; }
.study-session-search-field input { flex: 1; min-width: 0; height: 42px; padding: 0; border: 0; outline: 0; background: transparent; color: var(--sd-ink); font-size: 16px; }
.study-session-search-field input::placeholder { color: var(--sd-faint); }
.study-session-search-field input:disabled { opacity: .45; }

/* O contorno de foco pertence ao wrapper, não aos controles internos. */
.study-session-drawer .study-session-date-input input:focus,
.study-session-drawer .study-session-date-input input:focus-visible,
.study-session-drawer .study-session-search-field input:focus,
.study-session-drawer .study-session-search-field input:focus-visible {
  outline: 0;
  box-shadow: none;
}
.study-session-drawer .study-session-search-field input:focus,
.study-session-drawer .study-session-search-field input:focus-visible { border: 0; }
.study-session-drawer .study-session-date-input input:focus { border-color: var(--primary); }

.study-session-search-results { position: absolute; z-index: 12; top: calc(100% + 4px); right: 0; left: 0; max-height: 220px; overflow-y: auto; padding: 6px; border: 1px solid rgba(139, 92, 246, .34); border-radius: 9px; background: #090d1b; box-shadow: 0 18px 42px rgba(0,0,0,.48); }
.study-session-search-results button { display: grid; width: 100%; gap: 2px; padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; color: #f8fafc; text-align: left; cursor: pointer; }
.study-session-search-results button:hover,
.study-session-search-results button:focus-visible { background: rgba(139, 92, 246, .14); }
.study-session-search-results button span { color: #94a3b8; font-size: 11px; }
.study-session-search-empty { padding: 10px; color: #94a3b8; font-size: 12px; }

.study-session-subject-selected { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 8px 10px; min-width: 0; }
.study-session-subject.is-searching .study-session-subject-selected { display: none; }
.study-session-subject.is-selected .study-session-subject-search { display: none; }
.study-session-subject-copy { grid-column: 1; grid-row: 1; min-width: 0; }
.study-session-subject-copy strong { display: block; color: var(--sd-ink); font-weight: 650; font-size: 13.5px; line-height: 1.3; }
.study-session-subject-copy span {
  display: -webkit-box;
  margin-top: 2px;
  overflow: hidden;
  color: var(--sd-muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
/* Os controles da direita passam a ser itens da grade do bloco: "Alterar" ao lado do título, "Concluir teoria" abaixo. */
.study-session-subject-actions { display: contents; }
.study-session-change-subject { position: relative; grid-column: 2; grid-row: 1; padding: 0; border: 0; background: none; color: var(--sd-primary-ink); font-weight: 600; font-size: 12px; cursor: pointer; }
.study-session-change-subject::before { content: ""; position: absolute; inset: -14px -10px; }
.study-session-theory-done { grid-column: 1 / -1; grid-row: 2; position: relative; display: inline-flex; width: fit-content; min-height: 32px; align-items: center; gap: 8px; color: var(--sd-text); font-size: 13px; font-weight: 400; cursor: pointer; }
.study-session-theory-done::before { content: ""; position: absolute; inset: -6px -4px; }
.study-session-theory-done input,
.study-session-check input,
.study-session-review-options input,
.study-session-mood-options input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.study-session-theory-done i,
.study-session-check i,
.study-session-review-options i { display: grid; flex: none; width: 18px; height: 18px; place-items: center; border: 1.5px solid var(--sd-line); border-radius: 5px; background: var(--sd-field); color: transparent; }
.study-session-theory-done input:checked + i,
.study-session-check input:checked + i,
.study-session-review-options input:checked + i { border-color: var(--primary); background: var(--primary); color: #fff; }
.study-session-theory-done input:focus-visible + i,
.study-session-check input:focus-visible + i,
.study-session-review-options input:focus-visible + i { outline: 2px solid var(--primary); outline-offset: 2px; }
.study-session-theory-done i svg,
.study-session-check i svg,
.study-session-review-options i svg { width: 12px; height: 12px; }

/* Questões: sem título; Respondidas e Acertos lado a lado, com a linha de erros por baixo. */
.study-session-questions { display: grid; gap: 8px; }
.study-session-question-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.study-session-question-grid label { display: grid; gap: 4px; color: var(--sd-text); font-size: 12px; font-weight: 400; }
.study-session-question-grid label > span { display: block; color: var(--sd-text); font-size: 12px; font-weight: 400; }
.study-session-drawer .study-session-question-grid input { width: 100%; height: 44px; margin: 0; padding: 0 10px; border: 1px solid var(--sd-line); border-radius: 9px; background: var(--sd-field); color: var(--sd-ink); font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; text-align: left; }
.study-session-drawer .study-session-question-grid input:focus { border-color: var(--primary); outline: 0; box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }
.study-session-question-result { min-height: 0; margin: 0; color: var(--sd-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.study-session-question-result.invalid { color: var(--sd-danger); }

/* Revisões: "Criar revisões" + os três ciclos em linha, sem título. */
.study-session-reviews { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.study-session-review-main { display: flex; align-items: center; }
.study-session-check { position: relative; display: inline-flex; width: fit-content; min-height: 32px; align-items: center; gap: 8px; color: var(--sd-text); font-size: 13px; font-weight: 400; cursor: pointer; }
.study-session-check::before { content: ""; position: absolute; inset: -6px -4px; }
.study-session-review-options { display: inline-flex; gap: 6px; }
.study-session-review-options label { position: relative; display: inline-flex; height: 32px; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid var(--sd-line); border-radius: 8px; color: var(--sd-text); font-weight: 600; font-size: 12.5px; cursor: pointer; }
.study-session-review-options label::before { content: ""; position: absolute; inset: -6px -3px; }
.study-session-review-options label:has(input:checked) { border-color: var(--primary); background: var(--sd-chip); color: var(--sd-primary-ink); }
/* A cycle turned off in Configurações: visibly inert, with a line saying why (spans the whole row). */
.study-session-review-options label.is-disabled { opacity: .45; cursor: not-allowed; }
.study-session-review-options label.is-disabled input { cursor: not-allowed; }
.study-session-review-hint { flex-basis: 100%; margin: 0; color: var(--sd-muted); font-size: 11px; line-height: 1.4; }

/* Como foi: o rótulo à esquerda e as cinco carinhas à direita. */
.study-session-mood { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.study-session-section h3 { margin: 0; color: var(--sd-muted); font-weight: 650; font-size: 10.5px; line-height: 1.2; letter-spacing: .07em; text-transform: uppercase; }
.study-session-mood-options { display: flex; }
.study-session-mood-options label { position: relative; display: grid; width: 44px; height: 44px; place-items: center; color: var(--sd-faint); cursor: pointer; }
.study-session-mood-options label.mood-terrible { --c: #f43f5e; }
.study-session-mood-options label.mood-bad { --c: #fb923c; }
.study-session-mood-options label.mood-neutral { --c: #facc15; }
.study-session-mood-options label.mood-good { --c: #84cc16; }
.study-session-mood-options label.mood-great { --c: #2dd4bf; }
.study-session-mood-options label:hover { color: var(--c); }
.study-session-mood-options label:has(input:checked) { color: var(--c); }
.study-session-mood-options label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: -4px; border-radius: 10px; }
.study-session-mood-options i { display: grid; width: 28px; height: 28px; place-items: center; }
.study-session-mood-options svg { width: 28px; height: 28px; }
.study-session-mood-options label:has(input:checked) svg { stroke-width: 2; }

/* Observações: uma linha, cresce se precisar. */
.study-session-notes { display: grid; gap: 8px; }
.study-session-notes label { display: grid; gap: 8px; min-width: 0; font-weight: 400; }
.study-session-notes label > span { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0; color: var(--sd-muted); font-weight: 650; font-size: 10.5px; line-height: 1.2; letter-spacing: .07em; text-transform: uppercase; }
.study-session-notes label small { color: var(--sd-faint); font-weight: 400; font-size: 11px; letter-spacing: 0; text-transform: none; }
.study-session-drawer .study-session-notes textarea { width: 100%; min-height: 44px; max-height: 168px; padding: 10px 12px; border: 1px solid var(--sd-line); border-radius: 9px; background: var(--sd-field); color: var(--sd-ink); font-size: 16px; line-height: 1.4; resize: none; overflow-y: auto; }
.study-session-drawer .study-session-notes textarea::placeholder { color: var(--sd-faint); }
.study-session-drawer .study-session-notes textarea:focus { border-color: var(--primary); outline: 0; box-shadow: none; }

/* Rodapé fixo: Salvar sempre visível (o corpo é que rola). */
.study-session-footer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--sd-hair); background: var(--drawer-1); }
.study-session-footer button { min-height: 48px; border-radius: 10px; font-size: 14px; font-weight: 650; transition: border-color 160ms ease, background 160ms ease, color 160ms ease, filter 160ms ease; }
.study-session-footer .ghost { border: 1px solid var(--sd-line); background: none; color: var(--sd-text); }
.study-session-footer .primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: var(--sd-save); box-shadow: none; color: #fff; }
.study-session-footer .primary svg { flex: none; width: 18px; height: 18px; }
.study-session-footer .ghost:hover,
.study-session-footer .ghost:focus-visible { border-color: rgba(139, 92, 246, 0.5); background: rgba(139, 92, 246, 0.1); color: var(--sd-ink); }
.study-session-footer .primary:hover,
.study-session-footer .primary:focus-visible { filter: brightness(1.08); }

.study-session-drawer--revisao [data-study-theory-done],
.study-session-drawer--questoes [data-study-theory-done],
.study-session-drawer--simulado [data-study-theory-done] { display: none; }

/* Editing a review log has no reviews to create. Editing a theory log must show them: the save path reconciles the
   pending reviews with these checkboxes (unchecked pending ones are dropped, missing ones are created, done ones stay).
   Correção (2026-10-02, achado do dono): a regra vale só enquanto o registro editado continua revisão; trocado para
   teoria no próprio drawer, as opções de revisão voltam, como em qualquer teoria. */
.study-session-drawer--revisao[data-study-context="edit-review"] .study-session-reviews { display: none; }

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

@keyframes study-session-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes study-session-drawer-in { from { opacity: 0; transform: translateY(20px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes study-session-subject-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.study-session-subject.is-selected .study-session-subject-selected,
.study-session-subject.is-searching .study-session-subject-search { animation: study-session-subject-in 220ms ease-out backwards; }

@media (prefers-reduced-motion: reduce) {
  .study-session-backdrop,
  .study-session-drawer,
  .study-session-subject.is-selected .study-session-subject-selected,
  .study-session-subject.is-searching .study-session-subject-search { animation: none !important; }
}

/* Celular (largura): ancorado no alto, quase a largura toda. A largura não decide rodas × campos: isso é o ponteiro. */
@media (max-width: 760px) {
  .study-session-backdrop { padding: calc(8px + var(--study-vvtop, 0px)) 8px calc(8px + var(--study-vvbottom, 0px)); place-items: start center; }
  .study-session-drawer {
    width: min(448px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
    max-height: calc(var(--study-vvheight, 100dvh) - 16px);
  }
}
@media (max-width: 340px) {
  .study-session-heading h2 { font-size: 14.5px; }
  .study-session-type-trigger { padding: 0 6px 0 8px; font-size: 12px; }
  .study-session-body { padding: 0 12px; }
  .study-session-footer { padding-inline: 12px; }
  .study-session-mood-options label { width: 40px; }
}

/* Toque: alvos de pelo menos 44 px de verdade (no mouse o alvo compacto ganha área extra por ::before). */
@media (pointer: coarse) {
  .study-session-type-trigger,
  .study-session-time-chip,
  .study-session-date-presets button,
  .study-session-theory-done,
  .study-session-check,
  .study-session-review-options label { min-height: 44px; height: auto; }
  .study-session-time-chip { min-width: 44px; }
  .study-session-change-subject { min-height: 44px; }
  .study-session-type-trigger::before,
  .study-session-time-chip::before,
  .study-session-date-presets button::before,
  .study-session-theory-done::before,
  .study-session-check::before,
  .study-session-review-options label::before,
  .study-session-change-subject::before { display: none; }
}

/* ==========================================================================
   Tema claro — Drawer de sessão (registrar / editar estudo)
   Escopado em html[data-theme="light"]; o tema escuro não é afetado. Só cor, via tokens de design-system.css e as
   variáveis locais --sd-*. O acento por tipo (--study-accent-rgb) continua valendo nos dois temas.
   ========================================================================== */
html[data-theme="light"] .study-session-backdrop { background: var(--drawer-backdrop); }
html[data-theme="light"] .study-session-drawer {
  --sd-hair: rgba(57, 44, 89, 0.12);
  --sd-line: rgba(57, 44, 89, 0.2);
  --sd-field: #ffffff;
  --sd-track: rgba(57, 44, 89, 0.1);
  --sd-chip: rgba(124, 58, 237, 0.08);
  --sd-elev: #ffffff;
  --sd-border: rgba(124, 58, 237, 0.3);
  --sd-primary-ink: #6d28d9;
  --sd-danger: var(--danger);
  --sd-save: #6d28d9;
  box-shadow: 0 30px 80px rgba(57, 44, 89, 0.26);
}
html[data-theme="light"] .study-session-type-trigger { background: rgba(var(--study-selector-accent-rgb), 0.12); }
html[data-theme="light"] .study-session-type-menu { background: var(--panel); box-shadow: 0 18px 38px rgba(57, 44, 89, 0.2); }
html[data-theme="light"] .study-session-type-option { color: var(--text-secondary); }
html[data-theme="light"] .study-session-type-option:hover,
html[data-theme="light"] .study-session-type-option:focus-visible,
html[data-theme="light"] .study-session-type-option.is-selected { color: var(--ink); }

/* Cartão de tempo */
html[data-theme="light"] .study-session-time-card {
  border-color: rgba(var(--study-accent-rgb), 0.42);
  background:
    radial-gradient(ellipse at 50% 135%, rgba(var(--study-accent-rgb), 0.18), transparent 62%),
    linear-gradient(145deg, #ffffff, rgba(var(--study-accent-rgb), 0.06));
  box-shadow: none;
}
html[data-theme="light"] .study-session-time-card::after { border-color: rgba(var(--study-accent-rgb), 0.16); }

html[data-theme="light"] .study-session-search-results { border-color: var(--card-border); background: var(--panel); box-shadow: 0 18px 38px rgba(57, 44, 89, 0.2); }
html[data-theme="light"] .study-session-search-results button { color: var(--ink); }
html[data-theme="light"] .study-session-search-results button span,
html[data-theme="light"] .study-session-search-empty { color: var(--muted); }
html[data-theme="light"] .study-session-search-results button:hover,
html[data-theme="light"] .study-session-search-results button:focus-visible { background: var(--primary-2); }
/* CL-01 (BC-1): o estado marcado precisa vir depois do fundo claro das caixas, com o mesmo peso. */
html[data-theme="light"] .study-session-theory-done i,
html[data-theme="light"] .study-session-check i,
html[data-theme="light"] .study-session-review-options i { border-color: rgba(124, 58, 237, 0.4); background: var(--input-bg); }
html[data-theme="light"] .study-session-theory-done input:checked + i,
html[data-theme="light"] .study-session-check input:checked + i,
html[data-theme="light"] .study-session-review-options input:checked + i { border-color: var(--primary); background: var(--primary); color: #fff; }
html[data-theme="light"] .study-session-question-grid label > span svg { color: var(--primary); }
html[data-theme="light"] .study-session-footer { background: var(--drawer-footer-bg); }
html[data-theme="light"] .study-session-footer .ghost:hover,
html[data-theme="light"] .study-session-footer .ghost:focus-visible { border-color: rgba(124, 58, 237, 0.5); background: var(--primary-2); color: var(--primary); }

/* Saving feedback: a spinner in the button while the save and re-render run. A faixa que percorria o topo do drawer
   saiu (pedido do dono em 2026-10-02): parecia defeito e repetia o "Salvando…" do botão. */
.study-session-drawer.is-saving { position: relative; }
.study-session-drawer.is-saving > :not(.study-session-footer) { pointer-events: none; }
.study-session-footer .primary:disabled { cursor: progress; opacity: 1; filter: none; transform: none; }
.study-session-saving-spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.28); border-top-color: #fff; border-radius: 50%;
  animation: study-session-saving-spin 640ms linear infinite;
}
@keyframes study-session-saving-spin { to { transform: rotate(360deg); } }

/* Success hand-off: the bar completes and turns green, the button resolves into a drawn checkmark with a soft
   ring pulse, then the drawer settles away — the moment the student's data lands gets its own small celebration
   before the confirmation continues in the status toast (renderStatus's notice-rich). */
.study-session-drawer.is-saved { position: relative; }
.study-session-drawer.is-saved::before {
  content: ""; position: absolute; top: 0; left: 0; z-index: 3; height: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, #22c55e, #4ade80); box-shadow: 0 0 14px rgba(74, 222, 128, .6);
  animation: study-session-saved-bar 620ms ease both;
}
.study-session-drawer.is-saved { box-shadow: 0 0 0 1px rgba(74, 222, 128, .32), 0 0 40px rgba(74, 222, 128, .16), 0 30px 90px rgba(0, 0, 0, .58); transition: box-shadow 260ms ease; }
.study-session-footer .primary.is-saved-state { background: linear-gradient(100deg, #16a34a, #15803d 60%, #059669); box-shadow: 0 0 22px rgba(34, 197, 94, .3); }
.study-session-footer .primary.is-saved-state:disabled { cursor: default; opacity: 1; filter: none; }
.study-session-success-check { position: relative; display: inline-grid; place-items: center; width: 20px; height: 20px; }
.study-session-success-check svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.study-session-success-check svg path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: study-session-check-draw 320ms 60ms cubic-bezier(.65, 0, .35, 1) forwards; }
.study-session-success-check::after {
  content: ""; position: absolute; inset: -9px; border: 1.5px solid rgba(74, 222, 128, .65); border-radius: 50%;
  animation: study-session-check-ring 560ms ease-out 60ms both;
}
.study-session-backdrop--closing { animation: study-session-backdrop-out 200ms ease-in both; }
.study-session-drawer--closing { animation: study-session-drawer-out 210ms cubic-bezier(.4, 0, 1, 1) both; pointer-events: none; }
@keyframes study-session-saved-bar { from { width: 0; } to { width: 100%; } }
@keyframes study-session-check-draw { to { stroke-dashoffset: 0; } }
@keyframes study-session-check-ring { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.55); opacity: 0; } }
@keyframes study-session-backdrop-out { to { opacity: 0; } }
@keyframes study-session-drawer-out { to { opacity: 0; transform: translateY(-10px) scale(.97); } }
@media (prefers-reduced-motion: reduce) {
  .study-session-saving-spinner { animation-duration: 1.6s; }
  .study-session-drawer.is-saved::before { width: 100%; animation: none; }
  .study-session-success-check svg path { animation: none; stroke-dashoffset: 0; }
  .study-session-success-check::after { animation: none; opacity: 0; }
  .study-session-backdrop--closing, .study-session-drawer--closing { animation: none; opacity: 0; }
}

/* Categorias personalizadas de sessão (work/custom-session-categories-mvp-spec-2026-09-27.md). */
.study-session-type-separator { height: 1px; margin: 3px 4px; background: rgba(148, 163, 184, 0.18); }
.study-session-type-option--new { --study-option-accent: #94a3b8; }
html[data-theme="light"] .study-session-type-separator { background: rgba(15, 23, 42, 0.1); }

/* Mini drawer de criar/editar categoria: empilha sobre o drawer de sessão (ou aparece sozinho, a partir de
   Configurações). Reaproveita .modal-backdrop/.modal (styles.css) como base pro visual (cartão, borda, sombra),
   mas precisa VENCER o z-index genérico — e não só o de .modal-backdrop (uma classe, especificidade 0,1,0):
   quando o drawer pai foi aberto com `document.body.classList.add("focus-registering")` (ex.: openFreeStudyModal),
   `body.focus-registering .modal-backdrop { z-index: 45; }` (styles.css) empata em especificidade (0,2,0) com um
   seletor de duas classes, e como styles.css carrega depois deste arquivo, essa regra vencia o empate — medido no
   navegador: mini drawer em z-index 45 atrás do drawer de sessão (128), parecendo que o clique não fazia nada.
   `!important` evita depender de future novas regras de estado do body com a mesma especificidade. */
.study-session-new-category-backdrop { z-index: calc(var(--z-drawer) + 16) !important; }
.modal.study-session-new-category-modal { width: min(380px, 100%); display: grid; gap: 12px; }
.study-session-new-category-modal h2 { margin: 0; font-size: 17px; }
.free-category-field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.free-category-field input[type="text"],
.free-category-field select { padding: 9px 11px; border-radius: 8px; border: 1px solid var(--card-border); background: var(--surface-soft); color: var(--ink); font-size: 14px; }
.free-category-error { margin: 0; color: #f87171; font-size: 13px; }
.free-category-locked-type { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--surface-soft); color: var(--ink); }
.free-category-locked-type svg { width: 18px; height: 18px; }

/* Computador (mouse e teclado) com altura de sobra: o drawer fica ~15% maior, na mesma proporção (o zoom escala largura,
   texto e espaçamentos juntos). O teto de altura é dividido pelo zoom para o Salvar continuar visível. */
@media (pointer: fine) and (min-width: 901px) and (min-height: 800px) {
  .study-session-drawer {
    zoom: 1.15;
    max-height: calc((100vh - 32px) / 1.15);
    max-height: calc((var(--study-vvheight, 100dvh) - 32px) / 1.15);
  }

  /* Cancelar e Salvar mantêm a altura e o texto de antes (48 px, 14 px): só a largura acompanha o drawer. */
  .study-session-footer button { min-height: calc(48px / 1.15); font-size: calc(14px / 1.15); }
  .study-session-footer .primary svg { width: calc(18px / 1.15); height: calc(18px / 1.15); }
}

/* Resultados da busca de disciplina e de assunto: letra menor e mais leve que a do campo (o campo fica com 16 px por
   causa do zoom do iOS; a lista não é campo, então pode ser menor no celular e no computador). */
.study-session-search-results button strong { font-size: 13px; font-weight: 600; line-height: 1.3; }
.study-session-search-results button span { font-size: 10.5px; line-height: 1.35; }

/* O rodapé permanece no layout: removê-lo ao focar mudava a altura antes de o teclado abrir. */
.study-session-drawer.is-typing .study-session-search-results { max-height: clamp(160px, calc(var(--study-vvheight, 640px) - 190px), 420px); }

/* Ao fechar teclado/calendário, cresce suavemente; ao abrir, respeita a área visível sem atraso. */
@media (pointer: coarse) and (prefers-reduced-motion: no-preference) {
  .study-session-drawer.is-viewport-expanding:not(.is-saved) { transition: max-height 140ms ease-out; }
}
