/* Tema e variáveis compartilhadas */
:root {
  color-scheme: light;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  /* Paleta editorial oficial */
  --graphite: #15191f;
  --steel: #34485c;
  --off-white: #f5f3ee;
  --gold: #a8742a;
  /* Superfícies, texto e controles: tema claro */
  --bg: var(--off-white);
  --panel: #ffffff;
  --panel2: #eae8e2;
  --sidebar: var(--graphite);
  --ink: var(--graphite);
  --muted: #586471;
  --line: #d8d6cf;
  --control-line: #76808a;
  --accent: var(--steel);
  --accentfg: var(--off-white);
  --soft: #eeece6;
  --focus: var(--steel);
  --sidebar-ink: var(--off-white);
  --sidebar-muted: #bac3cc;
  --sidebar-active: var(--steel);
  --sidebar-line: #455363;
  --selected-line: var(--gold);
  --highlight-bg: #efdfc3;
  --highlight-ink: var(--graphite);
  --dot-bg: var(--steel);
  --dot-ink: var(--off-white);
  --good: #e6f6ed;
  --goodline: #208754;
  --good-solid: #137848;
  --bad: #fde9e9;
  --badline: #c1323e;
  --bad-solid: #b72f3b;
  --shadow: 0 10px 35px #15191f10;
  --overlay: #15191fb8;
  --modal-shadow: 0 25px 75px #15191f77;
}
/* Tema escuro: dourado reservado a detalhes, sem superfícies grandes. */
body.dark {
  color-scheme: dark;
  --bg: var(--graphite);
  --panel: #1e252e;
  --panel2: #29333f;
  --ink: var(--off-white);
  --muted: #b5bfc9;
  --line: #3e4956;
  --control-line: #7e8b99;
  --soft: #252e39;
  --accent: var(--steel);
  --accentfg: var(--off-white);
  --focus: #c2ccd5;
  --highlight-bg: #efdfc3;
  --highlight-ink: var(--graphite);
  --good: #073c27;
  --goodline: #1cb26b;
  --bad: #510b14;
  --badline: #ef5962;
  --shadow: 0 14px 36px #15191f55;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.hidden {
  display: none !important;
}
a {
  color: inherit;
}
/* Estrutura e navegação lateral */
.app {
  display: flex;
  min-height: 100vh;
}
.side {
  width: 255px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 29px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.logo {
  font-size: 29px;
  font-weight: 800;
  letter-spacing: -1px;
  margin: 0 12px 4px;
}
.logo span {
  color: var(--sidebar-ink);
}
.tagline {
  font-size: 11px;
  line-height: 1.55;
  color: var(--sidebar-muted);
  margin: 0 12px 30px;
}
.nav {
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  padding: 13px 14px;
  border-radius: 11px;
  color: var(--sidebar-muted);
  margin: 3px 0;
}
.nav.active,
.nav:hover {
  background: var(--sidebar-active);
  color: var(--sidebar-ink);
}
.asidefoot {
  margin: 29px 10px;
  padding-top: 17px;
  border-top: 1px solid var(--sidebar-line);
  font-size: 12px;
  color: var(--sidebar-muted);
  line-height: 1.65;
}
/* Cabeçalho e componentes compartilhados */
.main {
  flex: 1;
  min-width: 0;
  max-width: 1600px;
  margin: 0 auto;
  padding: 30px 35px 64px;
}
.head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 27px;
}
.head h1 {
  font-size: 28px;
  letter-spacing: -0.7px;
  margin: 0 0 6px;
}
.head p {
  color: var(--muted);
  margin: 0;
  font-size: 13px;
}
.headright {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}
.btn,
.btnout,
.mini {
  padding: 10px 15px;
  border-radius: 11px;
  border: 1px solid var(--line);
  font-weight: 650;
}
.btn {
  background: var(--accent);
  color: var(--accentfg);
  border-color: var(--control-line);
}
.btnout,
.mini {
  background: var(--panel);
  color: var(--ink);
}
.mini {
  padding: 7px 11px;
  font-size: 12px;
}
.mini.selected {
  background: var(--accent);
  color: var(--accentfg);
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.eyebrow {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  font-weight: 750;
  margin: 0 0 10px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
/* Painel inicial */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
}
.stat strong {
  display: block;
  font-size: 26px;
  margin-top: 6px;
}
.stat span {
  font-size: 12px;
  color: var(--muted);
}
.feature {
  grid-column: span 3;
}
.block {
  margin-top: 21px;
}
.h2 {
  font-size: 19px;
  margin: 0 0 13px;
  letter-spacing: -0.2px;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.between {
  justify-content: space-between;
}
.chip {
  font-size: 11px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
}
/* Filtros e catálogo de questões */
.controls {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 14px;
  align-items: end;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.field input,
.field select,
.field textarea {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 11px;
  border-radius: 11px;
}
.field textarea {
  resize: vertical;
}
.listtree {
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.tree-area {
  border: 1px solid var(--line);
  border-radius: 15px;
  overflow: hidden;
}
.tree-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 16px;
  align-items: center;
  background: var(--panel);
}
.tree-row:hover {
  background: var(--soft);
}
.tree-row > div:first-child {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.tree-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  accent-color: var(--focus);
}
.tree-row strong {
  font-size: 14px;
  font-weight: 650;
}
.tree-row .meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.tree-children {
  background: var(--panel2);
  padding: 8px 12px 14px 28px;
}
.tree-topic {
  border-left: 2px solid var(--line);
  margin: 8px 0 0;
  padding-left: 14px;
}
.tree-sub {
  padding: 4px 3px 7px 30px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 7px;
}
.subcheck {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 12px;
}
.subcheck input {
  accent-color: var(--focus);
}
.twist {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 20px;
  padding: 0 8px;
}
.counter {
  font-size: 12px;
  color: var(--muted);
}
/* Resolução e ferramentas de marcação */
.exam-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 15px;
}
.exam-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  align-self: start;
}
.progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
  margin: 15px 0 22px;
}
.dot {
  border: 0;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  background: var(--dot-bg);
  color: var(--dot-ink);
  font-weight: 650;
}
.dot.current {
  outline: 2px solid var(--selected-line);
  outline-offset: 2px;
}
.dot.good {
  background: var(--good-solid);
}
.dot.bad {
  background: var(--bad-solid);
}
.dot.done {
  background: var(--steel);
}
.exam-work {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 23px;
  padding: 24px;
  min-height: 540px;
}
.exam-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.marker {
  background: var(--soft);
  border: 0;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 17px;
  font-size: 12px;
  font-weight: 750;
}
.marker.off {
  background: var(--soft);
  color: var(--ink);
}
.stem {
  padding: 19px 20px;
  background: var(--panel2);
  border-radius: 17px;
  line-height: 1.72;
  font-size: 15px;
  margin: 19px 0 20px;
  white-space: pre-wrap;
}
.answers {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.answer {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  line-height: 1.55;
  cursor: pointer;
}
.answer:hover {
  background: var(--soft);
}
.answer input {
  margin-top: 4px;
  accent-color: var(--focus);
}
.answer.correct {
  border-color: var(--goodline);
  background: var(--good);
}
.answer.incorrect {
  border-color: var(--badline);
  background: var(--bad);
}
.examfooter {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 23px;
}
.annot-hi {
  background: var(--highlight-bg);
  color: var(--highlight-ink);
  border-radius: 2px;
}
.annot-strike {
  text-decoration: line-through;
  text-decoration-color: var(--badline);
  text-decoration-thickness: 2px;
  opacity: 0.65;
}
.annotation-tip {
  color: var(--muted);
  font-size: 11px;
  margin-top: 10px;
}
/* Correção e resultado do bloco */
.feedback {
  margin-top: 22px;
  display: grid;
  gap: 12px;
}
.feedback-card {
  border-radius: 17px;
  padding: 17px;
  border: 1px solid;
}
.feedback-card.correct {
  border-color: var(--goodline);
  background: var(--good);
}
.feedback-card.incorrect {
  border-color: var(--badline);
  background: var(--bad);
}
.feedback-card h4 {
  margin: 0 0 9px;
  font-size: 14px;
}
.feedback-card p {
  margin: 0;
  line-height: 1.6;
  font-size: 13px;
}
.corebox {
  background: var(--soft);
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.corebox h3 {
  font-size: 15px;
  margin: 0 0 10px;
}
.corebox ul {
  padding-left: 20px;
  margin: 0;
}
.corebox li {
  margin: 6px 0;
  line-height: 1.5;
  font-size: 13px;
}
.corebox p {
  margin: 0;
  line-height: 1.6;
  font-size: 13px;
}
.result {
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 18px;
  border-radius: 16px;
  margin-top: 20px;
}
/* Calendário e agenda de revisões */
.calendar-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 15px;
}
.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}
.cal-head {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 8px 0;
}
.cal-day {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px;
  background: var(--panel2);
}
.cal-day.today {
  outline: 2px solid var(--selected-line);
}
.cal-event {
  display: block;
  font-size: 10px;
  padding: 4px;
  margin-top: 4px;
  background: var(--steel);
  color: var(--off-white);
  border-radius: 6px;
  overflow-wrap: anywhere;
}
.reviewitem {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  margin-bottom: 10px;
}
.reviewitem strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}
.reviewitem p {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 9px;
}
/* Bibliotecas de conteúdo */
.basiclist {
  display: grid;
  gap: 11px;
}
.basiclist .card {
  padding: 17px;
}
.basiclist h3 {
  margin: 10px 0;
  font-size: 16px;
}
.basiclist p {
  font-size: 13px;
  line-height: 1.6;
}
.flashfront {
  font-size: 17px;
  font-weight: 650;
  line-height: 1.5;
  margin: 13px 0;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table td,
.table th {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  text-align: left;
}
.table th {
  color: var(--muted);
}
/* Modal de notas */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: grid;
  place-items: center;
  z-index: 30;
  padding: 20px;
}
.modal {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 19px;
  padding: 22px;
  box-shadow: var(--modal-shadow);
}
.modal h2 {
  margin: 0 0 9px;
  font-size: 20px;
}
.modal p {
  color: var(--muted);
  font-size: 13px;
}
.modal textarea {
  width: 100%;
  min-height: 165px;
  padding: 12px;
  border-radius: 11px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--ink);
  resize: vertical;
}
/* Adaptação para telas menores */
@media (max-width: 1050px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .feature {
    grid-column: span 2;
  }
  .controls {
    grid-template-columns: repeat(2, 1fr);
  }
  .calendar-layout {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 760px) {
  .app {
    display: block;
  }
  .side {
    height: auto;
    width: auto;
    position: static;
    padding: 15px;
  }
  .side nav {
    display: flex;
    overflow: auto;
  }
  .nav {
    white-space: nowrap;
    width: auto;
  }
  .asidefoot,
  .tagline {
    display: none;
  }
  .main {
    padding: 20px 13px;
  }
  .head {
    align-items: flex-start;
    flex-direction: column;
  }
  .controls {
    grid-template-columns: 1fr;
  }
  .exam-layout {
    grid-template-columns: 1fr;
  }
  .progress {
    grid-template-columns: repeat(10, 1fr);
  }
  .exam-panel {
    padding: 13px;
  }
  .exam-work {
    padding: 15px;
  }
  .tree-children {
    padding-left: 10px;
  }
  .tree-sub {
    padding-left: 8px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .feature {
    grid-column: span 1;
  }
}

/* Questões importadas e anulações */
.question-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}
.dot.annulled {
  background: var(--muted);
  outline: 1px dashed var(--line);
}

/* Administração utiliza os mesmos painéis e variáveis de tema. */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
#admin .field {
  margin: 14px 0;
}
#admin textarea {
  min-height: 90px;
  resize: vertical;
  background: var(--panel2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
#admin fieldset {
  margin: 14px 0;
}

