:root {
  --ink: #1c2b2b;
  --muted: #5a6e6e;
  --paper: #f7f3e8;
  --paper-line: #c9d6c8;
  --paper-baseline: #9eb89a;
  --teal: #2a6f6f;
  --teal-dark: #1e5252;
  --coral: #e07a5f;
  --sky: #7eb8c4;
  --white: #fffef9;
  --shadow: 0 10px 28px rgba(28, 43, 43, 0.12);
  --radius: 18px;
  --font-ui: "Nunito", system-ui, sans-serif;
  --font-brand: "Baloo 2", "Nunito", sans-serif;
  --font-print: "Nunito", system-ui, sans-serif;
  --font-cursive: "Caveat", "Segoe Script", cursive;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --avatar: 118px;
  --app-vw: 100vw;
  --app-vh: 100dvh;
  --vv-top: 0px;
  --vv-left: 0px;
  --space-page: clamp(12px, 2.2vw, 22px);
  --grid-gap: clamp(10px, 1.8vw, 16px);
  --card-min: min(100%, 240px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  height: auto;
  overflow-x: hidden;
  overflow-y: scroll;
  font-family: var(--font-ui);
  color: var(--ink);
  background-color: #111111;
  background-image: url("../img/fundo-app.jpg");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
}

body {
  display: block;
}

body.theme-marininha {
  background-color: #e6f7fc;
  background-image: url("../img/fundo-marininha.jpg");
}

body.theme-marininha .user-home-stats p,
body.theme-marininha .user-name,
body.theme-marininha .bar h2 {
  color: var(--teal-dark);
}

body.theme-marininha .user-home-stats strong {
  color: var(--ink);
}

body.theme-marininha .user-name.is-placeholder,
body.theme-marininha .user-age,
body.theme-marininha .bar-sub,
body.theme-marininha .subtitle {
  color: var(--muted);
}

body.theme-marininha .brand {
  color: #e46aa0;
}

body.theme-marininha .home-hero h1 {
  color: var(--ink);
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100%;
  padding:
    calc(var(--space-page) + var(--safe-top))
    calc(var(--space-page) + var(--safe-right))
    calc(var(--space-page) + var(--safe-bottom))
    calc(var(--space-page) + var(--safe-left));
  width: 100%;
  max-width: 100%;
}

.screen.active {
  display: flex;
  min-height: 100dvh;
  min-height: var(--app-vh, 100dvh);
  height: auto;
  max-height: none;
  overflow: visible;
  touch-action: auto;
}

/* HOME */
.home-top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px 16px;
  margin-bottom: 8px;
}

.home-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.home-report-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
  width: min(230px, 38vw);
  padding-top: 4px;
}

.home-report-btns .btn-primary,
.home-report-btns .btn-secondary {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  font-size: 0.88rem;
  line-height: 1.25;
  white-space: normal;
}

.home-users {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-width: 0;
}

.home-user-card {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 108px;
  max-width: 128px;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.home-user-card.is-active .home-user-photo {
  border-color: #7ec8ff;
  box-shadow: 0 0 0 3px rgba(126, 200, 255, 0.45);
}

.home-user-photo {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.35);
  background: radial-gradient(circle at 35% 30%, #e8f4f1 0%, #d2e6e2 100%);
}

.home-user-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-user-photo .ph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--teal);
  font-weight: 800;
  font-size: 1.4rem;
}

.home-pct-badge {
  position: absolute;
  right: -4px;
  bottom: -2px;
  min-width: 42px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #1e5252;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.home-user-name {
  margin: 0;
  font-size: clamp(0.72rem, 2.2vw, 0.86rem);
  font-weight: 800;
  text-align: center;
  color: #f4f4f4;
  line-height: 1.25;
  max-height: none;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.home-user-mail {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  color: #d8d8d8;
  line-height: 1.25;
}

.home-mail-line {
  margin-top: 4px !important;
  font-size: 0.82rem !important;
}

.user-home-stats {
  min-width: 0;
  padding-top: 10px;
}

.user-home-stats p {
  margin: 0 0 8px;
  font-weight: 800;
  font-size: clamp(0.86rem, 2.4vw, 1.05rem);
  line-height: 1.35;
  color: #f2f2f2;
}

.user-home-stats strong {
  font-weight: 800;
  color: #ffffff;
}

.user-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 130px;
  flex-shrink: 0;
  padding-top: 4px;
}

