/*
 * Design system "ruled notebook" (docs/DESIGN_SYSTEM.md).
 * The red margin (--margin) only means "now". Blue ink (--ink) means action.
 * Handwritten CSS, no build step.
 */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/atkinson-hyperlegible-next-latin-ext.290c109915a4.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/atkinson-hyperlegible-next-latin.825fabef695f.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #fcfdfe;
  --rail: #eef2f7;
  --rule: #d9e1eb;
  --rule-strong: #b9c5d3;
  --graphite-strong: #12161c;
  --graphite: #262b33;
  --graphite-soft: #5b6472;
  --ink: #2338a6;
  --ink-strong: #1a2a80;
  --ink-wash: #e6eaf8;
  --margin: #c8283f;
  --margin-wash: #fbe8eb;
  --present: #23704a;
  --present-wash: #e3f2ea;
  --attention: #8a5a00;
  --attention-wash: #fff4db;
  /* Texto sobre fundo cheio (botão, etiqueta, aviso) e o fundo translúcido da barra do topo. */
  --on-solid: #ffffff;
  --paper-veil: rgb(252 253 254 / 0.96);
  --lesson-hover: #d9dff5;
  /* Voltar tem cor própria: é navegação, não ação, e some no meio dos links se usar a cor de ação. */
  --back: #6b3fa0;

  --font: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text-xs: 0.8125rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.1875rem;
  --text-h2: 1.3125rem;
  --text-xl: 1.4375rem;
  --text-2xl: 1.75rem;

  --pauta: 2rem;
  --radius-field: 4px;
  --radius-layer: 10px;
  --shadow-layer: 0 12px 32px -8px rgb(38 43 51 / 0.22), 0 2px 6px rgb(38 43 51 / 0.08);
  /* A largura do conteúdo. Alto o bastante para a tela respirar num monitor, com teto para a tabela
     não virar um campo de futebol; texto corrido tem o seu próprio teto, mais estreito, para a linha
     não passar de umas 70 letras. */
  --content-max: 88rem;
  --prose-max: 70ch;
  /* A lista para de crescer antes da tela: esticada até a borda, o nome fica de um lado e o botão do outro, com um
     vão morto no meio que o olho tem de atravessar. Tela larga vira margem, não distância. */
  --list-max: 76rem;
  --duration-layer: 160ms;
  color-scheme: light;
}

/*
  Tema escuro. Os mesmos tokens, outros valores: nenhuma regra de layout muda, e por isso o tema não pode
  quebrar uma tela sozinho. A escolha da pessoa vence o sistema, e o servidor já escreve `data-theme` no html,
  então não existe o pisca de tela clara antes do JS rodar (não há JS nenhum nisto).
*/
:root[data-theme="dark"] {
  --paper: #12151a;
  --rail: #171b22;
  --rule: #2a313b;
  --rule-strong: #3d4653;
  --graphite-strong: #f2f5f8;
  --graphite: #dde3ea;
  --graphite-soft: #9ba6b4;
  --ink: #93a8ff;
  --ink-strong: #b6c4ff;
  --ink-wash: #1b2340;
  --margin: #ff8fa0;
  --margin-wash: #3a2027;
  --present: #6fd39b;
  --present-wash: #15301f;
  --attention: #e9ba55;
  --attention-wash: #322715;
  --on-solid: #12151a;
  --paper-veil: rgb(18 21 26 / 0.96);
  --lesson-hover: #232b40;
  --back: #c9aaf5;
  --shadow-layer: 0 12px 32px -8px rgb(0 0 0 / 0.55), 0 2px 6px rgb(0 0 0 / 0.35);
  color-scheme: dark;
}

/* Sem escolha explícita, vale o que o aparelho pede. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12151a;
    --rail: #171b22;
    --rule: #2a313b;
    --rule-strong: #3d4653;
    --graphite-strong: #f2f5f8;
    --graphite: #dde3ea;
    --graphite-soft: #9ba6b4;
    --ink: #93a8ff;
    --ink-strong: #b6c4ff;
    --ink-wash: #1b2340;
    --margin: #ff8fa0;
    --margin-wash: #3a2027;
    --present: #6fd39b;
    --present-wash: #15301f;
    --attention: #e9ba55;
    --attention-wash: #322715;
    --on-solid: #12151a;
    --paper-veil: rgb(18 21 26 / 0.96);
    --lesson-hover: #232b40;
    --back: #c9aaf5;
    --shadow-layer: 0 12px 32px -8px rgb(0 0 0 / 0.55), 0 2px 6px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { --duration-layer: 0ms; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--graphite);
  background: var(--paper);
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul[class], ol[class] { list-style: none; padding: 0; }
a { color: var(--ink); text-underline-offset: 2px; }
a:hover { color: var(--ink-strong); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.soft { color: var(--graphite-soft); }
/* ---------- Paginação ----------
   Números em quadradinhos, alinhada à direita, com a contagem à esquerda para a pessoa saber o tamanho do todo. */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; flex-wrap: wrap; margin-top: .9rem; }
.pagination ul { display: flex; align-items: center; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.pagination a, .pagination li > span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; height: 2rem; padding: 0 .4rem;
  border: 1px solid var(--rule); border-radius: var(--radius-field); font-size: var(--text-sm);
  font-variant-numeric: tabular-nums; color: var(--graphite-strong); text-decoration: none;
}
.pagination a:hover { border-color: var(--rule-strong); background: var(--rail); }
.pagination [aria-current="page"] { border-color: var(--ink); background: var(--ink); color: #fff; font-weight: 600; }
.pagination li > span:not([aria-current]) { color: var(--graphite-soft); }
.pagination .pagination-gap { border: 0; min-width: 1rem; }
.pagination-count { margin-right: auto; color: var(--graphite-soft); font-size: var(--text-sm); }
.pagination-count.solo { margin-top: .9rem; text-align: right; }
/* O número que a pessoa veio ver na tela, dentro de uma lista de detalhes. */
.details .figure { font-size: var(--text-lg); font-weight: 700; letter-spacing: -.02em; }
/* Campo numérico sem as setinhas: no faturamento se digita o valor, não se sobe de um em um. */
.form input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.form input[type="number"]::-webkit-outer-spin-button,
.form input[type="number"]::-webkit-inner-spin-button { appearance: none; -webkit-appearance: none; margin: 0; }
/* Aviso de que a plataforma está dentro de um cliente. Some do fluxo do conteúdo, mas não do olho de quem trabalha. */
.platform-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.6rem 1rem; background: var(--attention-wash); color: var(--attention); border-bottom: 1px solid var(--rule); }
.platform-banner p { margin: 0; font-size: var(--text-sm); max-width: var(--prose-max); }
/* Aviso de "estou buscando": escondido até o htmx marcar o pedido em curso. Sem isto, a linha fica sempre visível. */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }
.small { font-size: var(--text-sm); }
.strong { font-weight: 600; }

/* ---------- App layout ---------- */

.skip-link { position: absolute; left: -999px; top: 0.5rem; z-index: 60; background: var(--paper); padding: 0.5rem 0.75rem; }
.skip-link:focus { left: 0.5rem; }

