/* Atlas Clínico — chat (referência: apps da Apple)
   Mobile-first. Tokens no app.css; claro é o padrão (html[data-theme="light"]).
   Barras translúcidas, balões no estilo do iMessage, listas agrupadas, seletor de segmento. */

:root {
  --side-bg: #161617;
  --side-line: #2c2c2e;
  --main-bg: #000000;
  --seg-bg: #2c2c2e;
  --seg-on: #636366;
  --field-bg: #1c1c1e;
  --field-line: #38383a;
  --plus-bg: #2c2c2e;
  --group-bg: #1c1c1e;
  --row-line: #38383a;
  --sel-bg: #2c2c2e;
  --switch-off: #39393d;
  --switch-on: #30d158;
  --offline-bg: #2b2412;
  --offline-ink: #ff9f0a;
  /* o vermelho do botão com texto branco, nos dois temas: o --danger do escuro (#ff453a) dá 3,4:1 com o branco (axe-core;
     o AA pede 4,5:1) */
  --danger-botao: #d70015;

  /* ícones de estado (copiado, parar, certo/errado, abrir) */
  --ico-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  --ico-stop: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='7' y='7' width='10' height='10' rx='2' fill='black'/%3E%3C/svg%3E");
  --ico-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M7 7l10 10M17 7L7 17'/%3E%3C/svg%3E");
  --ico-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E");
  --ico-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='%23000'%3E%3Crect x='9.4' y='1' width='5.2' height='22' rx='2.6'/%3E%3Crect x='9.4' y='1' width='5.2' height='22' rx='2.6' transform='rotate(60 12 12)'/%3E%3Crect x='9.4' y='1' width='5.2' height='22' rx='2.6' transform='rotate(120 12 12)'/%3E%3C/g%3E%3C/svg%3E");
}

html[data-theme="light"] {
  --side-bg: #f5f5f7;
  --side-line: #e5e5ea;
  --main-bg: #ffffff;
  --seg-bg: #ececf0;
  --seg-on: #ffffff;
  --field-bg: #ffffff;
  --field-line: #d2d2d7;
  --plus-bg: #ececf0;
  --group-bg: #f5f5f7;
  --row-line: #e5e5ea;
  --sel-bg: #e3e3e8;
  --switch-off: #e9e9ea;
  --switch-on: #34c759;
  --offline-bg: #fff4e5;
  --offline-ink: #b25000;
}

body { background: var(--main-bg); }

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------------------------------------------------------- menu lateral (celular: gaveta) */

#sidebar {
  position: fixed;
  z-index: 50;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(86vw, 320px);
  display: flex;
  flex-direction: column;
  padding: calc(var(--s3) + env(safe-area-inset-top, 0px)) var(--s3) calc(var(--s3) + env(safe-area-inset-bottom, 0px)) calc(var(--s3) + env(safe-area-inset-left, 0px));
  background: var(--side-bg);
  border-right: 1px solid var(--side-line);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform var(--t-slow), visibility 0s linear .32s;
}
#sidebar.open {
  transform: none;
  visibility: visible;
  box-shadow: var(--shadow);
  transition: transform var(--t-slow);
}

#overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--overlay);
  transition: opacity .25s ease;
}
@starting-style {
  #overlay { opacity: 0; }
}

.sb-topo { display: flex; flex-direction: column; gap: var(--s3); }

.sb-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  min-height: 44px;
  padding-left: 8px;
}
#sidebar .logo { font-size: 18px; }

.sb-acoes {
  display: flex;
  flex-direction: column;
  padding: 4px;
  border-radius: var(--r);
  background: var(--panel);
}
html[data-theme="light"] .sb-acoes { box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }

.sb-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 10px 0 8px;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  transition: background-color var(--t);
}
.sb-item:hover { background: var(--hover); }
.sb-item + .sb-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 48px;
  right: 8px;
  height: 1px;
  background: var(--row-line);
}

/* quadradinho colorido com ícone, como nos Ajustes do iPhone */
.sb-tile {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 7px;
  color: #ffffff;
}
.sb-tile-azul { background: linear-gradient(160deg, #47a6ff, #0a6ce3); }
.sb-tile-laranja { background: linear-gradient(160deg, #ffb340, #ff8a00); }
.sb-tile-verde { background: linear-gradient(160deg, #4cd964, #28b446); }
.sb-tile-roxo { background: linear-gradient(160deg, #c27cf0, #9a3fd6); }
.sb-tile-ciano { background: linear-gradient(160deg, #3fd6e6, #0a8fb8); }
a.sb-item { text-decoration: none; }

.sb-label {
  margin: var(--s6) 10px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

#chatList {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 -4px;
  padding: 0 4px var(--s2);
}

/* item: título; à direita a data, que dá lugar à lixeira no hover/foco */
.chat-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s2);
  min-height: 40px;
  padding: 4px 4px 4px 10px;
  border-radius: var(--r-sm);
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--t);
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--sel-bg); }
.chat-item:focus-visible { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: -3px; }

.chat-item .title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 15px;
  line-height: 20px;
}
.chat-item.active .title { font-weight: 600; }

.chat-item .time,
.chat-item .del { grid-column: 2; grid-row: 1; }

.chat-item .time {
  pointer-events: none;
  padding-right: 6px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: opacity var(--t);
}

.chat-item .del {
  position: relative;
  z-index: 1;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  border-radius: var(--r-sm);
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t), color var(--t), background-color var(--t);
}
.chat-item .del:hover { color: var(--danger); background: var(--danger-soft); }

.chat-item:hover .del,
.chat-item:focus-within .del,
.chat-item.active .del { opacity: 1; pointer-events: auto; }
.chat-item:hover .time,
.chat-item:focus-within .time,
.chat-item.active .time { opacity: 0; }

.sb-rodape {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--s3) 4px 0 6px;
  border-top: 1px solid var(--side-line);
}
.sb-avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #a6a6ab, #85858a);
  color: #ffffff;
  overflow: hidden;
}
.sb-avatar svg { width: 28px; height: 28px; margin-top: 10px; }
.sb-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-info {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
  color: var(--text);
}
.user-info:hover { color: var(--accent); }
.sb-sub { font-size: 13px; line-height: 18px; color: var(--muted); }

.link-sair {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: 15px;
  color: var(--accent);
  transition: background-color var(--t);
}
.link-sair:hover { background: var(--hover); }

/* ---------------------------------------------------------- menu: conversas por data, busca e rodapé
   As conversas aparecem em seções (Hoje, Ontem, 7 dias, 30 dias, mais antigas); a busca surge
   quando a lista passa de cinco; um ícone discreto marca as conversas em modo especial. */
#sidebar #lblConversas {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.sb-busca { margin: 16px 0 2px; }
.sb-busca[hidden] { display: none; }
.sb-busca .input {
  height: 38px;
  min-height: 38px;
  padding: 0 12px 0 36px;
  border: 0;
  border-radius: 11px;
  background: var(--seg-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.3' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5L20 20'/%3E%3C/svg%3E") no-repeat 11px center / 17px;
  font-size: 16px;
  box-shadow: none;
}
.sb-busca .input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.sb-busca .input::-webkit-search-cancel-button { cursor: pointer; }
.sb-sec {
  margin: 14px 10px 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
#chatList > .sb-sec:first-child { margin-top: 18px; }
.sb-busca:not([hidden]) + #chatList > .sb-sec:first-child { margin-top: 12px; }
.sb-vazio { margin: 18px 10px 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.chat-item:not(.ci-hoje) .time { display: none; }
.ci-modo {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 7px;
  vertical-align: -2px;
  background: var(--muted);
  -webkit-mask: var(--ci-ico) center / contain no-repeat;
          mask: var(--ci-ico) center / contain no-repeat;
}
.ci-paciente {
  background: #30b0c7;
  --ci-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='7.6' r='4.2'/%3E%3Cpath d='M3.6 21c1.2-4.6 4.6-7.2 8.4-7.2s7.2 2.6 8.4 7.2z'/%3E%3C/svg%3E");
}
.ci-documento {
  --ci-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3.5h8.5L19 8v12.5H6z'/%3E%3Cpath d='M14 3.5V8.5h5'/%3E%3Cpath d='M9 12.5h7M9 16h5'/%3E%3C/svg%3E");
}
.ci-raciocinio {
  --ci-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 21h4'/%3E%3Cpath d='M12 3a6 6 0 0 0-3.6 10.8c.6.5 1 1.2 1.1 2V16h5v-.2c.1-.8.5-1.5 1.1-2A6 6 0 0 0 12 3z'/%3E%3C/svg%3E");
}
.ci-plantao {
  --ci-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M13.2 2.5L4.5 13.4h6.2L9.8 21.5l8.7-10.9h-6.2z'/%3E%3C/svg%3E");
}

/* rodapé: iniciais no avatar, sair discreto e o convite com ícone */
.sb-avatar.tem-iniciais {
  background: linear-gradient(160deg, #64d2ff, #0a84ff);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  color: #ffffff;
}
#sidebar .link-sair { color: var(--muted); }
#sidebar .sb-ref { gap: 6px; }
#sidebar .sb-ref-lab { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#sidebar .sb-ref-btn { padding: 0 8px; }
#sidebar .link-sair:hover { color: var(--danger); }
.sb-ref-ico {
  flex: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='8' width='17' height='4' rx='1'/%3E%3Cpath d='M5 12v8.5h14V12'/%3E%3Cpath d='M12 8v12.5'/%3E%3Cpath d='M12 8c-1.2-3-5-3.6-5-1.2C7 8 9.2 8 12 8zM12 8c1.2-3 5-3.6 5-1.2C17 8 14.8 8 12 8z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='8' width='17' height='4' rx='1'/%3E%3Cpath d='M5 12v8.5h14V12'/%3E%3Cpath d='M12 8v12.5'/%3E%3Cpath d='M12 8c-1.2-3-5-3.6-5-1.2C7 8 9.2 8 12 8zM12 8c1.2-3 5-3.6 5-1.2C17 8 14.8 8 12 8z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------------------------------------------------------- área principal */

#main {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--main-bg);
}

/* barra de cima: translúcida, com o modo no meio */
#topbar {
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 52px;
  padding: env(safe-area-inset-top, 0px) calc(var(--s2) + env(safe-area-inset-right, 0px)) 0 calc(var(--s2) + env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--side-line);
}

.topbar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  color: var(--accent);
  transition: background-color var(--t), opacity var(--t);
}
.topbar-icon:hover { background: var(--hover); }
.topbar-icon:active { opacity: .5; }
#sidebar .topbar-icon { color: var(--muted); }

#btnMenu { justify-self: start; }

.tb-modo { grid-column: 2; min-width: 0; }

/* o modo da conversa como seletor discreto (no Chrome novo vira menu no estilo iOS) */
.sel-modo {
  appearance: none;
  -webkit-appearance: none;
  max-width: 62vw;
  height: 36px;
  padding: 0 26px 0 12px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 8px center;
  color: var(--text);
  font: inherit;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  field-sizing: content;
  cursor: pointer;
  transition: background-color var(--t);
}
.sel-modo:hover { background-color: var(--hover); }
.sel-modo:focus-visible { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: 0; }
html:not([data-theme="light"]) .sel-modo option { background: var(--panel); color: var(--text); }

@supports (appearance: base-select) {
  .sel-modo,
  .sel-modo::picker(select) { appearance: base-select; }
  .sel-modo { background-image: none; padding: 0 10px 0 12px; display: inline-flex; align-items: center; gap: 4px; }
  .sel-modo::picker-icon {
    content: "";
    width: 12px;
    height: 12px;
    background: var(--muted);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  .sel-modo::picker(select) {
    min-width: 220px;
    margin-top: 6px;
    padding: 6px;
    border: 0;
    border-radius: 14px;
    background: var(--panel);
    box-shadow: 0 0 0 .5px rgba(0, 0, 0, .12), 0 12px 40px rgba(0, 0, 0, .18);
    font-family: var(--font);
  }
  .sel-modo option {
    padding: 10px 12px;
    border-radius: 9px;
    font-size: 16px;
    font-weight: 400;
    color: var(--text);
    background: transparent;
  }
  .sel-modo option:hover,
  .sel-modo option:focus-visible { background: var(--hover-strong); }
  .sel-modo option:checked { font-weight: 600; }
  .sel-modo option::checkmark { color: var(--accent); }
}

.tb-actions { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: 0; }

/* ---------------------------------------------------------- mensagens */

#messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  padding: var(--s5) calc(var(--s4) + env(safe-area-inset-right, 0px)) var(--s6) calc(var(--s4) + env(safe-area-inset-left, 0px));
}

.msg-area {
  flex: 1 0 auto;
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--s6);
}

/* estado vazio: ícone, título e quatro perguntas prontas, no centro */
#emptyState {
  margin: auto 0;
  padding: var(--s8) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.es-icon { width: 64px; height: 64px; margin-bottom: var(--s5); }

/* ---- o plano na tela de início: contagem regressiva e as tarefas de hoje ---- */
.hoje-card { width: 100%; max-width: 440px; margin: 0 0 var(--s6); text-align: left; }
.hoje-card .hc {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s4);
  border-radius: var(--r-lg);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  color: inherit;
  transition: border-color var(--t), background-color var(--t);
}
.hoje-card .hc:hover { border-color: var(--border); }
.hoje-card .hc-dias {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 64px; padding: 6px 8px; border-radius: var(--r);
  background: var(--accent-soft); color: var(--accent);
}
.hoje-card .hc-dias b { font: 600 24px/1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hoje-card .hc-dias i { font-style: normal; font-size: 10px; line-height: 1.2; margin-top: 2px; opacity: .85; text-align: center; }
.hoje-card .hc-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hoje-card .hc-txt b { font-size: var(--fs-base); font-weight: 500; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hoje-card .hc-txt span { font-size: var(--fs-sm); color: var(--muted); }
.hoje-card .hc-seta { flex: 0 0 auto; color: var(--muted); font-size: 20px; line-height: 1; }
.hoje-card .hc-tarefas { display: flex; flex-direction: column; gap: 1px; margin-top: var(--s2); }
.hoje-card .hc-t {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3);
  padding: 9px var(--s4); border-radius: var(--r-sm); color: var(--text-2); font-size: var(--fs-sm);
  background: var(--hover);
  transition: background-color var(--t);
}
.hoje-card .hc-t:hover { background: var(--hover-strong); color: var(--text); }
.hoje-card .hc-t span { flex: 0 0 auto; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- o dia do aluno: a tarefa principal primeiro, um toque, sem digitar ---- */
.dia { width: 100%; max-width: 440px; margin: 0 0 var(--s5); text-align: left; }
.dia .dia-k {
  margin: 0 0 var(--s2) 2px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--muted); letter-spacing: -.005em;
}
.dia .dia-go {
  display: flex; flex-direction: column; gap: 4px; width: 100%;
  min-height: 76px; padding: 14px var(--s5);
  border-radius: var(--r-lg); border: 0;
  background: var(--primary); color: var(--primary-ink);
  text-align: left;
  transition: background-color var(--t), transform 160ms var(--ease);
}
.dia .dia-go:hover { background: var(--primary-hover); }
.dia .dia-go:active { transform: scale(.99); }
.dia .dia-tt { font-size: var(--fs-md); font-weight: 600; letter-spacing: -.015em; }
.dia .dia-mt { font-size: var(--fs-sm); opacity: .86; }
.dia .dia-outras { display: flex; flex-direction: column; gap: 1px; margin-top: var(--s2); }
.dia .dia-t {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3);
  padding: 10px var(--s4); border-radius: var(--r-sm);
  color: var(--text-2); font-size: var(--fs-sm); text-align: left;
  background: var(--hover);
  transition: background-color var(--t), color var(--t);
}
.dia .dia-t:hover { background: var(--hover-strong); color: var(--text); }
.dia .dia-t span { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .dia .dia-go { transition: none; } }
#emptyState h2 {
  font-size: clamp(24px, 6.4vw, 32px);
  line-height: 1.15;
  letter-spacing: -.028em;
}
#emptyState > p {
  margin-top: var(--s2);
  max-width: 36ch;
  color: var(--muted);
  font-size: 16px;
}