.user-photo-btn {
  appearance: none;
  border: 3px solid rgba(42, 111, 111, 0.35);
  background:
    radial-gradient(circle at 35% 30%, #e8f4f1 0%, #d2e6e2 100%);
  width: var(--avatar, 118px);
  height: var(--avatar, 118px);
  border-radius: 50%;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  color: var(--teal);
  position: relative;
}

.user-photo-btn:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 3px;
}

.user-photo-btn.has-photo {
  border-color: var(--teal);
}

.user-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-photo-placeholder {
  display: grid;
  place-items: center;
  opacity: 0.85;
}

.user-photo-btn.has-photo .user-photo-placeholder {
  display: none;
}

.user-name {
  margin: 0;
  width: 100%;
  text-align: center;
  font-weight: 800;
  font-size: clamp(0.76rem, 2.1vw, 0.9rem);
  line-height: 1.25;
  color: #f4f4f4;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  max-height: none;
  overflow: visible;
}

.user-name.is-placeholder {
  color: #cfcfcf;
  font-weight: 700;
}

.user-age {
  margin: -4px 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: #cfcfcf;
}

.bar-sub {
  margin: 2px 0 0;
  color: #d0d0d0;
  font-size: 0.88rem;
}

.q-art {
  flex-shrink: 0;
  width: var(--avatar, 118px);
  display: flex;
  justify-content: center;
}

.q-art[hidden] {
  display: none !important;
}

.q-art-frame {
  width: var(--avatar, 118px);
  height: var(--avatar, 118px);
  background: var(--white);
  border-radius: 50%;
  box-shadow: var(--shadow);
  border: 3px solid rgba(42, 111, 111, 0.35);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.q-art-frame svg {
  width: 78%;
  height: 78%;
}

.quiz-subject {
  margin: 0 0 8px;
  padding: 0;
  font-weight: 800;
  color: var(--teal);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding: 0 0 8px;
  flex: 0 0 auto;
  overflow: visible;
}

.quiz-option {
  appearance: none;
  text-align: left;
  border: 2px solid rgba(42, 111, 111, 0.18);
  background: var(--white);
  border-radius: 14px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 700;
  font-size: clamp(0.88rem, 2.6vw, 1rem);
  line-height: 1.25;
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.quiz-option.is-selected {
  border-color: #5ec4e8;
  background: #c8eefc;
  box-shadow: 0 0 0 3px rgba(94, 196, 232, 0.35);
}

.quiz-option.is-correct {
  border-color: var(--teal);
  background: #e6f4ef;
}

.quiz-option.is-wrong {
  border-color: var(--coral);
  background: #fdece6;
}

.quiz-passage-card {
  margin: 0 0 8px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  border: 2px solid rgba(42, 111, 111, 0.12);
}

.quiz-passage-label {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--teal);
}

.quiz-passage {
  margin: 0;
  white-space: pre-line;
  text-align: left;
  line-height: 1.45;
  font-weight: 600;
}

.quiz-hint {
  margin: 6px 0 0;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 10px;
}

.chart-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.chart-legend .dot.hit {
  background: var(--teal);
  margin-left: 4px;
}

.chart-legend .dot.miss {
  background: var(--coral);
  margin-left: 12px;
}

.chart-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chart-row {
  background: var(--white);
  border-radius: 12px;
  padding: 10px 12px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.chart-head span {
  color: var(--muted);
  font-weight: 600;
}

.chart-bars {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #ece7dc;
}

.chart-bar.hit {
  background: var(--teal);
  height: 100%;
}

.chart-bar.miss {
  background: var(--coral);
  height: 100%;
}

.report-panel {
  max-width: 720px;
}

@media print {
  body * {
    visibility: hidden;
  }
  #screen-reports,
  #screen-reports * {
    visibility: visible;
  }
  #screen-reports {
    display: flex !important;
    position: absolute;
    inset: 0;
    height: auto;
    overflow: visible;
    background: #fff;
  }
  #btn-reports-back,
  #btn-report-pdf {
    display: none !important;
  }

  .calli-log-item {
    break-inside: avoid;
  }
}

.calli-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 16px;
}