/* Acentos editoriais: linhas curtas e estados selecionados. */
.nav.active {
  box-shadow: inset 3px 0 0 var(--gold);
}
.btn {
  box-shadow: inset 0 -2px 0 var(--gold);
}
.marker {
  border: 1px solid var(--control-line);
  box-shadow: inset 3px 0 0 var(--gold);
}
.mini.selected {
  border-color: var(--selected-line);
}
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 2px;
  background: var(--gold);
  vertical-align: middle;
  margin-right: 8px;
}
.dot.annulled {
  color: var(--bg);
}
.field input,
.field select,
#admin textarea,
.modal textarea {
  border-color: var(--control-line);
}

/* Foco de teclado legível também sobre a navegação em grafite. */
.nav:focus-visible {
  outline-color: var(--sidebar-ink);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}
/* A ferramenta desativada mantém contraste, sem o indicador dourado de seleção. */
.marker.off {
  box-shadow: none;
}

/* Administração editorial: superfícies neutras e acentos discretos. */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.admin-stat {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.admin-stat strong {
  font-size: 2.1rem;
  font-weight: 600;
  letter-spacing: -0.05em;
}
.admin-stat:first-child {
  border-top: 2px solid var(--gold);
}
.admin-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.admin-catalog > .field {
  margin-top: 20px;
}
.admin-import {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 16px;
}
.admin-import summary {
  color: var(--muted);
  cursor: pointer;
}
#adminList {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.admin-question {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.admin-question h3 {
  font-size: 1.05rem;
  margin: 18px 0 6px;
}
.admin-question-origin {
  margin-top: 16px;
  font-weight: 600;
  font-size: 0.85rem;
}
.admin-question-id {
  margin-top: 6px;
  overflow-wrap: anywhere;
}
.admin-stem-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.65;
}
.admin-question > .row:last-child {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.editorial-status {
  background: var(--soft);
  color: var(--ink);
}
.status-pending {
  border-left: 2px solid var(--gold);
}
.status-reviewed,
.status-published {
  border-left: 2px solid var(--steel);
}
.editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.editor-heading h3 {
  font-size: 1.6rem;
  margin: 8px 0;
}
.editor-section {
  margin: 28px 0 16px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--muted);
}
#questionForm fieldset {
  margin: 16px 0;
  border: 1px solid var(--line);
  box-shadow: none;
  background: var(--soft);
}
#questionForm legend {
  font-weight: 600;
  padding: 0 8px;
}
#questionForm textarea {
  min-height: 100px;
  line-height: 1.6;
  resize: vertical;
}
.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 20px;
}
.student-preview {
  width: min(850px, calc(100% - 32px));
  max-height: 90vh;
  overflow: auto;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--modal-shadow);
}
.student-preview::backdrop {
  background: var(--overlay);
}
.preview-notice {
  background: var(--soft);
  border-left: 2px solid var(--gold);
  padding: 12px 16px;
  font-size: 0.85rem;
  line-height: 1.6;
}
.preview-stem {
  white-space: pre-wrap;
  line-height: 1.8;
}
#adminPreviewContent .answer {
  margin: 12px 0;
}
#questionStem {
  white-space: pre-wrap;
  line-height: 1.8;
}
@media (max-width: 900px) {
  .admin-stats,
  .admin-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #adminList {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 520px) {
  .admin-filter-grid {
    grid-template-columns: 1fr;
  }
  .admin-stats {
    gap: 10px;
  }
  .admin-stat {
    padding: 16px;
  }
  .editor-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .editor-actions > button {
    width: 100%;
  }
  .student-preview {
    padding: 18px;
  }
}