.app { min-height: 100dvh; }
@media (min-width: 48rem) {
  .app { display: grid; grid-template-columns: 15rem minmax(0, 1fr); }
}
.rail { display: none; }
@media (min-width: 48rem) {
  .rail { position: sticky; top: 0; display: flex; flex-direction: column; height: 100dvh; background: var(--rail); border-right: 1px solid var(--rule); }
}
.brand { display: flex; align-items: center; height: 3.5rem; padding: 0 1.25rem; font-size: var(--text-lg); font-weight: 700; color: var(--graphite); text-decoration: none; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0.5rem; }
.nav a { position: relative; display: flex; align-items: center; gap: 0.75rem; min-height: 2.5rem; padding: 0 0.75rem; border-radius: var(--radius-field); color: var(--graphite-soft); text-decoration: none; }
.nav a:hover { background: var(--paper); color: var(--graphite); }
.nav a[aria-current="page"] { background: var(--paper); color: var(--graphite); font-weight: 600; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -0.5rem; top: 0.5rem; bottom: 0.5rem; width: 3px; background: var(--graphite); }

.nav-group { margin: 0.875rem 0 0.125rem; padding: 0 0.75rem; font-size: var(--text-xs); color: var(--graphite-soft); }

.main-column { display: flex; min-width: 0; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 0.5rem; height: 3.5rem; padding: 0 0.75rem; border-bottom: 1px solid var(--rule); background: var(--paper-veil); }
@media (min-width: 48rem) { .topbar { padding: 0 1.5rem; } }
.topbar .brand { padding: 0 0.25rem 0 0; }
@media (min-width: 48rem) { .topbar .brand { display: none; } }
.topbar .spacer { flex: 1; }
/* Alinhado à esquerda, junto do menu: centralizar deixava a tela com buraco dos dois lados. */
.content { width: 100%; max-width: var(--content-max); margin: 0; padding: 1.5rem 1rem 7rem; }
@media (min-width: 48rem) { .content { padding: 2rem 2.5rem 3rem; } }
.content.wide { max-width: none; }

/* Texto corrido e formulário não crescem com a tela: linha longa demais cansa, e campo de 1400px é pior de usar. */
.plan-body p, .plan-body section, .announcement-body, .thread .text { max-width: var(--prose-max); }
.form:not(.filters):not(.row-actions) { max-width: 52rem; }

.bottom-nav { position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--rule); background: var(--paper); padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 48rem) { .bottom-nav { display: none; } }
.bottom-nav a, .bottom-nav summary { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 4rem; font-size: var(--text-xs); color: var(--graphite-soft); text-decoration: none; cursor: pointer; list-style: none; }
.bottom-nav a[aria-current="page"] { color: var(--graphite); font-weight: 600; }
.bottom-nav details { position: relative; }
/* O "Mais" abre para cima e pode ter muitos itens: fica dentro da tela e rola por dentro, senão o topo da lista
   some acima da tela e ninguém alcança. */
.bottom-nav details .menu-panel { bottom: 4.5rem; top: auto; right: 0.5rem; max-height: calc(100dvh - 6rem); overflow-y: auto; overscroll-behavior: contain; }
/* Os itens do painel são linhas de menu, não os botões altos da barra: sem isto herdavam 4rem de altura cada. */
.bottom-nav .menu-panel a { height: auto !important; flex-direction: row; justify-content: flex-start; padding: 0.625rem 0.75rem; font-size: var(--text-sm); color: var(--graphite); }

.icon { width: 1.125rem; height: 1.125rem; flex: none; }

/* ---------- Page typography ---------- */

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; }
.page-header h1 { font-size: var(--text-2xl); line-height: 1.15; font-weight: 700; letter-spacing: -0.012em; color: var(--graphite-strong); }
/* Os dados do cabeçalho são separados por um filete: sem ele a linha vira uma frase só. */
.page-header .context { margin-top: 0.375rem; color: var(--graphite-soft); display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.page-header .context > span + span:not(.tag) { padding-left: 0.75rem; border-left: 1px solid var(--rule); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.back-link { display: inline-flex; align-items: center; gap: 0.375rem; margin-bottom: 0.75rem; font-size: var(--text-sm); font-weight: 600; color: var(--back); text-decoration: none; }
.back-link::before { content: ""; width: 1rem; height: 1rem; flex: none; 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.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 19-7-7 7-7'/%3E%3Cpath d='M19 12H5'/%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.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 19-7-7 7-7'/%3E%3Cpath d='M19 12H5'/%3E%3C/svg%3E") center / contain no-repeat; }
.back-link:hover { text-decoration: underline; }

.ruled, .table-wrap, .todo, .filters { max-width: var(--list-max); }
/* As telas largas de propósito (horário, conselho, frequência) usam a tela inteira. */
.content.wide .ruled, .content.wide .table-wrap, .content.wide .todo, .content.wide .filters { max-width: none; }

.section { margin-top: 2.5rem; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.875rem; }
.section-head h2 { font-size: var(--text-h2); font-weight: 600; letter-spacing: -0.008em; color: var(--graphite-strong); }
.section-head p { font-size: var(--text-sm); color: var(--graphite-soft); }
/* A long description wraps inside its column and leaves the action on the right. */
.section-head > div:first-child:not(:only-child) { flex: 1 1 18rem; min-width: 0; }

.sub-nav { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--rule); }
.sub-nav a { padding: 0.5rem 0.75rem; color: var(--graphite-soft); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sub-nav a[aria-current="page"] { color: var(--graphite); font-weight: 600; border-bottom-color: var(--graphite); }

/* ---------- Buttons ---------- */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 2.5rem; padding: 0 1rem; border: 1px solid var(--ink); border-radius: var(--radius-field); background: var(--ink); color: var(--on-solid); font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--ink-strong); border-color: var(--ink-strong); color: var(--on-solid); }
.btn.secondary { background: var(--paper); color: var(--ink); border-color: var(--rule-strong); }
.btn.secondary:hover { background: var(--ink-wash); color: var(--ink-strong); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--ink); }
.btn.quiet:hover { background: var(--ink-wash); }
.btn.danger { background: var(--paper); color: var(--margin); border-color: var(--rule-strong); }
.btn.danger:hover { background: var(--margin-wash); }
.btn.small { min-height: 2rem; padding: 0 0.625rem; font-size: var(--text-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn[aria-pressed="true"] { background: var(--ink-wash); color: var(--ink-strong); border-color: var(--ink); }
@media (max-width: 40rem) { .btn { min-height: 2.75rem; } }
.htmx-request .btn[type="submit"], .btn.htmx-request { opacity: 0.7; pointer-events: none; }

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 1rem; }
.form-grid { display: grid; gap: 1rem; }
@media (min-width: 40rem) { .form-grid.two { grid-template-columns: 1fr 1fr; } .form-grid.three { grid-template-columns: repeat(3, 1fr); } }
.span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 0.375rem; min-width: 0; }
.field > label, .field > .label { font-size: var(--text-sm); font-weight: 600; }
.field .optional { font-weight: 400; color: var(--graphite-soft); }
.field .hint { font-size: var(--text-sm); color: var(--graphite-soft); }
.field .error { font-size: var(--text-sm); font-weight: 600; color: var(--margin); }
.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea {
  width: 100%; min-height: 2.5rem; padding: 0.375rem 0.75rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-field); background: var(--paper);
}
.field select { appearance: none; padding-right: 2.25rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b6472' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; }
.field textarea { min-height: 5rem; resize: vertical; }
.field [aria-invalid="true"] { border-color: var(--margin); }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--graphite-soft); }
@media (max-width: 40rem) { .field input:not([type="checkbox"]):not([type="radio"]), .field select { min-height: 2.75rem; } }
.check { display: flex; align-items: flex-start; gap: 0.625rem; cursor: pointer; }
.check input { width: 1.125rem; height: 1.125rem; margin-top: 0.1875rem; accent-color: var(--ink); flex: none; }
.check .hint { display: block; font-size: var(--text-sm); color: var(--graphite-soft); }
.checks { display: flex; flex-direction: column; gap: 0.5rem; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; font-size: var(--text-sm); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; margin-bottom: 1rem; }
.filters .field { min-width: 11rem; }
.filters .grow { flex: 1; min-width: 14rem; max-width: 28rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.25rem 0.75rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-field); font-size: var(--text-sm); cursor: pointer; }
.chip:has(input:checked) { border-color: var(--ink); background: var(--ink-wash); color: var(--ink-strong); font-weight: 600; }
.chip input { accent-color: var(--ink); }
.form-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }

/* ---------- Ruled list ---------- */

.ruled { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.ruled > li { position: relative; display: flex; align-items: center; gap: 1rem; min-height: calc(var(--pauta) * 1.625); padding: 0.6875rem 0.5rem 0.6875rem 1rem; border-bottom: 1px solid var(--rule); }
.ruled > li.now::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--margin); }
.ruled .lead { width: 5.5rem; flex: none; font-size: var(--text-sm); color: var(--graphite-soft); font-variant-numeric: tabular-nums; }
.ruled .body { min-width: 0; flex: 1; }
.ruled .trail { flex: none; display: flex; align-items: center; gap: 0.25rem; }
.ruled .title { font-weight: 600; color: var(--graphite-strong); }
/* O título da linha é o nome da coisa, não um link: quando toda linha tem o nome em azul, a lista vira um muro
   de links e nada se destaca. Continua clicável, mas quem chama a ação é o botão da direita. */
.ruled a.title { color: inherit; text-decoration: none; }
.field.inline-unit { flex-direction: row; align-items: center; gap: 0.5rem; }
/* A button that belongs to one line of a list of details (send the access next to its state). */
form.inline { display: inline-block; margin-left: 0.5rem; vertical-align: middle; }
.field.inline-unit input { max-width: 7rem; }
.section > .group-label { margin: 1rem 0 0.25rem; font-size: var(--text-xs); font-weight: 600; color: var(--graphite-soft); }
.ruled a.title:hover { color: var(--ink); text-decoration: underline; }
.ruled .meta { display: block; margin-top: 0.0625rem; font-size: var(--text-sm); line-height: 1.4; color: var(--graphite-soft); overflow: hidden; text-overflow: ellipsis; }
/* No celular, a linha quebra: com três ações na mesma linha o título virava uma palavra por linha. */
@media (max-width: 30rem) {
  .ruled > li { flex-wrap: wrap; row-gap: 0.5rem; }
  .ruled .body { flex: 1 1 100%; }
  .ruled .trail { flex: 1 1 100%; justify-content: flex-start; }
}
@media (max-width: 40rem) { .ruled .lead { width: 4rem; } }

.details { display: grid; gap: 1rem 1.5rem; }
@media (min-width: 40rem) { .details { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); } }
.details dt { font-size: var(--text-sm); color: var(--graphite-soft); }
.details dd { color: var(--graphite); overflow-wrap: anywhere; }
.details dd.none { color: var(--graphite-soft); }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--rule); }
table.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { padding: 0.375rem 0.625rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: middle; }
table.grid th { font-size: var(--text-sm); font-weight: 600; color: var(--graphite-soft); background: var(--rail); }
table.grid td.num, table.grid th.num { text-align: right; }
table.grid input.cell { width: 3.5rem; min-height: 2rem; padding: 0.125rem 0.375rem; text-align: right; border: 1px solid var(--rule-strong); border-radius: var(--radius-field); }
table.grid tfoot td { font-weight: 600; background: var(--rail); }
table.grid .sticky-col { position: sticky; left: 0; z-index: 1; background: var(--paper); box-shadow: 1px 0 0 var(--rule); }
table.grid th.sticky-col { background: var(--rail); }
table.gradebook td.sticky-col { min-width: 9rem; }

/* ---------- States ---------- */

.tag { display: inline-flex; align-items: center; padding: 0.0625rem 0.5rem; border-radius: var(--radius-field); font-size: var(--text-sm); font-weight: 600; background: var(--rail); color: var(--graphite-soft); white-space: nowrap; }
.tag.present { background: var(--present-wash); color: var(--present); }
.tag.attention { background: var(--attention-wash); color: var(--attention); }
.tag.now { background: var(--margin-wash); color: var(--margin); }
.tag.ink { background: var(--ink-wash); color: var(--ink); }

.empty { padding: 1.5rem; border: 1px dashed var(--rule-strong); border-radius: var(--radius-field); }
.empty .title { font-weight: 600; }
.empty p { color: var(--graphite-soft); margin-top: 0.25rem; max-width: var(--prose-max); }
.empty .actions { margin-top: 1rem; }
.notice { padding: 0.75rem 1rem; border-radius: var(--radius-field); border: 1px solid var(--rule-strong); background: var(--rail); }
.notice.error { border-color: var(--margin); background: var(--margin-wash); }
.notice.error .title { color: var(--margin); }
.notice.warning { border-color: var(--attention); background: var(--attention-wash); }
.notice.success { border-color: var(--present); background: var(--present-wash); }
.notice .title { font-weight: 600; }
.notice p { font-size: var(--text-sm); }
.notice ul { margin: 0.5rem 0 0; padding-left: 1.25rem; font-size: var(--text-sm); }

/* ---------- Layers: menu, dialog, toast ---------- */

details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; top: calc(100% + 0.375rem); right: 0; z-index: 50; min-width: 14rem; max-width: min(24rem, calc(100vw - 2rem)); padding: 0.375rem; border: 1px solid var(--rule); border-radius: var(--radius-layer); background: var(--paper); box-shadow: var(--shadow-layer); }
.menu-panel.start { left: 0; right: auto; }
.menu-panel a, .menu-panel button.item { display: flex; width: 100%; align-items: center; min-height: 2.5rem; padding: 0 0.75rem; border: 0; border-radius: var(--radius-field); background: none; color: var(--graphite); text-align: left; text-decoration: none; cursor: pointer; }
.menu-panel a:hover, .menu-panel button.item:hover { background: var(--ink-wash); }
.menu-panel .danger { color: var(--margin); }
.menu-panel .header { padding: 0.5rem 0.75rem 0.75rem; margin-bottom: 0.25rem; border-bottom: 1px solid var(--rule); }
.menu-panel .group-label { padding: 0.5rem 0.75rem 0.25rem; font-size: var(--text-xs); color: var(--graphite-soft); }
.menu-panel [aria-current="true"] { font-weight: 600; background: var(--ink-wash); }
.topbar-button { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.5rem; padding: 0 0.625rem; border: 1px solid var(--rule); border-radius: var(--radius-field); background: var(--paper); color: var(--graphite-soft); cursor: pointer; }
.topbar-button:hover { border-color: var(--rule-strong); color: var(--graphite); }
.topbar-button.plain { border-color: transparent; }
.context-switcher summary { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--graphite); font-weight: 600; }
.badge-count { min-width: 1.25rem; padding: 0 0.3rem; border-radius: 999px; background: var(--margin); color: var(--on-solid); font-size: var(--text-xs); font-weight: 700; text-align: center; }
kbd { padding: 0 0.3rem; border: 1px solid var(--rule); border-radius: 3px; font-size: var(--text-xs); font-family: inherit; }