.chips {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s2);
  width: 100%;
  margin-top: var(--s8);
  text-align: left;
}
.chip-sugestao {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--group-bg);
  text-align: left;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  transition: background-color var(--t), transform 160ms var(--ease);
}
.chip-sugestao:hover { background: var(--sel-bg); }
.chip-sugestao:active { transform: scale(.985); }

.comp-cmds {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: var(--s5);
}
.cmds-label { margin-right: 4px; font-size: 13px; color: var(--muted); }
.chip-cmd {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-height: 30px;
  padding: 5px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--field-line);
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
  transition: background-color var(--t), color var(--t);
}
.chip-cmd .cmd { font-weight: 600; color: var(--text); }
.chip-cmd:hover { background: var(--hover); }

/* mensagem do usuário: balão azul à direita, como no iMessage */
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .msg-bubble {
  max-width: min(78%, 540px);
  padding: 9px 15px;
  border-radius: 20px;
  background: var(--user-bubble);
  color: #ffffff;
  font-size: 17px;
  line-height: 1.38;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* resposta do Atlas: texto corrido, com o nome e o símbolo em cima */
.msg-ai { display: flex; flex-direction: column; gap: var(--s2); }

.msg-avatar {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.msg-avatar::before {
  content: "";
  width: 16px;
  height: 16px;
  background: linear-gradient(140deg, var(--brand-a), var(--brand-b));
  -webkit-mask: var(--ico-star) center / contain no-repeat;
          mask: var(--ico-star) center / contain no-repeat;
}

.msg-content {
  font-size: 17px;
  line-height: 1.52;
  color: var(--text);
  overflow-wrap: anywhere;
}
.msg-content > * + * { margin-top: 12px; }
.msg-content strong { font-weight: 600; }
.msg-content em { font-style: italic; }

.msg-content h2,
.msg-content h3,
.msg-content h4 {
  margin-top: 22px;
  font-size: 19px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -.02em;
}
.msg-content h3,
.msg-content h4 { font-size: 17px; }
.msg-content > h2:first-child,
.msg-content > h3:first-child { margin-top: 0; }
.msg-content h2 + *,
.msg-content h3 + *,
.msg-content h4 + * { margin-top: 6px; }

.msg-content ul,
.msg-content ol { padding-left: 22px; }
.msg-content li + li { margin-top: 6px; }
.msg-content li::marker { color: var(--muted); }
.msg-content ol li::marker { font-variant-numeric: tabular-nums; }

.msg-content a { color: var(--accent); }
.msg-content a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* fonte citada: uma linha, cortada com reticências */
.msg-content a.src {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: bottom;
  font-size: 15px;
}

.msg-content code {
  font-family: var(--mono);
  font-size: .86em;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--group-bg);
}
.msg-content pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  border-radius: var(--r);
  background: var(--group-bg);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
}
.msg-content pre code { padding: 0; background: none; font-size: inherit; }

.code-wrap { position: relative; }
.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--muted);
  box-shadow: 0 0 0 1px var(--border-soft);
  transition: color var(--t);
}
.code-copy:hover { color: var(--text); }
.code-copy.copied svg { display: none; }
.code-copy.copied::before {
  content: "";
  width: 16px;
  height: 16px;
  background: var(--ok);
  -webkit-mask: var(--ico-check) center / contain no-repeat;
          mask: var(--ico-check) center / contain no-repeat;
}

.msg-content blockquote {
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--r);
  background: var(--group-bg);
  color: var(--text-2);
  font-size: 15px;
}

/* tabela como lista agrupada */
.msg-content table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: separate;
  border-spacing: 0;
  padding: 2px 14px;
  border-radius: var(--r);
  background: var(--group-bg);
  font-size: 15px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.msg-content th,
.msg-content td {
  padding: 10px 18px 10px 0;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--row-line);
}
.msg-content th:last-child,
.msg-content td:last-child { padding-right: 0; }
.msg-content th { font-size: 13px; font-weight: 600; color: var(--muted); }
.msg-content tr:last-child td { border-bottom: 0; }

.msg-content hr { border: 0; border-top: 1px solid var(--border-soft); margin: 20px 0; }

/* cursor enquanto a resposta chega */
.msg-content.streaming > :last-child::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  vertical-align: .1em;
  border-radius: 50%;
  background: var(--accent);
  animation: pulsar 1s ease-in-out infinite;
}
@keyframes pulsar { 50% { opacity: .25; transform: scale(.7); } }

/* aguardando a primeira palavra */
.dots-loading { display: inline-flex; gap: 5px; padding: 10px 0; }
.dots-loading span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: dot 1.2s ease-in-out infinite;
}
.dots-loading span:nth-child(2) { animation-delay: .15s; }
.dots-loading span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* "pensando": status com brilho passando e, embaixo, os passos já feitos */
.thinking-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
  color: var(--muted);
}
.thinking-rail:not([hidden]) + .msg-content .dots-loading { display: none; }
.rail-status { display: inline-flex; align-items: center; gap: 8px; min-height: 24px; }
.rspin {
  width: 16px;
  height: 16px;
  background: linear-gradient(140deg, var(--brand-a), var(--brand-b));
  -webkit-mask: var(--ico-star) center / contain no-repeat;
          mask: var(--ico-star) center / contain no-repeat;
  animation: girar 2.4s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
.rail-label {
  font-weight: 500;
  background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 40%, var(--text) 50%, var(--muted) 60%, var(--muted) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  animation: brilho 1.8s linear infinite;
}
@keyframes brilho { from { background-position: 100% 0; } to { background-position: -150% 0; } }

.step-chips { display: flex; flex-direction: column; gap: 4px; padding-left: 24px; }
.step-chips:empty { display: none; }
.step-chip { display: flex; align-items: center; gap: 8px; font-size: 14px; line-height: 20px; }
.step-chip::before {
  content: "";
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  background: var(--ok);
  -webkit-mask: var(--ico-check) center / contain no-repeat;
          mask: var(--ico-check) center / contain no-repeat;
}

/* erro na resposta */
.msg-erro {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 15px;
}
.msg-erro a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.btn-retry {
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--r-full);
  background: var(--danger-botao);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
}
/* sem cara de erro: o aluno parou a resposta, ou a pergunta ficou sem resposta */
.msg-erro.is-neutro { background: var(--group-bg); color: var(--muted); }
.msg-erro.is-neutro .btn-retry { background: var(--primary); }
/* a resposta que não veio não tem o que copiar, baixar, regenerar nem ouvir */
.msg-ai:has(.msg-erro) .msg-actions { display: none; }

/* ações da resposta: ícones cinza; o texto fica para leitor de tela e dica */
.msg-actions { display: flex; align-items: center; gap: 2px; margin-left: -8px; }
.msg-actions button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--muted);
  transition: background-color var(--t), color var(--t);
}
.msg-actions button:hover { background: var(--hover); color: var(--text); }
.msg-actions button span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.btn-copy.copied { color: var(--ok); }
.btn-copy.copied svg,
.btn-speak.speaking svg { display: none; }
.btn-copy.copied::before,
.btn-speak.speaking::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: var(--ico-check) center / contain no-repeat;
          mask: var(--ico-check) center / contain no-repeat;
}
.btn-speak.speaking { color: var(--accent); background: var(--accent-soft); }
.btn-speak.speaking::before { -webkit-mask-image: var(--ico-stop); mask-image: var(--ico-stop); }

/* ---------------------------------------------------------- composer (barra de baixo translúcida) */

#composer {
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  padding: var(--s2) calc(var(--s3) + env(safe-area-inset-right, 0px)) calc(var(--s2) + env(safe-area-inset-bottom, 0px)) calc(var(--s3) + env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--side-line);
}
.comp-inner { width: 100%; max-width: 740px; margin: 0 auto; }

/* seletor de segmento (web ao vivo ou calculadoras) */
.comp-tools { display: flex; justify-content: center; margin-bottom: var(--s2); }
.seg-ferramenta {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 2px;
  border-radius: 9px;
  background: var(--seg-bg);
}
.seg-btn {
  min-width: 112px;
  height: 28px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background-color var(--t), box-shadow var(--t);
}
.seg-btn.active {
  background: var(--seg-on);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04);
}

.comp-row { display: flex; align-items: flex-end; gap: var(--s2); }

.btn-img {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  color: var(--muted);
  transition: background-color var(--t), color var(--t);
}
.btn-img:hover { color: var(--text); }
.btn-plus { margin-bottom: 2px; background: var(--plus-bg); color: var(--text-2); }
.btn-plus:hover { background: var(--sel-bg); }

.comp-box {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  min-height: 40px;
  padding: 3px 3px 3px 0;
  border: 1px solid var(--field-line);
  border-radius: 20px;
  background: var(--field-bg);
  transition: border-color var(--t), box-shadow var(--t);
}
.comp-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 113, 227, .14); }

#input {
  flex: 1;
  min-width: 0;
  display: block;
  min-height: 32px;
  max-height: 150px;
  padding: 6px 4px 6px 14px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -.011em;
}
#input::placeholder { color: var(--placeholder); }
#input:disabled { opacity: .6; }

.btn-mic { width: 32px; height: 32px; }

#btnMic.listening {
  color: #ffffff;
  background: var(--danger);
  animation: pulsar 1.2s ease-in-out infinite;
}

#btnSend {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  transition: background-color var(--t), opacity var(--t), transform 160ms var(--ease);
}
#btnSend:hover { background: var(--primary-hover); }
#btnSend:active { transform: scale(.92); }
/* sem texto nem imagem, o enviar fica apagado (aria-disabled, do app.js): o clique leva ao campo */
#btnSend[aria-disabled="true"]:not(.is-stop) { opacity: .3; cursor: default; }
#btnSend[aria-disabled="true"]:not(.is-stop):hover { background: var(--primary); }
#btnSend[aria-disabled="true"]:not(.is-stop):active { transform: none; }
#btnSend.is-stop { background: var(--text); color: var(--main-bg); opacity: 1; }
#btnSend.is-stop .icon-send { display: none; }
#btnSend.is-stop::before {
  content: "";
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: var(--ico-stop) center / contain no-repeat;
          mask: var(--ico-stop) center / contain no-repeat;
}

.comp-note {
  margin-top: 6px;
  text-align: center;
  font-size: 11px;
  line-height: 14px;
  color: var(--muted);
}

/* prévia da imagem anexada */
.img-preview:not([hidden]) {
  position: relative;
  display: inline-block;
  margin: 0 0 var(--s2) 44px;
}
.img-preview img {
  display: block;
  height: 72px;
  width: auto;
  max-width: 180px;
  object-fit: cover;
  border-radius: 14px;
}
.img-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--main-bg);
  background: #8e8e93;
  color: #ffffff;
  font-size: 16px;
  line-height: 1;
}

/* ---------------------------------------------------------- fontes (folha lateral) */

.fontes-panel {
  position: fixed;
  z-index: 60;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--side-bg);
  box-shadow: var(--shadow);
  transition: transform var(--t-slow), opacity var(--t-slow);
}
@starting-style {
  .fontes-panel.open { transform: translateX(32px); opacity: 0; }
}
.fp-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 52px;
  padding: 0 var(--s2);
  border-bottom: 1px solid var(--side-line);
}
.fp-title { grid-column: 2; font-size: 17px; letter-spacing: -.02em; }
.fp-ok {
  grid-column: 3;
  justify-self: end;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  color: var(--accent);
  font-size: 17px;
  font-weight: 600;
}
.fp-ok:hover { background: var(--hover); }
.fp-sub {
  padding: var(--s5) var(--s5) var(--s2);
  font-size: 13px;
  color: var(--muted);
}
#fontesList {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0 var(--s4) var(--s8);
  border-radius: var(--r);
  background: var(--panel);
}
#fontesList li {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 40px 12px 16px;
  transition: background-color var(--t);
}
#fontesList li + li { border-top: 1px solid var(--row-line); }
#fontesList li::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  background: var(--border-strong);
  -webkit-mask: var(--ico-chevron) center / contain no-repeat;
          mask: var(--ico-chevron) center / contain no-repeat;
}
#fontesList li:hover { background: var(--hover); }
#fontesList li a {
  font-size: 16px;
  line-height: 1.35;
  color: var(--text);
  overflow-wrap: anywhere;
}
#fontesList li a::before { content: ""; position: absolute; inset: 0; }
#fontesList li a:focus-visible { outline: 0; }
#fontesList li a:focus-visible::before { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: -3px; }
.fp-dom { font-size: 13px; color: var(--muted); }
#fontesList .fp-empty { padding: 16px; font-size: 15px; color: var(--muted); }
#fontesList .fp-empty::after { content: none; }

/* ---------------------------------------------------------- treino com questões */

#quizView {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--side-bg);
}
.quiz-wrap {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: calc(var(--s2) + env(safe-area-inset-top, 0px)) var(--s4) var(--s12);
}
.quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-height: 52px;
  margin-bottom: var(--s2);
}
.quiz-voltar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 10px 0 4px;
  margin-left: -4px;
  border-radius: var(--r-sm);
  font-size: 17px;
  color: var(--accent);
}
.quiz-voltar:active { opacity: .5; }
.quiz-progress {
  min-width: 52px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  background: var(--panel);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.quiz-progress:empty { display: none; }

.quiz-card { display: flex; flex-direction: column; gap: var(--s4); }
.quiz-title {
  font-size: clamp(30px, 8vw, 40px);
  line-height: 1.1;
  letter-spacing: -.03em;
}
.quiz-sub { margin-top: calc(var(--s3) * -1); color: var(--muted); }

/* formulário agrupado: linhas brancas dentro de um bloco arredondado */
.quiz-grupo {
  border-radius: var(--r);
  background: var(--panel);
  overflow: hidden;
}
.quiz-label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--s3);
  min-height: 50px;
  padding: 0 0 0 16px;
  font-size: 17px;
  font-weight: 400;
}
.quiz-grupo > .quiz-label + .quiz-row,
.quiz-row .quiz-label + .quiz-label { border-top: 1px solid var(--row-line); }
.quiz-row { display: flex; flex-direction: column; }
.quiz-row-item { min-width: 0; }
.quiz-label .input {
  min-height: 48px;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  box-shadow: none;
  padding-left: 0;
  font-size: 17px;
  text-align: right;
  padding-right: 16px;
}
.quiz-label select.input { padding-right: 38px; text-align: right; text-align-last: right; }
.quiz-label .input:focus { box-shadow: none; }
#btnQuizGerar { width: 100%; }
.quiz-msg { min-height: 20px; font-size: 14px; color: var(--muted); text-align: center; }
.quiz-msg a { color: var(--accent); font-weight: 600; }

.quiz-p { display: flex; flex-direction: column; gap: var(--s4); }
.quiz-pergunta { font-size: 21px; line-height: 1.35; font-weight: 600; letter-spacing: -.02em; }
.quiz-alts { display: flex; flex-direction: column; gap: var(--s2); }
.quiz-alt {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  gap: var(--s3);
  width: 100%;
  padding: 14px 16px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--panel);
  text-align: left;
  font-size: 17px;
  line-height: 1.4;
  transition: border-color var(--t), opacity var(--t), transform 160ms var(--ease);
}
.quiz-alt:hover:not(:disabled) { border-color: var(--field-line); }
.quiz-alt:active:not(:disabled) { transform: scale(.99); }
.quiz-alt:disabled { cursor: default; }
.quiz-alt:disabled:not(.is-ok):not(.is-err) { opacity: .5; }
.quiz-alt-l {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--group-bg);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}
html[data-theme="light"] .quiz-alt-l { background: #ececf0; }
.quiz-alt.is-ok { border-color: var(--ok); }
.quiz-alt.is-err { border-color: var(--danger); }
.quiz-alt.is-ok .quiz-alt-l,
.quiz-alt.is-err .quiz-alt-l { color: transparent; position: relative; }
.quiz-alt.is-ok .quiz-alt-l { background: var(--ok); }
.quiz-alt.is-err .quiz-alt-l { background: var(--danger); }
.quiz-alt.is-ok .quiz-alt-l::after,
.quiz-alt.is-err .quiz-alt-l::after {
  content: "";
  position: absolute;
  inset: 7px;
  background: #ffffff;
  -webkit-mask: var(--ico-check) center / contain no-repeat;
          mask: var(--ico-check) center / contain no-repeat;
}
.quiz-alt.is-err .quiz-alt-l::after { -webkit-mask-image: var(--ico-x); mask-image: var(--ico-x); }

.quiz-expl {
  padding: 16px;
  border-radius: 14px;
  background: var(--panel);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-2);
}
.quiz-expl strong { color: var(--ok); }
.quiz-p:has(.quiz-alt.is-err) .quiz-expl strong { color: var(--danger); }
.quiz-prox { width: 100%; }