.calli-log-item {
  background: var(--white);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.calli-log-item strong {
  display: block;
  font-size: 1rem;
}

.calli-log-item span {
  color: var(--muted);
  font-size: 0.88rem;
}

.main-card {
  min-height: 170px;
}

.profile-photo-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.settings-photo {
  width: 134px;
  height: 134px;
}

.hint.center {
  text-align: center;
  width: 100%;
}

.btn-ghost.small,
.btn-secondary.small {
  padding: 10px 14px;
  font-size: 0.9rem;
}

.profile-switch {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-switch-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-switch select {
  font: inherit;
  font-weight: 500;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid rgba(42, 111, 111, 0.2);
  background: var(--paper);
  color: var(--ink);
}

.ocr-balance {
  background: rgba(42, 111, 111, 0.08);
  border-radius: 14px;
  padding: 14px;
}

.ocr-balance-line {
  margin: 6px 0 0;
  font-weight: 700;
  color: var(--teal-dark);
  font-size: 0.95rem;
  line-height: 1.35;
}

.ocr-balance-line.muted {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}

.stats-box {
  background: rgba(42, 111, 111, 0.08);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stats-title {
  margin: 0;
  font-weight: 800;
  color: var(--teal-dark);
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  background: var(--white);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.stat-num {
  display: block;
  font-family: var(--font-brand);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--teal);
  line-height: 1;
}

.stat-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.workbook-actions.dual {
  gap: 10px;
  flex-wrap: wrap;
}

.workbook-actions.dual .btn-primary,
.workbook-actions.dual .btn-ghost,
.workbook-actions.dual .btn-secondary {
  flex: 1;
  min-width: 140px;
  width: auto;
}

/* MATH */
.math-question-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  text-align: center;
  border: 2px solid rgba(42, 111, 111, 0.12);
}

.math-prompt {
  margin: 0 0 6px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.95rem;
}

.math-expression {
  margin: 0;
  font-family: var(--font-brand);
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 800;
  color: var(--teal-dark);
  letter-spacing: 0.02em;
}

.math-write-label {
  margin: 14px 0 8px;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.95rem;
}

.math-answer-stage {
  flex: 1;
  min-height: 208px; /* +30% vs 160px */
  background: var(--paper);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 2px solid rgba(42, 111, 111, 0.12);
  touch-action: none;
  position: relative;
}

#math-canvas,
#quiz-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.quiz-scratch-stage {
  flex: 0 0 auto;
  height: 22vh;
  min-height: 110px;
  max-height: 180px;
  margin-bottom: 8px;
}

.q-art {
  width: 44px;
  height: 32px;
  flex-shrink: 0;
  margin-top: 6px;
}

.q-art-frame,
.q-art-frame svg {
  width: 44px;
  height: 32px;
  display: block;
}

.quiz-q-wrap {
  position: relative;
  padding-top: 22px;
  padding-right: 18px;
}

.quiz-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 22px;
  padding: 0 10px;
  background: #7cb342;
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
  clip-path: polygon(
    6% 50%, 0 28%, 12% 22%, 10% 4%, 28% 10%, 40% 0, 52% 10%, 70% 0, 78% 12%, 96% 8%,
    90% 28%, 100% 50%, 90% 72%, 96% 92%, 78% 88%, 70% 100%, 52% 90%, 40% 100%, 28% 90%,
    10% 96%, 12% 78%, 0 72%
  );
}

.quiz-badge.is-retry {
  min-width: 92px;
  font-size: 0.5rem;
  padding: 0 12px;
}

.exercise-card.is-picked {
  outline: 3px solid var(--teal);
  background: #e8f6f4;
}

/* RESULT MODAL */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(12px, var(--safe-top)) 12px max(16px, var(--safe-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 43, 43, 0.5);
  touch-action: pan-y;
}