.cms-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.cms-nav .active {
  border-bottom: 2px solid var(--gold);
  color: var(--ink);
}
.cms-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.cms-id {
  overflow-wrap: anywhere;
}
.rich-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 16px 0;
  border-block: 1px solid var(--line);
}
.cms-block {
  margin: 20px 0;
  border: 1px solid var(--line);
  box-shadow: none;
}
.cms-block textarea {
  width: 100%;
  min-height: 110px;
  line-height: 1.7;
  resize: vertical;
}
.cms-table-scroll {
  overflow-x: auto;
}
.cms-table-scroll table {
  border-collapse: collapse;
  width: 100%;
  margin-block: 20px;
}
.cms-table-scroll td {
  border: 1px solid var(--line);
  padding: 12px;
  white-space: pre-wrap;
}
#summaryList p,
#cmsBack {
  white-space: pre-wrap;
  line-height: 1.8;
}
#cmsSequence {
  padding-left: 20px;
}
#cmsSequence li {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
#cmsSection textarea {
  line-height: 1.7;
}
#cmsImportDrafts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 700px) {
  .cms-list {
    grid-template-columns: 1fr;
  }
  .cms-nav button {
    flex: 1 1 auto;
  }
}
.flashfront,
#flashList p {
  white-space: pre-wrap;
}
.cms-list h3 {
  overflow-wrap: anywhere;
}