/* ---- explicação por alternativa (padrão UWorld) com o cenário brasileiro ---- */
.quiz-detalhe { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.quiz-detalhe .qd {
  border-radius: 12px;
  background: var(--bg-2, #f5f5f7);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  transition: border-color var(--t);
}
.quiz-detalhe .qd.is-certa { border-color: var(--ok); }
.quiz-detalhe .qd > summary {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-2);
}
.quiz-detalhe .qd > summary::-webkit-details-marker { display: none; }
.quiz-detalhe .qd > summary:hover { background: var(--hover); }
.quiz-detalhe .qd-l {
  flex: 0 0 auto;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 12px/1 var(--font);
  background: var(--panel-2);
  color: var(--muted);
}
.quiz-detalhe .qd.is-certa .qd-l { background: var(--ok); color: #fff; }
.quiz-detalhe .qd-t { flex: 1 1 auto; min-width: 0; }
.quiz-detalhe .qd-cen {
  margin: 0;
  padding: 2px 12px 10px 42px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}
.quiz-detalhe .qd-cen strong { font-weight: 600; }
.quiz-detalhe .qd-cen.is-sus strong { color: var(--accent); }
.quiz-detalhe .qd-cen.is-privado strong { color: var(--warn); }
.quiz-detalhe .qd-fontes {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}
@media (max-width: 430px) {
  .quiz-detalhe .qd-cen { padding-left: 12px; }
}

.quiz-rev { display: flex; flex-direction: column; border-radius: var(--r); background: var(--panel); overflow: hidden; }
.quiz-rev-item { padding: 12px 16px; font-size: 15px; line-height: 1.45; color: var(--text-2); }
.quiz-rev-item + .quiz-rev-item { border-top: 1px solid var(--row-line); }
.quiz-rev-item strong { color: var(--ok); }
.quiz-fim-actions { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s2); }
.quiz-fim-actions > * { width: 100%; }

/* ---------------------------------------------------------- perfil: folha no estilo iOS */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--overlay);
  transition: opacity .25s ease;
}
.modal-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    "cancelar titulo salvar"
    "sub sub sub"
    "campos campos campos"
    "msg msg msg";
  align-items: center;
  width: 100%;
  max-width: 560px;
  max-height: 94vh;
  max-height: 94dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px var(--s4) calc(var(--s6) + env(safe-area-inset-bottom, 0px));
  border-radius: 14px 14px 0 0;
  background: var(--side-bg);
  box-shadow: var(--shadow);
  transition: transform var(--t-slow);
}
@starting-style {
  .modal-overlay { opacity: 0; }
  .modal-card { transform: translateY(40px); }
}
.modal-card h3 { grid-area: titulo; font-size: 17px; letter-spacing: -.02em; text-align: center; }
.modal-actions { display: contents; }
#btnPfCancelar,
#btnPfSalvar {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-size: 17px;
}
#btnPfCancelar { grid-area: cancelar; justify-self: start; font-weight: 400; }
#btnPfSalvar { grid-area: salvar; justify-self: end; font-weight: 600; }
#btnPfCancelar:hover,
#btnPfSalvar:hover { background: transparent; opacity: .7; }
.modal-sub { grid-area: sub; margin: var(--s4) 4px var(--s2); font-size: 13px; color: var(--muted); }
.modal-fields {
  grid-area: campos;
  display: flex;
  flex-direction: column;
  border-radius: var(--r);
  background: var(--panel);
  overflow: hidden;
}
.modal-fields > label,
.modal-fields .field-row > label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: center;
  gap: var(--s3);
  min-height: 48px;
  padding-left: 16px;
  font-size: 17px;
  font-weight: 400;
  color: var(--text);
}
.modal-fields > * + *,
.modal-fields .field-row > label + label { border-top: 1px solid var(--row-line); }
.field-row { display: flex; flex-direction: column; }
.modal-fields .input {
  min-height: 46px;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  box-shadow: none;
  padding: 0 16px 0 0;
  text-align: right;
  font-size: 17px;
  color: var(--muted);
}
.modal-fields select.input { padding-right: 38px; text-align-last: right; }
.modal-fields .input:focus { color: var(--text); box-shadow: none; }
.modal-fields .label-hint { font-size: 15px; }

.modal-fields > label.pf-modelo {
  grid-template-columns: 1fr;
  gap: 0;
  padding-top: 12px;
}
.modal-fields .pf-modelo textarea.input {
  min-height: 84px;
  padding: 8px 16px 12px 0;
  text-align: left;
  color: var(--text);
}

.modal-fields .checkbox-row {
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px 16px;
  cursor: pointer;
}
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-title { font-size: 17px; }
.switch-sub { font-size: 13px; line-height: 1.35; color: var(--muted); }

/* interruptor no estilo iOS: verde quando ligado */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: var(--r-full);
  background: var(--switch-off);
  cursor: pointer;
  transition: background-color var(--t-slow);
}
.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 3px 1px rgba(0, 0, 0, .06);
  transition: transform var(--t-slow);
}
.switch:checked { background: var(--switch-on); }
.switch:checked::before { transform: translateX(20px); }
.switch:focus-visible { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: 2px; }

.modal-msg { grid-area: msg; min-height: 20px; margin-top: var(--s3); text-align: center; font-size: 14px; color: var(--muted); }
.modal-msg.ok { color: var(--ok); font-weight: 600; }
.modal-msg.err { color: var(--danger); font-weight: 600; }

/* ---------------------------------------------------------- avisos */

.toast {
  position: fixed;
  z-index: 200;
  left: 50%;
  top: calc(var(--s3) + env(safe-area-inset-top, 0px));
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: var(--r-full);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
          backdrop-filter: saturate(180%) blur(20px);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 0 0 .5px rgba(0, 0, 0, .1), 0 8px 30px rgba(0, 0, 0, .16);
  animation: toastIn .3s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } }

.offline-banner {
  position: fixed;
  z-index: 150;
  top: calc(60px + env(safe-area-inset-top, 0px));
  left: 50%;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: var(--r-full);
  background: var(--offline-bg);
  color: var(--offline-ink);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

/* ---------------------------------------------------------- telas maiores */

@media (min-width: 600px) {
  .chips { grid-template-columns: 1fr 1fr; }
  .fontes-panel { width: 400px; border-left: 1px solid var(--side-line); }
  .modal-overlay { align-items: center; padding: var(--s6); }
  .modal-card { border-radius: 14px; padding-bottom: var(--s6); }
  .quiz-row { flex-direction: row; }
  .quiz-row .quiz-label { flex: 1; }
  .quiz-row .quiz-label + .quiz-label { border-top: 0; border-left: 1px solid var(--row-line); }
}

@media (min-width: 769px) {
  #sidebar {
    position: relative;
    z-index: auto;
    width: 280px;
    flex-shrink: 0;
    transform: none;
    visibility: visible;
    transition: none;
  }
  #sidebar.open { box-shadow: none; }
  #overlay { display: none !important; }
  #btnMenu { visibility: hidden; }

  #topbar { min-height: 56px; padding: 0 var(--s4); }
  #messages { padding: var(--s6) var(--s8) var(--s8); }
  #composer { padding: var(--s3) var(--s8) var(--s3); }
  .msg-area { gap: var(--s8); }
}

@media (min-width: 1280px) {
  #sidebar { width: 300px; }
  .msg-area,
  .comp-inner { max-width: 780px; }
}

/* toque: sem hover, a lixeira aparece só na conversa aberta */
@media (hover: none) {
  .chat-item:hover:not(.active) .del { opacity: 0; pointer-events: none; }
  .chat-item:hover:not(.active) .time { opacity: 1; }
}

/* com mouse: ações das respostas antigas ficam mais leves até o hover */
@media (hover: hover) and (min-width: 769px) {
  .msg-ai:not(:last-child) .msg-actions { opacity: .45; transition: opacity var(--t); }
  .msg-ai:not(:last-child):hover .msg-actions,
  .msg-ai:not(:last-child) .msg-actions:focus-within { opacity: 1; }
}

/* ---------------------------------------------------------- impressão (Baixar PDF) */