.modal-panel,
.modal-card {
  position: relative;
  z-index: 2;
  width: min(420px, 100%);
  max-height: calc(100dvh - 24px);
  margin: auto 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: var(--white);
  border-radius: 24px;
  padding: 28px 22px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.quiz-explain {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 14px;
}

.quiz-explain p {
  margin: 0;
  background: rgba(42, 111, 111, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.92rem;
}

.quiz-explain strong {
  display: block;
  color: var(--ink);
  font-size: 1.02rem;
  margin-top: 4px;
}

.quiz-explain p:first-child strong {
  color: #b34a32;
}

.explain-why {
  background: #e8f6fc !important;
  color: var(--ink) !important;
  font-weight: 600 !important;
}

.fx-fireworks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.result-emoji {
  margin: 0;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-inline: auto;
  font-size: 2.2rem;
  font-weight: 800;
  color: #fff;
  background: var(--teal);
}

.modal.is-wrong .result-emoji {
  background: var(--coral);
}

.result-title {
  margin: 14px 0 8px;
  font-family: var(--font-brand);
  font-size: 2rem;
  font-weight: 800;
}

.modal.is-correct .result-title {
  color: var(--teal-dark);
}

.modal.is-wrong .result-title {
  color: #b34a32;
}

.result-detail {
  margin: 0 0 18px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.4;
}

.result-compare {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-compare li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  background: rgba(42, 111, 111, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.92rem;
}

.result-compare strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.modal-panel .btn-primary {
  width: 100%;
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin-top: 8px;
}

.confirm-panel .btn-ghost {
  width: 100%;
  margin-top: 8px;
}

.confirm-panel .btn-secondary,
.modal-panel .btn-secondary {
  width: 100%;
  margin: 0 0 10px;
}

.model-panel {
  width: min(440px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
}

.model-label {
  margin: 12px 0 6px;
  font-weight: 800;
  color: var(--teal-dark);
  text-align: left;
  font-size: 0.92rem;
}

.model-frame {
  background: var(--paper);
  border-radius: 14px;
  border: 2px solid rgba(42, 111, 111, 0.15);
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
}

.model-frame img {
  max-width: 100%;
  height: auto;
  display: block;
}

.model-empty {
  margin: 12px;
  color: var(--muted);
  font-weight: 700;
}

.confirm-input {
  width: 100%;
  font: inherit;
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.08em;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid rgba(42, 111, 111, 0.25);
  background: var(--paper);
  margin: 8px 0 12px;
  color: var(--ink);
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.numpad button {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 14px 0;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1.2rem;
  background: rgba(42, 111, 111, 0.12);
  color: var(--teal-dark);
  cursor: pointer;
}

.numpad button.numpad-wide {
  font-size: 0.95rem;
}

.crop-panel {
  width: min(440px, 100%);
}

.crop-stage {
  position: relative;
  width: min(340px, 86vw);
  height: min(340px, 86vw);
  margin: 10px auto 14px;
  overflow: hidden;
  border-radius: 22px;
  touch-action: none;
  background: #1c2b2b;
  user-select: none;
  cursor: grab;
}

.crop-stage.is-dragging {
  cursor: grabbing;
}

#crop-photo {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  height: auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.crop-circle-frame {
  pointer-events: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72%;
  height: 72%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid #fffef9;
  box-shadow: 0 0 0 999px rgba(12, 20, 20, 0.55);
}

.crop-zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.crop-zoom-row .btn-nav {
  width: 44px;
  height: 44px;
  font-size: 1.4rem;
}

.crop-zoom-row input[type="range"] {
  flex: 1;
}

.crop-panel .btn-ghost {
  width: 100%;
  margin-top: 8px;
}

/* OCR LOADING */
.ocr-loading {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(247, 243, 232, 0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-weight: 800;
  color: var(--teal-dark);
}

.ocr-loading[hidden] {
  display: none;
}

.ocr-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(42, 111, 111, 0.2);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.home-hero {
  text-align: center;
  padding: 4px 8px 20px;
  min-width: 0;
}

.brand {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: clamp(2.6rem, 8vw, 4rem);
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1;
}

.home-hero h1 {
  margin: 8px 0 10px;
  font-family: var(--font-brand);
  font-size: clamp(1.35rem, 3.5vw, 1.85rem);
  font-weight: 700;
  color: #f2f2f2;
}

.subtitle {
  margin: 0 auto;
  max-width: 34rem;
  color: #d8d8d8;
  font-size: 1.05rem;
  line-height: 1.45;
}

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--card-min), 1fr));
  gap: var(--grid-gap);
  max-width: min(980px, 100%);
  margin: 0 auto;
  width: 100%;
  align-items: stretch;
}

.main-menu-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.subject-pick-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  overflow-y: auto;
  padding-bottom: 8px;
}

.subject-pick {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 2px solid rgba(42, 111, 111, 0.2);
  background: var(--white);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 800;
  color: var(--teal-dark);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.subject-pick .radio-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--teal);
  background: transparent;
  flex-shrink: 0;
  box-sizing: border-box;
}

.subject-pick.is-on {
  border-color: var(--teal);
  background: #e7f4f1;
}

.subject-pick.is-on .radio-dot {
  background: var(--teal);
  box-shadow: inset 0 0 0 3px #fff;
}

.exercise-card {
  appearance: none;
  border: 2px solid rgba(42, 111, 111, 0.15);
  background: var(--white);
  border-radius: var(--radius);
  padding: clamp(14px, 2.4vw, 22px) clamp(12px, 2vw, 16px) clamp(12px, 2vw, 18px);
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  height: auto;
  min-width: 0;
}

.exercise-card:active {
  transform: scale(0.98);
}

.exercise-card:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

.card-sample {
  font-size: 2.4rem;
  line-height: 1;
  color: var(--teal);
  margin-bottom: 4px;
}