dialog.layer { width: min(34rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; border: 0; border-radius: var(--radius-layer); background: var(--paper); color: var(--graphite); box-shadow: var(--shadow-layer); }
dialog.layer::backdrop { background: rgb(38 43 51 / 0.35); }
dialog.layer.drawer { margin: 0 0 0 auto; width: min(38rem, 100vw); height: 100dvh; max-height: 100dvh; border-radius: 0; }
dialog.layer[open] { animation: rise-in var(--duration-layer) ease-out; }
dialog.layer.drawer[open] { animation: slide-in var(--duration-layer) ease-out; }
.layer-shell { display: flex; flex-direction: column; max-height: inherit; height: 100%; }
.layer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1rem 1.5rem; border-bottom: 1px solid var(--rule); }
.layer-head h2 { font-size: var(--text-xl); font-weight: 700; }
.layer-head p { color: var(--graphite-soft); margin-top: 0.25rem; }
.layer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 1.25rem 1.5rem; }
.layer-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.5rem; border-top: 1px solid var(--rule); }
/* Remover fica do lado oposto de Salvar, longe do clique de costume. */
.layer-foot .remove, .page-form-footer .remove, .form-footer .remove { margin-right: auto; }
.icon-button { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; margin: -0.25rem -0.5rem 0 0; border: 0; border-radius: var(--radius-field); background: none; color: var(--graphite-soft); cursor: pointer; }
.icon-button:hover { background: var(--rail); color: var(--graphite); }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }

.palette { width: min(40rem, calc(100vw - 2rem)); margin-top: 12vh; }
.palette input { width: 100%; height: 3.25rem; padding: 0 1rem; border: 0; border-bottom: 1px solid var(--rule); font-size: var(--text-lg); background: transparent; }
.palette input:focus { outline: none; }
.palette .results { max-height: 50vh; overflow-y: auto; padding: 0.375rem; }
.palette .results a { display: flex; flex-direction: column; padding: 0.5rem 0.75rem; border-radius: var(--radius-field); color: var(--graphite); text-decoration: none; }
.palette .results a:hover, .palette .results a[aria-selected="true"] { background: var(--ink-wash); }
.palette .results .group-label { padding: 0.5rem 0.75rem 0.25rem; font-size: var(--text-xs); color: var(--graphite-soft); }

.toasts { position: fixed; left: 50%; bottom: 5rem; z-index: 70; display: flex; flex-direction: column; gap: 0.5rem; transform: translateX(-50%); width: min(28rem, calc(100vw - 2rem)); }
@media (min-width: 48rem) { .toasts { bottom: 1.5rem; } }
.toast { padding: 0.75rem 1rem; border-radius: var(--radius-layer); background: var(--graphite); color: var(--on-solid); box-shadow: var(--shadow-layer); animation: rise-in var(--duration-layer) ease-out; }
.toast.error { background: var(--margin); }

/* ---------- Authentication screens ---------- */

.auth { display: grid; min-height: 100dvh; place-items: center; padding: 2rem 1rem; background: var(--rail); }
.auth-card { width: min(26rem, 100%); padding: 2rem; border: 1px solid var(--rule); border-radius: var(--radius-layer); background: var(--paper); }
/* A public form a family fills in once (the admission): room for two columns, and the steps read across. */
.auth-card.wide { width: min(46rem, 100%); }
.auth-card .how-it-works { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin: 1.25rem 0 0.5rem; padding: 0; list-style: none; counter-reset: step; }
.auth-card .how-it-works li { counter-increment: step; font-size: var(--text-sm); color: var(--graphite-soft); line-height: 1.4; }
.auth-card .how-it-works li::before { content: counter(step); display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; margin-bottom: 0.35rem; border: 1px solid var(--rule-strong); border-radius: 50%; color: var(--graphite); font-weight: 600; }
.auth-card .how-it-works li strong { display: block; color: var(--graphite); }
@media (max-width: 40rem) { .auth-card { padding: 1.25rem; } .auth-card .how-it-works { grid-template-columns: 1fr 1fr; } }
.auth-card h1 { font-size: var(--text-xl); font-weight: 700; }
.auth-card .intro { margin: 0.25rem 0 1.5rem; color: var(--graphite-soft); }
.auth-card .brand { height: auto; padding: 0 0 1.5rem; }
.auth-footer { margin-top: 1.25rem; font-size: var(--text-sm); }

/* ---------- Calendar ---------- */

.month { width: 100%; border-collapse: collapse; table-layout: fixed; }
.month th { padding: 0.375rem; font-size: var(--text-sm); font-weight: 600; color: var(--graphite-soft); text-align: left; }
.month td { height: 6rem; padding: 0.25rem 0.375rem; border: 1px solid var(--rule); vertical-align: top; }
.month td.outside { background: var(--rail); color: var(--graphite-soft); }
.month td.off .day-number { color: var(--graphite-soft); }
.month td.today { box-shadow: inset 3px 0 0 var(--margin); }
.month .day-number { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.month .ev { display: block; margin-top: 0.125rem; padding: 0 0.25rem; border-radius: 3px; font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--ink-wash); color: var(--ink); }
/* Cores por fonte da agenda: a escola em azul, avaliação em âmbar, tarefa em cinza, pagamento em vermelho. */
.month .ev.school { background: var(--attention-wash); color: var(--attention); }
.month .ev.assessment { background: var(--ink-wash); color: var(--ink); }
.month .ev.assignment { background: var(--rail); color: var(--graphite); }
.month .ev.finance { background: var(--margin-wash); color: var(--margin); }
.month .ev.more { background: none; color: var(--graphite-soft); font-style: italic; }
@media (max-width: 40rem) { .month td { height: 3.5rem; } .month .ev { display: none; } .month td.has-events .day-number { font-weight: 700; text-decoration: underline; } }

/* Os números dividem a linha em partes iguais: sem isso o quinto indicador cai sozinho na linha de baixo. */
.stat-row { display: flex; flex-wrap: wrap; gap: 1.25rem 2.5rem; }
.stat { flex: 1 1 9rem; }
.stat .value { font-size: var(--text-xl); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; color: var(--graphite-strong); }
.stat .label { font-size: var(--text-sm); color: var(--graphite-soft); }
.page-form-footer { margin-top: 1.5rem; }

/* Phone topbar: no brand and no keyboard shortcut, the school switcher takes the space. */
@media (max-width: 47.99rem) {
  .topbar .brand, .topbar kbd { display: none; }
  .topbar .context-switcher summary { max-width: 55vw; }
  .ruled .lead { width: auto; min-width: 3.5rem; }
}