@media print {
  body { background: #fff !important; color: #111 !important; }
  #app { display: block; height: auto; overflow: visible; }
  #sidebar, #topbar, #composer, #overlay, #emptyState, .msg-actions,
  .btn-copy, .btn-print, .btn-regen, .code-copy, .btn-retry, .comp-cmds,
  .toast, .offline-banner, .modal-overlay, .thinking-rail, .fontes-panel, #quizView, #provaView, #flashView { display: none !important; }
  #main { display: block; }
  #messages { display: block; overflow: visible; padding: 0; }
  .msg-area { display: block; max-width: none; }
  .msg { margin-bottom: 18px; page-break-inside: avoid; break-inside: avoid; }
  .msg-avatar { color: #555 !important; }
  .msg-content { font-size: 12pt; line-height: 1.5; color: #111 !important; }
  .msg-content.streaming > :last-child::after { content: none; }
  .msg-content a { color: #0b4fb3 !important; }
  .msg-content strong { color: inherit !important; }
  .msg-content a.src { display: inline; white-space: normal; overflow: visible; word-break: break-all; }
  .msg-user .msg-bubble { background: #f2f2f2 !important; color: #111 !important; border: 1px solid #ddd; }
  .msg-content pre,
  .msg-content code,
  .msg-content blockquote,
  .msg-content table { background: #f5f5f5 !important; color: #111 !important; }
  .msg-content table { display: table; width: 100%; white-space: normal; }
  .msg-content th { color: #333 !important; }
  .msg-content th,
  .msg-content td { border-color: #ccc !important; }
}

/* ---------------------------------------------------------- telas de treino e estudo
   Prova, flashcards, revisão, prova oral, estudo (guia, progresso, plano e roteiro),
   paciente simulado, convite e conferência de dose. Mesmo padrão das outras telas:
   fundo cinza, blocos brancos agrupados, seletor de segmento e cores do sistema. */

#provaView,
#flashView,
#estudoView {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--side-bg);
}

/* botões de gerar ocupam a largura do formulário */
.quiz-card > .btn-primary.btn-lg { width: 100%; }

/* linhas do formulário agrupado: separador entre rótulos seguidos */
.quiz-grupo > .quiz-label + .quiz-label { border-top: 1px solid var(--row-line); }

/* ícones do menu (cores do sistema) e selo de pendências */
.sb-tile-rosa { background: linear-gradient(160deg, #ff6482, #ff2d55); }
.sb-tile { position: relative; }
.tile-badge {
  position: absolute;
  top: -7px;
  right: -8px;
  display: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ff3b30;
  box-shadow: 0 0 0 2px var(--panel);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* convite: uma linha no rodapé do menu */
.sb-rodape { flex-wrap: wrap; }
.sb-ref {
  order: 3;
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 4px 6px 12px;
  border-radius: var(--r-sm);
  background: var(--panel);
}
.sb-ref[hidden] { display: none; }
html[data-theme="light"] .sb-ref { box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.sb-ref-lab { flex: 1; min-width: 0; font-size: 14px; color: var(--text); }
.sb-ref-code {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.sb-ref-btn {
  min-height: 30px;
  padding: 0 10px;
  border-radius: var(--r-full);
  font-size: 14px;
  color: var(--accent);
  transition: background-color var(--t);
}
.sb-ref-btn:hover { background: var(--hover); }

.oral-hint { margin: calc(var(--s2) * -1) 16px 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.oral-hint[hidden] { display: none; }

/* treinos recentes: lista agrupada; cada linha tem o anel de acerto e refaz o tema ao tocar */
.quiz-hist { display: none; }
.quiz-hist:not(:empty) { display: flex; flex-direction: column; margin-top: var(--s4); }
.quiz-hist-tit { margin: 0 16px 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.quiz-hist-item {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 8px 16px;
  background: var(--panel);
  text-align: left;
  color: var(--text);
  transition: opacity var(--t), background-color var(--t);
}
.quiz-hist-item + .quiz-hist-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 68px;
  right: 0;
  height: 1px;
  background: var(--row-line);
}
.quiz-hist-tit + .quiz-hist-item { border-radius: var(--r) var(--r) 0 0; }
.quiz-hist-item:last-child { border-radius: 0 0 var(--r) var(--r); }
.quiz-hist-tit + .quiz-hist-item:last-child { border-radius: var(--r); }
.quiz-hist-item:active { opacity: .6; }
.qh-anel {
  --qh-c: var(--ok);
  --qh-trilho: var(--row-line);
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.qh-anel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--qh-c) calc(var(--p) * 1%), var(--qh-trilho) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px));
}
.qh-anel.qh-meio { --qh-c: var(--warn); }
.qh-anel.qh-baixo { --qh-c: var(--danger); }
.qh-txt { display: flex; flex-direction: column; min-width: 0; }
.qh-tema { overflow: hidden; font-size: 16px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.qh-sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.qh-acao { font-size: 15px; color: var(--accent); }

/* gerando: o asterisco gira e o texto brilha, como o "pensando" do chat */
.quiz-generating {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 72px 24px;
  text-align: center;
}
.quiz-gen-dots {
  width: 30px;
  height: 30px;
  margin-bottom: 6px;
  background: linear-gradient(140deg, var(--brand-a), var(--brand-b));
  -webkit-mask: var(--ico-star) center / contain no-repeat;
          mask: var(--ico-star) center / contain no-repeat;
  animation: girar 2.4s linear infinite;
}
.quiz-gen-dots i { display: none; }
.quiz-gen-status {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.02em;
  background: linear-gradient(90deg, var(--text-2) 0%, var(--text-2) 40%, var(--muted) 50%, var(--text-2) 60%, var(--text-2) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  animation: brilho 2.2s linear infinite;
}
.quiz-gen-hint { max-width: 32ch; font-size: 15px; line-height: 1.4; color: var(--muted); }




/* ---------------------------------------------------------- paciente simulado
   Conversa vazia no modo paciente: a escolha do caso (perfil e jeito de responder).
   Durante a entrevista: uma barra fina com o resumo do caso e o debriefing; as respostas
   aparecem como "Paciente" e o debriefing chega num cartão. */

/* barra fina acima do campo */
.paciente-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 6px max(12px, calc((100% - 740px) / 2));
  border-top: 1px solid var(--side-line);
}
.paciente-bar[hidden] { display: none; }
/* com a conversa vazia, a escolha do caso fica no meio da tela */
#main:has(#emptyState:not([hidden])) .paciente-bar { display: none; }
.pb-resumo {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 38px;
  padding: 0 6px 0 0;
  border-radius: 12px;
  text-align: left;
  color: var(--text);
}
.pb-resumo:focus-visible { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: 2px; }
.pb-ico,
.pi-ico {
  flex: none;
  border-radius: 50%;
  background: rgba(48, 176, 199, .16) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2330b0c7' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='3.6'/%3E%3Cpath d='M4.8 20c1.1-3.9 4-5.9 7.2-5.9s6.1 2 7.2 5.9'/%3E%3C/svg%3E") center / 58% no-repeat;
}
.pb-ico { width: 34px; height: 34px; }
.pb-txt { display: flex; flex-direction: column; min-width: 0; }
.pb-tag { overflow: hidden; font-size: 15px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; color: var(--text); white-space: nowrap; text-overflow: ellipsis; }
.pb-sub { overflow: hidden; font-size: 13px; line-height: 1.3; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.pb-chev {
  flex: none;
  width: 11px;
  height: 7px;
  margin-left: 2px;
  background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5L6 6l4.5-4.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5L6 6l4.5-4.5'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform .2s var(--ease);
}
.paciente-bar.is-aberta .pb-chev { transform: rotate(180deg); }
.paciente-bar .pb-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 15px 0 12px;
  border: 0;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.paciente-bar .pb-btn::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 4.5H7A2 2 0 0 0 5 6.5v13A2 2 0 0 0 7 21.5h10a2 2 0 0 0 2-2v-13a2 2 0 0 0-2-2h-2'/%3E%3Crect x='9' y='2.5' width='6' height='4' rx='1.2'/%3E%3Cpath d='M9 13.5l2 2 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 4.5H7A2 2 0 0 0 5 6.5v13A2 2 0 0 0 7 21.5h10a2 2 0 0 0 2-2v-13a2 2 0 0 0-2-2h-2'/%3E%3Crect x='9' y='2.5' width='6' height='4' rx='1.2'/%3E%3Cpath d='M9 13.5l2 2 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.paciente-bar .pb-btn:active { transform: scale(.97); }
.paciente-bar .pb-btn:disabled { opacity: .5; }
@media (max-width: 359px) {
  .paciente-bar .pb-btn { padding: 0 14px; }
  .paciente-bar .pb-btn::before { display: none; }
}
/* trocar perfil e dificuldade no meio da entrevista: abre uma linha embaixo */
.pb-ajustes {
  display: none;
  flex: 1 0 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto auto;
  grid-auto-flow: column;
  gap: 4px 10px;
  padding: 2px 0 6px;
}
.paciente-bar.is-aberta .pb-ajustes { display: grid; }
.pb-label { padding-left: 4px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.paciente-bar select.pb-sel {
  width: 100%;
  min-width: 0;
  height: 34px;
  min-height: 34px;
  padding: 0 30px 0 12px;
  border: 0;
  border-radius: var(--r-full);
  background-color: var(--seg-bg);
  background-position: right 10px center;
  font-size: 14px;
  text-align: left;
}

/* no modo paciente: sem a escolha de ferramenta (o paciente não pesquisa) e as respostas são do "Paciente" */
#main.modo-paciente .comp-tools { display: none; }
#main.modo-paciente .msg-ai:not(.msg-debrief) .msg-avatar { gap: 0; font-size: 0; }
#main.modo-paciente .msg-ai:not(.msg-debrief) .msg-avatar::before {
  margin-right: 7px;
  background: #30b0c7;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='7.6' r='4.2'/%3E%3Cpath d='M3.6 21c1.2-4.6 4.6-7.2 8.4-7.2s7.2 2.6 8.4 7.2z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='7.6' r='4.2'/%3E%3Cpath d='M3.6 21c1.2-4.6 4.6-7.2 8.4-7.2s7.2 2.6 8.4 7.2z'/%3E%3C/svg%3E") center / contain no-repeat;
}
#main.modo-paciente .msg-ai:not(.msg-debrief) .msg-avatar::after { content: "Paciente"; font-size: 13px; }

/* conversa vazia no modo paciente: a escolha do caso */
.paciente-intro { display: none; }
#main.modo-paciente #emptyState > :not(.paciente-intro) { display: none; }
#main.modo-paciente #emptyState .paciente-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 560px;
  text-align: center;
}
.pi-ico { width: 64px; height: 64px; }
.pi-tit {
  margin-top: 16px;
  font-size: clamp(24px, 6.4vw, 32px);
  line-height: 1.15;
  letter-spacing: -.028em;
}
.pi-sub { max-width: 34ch; margin-top: 8px; font-size: 16px; line-height: 1.45; color: var(--muted); }
.pi-sec,
.pi-comecar { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 26px; text-align: left; }
.pi-k { font-size: 17px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.pi-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pi-chip,
.pi-seg-opt { position: relative; display: block; }
.pi-chip input,
.pi-seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.pi-chip span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 15px;
  border-radius: var(--r-full);
  background: var(--group-bg);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background-color .18s var(--ease), color .18s var(--ease), transform .14s var(--ease);
}
.pi-chip span:active { transform: scale(.95); }
.pi-chip input:checked + span { background: var(--primary); color: #ffffff; }
.pi-chip input:focus-visible + span,
.pi-seg-opt input:focus-visible + span { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: 2px; }
.pi-seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 3px;
  border-radius: 12px;
  background: var(--seg-bg);
}
.pi-seg-opt span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background-color .18s var(--ease), box-shadow .18s var(--ease);
}
.pi-seg-opt input:checked + span {
  background: var(--seg-on);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04);
}
.pi-nivel-dica { min-height: 20px; font-size: 14px; line-height: 1.4; color: var(--muted); }
.pi-nivel-dica span { display: none; }
.pi-sec:has(input[value="cooperativo"]:checked) [data-nivel="cooperativo"],
.pi-sec:has(input[value="realista"]:checked) [data-nivel="realista"],
.pi-sec:has(input[value="evasivo"]:checked) [data-nivel="evasivo"] { display: inline; }
/* a primeira fala, pronta para enviar */
.pi-comecar .pi-oi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: var(--accent-soft);
  font-size: 16px;
  font-weight: 500;
  color: var(--accent);
}
.pi-comecar .pi-oi::after {
  content: "";
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5'/%3E%3Cpath d='M5.5 11.5L12 5l6.5 6.5'/%3E%3C/svg%3E") center / 15px no-repeat;
}
.pi-comecar .pi-oi:hover { background: var(--accent-soft); filter: brightness(.97); }

/* debriefing: um cartão com o diagnóstico em destaque, o que faltou perguntar e as armadilhas */
.msg-debrief .debrief-card {
  margin-top: 8px;
  padding: 18px 18px 16px;
  border-radius: 20px;
  background: var(--group-bg);
}
.db-eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.debrief-card > .dose-alert-box { margin: 12px 0 0; }
.db-dx { margin-top: 12px; }
.db-k { display: block; font-size: 13px; color: var(--muted); }
.db-dx-nome { display: block; margin-top: 2px; font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -.02em; color: var(--text); }
.db-just { margin-top: 6px; font-size: 16px; line-height: 1.45; color: var(--text-2); }
.db-sec { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--row-line); }
.db-sec h4 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.db-sec h4::before {
  content: "";
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--warn) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.2 9.3a2.9 2.9 0 0 1 5.6 1c0 2-2.8 2.6-2.8 4.2'/%3E%3Cpath d='M12 18.3h.01'/%3E%3C/svg%3E") center / 15px no-repeat;
}
.db-armas h4::before {
  background: var(--danger) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.8' stroke-linecap='round'%3E%3Cpath d='M12 6.5v7'/%3E%3Cpath d='M12 17.6h.01'/%3E%3C/svg%3E") center / 15px no-repeat;
}
.db-sec ul { margin: 6px 0 0; padding: 0; list-style: none; }
.db-sec li { position: relative; padding: 5px 0 5px 30px; font-size: 16px; line-height: 1.4; color: var(--text); }
.db-sec li::before { content: ""; position: absolute; top: 14px; left: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.debrief-acao { margin-top: 18px; }
.debrief-acao .btn-primary { width: 100%; min-height: 48px; font-size: 16px; font-weight: 600; }
/* enquanto o debriefing é feito */
.debrief-tmp .msg-content {
  margin-top: 10px;
  font-size: 17px;
  font-weight: 500;
  background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 40%, var(--text) 50%, var(--muted) 60%, var(--muted) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  animation: brilho 1.8s linear infinite;
}
.db-skel { display: flex; flex-direction: column; gap: 9px; margin-top: 14px; }
.db-skel i {
  display: block;
  height: 11px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--seg-bg) 0%, var(--row-line) 50%, var(--seg-bg) 100%);
  background-size: 200% 100%;
  animation: q-brilho 1.6s linear infinite;
}
.db-skel i:nth-child(2) { width: 86%; }
.db-skel i:nth-child(3) { width: 58%; }
@media (prefers-reduced-motion: reduce) {
  .db-skel i { animation: none; }
}

/* conferência de dose e de CID
   No texto: uma nota curta logo antes da frase conferida (vermelha para dose, laranja para CID),
   em bloco e com peso normal, para não picotar a frase. No começo da resposta: a caixa com tudo
   o que pede conferência. Os ícones são desenhados aqui (o ⚠ virava emoji amarelo no iPhone). */
.dose-warn,
.cid-warn {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 6px 0 6px;
  padding: 7px 12px 7px 32px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
}
.dose-warn { background: var(--danger-soft); color: var(--danger); }
.cid-warn { background: var(--warn-soft); color: var(--warn); }
.aviso-ico {
  position: absolute;
  top: 9px;
  left: 11px;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10.3 3.6L1.9 18a2 2 0 0 0 1.7 3h16.8a2 2 0 0 0 1.7-3L13.7 3.6a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9v5M12 17.2v.3' stroke='white' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10.3 3.6L1.9 18a2 2 0 0 0 1.7 3h16.8a2 2 0 0 0 1.7-3L13.7 3.6a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9v5M12 17.2v.3' stroke='white' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.cid-warn .aviso-ico {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 12.6V4.5a1 1 0 0 1 1-1h8.1a1 1 0 0 1 .7.3l7.2 7.2a1 1 0 0 1 0 1.4l-8.1 8.1a1 1 0 0 1-1.4 0l-7.2-7.2a1 1 0 0 1-.3-.7z'/%3E%3Ccircle cx='8.2' cy='8.2' r='1.4' fill='black'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 12.6V4.5a1 1 0 0 1 1-1h8.1a1 1 0 0 1 .7.3l7.2 7.2a1 1 0 0 1 0 1.4l-8.1 8.1a1 1 0 0 1-1.4 0l-7.2-7.2a1 1 0 0 1-.3-.7z'/%3E%3Ccircle cx='8.2' cy='8.2' r='1.4' fill='black'/%3E%3C/svg%3E");
}
/* aviso sobre a resposta inteira (posição 0): a caixa logo acima já diz o mesmo */
.dose-alert-box ~ * .dose-warn.no-topo,
.dose-alert-box ~ .dose-warn.no-topo { display: none; }
/* dentro de tabela a nota fica do tamanho da célula */
.msg-content td .dose-warn,
.msg-content td .cid-warn { width: auto; margin: 0 0 4px; }

.dose-alert-box {
  display: block;
  margin: 0 0 14px;
  padding: 12px 14px 12px;
  border-radius: 14px;
  background: var(--danger-soft);
  font-size: 15px;
  line-height: 1.45;
  font-weight: 400;
  text-align: left;
  color: var(--text);
}
.dose-alert-box strong {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--danger);
}
.dose-alert-box strong::before {
  content: "";
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10.3 3.6L1.9 18a2 2 0 0 0 1.7 3h16.8a2 2 0 0 0 1.7-3L13.7 3.6a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9v5M12 17.2v.3' stroke='white' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10.3 3.6L1.9 18a2 2 0 0 0 1.7 3h16.8a2 2 0 0 0 1.7-3L13.7 3.6a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9v5M12 17.2v.3' stroke='white' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* os itens alinham com o texto do título; mais de um ganha uma linha fina entre eles */
.dose-alert-box ul { margin: 0; padding: 0; list-style: none; }
.dose-alert-box li,
.dose-alert-box > div { position: relative; margin: 0; padding: 6px 0 2px 26px; }
.dose-alert-box li + li,
.dose-alert-box > div + div { margin-top: 4px; padding-top: 8px; }
.dose-alert-box li + li::before,
.dose-alert-box > div + div::before {
  content: "";
  position: absolute;
  top: 0;
  left: 26px;
  right: 0;
  height: 1px;
  background: currentColor;
  opacity: .12;
}

@media (prefers-reduced-motion: reduce) {
  .quiz-gen-dots,
  .quiz-gen-status,
  .debrief-tmp .msg-content { animation: none; }
  .quiz-gen-status,
  .debrief-tmp .msg-content { background: none; color: var(--muted); }
}

@media print {
  .quiz-generating,
  .flash-bar,
  .flash-revealhint,
  .estudo-tabs,
  .guide-actions,
  .paciente-bar { display: none !important; }
  /* imprimir o guia: só o guia aparece (a conversa continua imprimindo normal) */
  body:has(#estudoView:not([hidden]) #guiaBody:not([hidden])) * { visibility: hidden; }
  body:has(#estudoView:not([hidden]) #guiaBody:not([hidden])) #guiaBody,
  body:has(#estudoView:not([hidden]) #guiaBody:not([hidden])) #guiaBody * { visibility: visible; }
  body:has(#estudoView:not([hidden]) #guiaBody:not([hidden])) #guiaBody {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    border: none !important;
    box-shadow: none !important;
  }
  #estudoView:not([hidden]) { position: static; overflow: visible; background: none; }
  .guia-print-head { display: block; }
  .guide-body { padding: 0; background: none; }
  .dose-warn { color: #b3242a !important; background: none !important; }
  .cid-warn { color: #9a6200 !important; background: none !important; }
  .dose-alert-box { color: #1d1d1f !important; background: none !important; border: 1px solid #b3242a !important; }
  .dose-alert-box strong { color: #b3242a !important; }
}

/* ---------------------------------------------------------- treinar (questões escritas e prova oral)
   Tela de app, não de formulário: o tipo de treino em dois cartões, temas prontos, ajustes
   em blocos tocáveis, botão fixo no pé, trilha das respostas no topo e a correção numa
   folha que sobe. Tudo preso a #quizView: as outras telas de treino não mudam. */

:is(#quizView, #provaView, #flashView, #estudoView) {
  --q-fill: #1c1c1e;
  --q-fill-2: #2c2c2e;
  --q-fill-hover: #2c2c2e;
  --q-line: #38383a;
  --q-card: #1c1c1e;
  --q-ok: #0c2e15;
  --q-err: #380f0d;
  --q-warn: #382302;
  --q-sel: #071b2e;
  --q-ind: #5e5ce6;
  --q-glass: rgba(0, 0, 0, .72);
  background: var(--main-bg);
}
html[data-theme="light"] :is(#quizView, #provaView, #flashView, #estudoView) {
  --q-fill: #f2f2f7;
  --q-fill-2: #e5e5ea;
  /* o azul do texto (#0066cc) sobre o #e5e5ea dava 4,43:1; sobre este, 4,68:1 (AA) */
  --q-fill-hover: #ebebf0;
  --q-line: #e5e5ea;
  --q-card: #ffffff;
  --q-ok: #e8f7ec;
  --q-err: #fdeeee;
  --q-warn: #fff3e2;
  --q-sel: #eef5fe;
  --q-glass: rgba(255, 255, 255, .8);
}

:is(#quizView, #provaView, #flashView, #estudoView) .quiz-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-width: 640px;
  padding: 0 20px;
}

/* topo fixo: voltar; durante o treino vira um X, com a trilha e o "1 de 5" */
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-head {
  position: sticky;
  top: 0;
  z-index: 4;
  gap: 14px;
  min-height: 0;
  height: calc(54px + env(safe-area-inset-top, 0px));
  margin: 0 -20px;
  padding: env(safe-area-inset-top, 0px) 20px 0;
  background: var(--q-glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
          backdrop-filter: saturate(180%) blur(20px);
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-voltar { flex: none; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-progress {
  flex: none;
  min-width: 0;
  margin-left: auto;
  padding: 0;
  background: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}
#quizView:has(#quizBody:not([hidden])) .quiz-voltar, #provaView:has(#provaBody:not([hidden])) .quiz-voltar, #flashView:has(#flashBody:not([hidden])) .quiz-voltar {
  justify-content: center;
  width: 44px;
  height: 44px;
  min-height: 0;
  padding: 0;
  margin: 0 -6px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--q-fill) 16.5px, transparent 17px);
  color: var(--text-2);
}
#quizView:has(#quizBody:not([hidden])) .quiz-voltar > svg,
#provaView:has(#provaBody:not([hidden])) .quiz-voltar > svg,
#flashView:has(#flashBody:not([hidden])) .quiz-voltar > svg,
#quizView:has(#quizBody:not([hidden])) .quiz-voltar-txt,
#provaView:has(#provaBody:not([hidden])) .quiz-voltar-txt,
#flashView:has(#flashBody:not([hidden])) .quiz-voltar-txt { display: none; }
#quizView:has(#quizBody:not([hidden])) .quiz-voltar::before, #provaView:has(#provaBody:not([hidden])) .quiz-voltar::before, #flashView:has(#flashBody:not([hidden])) .quiz-voltar::before {
  content: "";
  width: 12px;
  height: 12px;
  background: currentColor;
  -webkit-mask: var(--ico-x) center / contain no-repeat;
          mask: var(--ico-x) center / contain no-repeat;
}
:is(#quizView, #flashView) .quiz-trilha { flex: 1; display: flex; gap: 4px; min-width: 0; }
:is(#quizView, #flashView) .quiz-trilha:empty,
#quizView:has(#quizBody[hidden]) .quiz-trilha,
#flashView:has(#flashBody[hidden]) .quiz-trilha,
#quizView:has(.quiz-generating) .quiz-trilha,
#flashView:has(.quiz-generating) .quiz-trilha { display: none; }
:is(#quizView, #flashView) .quiz-trilha i {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--q-fill-2);
  transition: background-color .3s var(--ease);
}
:is(#quizView, #flashView) .quiz-trilha i.is-agora { background: var(--accent); }
:is(#quizView, #flashView) .quiz-trilha i.is-ok { background: var(--ok); }
:is(#quizView, #flashView) .quiz-trilha i.is-err { background: var(--danger); }
:is(#quizView, #flashView) .quiz-trilha i.is-quase { background: var(--warn); }

/* ------------- preparar o treino */
#quizView #quizForm, #provaView #provaForm, #flashView #flashForm { flex: 1; gap: 0; padding-top: 6px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-title {
  font-size: 34px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.026em;
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-sub { margin-top: 6px; font-size: 17px; line-height: 1.4; color: var(--muted); }

/* tipo de treino: dois cartões com ícone e o círculo de seleção no canto */
#quizView .quiz-tipo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-flow: row;
  gap: 12px;
  margin-top: 24px;
  padding: 0;
  border-radius: 0;
  background: none;
}
#quizView .quiz-tipo-opt {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 124px;
  padding: 14px;
  border-radius: 20px;
  background: var(--q-fill);
  cursor: pointer;
  user-select: none;
  transition: background-color .2s var(--ease), box-shadow .2s var(--ease), transform .16s var(--ease);
}
#quizView .quiz-tipo-opt:active { transform: scale(.97); }
#quizView .quiz-tipo-opt input { position: absolute; opacity: 0; pointer-events: none; }
#quizView .quiz-tipo-opt:has(input:checked) { background: var(--q-sel); box-shadow: inset 0 0 0 2px var(--accent); }
#quizView .quiz-tipo-opt:has(input:focus-visible) { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: 2px; }
#quizView .quiz-tipo-opt::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--border-strong);
  transition: background-color .2s var(--ease), box-shadow .2s var(--ease);
}
#quizView .quiz-tipo-opt:has(input:checked)::after {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 12.5l4 4L18.5 8'/%3E%3C/svg%3E") center / 14px no-repeat;
  box-shadow: none;
}
#quizView .qt-ico {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(160deg, #ffb340, #ff9500);
  color: #ffffff;
}
#quizView .quiz-tipo-oral .qt-ico { background: linear-gradient(160deg, #7d7aff, var(--q-ind)); }
#quizView .qt-tit {
  margin-top: auto;
  padding-top: 12px;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text);
}
#quizView .qt-sub { margin-top: 1px; font-size: 14px; line-height: 1.3; color: var(--muted); }

/* tema: título de seção, campo de busca e temas prontos que rolam de lado */
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-sec { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-sec-tit {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.022em;
  color: var(--text);
}
#quizView #quizTema, #provaView #provaEsp, #flashView #flashTema, #estudoView :is(#guiaTema, #planoProva, #roteiroEsp) {
  min-height: 50px;
  padding: 0 16px 0 44px;
  border: 0;
  border-radius: 14px;
  background: var(--q-fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.3' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5L20 20'/%3E%3C/svg%3E") no-repeat 14px center / 19px;
  font-size: 17px;
  box-shadow: none;
  transition: box-shadow .18s var(--ease), background-color .18s var(--ease);
}
#quizView #quizTema:focus, #provaView #provaEsp:focus, #flashView #flashTema:focus, #estudoView :is(#guiaTema, #planoProva, #roteiroEsp):focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-chips {
  display: flex;
  gap: 8px;
  margin: 0 -20px;
  padding: 0 20px 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-chips::-webkit-scrollbar { display: none; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-chip {
  flex: none;
  min-height: 36px;
  padding: 0 15px;
  border-radius: var(--r-full);
  background: var(--q-fill);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  transition: background-color .18s var(--ease), color .18s var(--ease), transform .14s var(--ease);
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-chip:active { transform: scale(.95); }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-chip[aria-pressed="true"] { background: var(--primary); color: #ffffff; }
@media (hover: hover) {
  :is(#quizView, #provaView, #flashView, #estudoView) .quiz-chip:hover:not([aria-pressed="true"]) { background: var(--q-fill-2); }
}

/* quantidade e nível: dois blocos; o seletor nativo cobre o bloco inteiro */
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-ajustes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-ajuste {
  position: relative;
  display: block;
  height: 64px;
  border-radius: 16px;
  background: var(--q-fill);
  transition: transform .14s var(--ease);
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-ajuste:active { transform: scale(.98); }
:is(#quizView, #provaView, #flashView, #estudoView) .qa-k {
  position: absolute;
  top: 10px;
  left: 14px;
  z-index: 1;
  pointer-events: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-ajuste select.input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 24px 36px 0 14px;
  border: 0;
  border-radius: 16px;
  background-color: transparent;
  background-position: right 14px center;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  box-shadow: none;
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-ajuste select.input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }

/* na prova oral os ajustes dão lugar a um aviso curto */
#quizView .oral-hint {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 20px 0 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--q-fill);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-2);
}
#quizView .oral-hint::before {
  content: "";
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  background: var(--q-ind);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M4 10v4M8 7v10M12 4v16M16 8v8M20 11v2'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M4 10v4M8 7v10M12 4v16M16 8v8M20 11v2'/%3E%3C/svg%3E") center / contain no-repeat;
}
html[data-theme="light"] #quizView .oral-hint::before { background: #5856d6; }

/* recentes: linhas com o anel de acerto; o histórico é das escritas */
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-hist:not(:empty) { margin-top: 28px; }
#quizView:has(#quizTipoOral:checked) #quizHist { display: none; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-hist-tit {
  margin: 0 0 2px;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.022em;
  color: var(--text);
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-hist-item {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  min-height: 66px;
  padding: 10px 0;
  border-radius: 0;
  background: transparent;
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-hist-item + .quiz-hist-item::before { left: 56px; background: var(--q-line); }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-hist-item:active { opacity: .6; }
:is(#quizView, #provaView, #flashView, #estudoView) .qh-anel { width: 44px; height: 44px; --qh-trilho: var(--q-fill-2); }
:is(#quizView, #provaView, #flashView, #estudoView) .qh-tema { font-size: 17px; }

/* botão de gerar sempre à mão, no pé da tela */
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-cta {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  margin: auto -20px 0;
  padding: 22px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, transparent, var(--main-bg) 22px);
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-cta .btn-primary,
#quizView .quiz-pe .btn-primary,
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-fim-actions > button {
  width: 100%;
  min-height: 52px;
  font-size: 17px;
  font-weight: 600;
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-msg { min-height: 0; font-size: 15px; line-height: 1.4; color: var(--danger); text-align: center; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-msg:not(:empty) { margin-bottom: 12px; }

/* ------------- gerando: o asterisco gira e o esqueleto da questão brilha */
#quizView #quizBody,
#provaView #provaBody,
#flashView #flashBody,
#quizView #quizFim,
#provaView #provaFim,
#flashView #flashFim { flex: 1; gap: 0; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-generating { flex: 1; justify-content: center; gap: 0; padding: 24px 0 56px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-gen-dots { width: 40px; height: 40px; margin-bottom: 20px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-gen-status { font-size: 21px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-gen-tema { margin-top: 6px; font-size: 15px; color: var(--muted); }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-gen-hint { margin-top: 18px; font-size: 14px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-skel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 420px;
  margin-top: 28px;
  padding: 18px;
  border-radius: 20px;
  box-shadow: inset 0 0 0 1.5px var(--q-line);
  text-align: left;
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-skel i,
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-skel b {
  display: block;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--q-fill) 0%, var(--q-fill-2) 50%, var(--q-fill) 100%);
  background-size: 200% 100%;
  animation: q-brilho 1.6s linear infinite;
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-skel i { height: 12px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-skel i:nth-child(2) { width: 92%; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-skel i:nth-child(3) { width: 58%; margin-bottom: 8px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-skel b { height: 42px; border-radius: 12px; }
@keyframes q-brilho { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ------------- questão */
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-p { flex: 1; gap: 0; padding-top: 10px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-eyebrow {
  font-size: 13px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-pergunta,
#quizView .oral-pq {
  margin-top: 8px;
  font-size: 19px;
  line-height: 1.45;
  font-weight: 500;
  letter-spacing: -.016em;
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-p > .dose-alert-box { margin-top: 14px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-alts { gap: 10px; margin: 22px 0 22px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-alt {
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 12px 16px 12px 12px;
  border: 0;
  border-radius: 16px;
  background: var(--q-card);
  box-shadow: inset 0 0 0 1.5px var(--q-line);
  font-size: 17px;
  line-height: 1.35;
  color: var(--text);
  transition: box-shadow .18s var(--ease), background-color .18s var(--ease), opacity .25s var(--ease), transform .14s var(--ease);
}
@media (hover: hover) {
  :is(#quizView, #provaView, #flashView, #estudoView) .quiz-alt:hover:not(:disabled) { box-shadow: inset 0 0 0 1.5px var(--border-strong); }
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-alt:active:not(:disabled) { transform: scale(.985); background: var(--q-fill); }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-alt:disabled:not(.is-ok):not(.is-err) { opacity: .45; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-alt-l {
  width: 32px;
  height: 32px;
  background: var(--q-fill);
  font-size: 15px;
  color: var(--text-2);
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-alt.is-ok { background: var(--q-ok); box-shadow: inset 0 0 0 2px var(--ok); }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-alt.is-err { background: var(--q-err); box-shadow: inset 0 0 0 2px var(--danger); }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-alt.is-ok .quiz-alt-l { background: var(--ok); color: transparent; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-alt.is-err .quiz-alt-l { background: var(--danger); color: transparent; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-alt.is-ok .quiz-alt-l::after,
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-alt.is-err .quiz-alt-l::after { inset: 8px; }

/* correção: folha que sobe no pé da tela, na cor do resultado */
#quizView .quiz-pe {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 72vh;
  max-height: 72dvh;
  margin: auto -20px 0;
  padding: 20px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-radius: 24px 24px 0 0;
  background: var(--main-bg);
  box-shadow: 0 -1px 0 var(--q-line), 0 -14px 34px rgba(0, 0, 0, .07);
  animation: q-subir .34s cubic-bezier(.2, .8, .2, 1);
}
#quizView .quiz-pe:has(> .quiz-prox[hidden]) { display: none; }
#quizView .quiz-pe.is-ok { background: var(--q-ok); }
#quizView .quiz-pe.is-err { background: var(--q-err); }
#quizView .quiz-pe.is-quase { background: var(--q-warn); }
@keyframes q-subir { from { transform: translateY(28px); opacity: 0; } }

#quizView .quiz-expl {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
  border-radius: 0;
  background: none;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
}
#quizView .quiz-veredito {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
}
#quizView .quiz-veredito strong {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ok);
}
#quizView .quiz-veredito strong::before {
  content: "";
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 12.5l4 4L18.5 8'/%3E%3C/svg%3E") center / 15px no-repeat;
}
#quizView .quiz-veredito span { margin-left: auto; font-size: 15px; font-weight: 600; color: var(--text-2); }
#quizView .is-err .quiz-veredito strong,
#quizView .verdict-errada .quiz-veredito strong { color: var(--danger); }
#quizView .is-err .quiz-veredito strong::before,
#quizView .verdict-errada .quiz-veredito strong::before {
  background: var(--danger) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M7.5 7.5l9 9M16.5 7.5l-9 9'/%3E%3C/svg%3E") center / 14px no-repeat;
}
#quizView .verdict-quase .quiz-veredito strong { color: var(--warn); }
#quizView .verdict-quase .quiz-veredito strong::before {
  background: var(--warn) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M12 6.5v7'/%3E%3Cpath d='M12 17.6v.1'/%3E%3C/svg%3E") center / 15px no-repeat;
}
#quizView .quiz-expl-txt { margin: 0; }
#quizView .quiz-expl > .dose-alert-box,
#quizView .oral-fb-wrap > .dose-alert-box { margin: 0; }

/* ------------- prova oral */
#quizView .oral-ouvir {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin-top: 14px;
  padding: 0 15px 0 12px;
  border-radius: var(--r-full);
  background: var(--q-sel);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  transition: transform .14s var(--ease), opacity .14s var(--ease);
}
#quizView .oral-ouvir:active { transform: scale(.96); }
#quizView .oral-ouvir::before {
  content: "";
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9.5v5h3.5L12 19V5L7.5 9.5z'/%3E%3Cpath d='M15.5 9a4 4 0 0 1 0 6'/%3E%3Cpath d='M18.5 6.5a7.5 7.5 0 0 1 0 11'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9.5v5h3.5L12 19V5L7.5 9.5z'/%3E%3Cpath d='M15.5 9a4 4 0 0 1 0 6'/%3E%3Cpath d='M18.5 6.5a7.5 7.5 0 0 1 0 11'/%3E%3C/svg%3E") center / contain no-repeat;
}
.oral-alts { list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 20px 0 0; padding: 0; }
.oral-alts li {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px 10px 12px;
  border-radius: 16px;
  background: var(--q-card, var(--panel));
  box-shadow: inset 0 0 0 1.5px var(--q-line, var(--row-line));
  font-size: 16px;
  line-height: 1.35;
  cursor: pointer;
  transition: box-shadow .18s var(--ease), background-color .18s var(--ease), transform .14s var(--ease);
}
.oral-alts li:active { transform: scale(.985); }
.oral-alts li:focus-visible { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: 2px; }
.oral-alts .oral-l {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--q-fill, var(--group-bg));
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
}
.oral-alts li > .dose-alert-box { grid-column: 1 / -1; margin: 6px 0 0; }
.oral-alts li.is-sel { background: var(--q-sel, var(--accent-soft)); box-shadow: inset 0 0 0 2px var(--accent); }
.oral-alts li.is-sel .oral-l { background: var(--accent); color: #ffffff; }
.oral-alts li.is-ok { background: var(--q-ok, var(--ok-soft)); box-shadow: inset 0 0 0 2px var(--ok); }
.oral-alts li.is-err { background: var(--q-err, var(--danger-soft)); box-shadow: inset 0 0 0 2px var(--danger); }
.oral-alts li.is-ok .oral-l,
.oral-alts li.is-err .oral-l { color: transparent; }
.oral-alts li.is-ok .oral-l { background: var(--ok); }
.oral-alts li.is-err .oral-l { background: var(--danger); }
.oral-alts li.is-ok .oral-l::after,
.oral-alts li.is-err .oral-l::after {
  content: "";
  position: absolute;
  inset: 8px;
  background: #ffffff;
  -webkit-mask: var(--ico-check) center / contain no-repeat;
          mask: var(--ico-check) center / contain no-repeat;
}
.oral-alts li.is-err .oral-l::after { -webkit-mask-image: var(--ico-x); mask-image: var(--ico-x); }
.oral-p:has(.oral-fb-wrap:not([hidden])) .oral-alts li { cursor: default; }

/* resposta: campo arredondado com o microfone ao lado, como no chat */
#quizView .oral-resp {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  margin: 20px 0 22px;
  padding: 6px 6px 6px 16px;
  border-radius: 26px;
  background: var(--q-fill);
  transition: box-shadow .18s var(--ease);
}
#quizView .oral-resp:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent); }
#quizView .oral-resp textarea {
  width: 100%;
  min-height: 92px;
  padding: 10px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  line-height: 1.4;
  resize: none;
}
#quizView .oral-resp textarea::placeholder { color: var(--placeholder); }
#quizView .oral-resp textarea:focus { outline: 0; }
#quizView .oral-resp:has(.listening)::before {
  content: "Gravando… toque de novo para parar";
  grid-column: 1 / -1;
  padding-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
}
#quizView .oral-actions { display: block; }
#quizView .oral-actions .btn-mic {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-size: 0;
  cursor: pointer;
  transition: background-color .18s var(--ease), transform .14s var(--ease);
}
#quizView .oral-actions .btn-mic:active { transform: scale(.94); }
#quizView .oral-actions .btn-mic::before {
  content: "";
  width: 24px;
  height: 24px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='3' width='6' height='11' rx='3'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0M12 18v3'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='3' width='6' height='11' rx='3'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0M12 18v3'/%3E%3C/svg%3E") center / contain no-repeat;
}
#quizView .oral-actions .btn-mic.listening { background: var(--danger); animation: q-pulso 1.5s ease-out infinite; }
#quizView .oral-actions .btn-mic.listening::before {
  width: 18px;
  height: 18px;
  -webkit-mask-image: var(--ico-stop);
          mask-image: var(--ico-stop);
}
@keyframes q-pulso {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, .45); }
  100% { box-shadow: 0 0 0 16px rgba(255, 59, 48, 0); }
}

/* depois da correção, a resposta fica como citação: sem microfone e do tamanho do texto */
#quizView .oral-p:has(.oral-fb-wrap:not([hidden])) .oral-actions { display: none; }
#quizView .oral-p:has(.oral-fb-wrap:not([hidden])) .oral-resp { padding: 12px 16px; border-radius: 18px; }
#quizView .oral-p:has(.oral-fb-wrap:not([hidden])) .oral-resp::before {
  content: "Sua resposta";
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
#quizView .oral-p:has(.oral-fb-wrap:not([hidden])) .oral-resp textarea {
  min-height: 0;
  padding: 2px 0 0;
  field-sizing: content;
  pointer-events: none;
}

/* antes da correção, o pé da prova oral é só o botão de avaliar */
#quizView .oral-p .quiz-pe:has(> .oral-fb-wrap[hidden]) {
  border-radius: 0;
  padding-top: 22px;
  background: linear-gradient(to bottom, transparent, var(--main-bg) 22px);
  box-shadow: none;
  animation: none;
}
#quizView .oral-fb-wrap { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; }
.oral-fb { display: flex; flex-direction: column; gap: 10px; font-size: 16px; line-height: 1.5; color: var(--text); }

/* ------------- resultado: anel grande, gabarito em bolinhas e o que revisar */
@property --qa-p { syntax: "<number>"; inherits: true; initial-value: 0; }
#quizView #quizFim, #provaView #provaFim, #flashView #flashFim { padding-top: 6px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-res { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 8px; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-anel {
  --qa-p: var(--p);
  --qa-c: var(--ok);
  position: relative;
  display: grid;
  place-items: center;
  width: 172px;
  height: 172px;
  animation: q-encher 1.1s cubic-bezier(.2, .8, .2, 1) .1s both;
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-anel.qa-meio { --qa-c: var(--warn); }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-anel.qa-baixo { --qa-c: var(--danger); }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-anel.qa-vazio .qa-pct { color: var(--muted); font-weight: 500; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-anel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--qa-c) calc(var(--qa-p) * 1%), var(--q-fill-2) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 15px), #000 calc(100% - 14px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 15px), #000 calc(100% - 14px));
}
@keyframes q-encher { from { --qa-p: 0; } }
:is(#quizView, #provaView, #flashView, #estudoView) .qa-pct {
  position: relative;
  font-family: var(--font-display);
  font-size: 46px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}
:is(#quizView, #provaView, #flashView, #estudoView) .qa-pct small { margin-left: 1px; font-size: 24px; font-weight: 600; letter-spacing: 0; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-res .quiz-title { margin-top: 18px; font-size: 26px; line-height: 1.2; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-res .quiz-sub { max-width: 34ch; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-gabarito {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-gabarito span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--q-fill-2);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-gabarito .is-ok { background: var(--ok); }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-gabarito .is-err { background: var(--danger); }
#quizView .quiz-gabarito .is-quase { background: var(--warn); }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-rev-tit {
  margin-top: 30px;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.022em;
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-rev { gap: 10px; margin-top: 12px; border-radius: 0; background: none; overflow: visible; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-rev-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 14px 16px 14px 12px;
  border-radius: 16px;
  background: var(--q-fill);
  color: var(--text);
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-rev-item + .quiz-rev-item { border-top: 0; }
:is(#quizView, #provaView, #flashView, #estudoView) .qr-n {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--danger);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}
:is(#quizView, #provaView, #flashView, #estudoView) .qr-ok .qr-n { background: var(--ok); }
:is(#quizView, #provaView, #flashView, #estudoView) .qr-quase .qr-n { background: var(--warn); }
:is(#quizView, #provaView, #flashView, #estudoView) .qr-txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
:is(#quizView, #provaView, #flashView, #estudoView) .qr-q {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  font-size: 15px;
  line-height: 1.4;
}
:is(#quizView, #provaView, #flashView, #estudoView) .qr-meta { font-size: 14px; color: var(--muted); }
:is(#quizView, #provaView, #flashView, #estudoView) .qr-meta strong { color: var(--ok); }
:is(#quizView, #provaView, #flashView, #estudoView) .qr-quase .qr-meta strong { color: var(--warn); }
#quizView .qr-oral.qr-err .qr-meta strong { color: var(--danger); }
:is(#quizView, #provaView, #flashView, #estudoView) .qr-fb { font-size: 15px; line-height: 1.45; color: var(--text-2); }
:is(#quizView, #provaView, #flashView, #estudoView) .qr-txt > .dose-alert-box { margin: 4px 0 0; }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-fim-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  gap: 10px;
  margin: auto -20px 0;
  padding: 24px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, transparent, var(--main-bg) 24px);
}
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-fim-actions .btn-secondary { border: 0; background: var(--q-fill); color: var(--accent); }
:is(#quizView, #provaView, #flashView, #estudoView) .quiz-fim-actions .btn-secondary:hover { background: var(--q-fill-hover); }

/* computador e tablet: temas em várias linhas e a correção como cartão flutuante */
@media (min-width: 600px) {
  :is(#quizView, #provaView, #flashView, #estudoView) .quiz-chips { flex-wrap: wrap; margin: 0; padding: 0; overflow: visible; }
}
@media (min-width: 769px) {
  :is(#quizView, #provaView, #flashView, #estudoView) .quiz-wrap { padding: 0 24px; }
  :is(#quizView, #provaView, #flashView, #estudoView) .quiz-head { margin: 0 -24px; padding-left: 24px; padding-right: 24px; }
  :is(#quizView, #provaView, #flashView, #estudoView) .quiz-title { font-size: 40px; }
  #quizView .quiz-tipo-opt { min-height: 132px; padding: 16px; }
  #quizView .quiz-tipo-opt::after { top: 16px; right: 16px; }
  :is(#quizView, #provaView, #flashView, #estudoView) .quiz-cta,
  :is(#quizView, #provaView, #flashView, #estudoView) .quiz-fim-actions { margin-left: -24px; margin-right: -24px; padding-left: 24px; padding-right: 24px; }
  /* no computador a correção vem logo abaixo das alternativas, como um cartão */
  #quizView .quiz-pe { bottom: 16px; margin: 0 0 16px; padding-bottom: 18px; border-radius: 24px; box-shadow: 0 0 0 1px var(--q-line), 0 18px 48px rgba(0, 0, 0, .12); }
  #quizView .oral-p .quiz-pe:has(> .oral-fb-wrap[hidden]) { bottom: 0; margin: auto -24px 0; padding: 22px 24px 16px; border-radius: 0; box-shadow: none; }
  :is(#quizView, #provaView, #flashView, #estudoView) .quiz-fim-actions { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  #quizView .quiz-pe,
  :is(#quizView, #provaView, #flashView, #estudoView) .quiz-anel,
  :is(#quizView, #provaView, #flashView, #estudoView) .quiz-skel i,
  :is(#quizView, #provaView, #flashView, #estudoView) .quiz-skel b,
  #quizView .oral-actions .btn-mic.listening { animation: none; }
}

/* ---------------------------------------------------------- prova simulada
   Mesmo padrão do Treinar: especialidades prontas, tamanho em cartões, nível num seletor de
   segmento, relógio no topo, folha de respostas em bolinhas e o pé fixo com voltar e seguir. */

/* tamanho: três cartões com o número grande e o tempo de prova */
:is(#provaView, #estudoView) .prova-tam { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
:is(#provaView, #estudoView) .prova-tam-opt {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 6px 12px;
  border-radius: 18px;
  background: var(--q-fill);
  cursor: pointer;
  user-select: none;
  transition: background-color .2s var(--ease), box-shadow .2s var(--ease), transform .16s var(--ease);
}
:is(#provaView, #estudoView) .prova-tam-opt:active { transform: scale(.97); }
:is(#provaView, #estudoView) .prova-tam-opt input { position: absolute; opacity: 0; pointer-events: none; }
:is(#provaView, #estudoView) .prova-tam-opt:has(input:checked) { background: var(--q-sel); box-shadow: inset 0 0 0 2px var(--accent); }
:is(#provaView, #estudoView) .prova-tam-opt:has(input:focus-visible) { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: 2px; }
:is(#provaView, #estudoView) .pt-n {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
:is(#provaView, #estudoView) .pt-k { font-size: 13px; color: var(--muted); }
:is(#provaView, #estudoView) .pt-t {
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  background: var(--q-fill-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
/* o azul do botão principal: o texto branco sobre o azul claro do escuro (#2997ff) dava 3:1; sobre este, 4,7:1 (AA) */
:is(#provaView, #estudoView) .prova-tam-opt:has(input:checked) .pt-t { background: var(--primary); color: #ffffff; }

/* nível: seletor de segmento, como no iOS */
:is(#provaView, #estudoView) .prova-seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 3px;
  border-radius: 12px;
  background: var(--q-fill);
}
:is(#provaView, #estudoView) .prova-seg-opt { position: relative; display: block; }
:is(#provaView, #estudoView) .prova-seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
:is(#provaView, #estudoView) .prova-seg-opt span {
  display: grid;
  place-items: center;
  min-height: 40px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background-color .18s var(--ease), box-shadow .18s var(--ease);
}
:is(#provaView, #estudoView) .prova-seg-opt input:checked + span {
  background: var(--q-card);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04);
}
html:not([data-theme="light"]) :is(#provaView, #estudoView) .prova-seg-opt input:checked + span { background: #636366; }
:is(#provaView, #estudoView) .prova-seg-opt input:focus-visible + span { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: 1px; }

#provaView .prova-dica {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}
#provaView .prova-dica::before,
#provaView .prova-relogio::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='13' r='8'/%3E%3Cpath d='M12 9v4l2.5 2.5'/%3E%3Cpath d='M9 2h6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='13' r='8'/%3E%3Cpath d='M12 9v4l2.5 2.5'/%3E%3Cpath d='M9 2h6'/%3E%3C/svg%3E") center / contain no-repeat;
}
#provaView .prova-dica::before { margin-top: 1px; }

/* relógio no meio do topo e a barra do tempo na borda de baixo */
#provaView .prova-relogio {
  position: absolute;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 27px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
#provaView .prova-relogio::before { width: 17px; height: 17px; color: var(--muted); }
#provaView .prova-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  margin: 0;
  overflow: hidden;
  border-radius: 0;
  background: var(--q-fill-2);
}
#provaView .prova-bar div { height: 100%; background: var(--accent); transition: width 1s linear; }
#provaView:has(#provaBody[hidden]) .prova-relogio,
#provaView:has(#provaBody[hidden]) .prova-bar,
#provaView:has(.quiz-generating) .prova-relogio,
#provaView:has(.quiz-generating) .prova-bar { display: none; }
#provaView .prova-warn {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-full);
  background: var(--q-err);
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}
#provaView:has(.prova-warn) .prova-relogio,
#provaView:has(.prova-warn) .prova-relogio::before { color: var(--danger); }
#provaView:has(.prova-warn) .prova-bar div { background: var(--danger); }

/* folha de respostas: igual ao gabarito do resultado, bolinhas numeradas em linhas centralizadas.
   Cinza = em branco, azul = respondida, anel = questão atual. No fim elas viram verde e vermelho. */
#provaView .prova-mapa {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
#provaView .pm-n {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--q-fill-2);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  transition: background-color .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease), transform .14s var(--ease);
}
#provaView .pm-n:active { transform: scale(.92); }
#provaView .pm-n.is-resp { background: var(--primary); color: #ffffff; }
#provaView .pm-n.is-agora { box-shadow: 0 0 0 2px var(--main-bg), 0 0 0 4px var(--accent); color: var(--text); }
#provaView .pm-n.is-resp.is-agora { color: #ffffff; }
#provaView .quiz-p { padding-top: 18px; }

/* na prova a escolha só fica marcada (a correção vem no fim) */
#provaView .quiz-alt.is-sel { background: var(--q-sel); box-shadow: inset 0 0 0 2px var(--accent); }
#provaView .quiz-alt.is-sel .quiz-alt-l { background: var(--accent); color: #ffffff; }

/* pé fixo: voltar redondo e o botão de seguir (ou entregar) */
#provaView .prova-nav {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  margin: auto -20px 0;
  padding: 22px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, transparent, var(--main-bg) 22px);
}
#provaView .prova-nav .btn-primary { width: 100%; min-height: 52px; font-size: 17px; font-weight: 600; }
#provaView .prova-ant {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--q-fill);
  color: var(--text);
  font-size: 0;
  transition: background-color .18s var(--ease), transform .14s var(--ease), opacity .18s var(--ease);
}
#provaView .prova-ant::before {
  content: "";
  width: 20px;
  height: 20px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 6l-6 6 6 6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 6l-6 6 6 6'/%3E%3C/svg%3E") center / contain no-repeat;
}
#provaView .prova-ant:active:not(:disabled) { transform: scale(.94); }
#provaView .prova-ant:disabled { opacity: .35; cursor: default; }
@media (hover: hover) {
  #provaView .prova-ant:hover:not(:disabled) { background: var(--q-fill-2); }
}

/* resultado: além do anel, o tempo usado, o ritmo e as questões em branco */
#provaView .prova-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
#provaView .ps-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 6px;
  border-radius: 16px;
  background: var(--q-fill);
}
#provaView .ps-v {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
#provaView .ps-k { font-size: 13px; color: var(--muted); }
#provaView .quiz-gabarito .is-branco { background: var(--q-fill-2); color: var(--muted); }
#provaView .qr-branco .qr-n { background: var(--q-fill-2); color: var(--text-2); }

@media (min-width: 769px) {
  #provaView .prova-nav { margin: auto -24px 0; padding-left: 24px; padding-right: 24px; }
}

/* ---------------------------------------------------------- flashcards
   Revisão de hoje como um baralho (um cartão por vez), cartões novos com temas prontos e a
   sessão com o cartão grande que vira: "Mostrar resposta" e, depois, "Não sabia" e "Sabia". */

/* o cartão que sai para o lado não pode abrir rolagem lateral */
#flashView { overflow-x: hidden; }

/* revisão de hoje */
#flashView .srs-box { display: flex; flex-direction: column; gap: 12px; margin-top: 26px; }
#flashView .srs-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0; }
#flashView .srs-head h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.022em;
  color: var(--text);
}
#flashView .srs-cont { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* o baralho: o cartão de cima e, por trás, as bordas dos próximos */
#flashView .srs-deck { position: relative; }
#flashView .srs-deck[data-resta="2"] { padding-bottom: 8px; }
#flashView .srs-deck[data-resta="3"] { padding-bottom: 16px; }
#flashView .srs-deck::before,
#flashView .srs-deck::after {
  content: "";
  position: absolute;
  display: none;
  border-radius: 22px;
  background: var(--q-card);
  box-shadow: inset 0 0 0 1.5px var(--q-line);
}
#flashView .srs-deck[data-resta="2"]::before { display: block; top: 14px; right: 12px; bottom: 0; left: 12px; z-index: 1; }
#flashView .srs-deck[data-resta="3"]::before { display: block; top: 14px; right: 12px; bottom: 8px; left: 12px; z-index: 1; }
#flashView .srs-deck[data-resta="3"]::after { display: block; top: 28px; right: 24px; bottom: 0; left: 24px; z-index: 0; }
html[data-theme="light"] #flashView .srs-deck::before { background: #fafafc; }
html[data-theme="light"] #flashView .srs-deck::after { background: #f4f4f7; }
#flashView .srs-card {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 22px;
  background: var(--q-card);
  box-shadow: inset 0 0 0 1.5px var(--q-line), 0 10px 30px rgba(0, 0, 0, .06);
}
#flashView .srs-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}
#flashView .srs-card.revealed .srs-item { cursor: default; }
/* nota dada: o cartão sai para o lado (direita sabia, esquerda não sabia) e o de trás sobe */
#flashView .srs-card.is-saindo { pointer-events: none; animation: srs-sai .26s cubic-bezier(.4, 0, .7, .2) forwards; }
#flashView .srs-card.sai-nao { animation-name: srs-sai-esq; }
#flashView .srs-card.is-chegando { animation: srs-chega .3s cubic-bezier(.2, .8, .2, 1); }
@keyframes srs-sai { to { transform: translateX(46%) rotate(5deg); opacity: 0; } }
@keyframes srs-sai-esq { to { transform: translateX(-46%) rotate(-5deg); opacity: 0; } }
@keyframes srs-chega { from { transform: translateY(14px) scale(.96); opacity: .5; } }
#flashView .srs-meta {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
}
#flashView .srs-front { font-size: 20px; line-height: 1.35; font-weight: 600; letter-spacing: -.016em; }
#flashView .srs-dica { margin-top: 8px; font-size: 15px; font-weight: 500; color: var(--accent); }
#flashView .srs-card.revealed .srs-dica { display: none; }
#flashView .srs-card > .dose-alert-box { margin: 0; }
#flashView .srs-flip-verso {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--q-line);
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  animation: q-subir .3s cubic-bezier(.2, .8, .2, 1);
}
#flashView .srs-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; }

/* quatro notas (Errei / Difícil / Bom / Fácil): cada botão diz quando o card volta */
#flashView .srs-nota {
  flex-direction: column;
  gap: 2px;
  min-height: 58px;
  padding: 8px 4px;
  border-radius: 15px;
  font-size: 15px;
}
#flashView .srs-nota::before { display: none; }
#flashView .srs-nota b { font-size: 15px; font-weight: 600; line-height: 1.1; }
#flashView .srs-nota span { font-size: 11px; font-weight: 500; line-height: 1.1; opacity: .78; }
#flashView .srs-nota.is-errei { background: var(--q-err); color: var(--danger); }
#flashView .srs-nota.is-dificil { background: var(--q-fill); color: var(--warn); }
#flashView .srs-nota.is-bom { background: var(--q-fill-2, var(--q-fill)); color: var(--primary); }
#flashView .srs-nota.is-facil { background: var(--q-ok); color: var(--ok); }
@media (max-width: 430px) {
  #flashView .srs-btns { grid-template-columns: repeat(2, 1fr); }
}

/* botões de nota (revisão e sessão): pílulas tingidas com ✕ e ✓ */
#flashView .srs-btns button,
#flashView .flash-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  border: 0;
  border-radius: var(--r-full);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .14s var(--ease), background-color .18s var(--ease);
}
#flashView .srs-btns button::before,
#flashView .flash-grade::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: var(--ico-check) center / contain no-repeat;
          mask: var(--ico-check) center / contain no-repeat;
}
#flashView .srs-btns button:active,
#flashView .flash-grade:active { transform: scale(.97); }
#flashView .srs-errei,
#flashView .flash-grade.flash-nao { background: var(--q-err); color: var(--danger); }
#flashView .srs-btns .srs-errei::before,
#flashView .flash-grade.flash-nao::before { -webkit-mask-image: var(--ico-x); mask-image: var(--ico-x); }
#flashView .srs-sei,
#flashView .flash-grade.flash-sim { background: var(--q-ok); color: var(--ok); }

/* revisão em dia e carregando */
#flashView .srs-vazio {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  column-gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--q-fill);
}
#flashView .srs-vazio::before {
  content: "";
  grid-row: span 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 12.5l4 4L18.5 8'/%3E%3C/svg%3E") center / 18px no-repeat;
}
#flashView .srs-vazio strong { font-size: 17px; font-weight: 600; color: var(--text); }
#flashView .srs-vazio span { font-size: 14px; line-height: 1.4; color: var(--muted); }
#flashView .srs-carregando {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 132px;
  border-radius: 22px;
  background: linear-gradient(90deg, var(--q-fill) 0%, var(--q-fill-2) 50%, var(--q-fill) 100%);
  background-size: 200% 100%;
  animation: q-brilho 1.6s linear infinite;
  font-size: 15px;
  color: var(--muted);
}
#flashView .srs-card.is-salvando .srs-btns { opacity: .6; }
#flashView .srs-erro { margin: 10px 2px 0; font-size: 14px; line-height: 1.4; color: var(--danger); }
#flashView .srs-vazia { margin: 0; font-size: 14px; line-height: 1.45; color: var(--muted); }

/* sessão: o cartão grande no meio da tela */
#flashView .flash-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: min(52vh, 420px);
  margin-top: 12px;
  overflow: visible;
  padding: 28px 24px;
  border-radius: 28px;
  background: var(--q-card);
  box-shadow: inset 0 0 0 1.5px var(--q-line), 0 18px 44px rgba(0, 0, 0, .08);
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: transform .14s var(--ease);
}
#flashView .flash-card:focus-visible { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: 3px; }
#flashView .flash-card:active:not(.revealed) { transform: scale(.985); }
#flashView .flash-card.revealed {
  cursor: default;
  user-select: text;
  animation: flash-virar .45s cubic-bezier(.2, .8, .2, 1);
}
@keyframes flash-virar {
  from { transform: perspective(1200px) rotateY(-90deg); }
  to { transform: perspective(1200px) rotateY(0); }
}
#flashView .flash-card > .dose-alert-box { margin: 0 0 16px; text-align: left; }
#flashView .flash-q {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  min-height: 0;
  padding: 0;
}
#flashView .flash-pergunta { font-size: 24px; line-height: 1.3; font-weight: 600; letter-spacing: -.02em; }
#flashView .flash-revealhint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
}
#flashView .flash-revealhint::before {
  content: "";
  width: 17px;
  height: 17px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12a8 8 0 0 1 13.7-5.6L20 8.7'/%3E%3Cpath d='M20 4v4.7h-4.7'/%3E%3Cpath d='M20 12a8 8 0 0 1-13.7 5.6L4 15.3'/%3E%3Cpath d='M4 20v-4.7h4.7'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12a8 8 0 0 1 13.7-5.6L20 8.7'/%3E%3Cpath d='M20 4v4.7h-4.7'/%3E%3Cpath d='M20 12a8 8 0 0 1-13.7 5.6L4 15.3'/%3E%3Cpath d='M4 20v-4.7h4.7'/%3E%3C/svg%3E") center / contain no-repeat;
}
#flashView .flash-card.revealed .flash-revealhint { display: none; }
#flashView .flash-card.revealed .flash-q { gap: 0; }
#flashView .flash-card.revealed .flash-pergunta { font-size: 17px; line-height: 1.4; font-weight: 500; color: var(--muted); }
#flashView .flash-a {
  margin-top: 18px;
  padding: 18px 0 0;
  border-top: 1px solid var(--q-line);
  font-size: 21px;
  line-height: 1.45;
  font-weight: 500;
  color: var(--text);
  white-space: pre-wrap;
}
#flashView .flash-a > .dose-alert-box { margin: 14px 0 0; text-align: left; white-space: normal; }

/* pé fixo: "Mostrar resposta" até virar; depois "Não sabia" e "Sabia" */
#flashView .flash-pe {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin: auto -20px 0;
  padding: 22px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, transparent, var(--main-bg) 22px);
}
#flashView .flash-ver { width: 100%; min-height: 52px; font-size: 17px; font-weight: 600; }
#flashView .flash-bar { display: none; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
#flashView .flash-p:has(.flash-card.revealed) .flash-ver { display: none; }
#flashView .flash-p:has(.flash-card.revealed) .flash-bar { display: grid; }

/* gerando: o esqueleto é um cartão */
#flashView .flash-skel { align-items: center; justify-content: center; min-height: 230px; border-radius: 28px; }
#flashView .flash-skel i { width: 80%; height: 14px; }
#flashView .flash-skel i:nth-child(2) { width: 64%; }
#flashView .flash-skel i:nth-child(3) { width: 40%; margin-bottom: 0; }

@media (min-width: 769px) {
  #flashView .flash-pe { margin-left: -24px; margin-right: -24px; padding-left: 24px; padding-right: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  #flashView .flash-card.revealed,
  #flashView .srs-flip-verso,
  #flashView .srs-card.is-chegando,
  #flashView .srs-carregando { animation: none; }
  #flashView .srs-card.is-saindo { animation-duration: .01s; }
}

/* ---------------------------------------------------------- estudar
   Mesmo padrão do Treinar: título, seletor de segmento com as quatro partes, temas prontos,
   ajustes em blocos e botão fixo no pé. Guia aberto, plano aberto e roteiro pronto são telas
   "empurradas": o topo vira "‹ Estudar" e somem o título e as abas. */

#estudoView [hidden] { display: none !important; }

/* topo: "Conversas" na tela inicial; "Estudar" dentro de um guia, plano ou roteiro */
#estudoView .ev-detalhe { display: none; }
#estudoView:has(.estudo-pane.active > .estudo-detalhe:not([hidden])) .ev-casa,
#estudoView:has(.estudo-pane.active > .estudo-detalhe:not([hidden])) .estudo-topo { display: none; }
#estudoView:has(.estudo-pane.active > .estudo-detalhe:not([hidden])) .ev-detalhe { display: inline; }

#estudoView .estudo-topo { padding-top: 6px; }

/* as quatro partes num seletor de segmento, como no iOS */
#estudoView .estudo-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 22px 0 0;
  padding: 3px;
  border-radius: 12px;
  background: var(--q-fill);
}
#estudoView .estudo-tab {
  min-width: 0;
  height: auto;
  min-height: 36px;
  padding: 0 4px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  transition: background-color .18s var(--ease), box-shadow .18s var(--ease);
}
#estudoView .estudo-tab.active {
  background: var(--q-card);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04);
}
html:not([data-theme="light"]) #estudoView .estudo-tab.active { background: #636366; }
#estudoView .estudo-tab:focus-visible { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: 1px; }
@media (max-width: 359px) {
  #estudoView .estudo-tab { font-size: 14px; }
}

/* cada parte ocupa a tela até o pé, para o botão de gerar ficar sempre embaixo */
#estudoView .estudo-pane { display: none; }
#estudoView .estudo-pane.active { display: flex; flex: 1; flex-direction: column; }
#estudoView #guiaForm,
#estudoView #planoForm,
#estudoView #roteiroForm,
#estudoView #progressoBody,
#estudoView .estudo-detalhe { flex: 1; gap: 0; }
#estudoView .estudo-intro { margin: 16px 0 0; font-size: 15px; line-height: 1.45; color: var(--muted); }

/* campos de texto dentro dos blocos (especialidade e foco) */
#estudoView .quiz-ajuste input.input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 24px 14px 0;
  border: 0;
  border-radius: 16px;
  background: transparent;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  box-shadow: none;
}
#estudoView .quiz-ajuste input.input::placeholder { font-weight: 400; color: var(--muted); opacity: 1; }
#estudoView .quiz-ajuste input.input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
#estudoView .estudo-ajuste-1 { grid-template-columns: minmax(0, 1fr); }

/* dias até a prova: cinco cartões numa linha */
#estudoView .estudo-dias { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
#estudoView .estudo-dias .prova-tam-opt { padding: 12px 2px 10px; border-radius: 16px; }
#estudoView .estudo-dias .pt-n { font-size: 24px; }

/* o guia sendo escrito: o asterisco girando ao lado do título e o rascunho crescendo embaixo */
#estudoView .guia-escrevendo { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
#estudoView .ge-topo { display: flex; align-items: center; gap: 14px; }
#estudoView .ge-topo .quiz-gen-dots { flex: none; width: 30px; height: 30px; margin: 0; }
#estudoView .ge-txt { min-width: 0; }
#estudoView .ge-topo .quiz-gen-status { margin: 0; font-size: 21px; line-height: 1.2; }
#estudoView .ge-topo .quiz-gen-tema { margin-top: 3px; font-size: 15px; color: var(--muted); }
#estudoView .ge-conta { margin: 0; font-size: 15px; color: var(--text-2); }
#estudoView .ge-rascunho:empty { display: none; }
#estudoView .ge-pe .ge-dica { margin: 0 0 2px; font-size: 13px; line-height: 1.35; color: var(--muted); text-align: center; }
/* o guia que parou no meio: o aviso no topo, com o "Escrever de novo" */
#estudoView .guia-incompleto {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin: 4px 0 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--q-warn);
  color: var(--text);
}
#estudoView .guia-incompleto p { margin: 0; font-size: 15px; line-height: 1.4; }
#estudoView .guia-acao[data-acao="refazer"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11a8 8 0 1 0-2.3 5.7'/%3E%3Cpath d='M20 4v7h-7'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11a8 8 0 1 0-2.3 5.7'/%3E%3Cpath d='M20 4v7h-7'/%3E%3C/svg%3E");
}
/* "Seus guias": o que está sendo escrito tem o asterisco girando no canto do ícone */
#estudoView .guia-card.is-escrevendo .gc-ico { position: relative; }
#estudoView .guia-card.is-escrevendo .gc-ico::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 18px;
  height: 18px;
  background: linear-gradient(140deg, var(--brand-a), var(--brand-b));
  -webkit-mask: var(--ico-star) center / contain no-repeat;
          mask: var(--ico-star) center / contain no-repeat;
  animation: girar 2.4s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  #estudoView .guia-card.is-escrevendo .gc-ico::after { animation: none; }
}

/* prova: cinco tamanhos numa linha (5, 10, 20, 30 e 50), como os dias do plano */
#provaView .prova-tam { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
#provaView .prova-tam-opt { padding: 12px 2px 10px; border-radius: 16px; }
#provaView .pt-n { font-size: 24px; }
#provaView .pt-t { padding: 3px 7px; font-size: 12px; white-space: nowrap; }

/* a prova montada no servidor: o anel enche a cada parte pronta; a pronta e a parcial esperam o "Começar" */
#provaView .prova-espera .quiz-anel { margin-bottom: 22px; transition: --qa-p .7s var(--ease); }
#provaView .quiz-anel.qa-montando { --qa-c: var(--accent); animation: none; }
#provaView .prova-espera .qa-pct small { margin-left: 2px; font-size: 22px; color: var(--muted); }
#provaView .pe-conta { min-height: 21px; margin-top: 14px; font-size: 15px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
#provaView .prova-espera .quiz-title { font-size: 26px; line-height: 1.2; }
#provaView .prova-espera .quiz-sub { max-width: 36ch; margin-top: 8px; }
#provaView .prova-espera .quiz-gen-hint { max-width: 34ch; }
.tile-badge.is-ponto { top: -3px; right: -3px; min-width: 10px; width: 10px; height: 10px; padding: 0; }
/* o título da troca de estado recebe o foco (o botão que o tinha some): é texto, não controle, e fica sem o anel */
#provaView .prova-espera .quiz-title:focus { outline: none; }
/* telas estreitas (320 px): os cinco tamanhos sem estourar o cartão */
@media (max-width: 359px) {
  #provaView .prova-tam { gap: 6px; }
  #provaView .prova-tam-opt { padding: 10px 1px 9px; }
  #provaView .pt-n { font-size: 21px; }
  #provaView .pt-k { font-size: 11px; }
  #provaView .pt-t { padding: 2px 4px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  #provaView .prova-espera .quiz-anel { transition: none; }
}

/* listas (seus guias, seus planos, por tema): linhas como os recentes do Treinar */
#estudoView .estudo-lista:not(:empty) { margin-top: 26px; }
#estudoView .quiz-hist-item { cursor: pointer; }
#estudoView .gc-ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(175, 82, 222, .14) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23af52de' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3.5h8.5L19 8v12.5H6z'/%3E%3Cpath d='M14 3.5V8.5h5'/%3E%3Cpath d='M9 12.5h7M9 16h5'/%3E%3C/svg%3E") center / 22px no-repeat;
}
#estudoView .est-chev {
  width: 8px;
  height: 14px;
  margin-right: 2px;
  background: var(--muted);
  opacity: .55;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 14' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5L6.5 7l-5 5.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 14' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5L6.5 7l-5 5.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
#estudoView .qh-anel.qh-plano { --qh-c: var(--accent); }
#estudoView .qh-anel.qh-plano.qh-ok { --qh-c: var(--ok); }

/* gerando: o esqueleto é uma página de texto */
#estudoView .est-skel { gap: 9px; }
#estudoView .est-skel b { width: 46%; height: 16px; margin-top: 8px; border-radius: 6px; }
#estudoView .est-skel b:first-child { margin-top: 0; }
#estudoView .est-skel i { width: 100%; height: 11px; margin: 0; }
#estudoView .est-skel i:nth-child(4),
#estudoView .est-skel i:nth-child(7) { width: 64%; }
#estudoView .est-carregando {
  height: 260px;
  margin-top: 26px;
  border-radius: 22px;
  background: linear-gradient(90deg, var(--q-fill) 0%, var(--q-fill-2) 50%, var(--q-fill) 100%);
  background-size: 200% 100%;
  animation: q-brilho 1.6s linear infinite;
}

/* vazio e "plano concluído" */
#estudoView .estudo-vazio {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 44px 12px 24px;
  text-align: center;
}
#estudoView .estudo-vazio::before {
  content: "";
  width: 56px;
  height: 56px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--q-sel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230071e3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19.5h16'/%3E%3Cpath d='M6.5 16v-4'/%3E%3Cpath d='M11 16V8'/%3E%3Cpath d='M15.5 16v-6'/%3E%3Cpath d='M20 16V5'/%3E%3C/svg%3E") center / 26px no-repeat;
}
#estudoView .estudo-vazio strong { font-size: 19px; font-weight: 700; letter-spacing: -.02em; color: var(--text); }
#estudoView .estudo-vazio span { max-width: 34ch; font-size: 15px; line-height: 1.45; color: var(--muted); }
#estudoView .grade-fim::before {
  background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 12.5l4 4L18.5 8'/%3E%3C/svg%3E") center / 26px no-repeat;
}

/* ------------- progresso */
#estudoView #progressoBody { padding-top: 26px; }
#estudoView .prog-res { padding-top: 0; }
#estudoView .prog-res .quiz-anel { width: 156px; height: 156px; }
#estudoView .prog-res .qa-pct { font-size: 42px; }
#estudoView .prog-res .quiz-title { margin-top: 16px; font-size: 24px; }
#estudoView .prog-streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 7px 14px 7px 11px;
  border-radius: var(--r-full);
  background: var(--q-warn);
  font-size: 15px;
  font-weight: 600;
  color: #c93400;
}
html:not([data-theme="light"]) #estudoView .prog-streak { color: #ff9f0a; }
#estudoView .prog-streak::before {
  content: "";
  width: 15px;
  height: 17px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 24'%3E%3Cpath d='M10 1c1 4.4 6.5 6.6 6.5 13a6.5 6.5 0 0 1-13 0c0-3 1.4-5 3-6.4.2 2 1 3.3 2.3 4C8 7.6 8.7 4 10 1z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 24'%3E%3Cpath d='M10 1c1 4.4 6.5 6.6 6.5 13a6.5 6.5 0 0 1-13 0c0-3 1.4-5 3-6.4.2 2 1 3.3 2.3 4C8 7.6 8.7 4 10 1z'/%3E%3C/svg%3E") center / contain no-repeat;
}
#estudoView .prog-semana { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
#estudoView .prog-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
#estudoView .prog-stat { padding: 14px 14px 12px; border-radius: 16px; background: var(--q-fill); }
#estudoView .prog-val {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
#estudoView .prog-lab { margin-top: 2px; font-size: 13px; color: var(--muted); }
#estudoView .prog-linha {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 13px 16px;
  border-radius: 16px;
  background: var(--q-fill);
  font-size: 15px;
}
#estudoView .prog-linha span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
#estudoView .prog-linha span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
#estudoView .pl-forte span::before { background: var(--ok); }
#estudoView .pl-fraco span::before { background: var(--danger); }
#estudoView .prog-linha strong { overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; text-align: right; color: var(--text); }
#estudoView .prog-linha em { font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
#estudoView .pl-forte em { color: var(--ok); }
#estudoView .pl-fraco em { color: var(--danger); }
#estudoView .prog-list:not(:empty) { margin-top: 30px; }
#estudoView .prog-dica { margin: 4px 0 6px; font-size: 15px; color: var(--muted); }
#estudoView .prog-list .quiz-hist-tit { margin-bottom: 0; }
#estudoView .prog-list { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }

/* ------------- plano aberto: lista de dias com o "próximo" marcado */
#estudoView .grade-head { padding-top: 10px; }
#estudoView .grade-titulo { margin-top: 6px; font-size: 30px; line-height: 1.12; font-weight: 700; letter-spacing: -.026em; color: var(--text); }
#estudoView .grade-sub { margin-top: 6px; font-size: 16px; line-height: 1.4; color: var(--muted); font-variant-numeric: tabular-nums; }
#estudoView .grade-bar { height: 8px; margin: 18px 0 6px; overflow: hidden; border-radius: 4px; background: var(--q-fill-2); }
#estudoView .grade-bar .prog-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width .35s var(--ease); }
#estudoView .day-list { display: flex; flex-direction: column; margin-top: 6px; }
#estudoView .day-row {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 12px 0;
}
#estudoView .day-row + .day-row::before { content: ""; position: absolute; top: 0; left: 54px; right: 0; height: 1px; background: var(--q-line); }
#estudoView .day-check {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -6px 0 0 -4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
#estudoView .day-check::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--q-line);
  transition: background-color .2s var(--ease), box-shadow .2s var(--ease), transform .14s var(--ease);
}
html:not([data-theme="light"]) #estudoView .day-check::before { box-shadow: inset 0 0 0 2px #636366; }
#estudoView .day-check:active::before { transform: scale(.88); }
#estudoView .day-prox .day-check::before { box-shadow: inset 0 0 0 2px var(--accent); }
#estudoView .day-feito .day-check::before { background: var(--ok); box-shadow: none; }
#estudoView .day-check::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  background: #ffffff;
  opacity: 0;
  -webkit-mask: var(--ico-check) center / contain no-repeat;
          mask: var(--ico-check) center / contain no-repeat;
  transition: opacity .2s var(--ease);
}
#estudoView .day-feito .day-check::after { opacity: 1; }
#estudoView .day-check:focus-visible { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: -4px; }
#estudoView .day-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#estudoView .day-l1 { display: flex; align-items: center; gap: 8px; }
#estudoView .day-num { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-variant-numeric: tabular-nums; }
#estudoView .day-tag { display: none; padding: 2px 8px; border-radius: var(--r-full); background: var(--accent); font-size: 12px; font-weight: 600; color: #ffffff; }
#estudoView .day-prox .day-tag { display: inline-block; }
#estudoView .day-tema { font-size: 17px; line-height: 1.35; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
#estudoView .day-foco { font-size: 15px; line-height: 1.4; color: var(--muted); }
#estudoView .day-feito .day-tema { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
#estudoView .day-body > .dose-alert-box { margin: 6px 0 0; }
#estudoView .is-salvando .day-check { pointer-events: none; }