.sample-print {
  font-family: var(--font-print);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.sample-cursive {
  font-family: var(--font-cursive);
  font-weight: 700;
  font-size: 2.8rem;
}

.card-title {
  font-weight: 800;
  font-size: clamp(0.98rem, 2.4vw, 1.15rem);
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.card-desc {
  color: var(--muted);
  font-size: clamp(0.84rem, 2vw, 0.95rem);
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.home-footer {
  margin-top: auto;
  padding-top: 28px;
  display: flex;
  justify-content: center;
}

.home-mail-actions {
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.home-mail-actions .btn-primary {
  width: 100%;
}

.home-mail-actions .hint {
  margin: 0;
  color: #ececec;
}

/* BAR */
.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.bar h2 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 1.35rem;
  color: #f4f4f4;
}

.workbook-bar {
  align-items: flex-start;
}

.workbook-bar .btn-icon,
.workbook-bar .btn-ghost.small,
.workbook-bar .workbook-tools {
  margin-top: 10px;
}

.workbook-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-undo {
  display: grid;
  place-items: center;
  padding: 0;
}

.btn-undo:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.workbook-meta {
  flex: 1;
  min-width: 0;
}

.workbook-meta h2 {
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
}

#page-indicator {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* BUTTONS */
.btn-icon,
.btn-nav {
  appearance: none;
  border: none;
  background: var(--white);
  color: var(--teal-dark);
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 1.35rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-nav {
  width: 56px;
  height: 56px;
  font-size: 1.5rem;
  background: var(--teal);
  color: var(--white);
}

.btn-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary,
.btn-secondary,
.btn-ghost {
  appearance: none;
  border: none;
  border-radius: 14px;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1rem;
  padding: 14px 20px;
  cursor: pointer;
}

.btn-primary {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 8px 20px rgba(224, 122, 95, 0.35);
}

.btn-secondary {
  background: var(--white);
  color: var(--teal-dark);
  border: 2px solid rgba(42, 111, 111, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--teal-dark);
  border: 2px solid rgba(42, 111, 111, 0.25);
}

.btn-ghost.small {
  padding: 10px 14px;
  font-size: 0.9rem;
}

/* SETTINGS */
.settings-form {
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--white);
  padding: 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.settings-form label,
.settings-form fieldset {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
  border: none;
  padding: 0;
  margin: 0;
}

.settings-form input[type="text"],
.settings-form input[type="email"],
.settings-form input[type="tel"] {
  font: inherit;
  font-weight: 500;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid rgba(42, 111, 111, 0.2);
  background: var(--paper);
  color: var(--ink);
}

.settings-form .check {
  flex-direction: row;
  align-items: center;
  font-weight: 600;
  gap: 10px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.45;
}

/* WORKBOOK */
#screen-workbook {
  padding-bottom: calc(10px + var(--safe-bottom));
}

.workbook-stage {
  flex: 1;
  min-height: 0;
  background: var(--paper);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 2px solid rgba(42, 111, 111, 0.12);
  position: relative;
  touch-action: none;
}

#write-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.workbook-nav .btn-primary {
  flex: 1;
  max-width: 280px;
  width: auto;
}

.workbook-actions {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.workbook-actions .btn-primary {
  width: min(100%, 360px);
}

/* TOAST */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  z-index: 50;
  box-shadow: var(--shadow);
  max-width: calc(100% - 32px);
  text-align: center;
}

.toast[hidden] {
  display: none;
}

/* PHOTO SHEET */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet[hidden] {
  display: none;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 43, 43, 0.45);
}

.sheet-panel {
  position: relative;
  width: min(420px, calc(100% - 24px));
  margin-bottom: calc(16px + var(--safe-bottom));
  background: var(--white);
  border-radius: 20px;
  padding: 18px 16px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-title {
  margin: 0 0 6px;
  text-align: center;
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 1.15rem;
}

.sheet-action {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1rem;
  background: rgba(42, 111, 111, 0.1);
  color: var(--teal-dark);
  cursor: pointer;
}

.sheet-action.danger {
  background: rgba(224, 122, 95, 0.15);
  color: #b34a32;
}

.sheet-action.ghost {
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

/* Celular */
@media (max-width: 699px) {
  :root {
    --avatar: 88px;
    --card-min: 100%;
  }

  .user-profile {
    width: 100px;
  }

  .main-menu-grid,
  .exercise-grid {
    grid-template-columns: 1fr;
  }

  .home-top-row {
    flex-wrap: wrap;
  }

  .home-report-btns {
    width: 100%;
    max-width: none;
  }

  .home-top {
    display: flex;
    flex-direction: column;
  }

  .home-hero {
    width: 100%;
    text-align: center;
  }

  .workbook-bar {
    flex-wrap: wrap;
  }

  .workbook-bar .btn-ghost.small {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .book-card {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .book-card-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .book-continue {
    white-space: normal;
  }

  /* Tabuada/maratona: 1 coluna no celular (sem grid truncado) */
  .maratona-sheet.is-two-col {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    grid-template-rows: none;
    grid-auto-flow: row;
    gap: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .maratona-sheet.is-two-col .maratona-row {
    flex: 0 0 auto;
    min-height: 153px; /* +30% vs 118px */
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 6px 8px 8px;
  }

  .maratona-sheet.is-two-col .maratona-row-head {
    width: auto;
    flex: 0 0 auto;
    gap: 8px;
  }

  .maratona-sheet.is-two-col .maratona-num {
    display: inline;
  }

  .maratona-sheet.is-two-col .maratona-clear-one {
    align-self: flex-end;
    margin-top: 2px;
  }

  .maratona-sheet.is-two-col .maratona-pad {
    min-width: 0;
    min-height: 94px; /* +30% vs 72px */
    height: 94px;
  }

  #screen-maratona.is-tabuada-grid .maratona-hint {
    display: block;
  }
}

/* iPad / tablet */
@media (min-width: 700px) and (max-width: 1099px) {
  :root {
    --avatar: 104px;
    --card-min: min(100%, 260px);
  }

  .main-menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .exercise-grid:not(.main-menu-grid) {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  }

  .screen.active {
    width: min(920px, 100%);
    margin-left: auto;
    margin-right: auto;
  }

  .home-report-btns {
    width: min(210px, 34vw);
  }
}

/* Computador */
@media (min-width: 1100px) {
  :root {
    --avatar: 118px;
    --card-min: min(100%, 280px);
  }

  .screen.active {
    width: min(1040px, 100%);
    margin-left: auto;
    margin-right: auto;
  }

  .main-menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 860px;
  }

  .exercise-grid:not(.main-menu-grid) {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  }
}

/* Densidade dinâmica (viewport-fit.js) */
body.density-phone .main-menu-grid,
body.density-phone .exercise-grid {
  grid-template-columns: 1fr;
}

/* Reforço: densidade phone também força 1 coluna na tabuada */
body.density-phone .maratona-sheet.is-two-col {
  display: flex;
  flex-direction: column;
  grid-template-columns: none;
  grid-template-rows: none;
  grid-auto-flow: row;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.density-phone .maratona-sheet.is-two-col .maratona-row {
  flex: 0 0 auto;
  min-height: 153px; /* +30% vs 118px */
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px 8px 8px;
}

body.density-phone .maratona-sheet.is-two-col .maratona-row-head {
  width: auto;
  flex: 0 0 auto;
}

body.density-phone .maratona-sheet.is-two-col .maratona-num {
  display: inline;
}

body.density-phone .maratona-sheet.is-two-col .maratona-clear-one {
  align-self: flex-end;
}

body.density-phone .maratona-sheet.is-two-col .maratona-pad {
  min-width: 0;
  min-height: 94px; /* +30% vs 72px */
  height: 94px;
}

body.density-phone #screen-maratona.is-tabuada-grid .maratona-hint {
  display: block;
}

body.density-tablet .main-menu-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.density-short .subtitle {
  font-size: 0.92rem;
  line-height: 1.35;
}

body.density-short .home-hero {
  padding-bottom: 8px;
}

body.density-short .exercise-card {
  padding: 12px 12px 10px;
}

#screen-workbook.screen.active {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

#screen-workbook .workbook-stage,
#screen-math .math-answer-stage,
#write-canvas,
#math-canvas,
#quiz-canvas,
.quiz-scratch-stage,
.maratona-pad canvas {
  touch-action: none;
}

.workbook-actions {
  flex-shrink: 0;
}

@media (orientation: landscape) {
  :root {
    --avatar: 72px;
  }

  .screen.active {
    padding-top: calc(8px + var(--safe-top));
    padding-bottom: calc(8px + var(--safe-bottom));
  }

  .home-hero {
    padding-bottom: 6px;
  }

  .subtitle {
    display: block;
    font-size: clamp(0.85rem, 2.2vh, 1rem);
    max-width: 40rem;
  }

  .main-menu-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quiz-option {
    padding: 8px 12px;
    font-size: 0.92rem;
  }

  #screen-quiz .quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    overflow: visible;
    flex: 0 1 auto;
  }

  .math-question-card {
    padding: 8px 12px;
  }

  .math-expression {
    font-size: clamp(1.25rem, 3.6vw, 2rem);
  }

  .math-write-label {
    margin: 6px 0 4px;
  }

  .math-answer-stage {
    min-height: 114px; /* +30% vs 88px */
  }

  .btn-primary,
  .btn-secondary,
  .btn-ghost {
    padding: 10px 14px;
  }

  .bar {
    margin-bottom: 8px;
    flex-wrap: wrap;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --avatar: 84px;
  }

  .home-hero {
    padding-bottom: 8px;
  }

  .brand {
    font-size: clamp(1.6rem, 5vw, 2rem);
  }

  .home-hero h1 {
    font-size: clamp(1rem, 3vw, 1.15rem);
  }

  .subtitle {
    display: block;
    font-size: 0.85rem;
  }

  .main-menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .user-photo-btn {
    width: var(--avatar);
    height: var(--avatar);
  }

  .user-profile {
    width: 104px;
  }
}

/* Evita corte horizontal geral */
img,
svg,
video,
canvas {
  max-width: 100%;
}

.book-card-title,
.book-card-meta,
.bar-sub,
.hint {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(255, 254, 249, 0.94);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card .brand {
  color: var(--teal);
  font-size: 2.4rem;
  text-align: center;
}

.login-card h1 {
  margin: 0;
  text-align: center;
  font-family: var(--font-brand);
  color: var(--ink);
}

.login-lead {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.login-error {
  margin: 0;
  background: #fdece6;
  color: #b34a32;
  font-weight: 800;
  border-radius: 12px;
  padding: 10px 12px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 800;
  color: var(--teal-dark);
}

.login-card input {
  font: inherit;
  font-weight: 700;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid rgba(42, 111, 111, 0.22);
  background: var(--paper);
  color: var(--ink);
}

.captcha-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.captcha-row img {
  width: 100%;
  height: 64px;
  object-fit: contain;
  background: #111;
  border-radius: 12px;
}

.book-library {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.book-upload {
  display: block;
  cursor: pointer;
}

.book-upload .btn-primary {
  display: inline-flex;
}

.book-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.book-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 254, 249, 0.92);
  border-radius: 16px;
  padding: 8px 10px 8px 4px;
  box-shadow: var(--shadow);
}

.book-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.book-continue {
  white-space: nowrap;
}

.book-open {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  cursor: pointer;
}

.book-card-title {
  display: block;
  font-weight: 800;
  color: var(--teal-dark);
}

.book-card-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.88rem;
}

.reader-screen.active {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 100dvh;
  min-height: var(--app-vh, 100dvh);
  height: var(--app-vh, 100dvh);
  max-height: var(--app-vh, 100dvh);
  overflow: hidden;
  padding:
    calc(6px + var(--safe-top))
    calc(4px + var(--safe-right))
    calc(6px + var(--safe-bottom))
    calc(4px + var(--safe-left));
}

#screen-reader.screen.active {
  width: 100%;
  max-width: none;
  margin: 0;
}

.reader-bar {
  flex-shrink: 0;
  margin-bottom: 6px;
}

.reader-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-primary.small,
.btn-ghost.small {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.book-goto {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--teal-dark);
  background: rgba(255, 254, 249, 0.92);
  border-radius: 12px;
  padding: 6px 8px;
}

.book-goto input {
  width: 4.2rem;
  font: inherit;
  font-weight: 800;
  text-align: center;
  border: 2px solid rgba(42, 111, 111, 0.22);
  border-radius: 10px;
  padding: 6px 4px;
  background: var(--paper);
  color: var(--ink);
}

.book-arrow {
  position: absolute;
  top: 50%;
  z-index: 5;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 254, 249, 0.92);
  color: var(--teal-dark);
  font-size: 2.2rem;
  line-height: 1;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.book-arrow:disabled {
  opacity: 0.35;
  cursor: default;
}

.book-arrow-prev {
  left: 10px;
}

.book-arrow-next {
  right: 10px;
}

.book-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  perspective: 1400px;
  touch-action: none;
  overscroll-behavior: none;
  background: rgba(12, 16, 18, 0.28);
  border-radius: 10px;
}

.book-spread {
  position: absolute;
  inset: 0;
  transform-origin: center top;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.book-leaf {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  backface-visibility: hidden;
  transform-origin: left center;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
  background: #fffef9;
}

.book-leaf img {
  max-width: 100%;
  max-height: none;
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: top center;
  transform-origin: top center;
  will-change: transform;
  background: #fff;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.book-leaf.is-under {
  z-index: 1;
}

.book-leaf.is-front {
  z-index: 2;
  transform-origin: left center;
}

.book-leaf.turn-next {
  transform-origin: left center;
  animation: book-turn-next 0.42s ease-in forwards;
}

.book-leaf.turn-prev {
  transform-origin: right center;
  animation: book-turn-prev 0.42s ease-in forwards;
}

@keyframes book-turn-next {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(105deg); }
}

@keyframes book-turn-prev {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(-105deg); }
}