/* ---------- Timetable ---------- */

.period-nav { margin-left: auto; }
.section > .period-nav { margin: 0 0 0.75rem; }
table.timetable { width: 100%; min-width: 44rem; border-collapse: collapse; table-layout: fixed; }
table.timetable th, table.timetable td { border: 1px solid var(--rule); padding: 0.25rem; vertical-align: top; }
table.timetable thead th { padding: 0.375rem 0.5rem; background: var(--rail); font-size: var(--text-sm); font-weight: 600; text-align: left; }
table.timetable thead th a { color: var(--graphite); text-decoration: none; }
table.timetable thead th a:hover { text-decoration: underline; }
table.timetable thead th .date { color: var(--graphite-soft); font-weight: 400; font-variant-numeric: tabular-nums; }
table.timetable thead th.today { box-shadow: inset 0 3px 0 var(--margin); }
table.timetable .day-note { display: block; font-size: var(--text-xs); font-weight: 400; color: var(--attention); }
table.timetable th.time { width: 4.5rem; padding: 0.375rem 0.5rem; background: var(--rail); font-size: var(--text-sm); font-weight: 600; font-variant-numeric: tabular-nums; text-align: left; }
table.timetable th.time span { display: block; font-weight: 400; color: var(--graphite-soft); }
table.timetable td.off { background: repeating-linear-gradient(135deg, var(--rail) 0 6px, var(--paper) 6px 12px); }
table.timetable tr.break th, table.timetable tr.break td { padding: 0.125rem 0.5rem; background: var(--rail); font-size: var(--text-xs); color: var(--graphite-soft); }
.lesson { display: block; padding: 0.25rem 0.375rem; border-left: 3px solid var(--ink); border-radius: 3px; background: var(--ink-wash); color: var(--graphite); text-decoration: none; font-size: var(--text-sm); line-height: 1.3; }
.lesson + .lesson { margin-top: 0.25rem; }
a.lesson:hover { background: var(--lesson-hover); color: var(--graphite); }
.lesson .subject { display: block; font-weight: 600; overflow-wrap: anywhere; }
.lesson .detail { display: block; font-size: var(--text-xs); color: var(--graphite-soft); overflow-wrap: anywhere; }
.lesson .note { display: block; margin-top: 0.125rem; font-size: var(--text-xs); font-weight: 600; color: var(--attention); }
.lesson.changed { border-left-color: var(--attention); background: var(--attention-wash); }
.lesson.cancelled { border-left-color: var(--margin); background: var(--margin-wash); }
.lesson.cancelled .subject { text-decoration: line-through; }
.lesson.cancelled .note { color: var(--margin); }
.ruled > li.cancelled .title { text-decoration: line-through; color: var(--graphite-soft); }
.month a.day-number { color: inherit; text-decoration: none; }
.month a.day-number:hover { text-decoration: underline; }

.editor-layout { display: grid; gap: 1.5rem; }
@media (min-width: 96rem) { .editor-layout { grid-template-columns: minmax(0, 1fr) 16rem; align-items: start; } }
@media (min-width: 40rem) and (max-width: 95.99rem) { .load .ruled { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); column-gap: 1.5rem; } }
table.timetable.editing td { padding: 0.25rem; }
table.timetable.editing select { width: 100%; min-height: 2.25rem; padding: 0 0.25rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-field); background: var(--paper); font-size: var(--text-sm); }
table.timetable.editing td.conflict { background: var(--margin-wash); }
table.timetable.editing td.conflict select { border-color: var(--margin); }
.cell-problems { margin: 0.25rem 0 0; padding: 0; list-style: none; font-size: var(--text-xs); color: var(--margin); }
.load h2 { font-size: var(--text-lg); font-weight: 600; }
.load .hint { margin-bottom: 0.5rem; }
.hint { font-size: var(--text-sm); color: var(--graphite-soft); }
.filters .hint { align-self: center; }
/* A checkbox in a filter row sits on the same line as the inputs beside it. */
.filters > .check { min-height: 2.5rem; align-items: center; }
.filters > .check input { margin-top: 0; }
@media (max-width: 40rem) { .filters > .check { min-height: 2.75rem; } }
table.timetable.editing select.room-select { min-height: 1.75rem; margin-top: 0.25rem; font-size: var(--text-xs); color: var(--graphite-soft); }

/* ---------- Attendance ---------- */