/* ------------- roteiro pronto: módulos numerados */
#estudoView .roteiro-mod { margin-top: 26px; padding: 0; border-radius: 0; background: none; }
#estudoView .rm-head { display: flex; align-items: center; gap: 12px; }
#estudoView .rm-n {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}
#estudoView .roteiro-mod-titulo { margin: 0; font-size: 20px; line-height: 1.25; font-weight: 700; letter-spacing: -.022em; color: var(--text); }
#estudoView .roteiro-mod > .dose-alert-box { margin: 10px 0 0; }
#estudoView .roteiro-dica {
  margin: 10px 0 0;
  padding: 11px 14px;
  border-radius: 14px;
  background: var(--q-warn);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
}
#estudoView .roteiro-topics { margin: 6px 0 0; padding: 0; list-style: none; }
#estudoView .roteiro-topics li {
  position: relative;
  padding: 11px 0 11px 42px;
  font-size: 17px;
  line-height: 1.35;
  color: var(--text);
}
#estudoView .roteiro-topics li + li { margin: 0; }
#estudoView .roteiro-topics li + li::after { content: ""; position: absolute; top: 0; left: 42px; right: 0; height: 1px; background: var(--q-line); }
#estudoView .roteiro-topics li::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 11px;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--muted);
}

/* ------------- guia aberto: título grande, ações em pílulas e o texto direto na página */
@media screen {
  #estudoView .guia-print-head { display: block; margin: 0; padding: 10px 0 0; border: 0; }
  #estudoView .guia-print-head h1 { margin: 6px 0 0; font-size: 30px; line-height: 1.12; font-weight: 700; letter-spacing: -.026em; color: var(--text); }
  /* o foco vai para o título quando o guia abre sozinho (o leitor de tela começa por ele); o título não é um controle */
  #estudoView .guia-print-head h1:focus { outline: none; }
  #estudoView .guia-print-head span { display: block; margin-top: 6px; font-size: 15px; color: var(--muted); }
  #estudoView .gph-marca { display: none; }
}
#estudoView .guide-actions { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; margin-top: 14px; }
#estudoView .guia-acao {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px 0 12px;
  border-radius: var(--r-full);
  background: var(--q-fill);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  transition: background-color .18s var(--ease), transform .14s var(--ease);
}
#estudoView .guia-acao:active { transform: scale(.96); }
#estudoView .guia-acao::before {
  content: "";
  width: 15px;
  height: 15px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11'/%3E%3Cpath d='M7 10.5l5 5 5-5'/%3E%3Cpath d='M5 20h14'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11'/%3E%3Cpath d='M7 10.5l5 5 5-5'/%3E%3Cpath d='M5 20h14'/%3E%3C/svg%3E") center / contain no-repeat;
}
#estudoView .guia-acao[data-acao="novo"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
}
@media (hover: hover) {
  #estudoView .guia-acao:hover { background: var(--q-fill-2); }
}
#estudoView .guide-body {
  margin-top: 20px;
  padding: 0 0 calc(32px + env(safe-area-inset-bottom, 0px));
  border-radius: 0;
  background: none;
  font-size: 17px;
  line-height: 1.55;
}
#estudoView .guide-body > .dose-alert-box:first-child { margin-top: 0; }