.book-quiz-card {
  width: min(720px, 96vw);
  max-height: 88dvh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  text-align: left;
}

#book-quiz-explain {
  background: #fdece6;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
}

#screen-maratona.screen.active {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

#screen-maratona .bar,
#screen-maratona .maratona-hint,
#screen-maratona .workbook-actions {
  flex-shrink: 0;
}

#screen-maratona.is-tabuada-grid .bar {
  margin-bottom: 4px;
}

#screen-maratona.is-tabuada-grid .maratona-hint {
  display: none;
}

#screen-maratona.is-tabuada-grid .workbook-actions {
  padding-top: 6px;
}

.maratona-hint {
  margin: 2px 0 6px;
  flex-shrink: 0;
}

.maratona-sheet {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.maratona-sheet.is-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(5, minmax(114px, 1fr)); /* +30% vs 88px */
  grid-auto-flow: column;
  gap: 8px 14px;
  overflow: hidden;
}

.maratona-sheet.is-two-col .maratona-row {
  min-height: 114px; /* +30% vs 88px */
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
  padding: 8px 10px;
}

.maratona-sheet.is-two-col .maratona-row-head {
  flex: 0 0 auto;
  width: min(38%, 8.8rem);
  gap: 4px;
}

.maratona-sheet.is-two-col .maratona-num {
  display: none;
}