.roll-call { margin: 0.5rem 0 1rem; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.roll-call > li { padding: 0.5rem 0; border-bottom: 1px solid var(--rule); }
.roll-call fieldset { display: grid; gap: 0.375rem; }
@media (min-width: 48rem) { .roll-call fieldset { grid-template-columns: minmax(0, 1fr) auto; align-items: center; } .roll-call details.note { grid-column: 1 / -1; } }
.roll-call legend { float: left; font-size: var(--text-md); font-weight: 600; }
.roll-call legend .number { display: inline-block; min-width: 1.75rem; color: var(--graphite-soft); font-weight: 400; font-variant-numeric: tabular-nums; }
.roll-call .codes { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.roll-call .code { position: relative; display: inline-grid; place-items: center; min-width: 2.75rem; height: 2.75rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-field); font-weight: 700; cursor: pointer; }
.roll-call .code input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.roll-call .code:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.roll-call .code:has(input:checked) { border-color: var(--ink); background: var(--ink-wash); color: var(--ink-strong); }
.roll-call .code.absent:has(input:checked) { border-color: var(--margin); background: var(--margin-wash); color: var(--margin); }
.roll-call .code.present:has(input:checked) { border-color: var(--present); background: var(--present-wash); color: var(--present); }
.roll-call .code:has(input:disabled) { cursor: default; opacity: 0.75; }
.roll-call details.note summary { font-size: var(--text-sm); color: var(--graphite-soft); cursor: pointer; }
.roll-call details.note input { width: 100%; min-height: 2.25rem; margin-top: 0.25rem; padding: 0 0.5rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-field); }
.legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: var(--text-sm); color: var(--graphite-soft); }
/* The buttons of a form close the form: at its end, on the page itself, never floating over the fields. */
.sticky-footer { margin-top: 1.5rem; }
.code-badge { display: inline-grid; place-items: center; min-width: 2rem; height: 2rem; border-radius: var(--radius-field); font-weight: 700; background: var(--ink-wash); color: var(--ink-strong); }
.code-badge.absent { background: var(--margin-wash); color: var(--margin); }
.code-badge.present { background: var(--present-wash); color: var(--present); }
table.grid tr.at-risk td:first-child { box-shadow: inset 3px 0 0 var(--attention); }
table.grid td.low, .stat .value.low { color: var(--margin); }
.trend { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.375rem; }
.trend li { display: grid; grid-template-columns: 3.5rem minmax(0, 1fr) 4rem; align-items: center; gap: 0.75rem; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.trend meter { width: 100%; height: 0.75rem; }
.trend .value { text-align: right; }

/* ---------- Curriculum ---------- */

.code-tag { display: inline-block; padding: 0 0.375rem; border-radius: 3px; background: var(--ink-wash); color: var(--ink-strong); font-size: var(--text-sm); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.learning-list > li { align-items: flex-start; }
.learning-list .lead { width: 7.5rem; }
.learning-list .body p { margin-top: 0.125rem; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; font-size: var(--text-sm); color: var(--graphite-soft); }
.breadcrumbs span + span::before { content: "›"; margin-right: 0.5rem; }
.curriculum-text { max-width: 44rem; font-size: var(--text-lg); line-height: 1.55; }
.learnings .checks { max-height: 18rem; overflow-y: auto; padding-right: 0.25rem; }
/* Skills, competencies and any option that is a sentence: one under the other, never side by side. */
.learnings .chips, .chips.stacked { flex-direction: column; flex-wrap: nowrap; max-height: 24rem; overflow-y: auto; padding-right: 0.25rem; }
.learnings .chip, .chips.stacked .chip { display: flex; align-items: flex-start; padding: 0.5rem 0.75rem; line-height: 1.4; }
.learnings .chip input, .chips.stacked .chip input { margin-top: 0.2rem; flex: none; }
.plan-list label.check { align-items: flex-start; }

/* Trilha de abertura da escola: passos numerados, o que já foi feito recua. */
.steps > li.done { color: var(--graphite-soft); }
.steps > li.done .title { font-weight: 400; }
.steps .number { display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; border: 1px solid var(--rule-strong); border-radius: 50%; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.steps > li.done .number { border-color: var(--present); color: var(--present); }

/* "Para fazer": o que está pendente abre a tela, com o número na frente para dar a medida do trabalho. */
.todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.todo a { display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem 0.875rem; border: 1px solid var(--rule); border-left: 3px solid var(--margin); border-radius: var(--radius-field); background: var(--rail); color: var(--ink-strong); text-decoration: none; }
.todo a:hover { border-color: var(--rule-strong); border-left-color: var(--margin); }
.todo.wide a { align-items: flex-start; }
.todo.wide span span { display: block; }
.todo.wide .hint { font-size: var(--text-sm); color: var(--graphite-soft); }
.todo .count { min-width: 1.75rem; flex: none; text-align: center; font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--margin); }

/* Registro da aula: dobrado por padrão, para a chamada não dividir espaço com o que é opcional. */
.after-class { border-top: 1px solid var(--rule); padding-top: 0.75rem; }
.after-class > summary { font-weight: 600; color: var(--graphite-strong); cursor: pointer; padding: 0.25rem 0; }
.after-class > summary .optional { font-weight: 400; }
.after-class > * + * { margin-top: 1rem; }

/* ---------- Planning ---------- */

.plan-box { padding: 0.75rem 1rem; border: 1px solid var(--rule); border-left: 3px solid var(--ink); border-radius: var(--radius-field); background: var(--rail); }
.plan-box legend { float: left; width: 100%; margin-bottom: 0.5rem; }
.plan-box textarea { width: 100%; margin-top: 0.5rem; padding: 0.5rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-field); }
.plan-sections { display: grid; gap: 1.25rem; }
@media (min-width: 64rem) { .plan-sections { grid-template-columns: minmax(0, 1fr) 20rem; align-items: start; } }
.plan-body section h2 { font-size: var(--text-md); font-weight: 600; margin-bottom: 0.25rem; }
.plan-body section + section { margin-top: 1rem; }
.plan-body p { white-space: pre-line; }
.timeline { margin: 0; padding: 0; list-style: none; border-left: 2px solid var(--rule); }
.timeline li { position: relative; margin-left: 0.75rem; padding: 0 0 0.75rem 0.75rem; }
.timeline li::before { content: ""; position: absolute; left: -1.2rem; top: 0.45rem; width: 0.625rem; height: 0.625rem; border-radius: 50%; background: var(--rule-strong); }
.timeline .when { font-size: var(--text-xs); color: var(--graphite-soft); }
.day-block + .day-block { margin-top: 1.25rem; }
.day-block h2 { font-size: var(--text-md); font-weight: 600; margin-bottom: 0.25rem; }

.month .plan-count { display: block; margin-top: 0.125rem; font-size: var(--text-xs); color: var(--graphite-soft); }

/* ---------- Assignments ---------- */

.rubric-row { padding: 0.75rem 1rem; border: 1px solid var(--rule); border-radius: var(--radius-field); }
.rubric-row legend { padding: 0 0.25rem; }
input.rubric-comment { width: 100%; min-height: 2.25rem; margin-top: 0.375rem; padding: 0 0.5rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-field); }

/* Gradebook: period tabs, score entry list (one student per row, comfortable on a phone) */
.tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; overflow-x: auto; border-bottom: 1px solid var(--rule); }
.tabs a { flex: none; padding: 0.625rem 0.875rem; border-bottom: 2px solid transparent; font-size: var(--text-sm); font-weight: 600; color: var(--graphite-soft); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.grade-low { color: var(--margin); }
.error-text { color: var(--margin); font-weight: 600; }
.ruled.scores li { flex-wrap: wrap; }
.score-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.score-controls input, .score-controls select { min-height: 2.5rem; padding: 0 0.5rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-field); background: var(--paper); font-size: var(--text-md); }
.score-controls input.score-input { width: 5.5rem; text-align: right; }
.score-controls input.invalid { border-color: var(--margin); }
.score-comment summary { font-size: var(--text-sm); color: var(--ink); cursor: pointer; }
.score-comment input { width: 100%; margin-top: 0.375rem; }
.category-row { padding: 0.75rem; border: 1px solid var(--rule); border-radius: var(--radius-field); }
@media (max-width: 40rem) { .ruled.scores .trail { flex-basis: 100%; } .score-comment { flex-basis: 100%; } .score-controls input.score-input { width: 6.5rem; } }

/* Documents: actions inside table rows and long fingerprints */
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; }
.row-actions form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; }
.row-actions input { min-height: 2rem; padding: 0 0.5rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-field); background: var(--paper); }
.hash { word-break: break-all; }

/* ---------- Messages ---------- */
.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.thread > li { max-width: min(38rem, 92%); padding: 0.625rem 0.875rem; border: 1px solid var(--rule); border-radius: 0.75rem 0.75rem 0.75rem 0.25rem; background: var(--paper); }
.thread > li.mine { align-self: flex-end; border-color: transparent; border-radius: 0.75rem 0.75rem 0.25rem 0.75rem; background: var(--ink-wash); }
.thread .who { display: flex; flex-wrap: wrap; gap: 0 0.5rem; margin: 0 0 0.25rem; font-size: var(--text-sm); font-weight: 600; color: var(--graphite-strong); }
.thread .who time { font-weight: 400; color: var(--graphite-soft); }
.thread .text { overflow-wrap: anywhere; line-height: 1.5; }