/* impressão do guia: o cabeçalho com a marca, como antes */
.guia-print-head { display: none; margin-bottom: var(--s4); padding-bottom: 8px; border-bottom: 2px solid var(--text); }
.guia-print-head h1 { margin: 0 0 4px; font-size: 20px; }
.guia-print-head span { font-size: 12px; color: #555555; }
@media print {
  .guia-print-head { display: block; }
  .guia-print-head .quiz-eyebrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #estudoView .est-carregando { animation: none; }
}

/* o treino montado no servidor (E1.3c): as primeiras questões chegam em segundos e as outras enquanto o aluno responde */
#quizView .quiz-generating .quiz-fim-actions { width: min(100%, 320px); margin-top: 22px; }
/* esperando a próxima questão: a trilha continua no topo (o aluno vê onde está) */
#quizView:has(.quiz-espera) .quiz-trilha { display: flex; }
/* o treino em andamento (a tela fechou no meio, ou a página recarregou): o aviso no topo do formulário */
#quizView .quiz-andamento {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin: 0 0 20px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--q-sel);
  color: var(--text);
}
#quizView .quiz-andamento[hidden] { display: none; }
#quizView .qan-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#quizView .qan-txt strong { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
#quizView .qan-txt span { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
#quizView .qan-bts { display: flex; gap: 8px; }
#quizView .qan-bts button { min-height: 40px; padding: 0 18px; white-space: nowrap; }
/* o Descartar numa pílula clara: transparente, o azul do texto sobre o azul do aviso dava 4,27:1 no claro;
   sobre o branco, 4,70:1 (AA). O hover fica igual, para não baixar o contraste. */