.maratona-sheet.is-two-col .maratona-clear-one {
  display: inline-flex;
  flex: 0 0 auto;
  align-self: center;
  margin: 0;
  padding: 8px 12px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.maratona-sheet.is-two-col .maratona-expr {
  font-size: clamp(1.15rem, 3vw, 1.55rem);
}

.maratona-sheet.is-two-col .maratona-eq {
  font-size: 1.45rem;
}

.maratona-sheet.is-two-col .maratona-pad {
  flex: 1 1 auto;
  min-width: 120px;
  min-height: 88px; /* +30% vs 68px */
  height: auto;
}

.maratona-row {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--white);
  border-radius: 14px;
  padding: 6px 8px 8px;
  box-shadow: var(--shadow);
  border: 2px solid rgba(42, 111, 111, 0.12);
}

.maratona-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.maratona-num {
  font-weight: 800;
  color: var(--teal);
  font-size: 1.05rem;
}

.maratona-expr {
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: clamp(1rem, 3.2vw, 1.45rem);
  color: var(--teal-dark);
  line-height: 1.2;
  flex: 1;
  min-width: 0;
}

.maratona-eq {
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--ink);
}

.maratona-pad {
  flex: 1 1 auto;
  min-height: 88px; /* +30% área vertical de resposta */
  height: auto;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(42, 111, 111, 0.2);
  touch-action: none;
}