/* ---------- Dashboard bars (sem biblioteca de gráfico: a barra é uma faixa com largura) ---------- */
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.bars > li { display: grid; grid-template-columns: minmax(6rem, 12rem) 1fr auto; align-items: center; gap: 0.75rem; }
.bars .bar-label { font-size: var(--text-sm); color: var(--graphite-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bar-track { height: 0.875rem; border-radius: 0.4375rem; background: var(--rail); overflow: hidden; }
.bars .bar-fill { display: block; height: 100%; border-radius: 0.4375rem; background: var(--ink); }
.bars .bar-fill.low { background: var(--margin); }
.bars .bar-fill.w0 { width: 0%; }
.bars .bar-fill.w5 { width: 5%; }
.bars .bar-fill.w10 { width: 10%; }
.bars .bar-fill.w15 { width: 15%; }
.bars .bar-fill.w20 { width: 20%; }
.bars .bar-fill.w25 { width: 25%; }
.bars .bar-fill.w30 { width: 30%; }
.bars .bar-fill.w35 { width: 35%; }
.bars .bar-fill.w40 { width: 40%; }
.bars .bar-fill.w45 { width: 45%; }
.bars .bar-fill.w50 { width: 50%; }
.bars .bar-fill.w55 { width: 55%; }
.bars .bar-fill.w60 { width: 60%; }
.bars .bar-fill.w65 { width: 65%; }
.bars .bar-fill.w70 { width: 70%; }
.bars .bar-fill.w75 { width: 75%; }
.bars .bar-fill.w80 { width: 80%; }
.bars .bar-fill.w85 { width: 85%; }
.bars .bar-fill.w90 { width: 90%; }
.bars .bar-fill.w95 { width: 95%; }
.bars .bar-fill.w100 { width: 100%; }
.row-actions input.narrow, .form input.narrow { width: 4.5rem; }
.bars .bar-value { font-size: var(--text-sm); font-variant-numeric: tabular-nums; color: var(--graphite-strong); }
@media (max-width: 30rem) { .bars > li { grid-template-columns: 1fr auto; } .bars .bar-track { grid-column: 1 / -1; } }

/* Foto da pessoa: a imagem e o envio lado a lado, empilhados no celular. */
.photo-block { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1rem; }
.photo-block .avatar { width: 6rem; height: 6rem; border-radius: 50%; object-fit: cover; border: 1px solid var(--rule); background: var(--rail); }
.photo-block .avatar.empty { display: grid; place-items: center; font-size: 2rem; color: var(--graphite-soft); text-transform: uppercase; }
.photo-block .photo-form { flex: 1 1 14rem; gap: 0.5rem; }
.photo-block .photo-form input[type="file"] { max-width: 100%; }

/* Lacunas: o campo aparece no meio do enunciado e acompanha a linha. */
.blanks { line-height: 2.2; }
.blanks input { display: inline-block; width: 9rem; max-width: 100%; margin: 0 0.25rem; }

/* ---------- UX refresh: workspace amplo e ações explícitas ---------- */
:root {
  --canvas: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-hover: #f1f5fb;
  --radius-card: 14px;
  --shadow-card: 0 1px 2px rgb(15 23 42 / 0.05), 0 8px 24px rgb(15 23 42 / 0.04);
  --paper: #ffffff;
  --rail: #f7f9fc;
  --rule: #dbe3ed;
  --rule-strong: #bcc8d7;
  --graphite-strong: #172033;
  --graphite: #2a3446;
  --graphite-soft: #667085;
  --ink: #3158d5;
  --ink-strong: #2445ad;
  --ink-wash: #edf2ff;
  --content-max: none;
  --list-max: none;
  --radius-field: 8px;
  --radius-layer: 14px;
}
:root[data-theme="dark"] { --canvas: #0c111b; --surface: #121821; --surface-soft: #171f2c; --surface-hover: #1d2736; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --canvas: #0c111b; --surface: #121821; --surface-soft: #171f2c; --surface-hover: #1d2736; }
}
body { background: var(--canvas); }
.main-column { background: var(--canvas); }
@media (min-width: 48rem) { .app { grid-template-columns: 16.5rem minmax(0, 1fr); } }
@media (min-width: 48rem) {
  .rail { background: #111827; border-right-color: #1f2937; }
  .rail .brand { color: #f8fafc; padding-left: 1.25rem; }
  .rail .nav-group { color: #94a3b8; }
  .rail .nav a { color: #cbd5e1; border-radius: 8px; min-height: 2.75rem; }
  .rail .nav a:hover { background: #1f2937; color: #ffffff; }
  .rail .nav a[aria-current="page"] { background: #263247; color: #ffffff; }
  .rail .nav a[aria-current="page"]::before { left: -0.5rem; background: #7c9cff; }
}
.topbar { height: 4rem; background: var(--paper-veil); box-shadow: 0 1px 0 var(--rule); }
.content { max-width: none; padding-left: clamp(1rem, 2.5vw, 3rem); padding-right: clamp(1rem, 2.5vw, 3rem); }
@media (min-width: 48rem) { .content { padding-top: 2rem; padding-bottom: 4rem; } }
.page-header { align-items: center; padding: 1.25rem 1.375rem; margin-bottom: 1.25rem; border: 1px solid var(--rule); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.page-header h1 { font-size: clamp(1.65rem, 2.2vw, 2rem); }
.content > .section, .content > .plan-sections.section, .content > form.section {
  margin-top: 1.25rem; padding: 1.25rem; border: 1px solid var(--rule); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card);
}
.content > .section:first-child { margin-top: 0; }
.section-head { align-items: center; }
.ruled { border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; background: var(--surface); }
.ruled > li { padding: 0.875rem 1rem; border-bottom-color: var(--rule); }
.ruled > li:last-child { border-bottom: 0; }
.ruled > li:hover { background: var(--surface-hover); }
.todo { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.todo a { min-height: 4rem; background: var(--surface-soft); border-radius: 10px; }
.btn { min-height: 2.625rem; border-radius: 8px; padding-inline: 1rem; box-shadow: 0 1px 1px rgb(15 23 42 / 0.04); }
.btn.quiet { box-shadow: none; }
.btn.small { min-height: 2.25rem; }
.action-panel { margin-top: 1.25rem; padding: 1.25rem; border: 1px solid var(--rule); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.action-panel .section-head { margin-bottom: 1rem; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); gap: 0.75rem; }
.action-tile { display: flex; min-height: 6.25rem; flex-direction: column; justify-content: space-between; gap: 0.5rem; padding: 1rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface-soft); color: var(--graphite); text-decoration: none; }
.action-tile:hover { border-color: var(--ink); background: var(--ink-wash); color: var(--graphite-strong); transform: translateY(-1px); }
.action-title { display: block; font-weight: 700; color: var(--graphite-strong); }
.action-copy { display: block; font-size: var(--text-sm); line-height: 1.35; color: var(--graphite-soft); }
.workflow-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.25rem; }
.plan-sections { gap: 1.5rem; }
@media (min-width: 64rem) { .plan-sections { grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem); } }
.plan-sections > aside { padding: 1rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface-soft); }
.plan-sections > aside > section:first-child { margin-top: 0; }
@media (max-width: 40rem) {
  .page-header { padding: 1rem; align-items: stretch; }
  .page-header .actions { width: 100%; }
  .page-header .actions .btn { flex: 1 1 auto; }
  .action-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 28rem) { .action-grid { grid-template-columns: 1fr; } }

/* Tempos de aula: o turno resumido numa linha de horários, só para leitura. */
.time-strip { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.time-strip .tag { font-variant-numeric: tabular-nums; }
.time-strip .time-break { background: transparent; border: 1px dashed var(--rule-strong); color: var(--graphite-soft); }

/* Ajuste raro dentro de uma linha: fica fechado até alguém pedir. */
.inline-edit > summary { list-style: none; cursor: pointer; }
.inline-edit > summary::-webkit-details-marker { display: none; }
.inline-edit[open] > summary { display: none; }
.inline-edit .filters { margin: 0; }

/* Notificações: mais largo e mais baixo, com rolagem, em vez de uma coluna estreita e comprida. */
#notifications-panel { width: min(30rem, calc(100vw - 2rem)); max-width: none !important; max-height: min(26rem, 70vh); overflow-y: auto; overscroll-behavior: contain; }
#notifications-panel .header { position: sticky; top: 0; z-index: 1; background: var(--paper); }
/* No celular o sino não fica na borda direita: ancorado nele, o painel largo saía pela esquerda da tela. */
@media (max-width: 47.99rem) { #notifications-menu[open] #notifications-panel { position: fixed; top: 3.5rem; left: 0.75rem !important; right: 0.75rem !important; width: auto !important; } }
/* Each notice is its own block, with a rule between them: title, text and when, one under the other. */
#notifications-panel > a { align-items: flex-start; min-height: 0 !important; padding: 0.7rem 0.75rem !important; border-radius: 0 !important; border-bottom: 1px solid var(--rule); }
#notifications-panel > a:last-child { border-bottom: 0; }
#notifications-panel .notification { display: flex; flex-direction: column; gap: 0.2rem; }
#notifications-panel .notification .when { font-size: 0.75rem; }

/* O menu lateral e a página rolam cada um por si: chegar ao fim do menu não passa a rolar a página. */
.rail .nav { overscroll-behavior: contain; }

/* Calendário: o quadradinho do dia inteiro abre "Adicionar data" com o dia já marcado. */
table.month td { position: relative; }
table.month td .day-add { position: absolute; inset: 0; z-index: 0; border-radius: inherit; }
table.month td .day-add:hover, table.month td .day-add:focus-visible { background: var(--ink-wash, rgb(35 56 166 / .06)); outline-offset: -2px; }
table.month td .day-number, table.month td .ev { position: relative; z-index: 1; pointer-events: none; }

/* ---------- Loading a page read live ---------- */

.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; min-height: 16rem; color: var(--graphite-soft); font-size: var(--text-sm); }
.spinner { width: 2rem; height: 2rem; border: 3px solid var(--rule); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
/* A loading block used as an htmx indicator is hidden until its request runs, then stays centred while it shows. */
.loading.htmx-indicator { display: none; }
.loading.htmx-indicator.htmx-request { display: flex; min-height: 8rem; }

/* ---------- Assistant ---------- */

.check-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.question-types { border: 0; padding: 0; margin: 0 0 1rem; }
.question-types legend { margin-bottom: 0.5rem; font-size: var(--text-sm); font-weight: 600; color: var(--graphite-strong); }
.generated-questions .body { gap: 0.35rem; }
.generated-questions .options { display: grid; gap: 0.25rem; margin: 0.25rem 0 0; padding: 0; list-style: none; font-size: var(--text-sm); }

/* ---------- Forms that are the page ---------- */

/* A form that is the whole page sits on one card, like every other block of content, and its buttons close the card:
   the last row, under a rule, at the end of the page. Nothing floats over the fields. */
.content > form.form:not(.filters) { width: 100%; max-width: none; padding: 1.35rem; border: 1px solid var(--rule); border-radius: var(--radius-card); background: var(--paper); box-shadow: var(--shadow-card); }
.content > form.form:not(.filters) > .form-footer { margin-top: 1.5rem; padding-top: 1rem !important; border-top: 1px solid var(--rule); }
@media (max-width: 40rem) { .content > form.form:not(.filters) { padding: 1rem; } }
.generator-sub { margin-top: 1.5rem; }


/* ---------- Curriculum item ---------- */

/* The description is the point of the page: the whole width of its card, in a size that reads easily. */
.skill-text { max-width: none; font-size: 1.05rem; line-height: 1.6; color: var(--graphite-strong); }
.skill-source { font-size: var(--text-sm); }
.skill-source + .skill-source { margin-top: 0.35rem; }

/* A small select inside a list row (the folder when placing a material). */
.compact-select { min-height: 2rem; padding: 0.2rem 0.5rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-field); background: var(--paper); font-size: var(--text-sm); }

/* Fields where one of several is needed: grouped, with the rule said once at the top instead of "(opcional)" on each. */
.one-of { margin: 0.5rem 0 1.25rem; padding: 1rem 1.1rem; border: 1px solid var(--rule); border-radius: var(--radius-field); }
.one-of > legend { padding: 0 0.35rem; font-weight: 600; color: var(--graphite-strong); }
.one-of > .hint { margin-bottom: 0.75rem; }
.one-of > .field + .field { margin-top: 1rem; }
.grid .money { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Questions with their answer key ---------- */
.options.lettered { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.375rem; }
.options.lettered li { display: grid; grid-template-columns: 1.75rem minmax(0, 1fr); align-items: baseline; column-gap: 0.25rem; row-gap: 0.25rem; padding: 0.375rem 0.5rem; border-radius: var(--radius-field); }
.options.lettered li .tag { grid-column: 2; justify-self: start; }
.options.lettered li.right { background: var(--rail); }
.option-letter { font-weight: 700; min-width: 1.5rem; }
.answer-line { margin-top: 0.5rem; font-size: var(--text-sm); color: var(--graphite-soft); }
.answer-line strong { color: var(--graphite-strong, inherit); }
.option-edit { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.5rem; margin-top: 0.5rem; }
.generated-questions > li, .quiz-questions > li { align-items: flex-start; }

/* ---------- Formatted text (question statements) ---------- */
.rich-editor { border: 1px solid var(--rule); border-radius: var(--radius-field); background: var(--surface, #fff); }
.rich-editor:focus-within { outline: 2px solid var(--ink); outline-offset: 1px; }
.rich-toolbar { display: flex; flex-wrap: wrap; gap: 0.25rem; padding: 0.375rem; border-bottom: 1px solid var(--rule); background: var(--rail); border-radius: var(--radius-field) var(--radius-field) 0 0; }
.rich-tool { min-height: 2.25rem; min-width: 2.25rem; padding: 0 0.625rem; border: 1px solid var(--rule); border-radius: var(--radius-field); background: var(--surface, #fff); color: inherit; font: inherit; font-size: var(--text-sm); cursor: pointer; }
.rich-tool:hover { border-color: var(--ink); }
.rich-tool:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.rich-area { min-height: 9rem; padding: 0.75rem; overflow-wrap: anywhere; }
.rich-area:focus { outline: none; }
.rich-status { margin: 0; padding: 0 0.75rem 0.5rem; min-height: 1rem; }
.rich-text img, .rich-area img { max-width: 100%; height: auto; }
.rich-text table, .rich-area table { border-collapse: collapse; margin: 0.5rem 0; }
.rich-text td, .rich-text th, .rich-area td, .rich-area th { border: 1px solid var(--rule); padding: 0.25rem 0.5rem; min-width: 3rem; }
.rich-text p, .rich-area p { margin: 0 0 0.5rem; }
.rich-text ul, .rich-text ol, .rich-area ul, .rich-area ol { margin: 0 0 0.5rem; padding-left: 1.5rem; }
.question-figure { margin: 0.5rem 0; max-width: 100%; }
.question-figure svg { max-width: 100%; height: auto; display: block; }