#quizView .qan-bts .btn-secondary,
#quizView .qan-bts .btn-secondary:hover { background: var(--q-card); }
/* o Descartar ou o Cancelar esperando o servidor: parados, sem perder o foco */
#quizView :is(.qan-bts button, .quiz-fim-actions button, #btnQuizGerar)[aria-disabled="true"] { opacity: .5; cursor: progress; }
/* o título que recebe o foco na troca de tela (o leitor de tela lê dali): sem o anel, como na prova */
#quizView :is(.quiz-pergunta, .quiz-gen-status, .quiz-res .quiz-title):focus { outline: none; }
@media (max-width: 520px) {
  #quizView .qan-bts { width: 100%; }
  #quizView .qan-bts button { flex: 1; }
}

/* ---------------------------------------------------------- o banco de questões (M8)
   Quais questões o treino tira (com quantas há de cada), o atalho das salvas, e, na correção da questão do banco,
   quantos alunos acertaram, o Salvar e o Reportar erro. Tudo preso a #quizView. */
#quizView .quiz-filtro[hidden] { display: none; }
#quizView .qf-seg {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 3px;
  border-radius: 12px;
  background: var(--q-fill);
}
#quizView .qf-opt { position: relative; display: block; min-width: 0; }
#quizView .qf-opt input { position: absolute; opacity: 0; pointer-events: none; }
#quizView .qf-opt span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 50px;
  padding: 4px 2px;
  border-radius: 9px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background-color .18s var(--ease), box-shadow .18s var(--ease);
}
#quizView .qf-opt b { font-size: 14px; font-weight: 500; letter-spacing: -.01em; white-space: nowrap; }
#quizView .qf-opt small { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
#quizView .qf-opt input:checked + span {
  background: var(--q-card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04);
}
#quizView .qf-opt input:checked + span b { font-weight: 600; }
html:not([data-theme="light"]) #quizView .qf-opt input:checked + span { background: #636366; }
html:not([data-theme="light"]) #quizView .qf-opt input:checked + span small { color: #ffffff; }
#quizView .qf-opt.is-vazio span { cursor: default; }
#quizView .qf-opt.is-vazio b { color: var(--muted); font-weight: 400; }
#quizView .qf-opt input:focus-visible + span { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: 1px; }
#quizView .qf-dica { margin: 8px 2px 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
#quizView .quiz-chip.qc-salvas { color: var(--accent); font-weight: 600; }
#quizView .quiz-chip.qc-salvas[hidden] { display: none; }