.maratona-pad canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.report-view-panel {
  width: min(920px, 96vw);
  max-width: 96vw;
  max-height: calc(100dvh - 24px);
  text-align: center;
  padding: 18px 14px 16px;
}

.report-view-body {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100dvh - 170px);
  text-align: center;
  touch-action: pan-y;
}

.report-view-body table {
  margin-left: auto;
  margin-right: auto;
}

.maratona-review-list {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.maratona-review-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.maratona-review-expr {
  font-weight: 700;
  flex: 1;
}

.maratona-circle {
  display: inline-flex;
  min-width: 56px;
  min-height: 56px;
  padding: 0 10px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 3px solid #2b7fff;
  font-weight: 800;
  font-size: 1.05rem;
}

.maratona-circle.is-ok {
  border-color: #2b7fff;
  color: #1c4ea8;
  background: #e8f3ff;
}

.maratona-circle.is-bad {
  border-color: #e23d3d;
  color: #a11818;
  background: #fde8e8;
}

.maratona-fixes {
  background: #f6faf8;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.maratona-fixes-title {
  margin: 0 0 8px;
  font-weight: 800;
}

.maratona-fixes p {
  margin: 4px 0;
}

@media (max-width: 720px) {
  .maratona-expr {
    font-size: clamp(0.95rem, 3.8vw, 1.2rem);
  }
}