#quizView .quiz-acoes { display: grid; gap: 10px; margin-top: 14px; }
#quizView .qac-taxa { display: grid; gap: 6px; }
#quizView .qac-barra { display: block; height: 6px; border-radius: 3px; background: var(--q-fill-2); overflow: hidden; }
#quizView .qac-barra i { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
#quizView .qac-txt { font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
#quizView .qac-bts { display: flex; flex-wrap: wrap; gap: 8px; }
#quizView .qac-bt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--r-full);
  background: var(--q-card);
  box-shadow: inset 0 0 0 1px var(--q-line);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
#quizView .qac-bt[hidden] { display: none; }
#quizView .qac-bt[aria-pressed="true"] { color: var(--accent); }
#quizView .qac-bt[aria-pressed="true"] svg path { fill: currentColor; }
#quizView .qac-bt[aria-disabled="true"] { opacity: .6; cursor: progress; }
#quizView .qac-reporte { display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: var(--q-card);
  box-shadow: inset 0 0 0 1px var(--q-line); }
#quizView .qac-rep-tit { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
#quizView .qac-motivos { display: flex; flex-wrap: wrap; gap: 6px; }
#quizView .qac-motivo { position: relative; }
#quizView .qac-motivo input { position: absolute; opacity: 0; pointer-events: none; }
#quizView .qac-motivo span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--r-full);
  background: var(--q-fill);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
#quizView .qac-motivo input:checked + span { background: var(--primary); color: #ffffff; }
#quizView .qac-motivo input:focus-visible + span { outline: 3px solid rgba(0, 113, 227, .55); outline-offset: 2px; }
#quizView .qac-reporte textarea {
  min-height: 64px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: var(--q-fill);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  resize: vertical;
}
#quizView .qac-reporte textarea:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent); }
#quizView .qac-rep-bts { display: flex; gap: 8px; }
#quizView .qac-rep-bts button { min-height: 40px; padding: 0 18px; }
#quizView .qac-rep-bts button[aria-disabled="true"] { opacity: .5; cursor: progress; }
#quizView .qac-ok { margin: 0; font-size: 14px; color: var(--text); }
#quizView .qac-ok:focus { outline: none; }
@media (max-width: 520px) {
  #quizView .qac-rep-bts button { flex: 1; }
}
