/* Camada visual do aplicativo. Mantem a logica e os componentes existentes. */

:root {
  --app-blue: #1ca7f2;
  --app-blue-dark: #0c86ce;
  --app-green: #62cf16;
  --app-yellow: #ffc94a;
  --app-coral: #ff6671;
  --app-violet: #9b72ec;
  --app-navy: #16163b;
  --app-muted: #78839a;
  --app-canvas: #f6fbff;
  --app-line: #dce8f1;
  --app-shadow: 0 12px 28px rgba(53, 91, 122, 0.14);
  --app-shadow-soft: 0 5px 14px rgba(53, 91, 122, 0.11);
  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", Inter, system-ui, sans-serif;
}

body[data-design="light"] {
  --ink: var(--app-navy);
  --muted: var(--app-muted);
  --paper: var(--app-canvas);
  --panel: #ffffff;
  --soft: #eaf6ff;
  --line: var(--app-line);
  --blue: var(--app-blue);
  --green: var(--app-green);
  --yellow: var(--app-yellow);
  --red: #ef4857;
  --white: #ffffff;
  --shadow: var(--app-shadow);
  --shadow-soft: var(--app-shadow-soft);
}

body {
  background: var(--paper);
}

.app-shell {
  min-height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr);
}

main {
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
}

/* Cabecalho de app */
.topbar,
body[data-design="light"] .topbar {
  top: 0;
  grid-template-columns: minmax(240px, 1fr) auto minmax(240px, 1fr);
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid #e9f0f5;
}

.header-brand-group {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-self: start;
  gap: 12px;
}

.app-home-button {
  color: var(--app-blue);
  font-size: 2rem;
  font-weight: 950;
  line-height: 1;
}

.app-home-button:focus-visible,
.app-home-button.is-active {
  border-color: #9ed8fa;
  background: #edf8ff;
  color: var(--app-blue-dark);
  transform: translateY(-1px);
}
@media (hover: hover) and (pointer: fine) {
.app-home-button:hover {
  color: var(--app-blue-dark);
}
}

body[data-design] .app-home-button.is-active {
  border-color: #9ed8fa;
  background: #edf8ff;
  color: var(--app-blue-dark);
  box-shadow: 0 5px 0 #c7e7f8, 0 9px 18px rgba(53, 91, 122, 0.14);
}

.app-control-image {
  width: 34px;
  height: 34px;
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.home-control-image {
  width: 38px;
  height: 38px;
}

.brand {
  min-width: 0;
  justify-self: auto;
  gap: 9px;
}

.brand-mark,
body[data-design="light"] .brand-mark {
  width: 44px;
  height: 44px;
  border: 4px solid #dff4ff;
  border-radius: 50%;
  background: var(--app-blue);
  color: #ffffff;
  box-shadow: 0 3px 0 var(--app-blue-dark);
  font-size: 0.82rem;
  letter-spacing: 0;
}

.brand h1 {
  color: var(--app-navy);
  font-size: 1.05rem;
  font-weight: 950;
}

.brand p {
  margin-top: 2px;
  color: var(--app-muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.tabs {
  grid-column: 2;
  justify-self: center;
}

.utility-actions {
  grid-column: 3;
  justify-self: end;
  gap: 9px;
}

.utility-actions .icon-button,
.design-switcher {
  width: 50px;
  height: 50px;
  min-height: 50px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
  border: 1px solid #dce8f1;
  border-radius: 14px;
  background: #ffffff;
  color: var(--app-blue);
  box-shadow: 0 5px 0 #dbe7ef, 0 9px 18px rgba(53, 91, 122, 0.1);
  font-size: 1.42rem;
  font-weight: 950;
}

.design-switcher {
  grid-template-columns: 1fr;
}

@media (hover: hover) and (pointer: fine) {
.utility-actions .icon-button:hover,.design-switcher:hover {
  border-color: #9ed8fa;
  background: #edf8ff;
  color: var(--app-blue-dark);
  transform: translateY(-1px);
}
}

.utility-actions .icon-button:active,
.design-switcher:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #dbe7ef;
}

.utility-actions .screen-control-button {
  width: 54px;
  height: 54px;
  min-height: 54px;
  overflow: visible;
  border-width: 2px;
}

#fullscreenButton {
  border-color: #b9e3fa;
  background: #f1faff;
  color: #0787ca;
  box-shadow: 0 5px 0 #cbe9f8, 0 9px 18px rgba(26, 156, 221, 0.15);
}

#fullscreenButton.is-active {
  border-color: #77ccf7;
  background: #e5f7ff;
  color: var(--app-blue-dark);
  box-shadow: 0 5px 0 #b9e5f9, 0 10px 20px rgba(17, 155, 224, 0.2);
}

#lockButton {
  border-color: #c9e6d7;
  background: #f2fbf6;
  color: #16955a;
  box-shadow: 0 5px 0 #d2eadc, 0 9px 18px rgba(31, 157, 91, 0.14);
}

#lockButton.is-locked {
  border-color: #f5b5aa;
  background: #fff2ef;
  color: #e45845;
  box-shadow: 0 5px 0 #f1c6be, 0 9px 18px rgba(224, 88, 69, 0.16);
}

#lockButton[data-count]::after {
  right: -3px;
  top: -7px;
  z-index: 3;
  width: 22px;
  height: 22px;
  border: 2px solid #ffffff;
  background: #e45845;
  box-shadow: 0 2px 5px rgba(126, 38, 27, 0.24);
  font-size: 0.76rem;
  font-weight: 950;
}

#fullscreenButton:disabled {
  border-color: #d8e0e6;
  background: #eef2f5;
  color: #92a0ab;
  box-shadow: 0 3px 0 #d7dfe5;
  opacity: 1;
}

.design-switcher .design-switcher-icon {
  position: static;
  width: 34px;
  height: 34px;
  overflow: visible;
  clip: auto;
}

.design-switcher-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.design-switcher select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  cursor: pointer;
  opacity: 0;
}

/* Navegacao principal no cabecalho */
.tabs,
body[data-design="light"] .tabs {
  position: static;
  z-index: auto;
  right: auto;
  bottom: auto;
  left: auto;
  width: auto;
  max-width: none;
  min-width: 0;
  display: flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid #dce8f1;
  border-radius: 14px;
  background: #f4f9fc;
  box-shadow: inset 0 1px 0 #ffffff;
  transform: none;
}

.tabs .tab {
  min-width: 76px;
  min-height: 46px;
  display: flex;
  flex: initial;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #7a879b;
  box-shadow: none;
  font-size: 0.74rem;
  font-weight: 900;
}

.tabs .tab-icon {
  color: currentColor;
  font-size: 1.05rem;
  line-height: 1;
}

.tabs .tab:focus-visible {
  background: #edf8ff;
  color: var(--app-blue-dark);
}
@media (hover: hover) and (pointer: fine) {
.tabs .tab:hover {
  background: #edf8ff;
  color: var(--app-blue-dark);
}
}

.tabs .tab.is-active {
  background: var(--app-blue);
  color: #ffffff;
  box-shadow: inset 0 -4px 0 var(--app-blue-dark);
}

/* Pagina inicial */
#view-inicio.is-active {
  min-height: 0;
}

#view-inicio .home-layout {
  width: 100%;
  max-width: 1240px;
  min-height: calc(100dvh - 168px);
  align-content: center;
  gap: clamp(20px, 3vh, 30px);
  padding: clamp(24px, 4vh, 42px) clamp(18px, 3vw, 38px) 28px;
}

.home-heading-row {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
}

.home-heading h2 {
  color: var(--app-navy);
  font-size: clamp(1.85rem, 3.4vw, 2.9rem);
  font-weight: 950;
  line-height: 1.08;
}

.home-heading p {
  margin-top: 9px;
  color: var(--app-muted);
  font-size: clamp(0.92rem, 1.5vw, 1.08rem);
  font-weight: 850;
}

.home-back-button,
.training-back-button {
  display: grid;
  place-items: center;
  padding: 0;
  border-color: #cce5f4;
  background: #ffffff;
  color: var(--app-blue);
  box-shadow: 0 5px 0 #dbe7ef, var(--app-shadow-soft);
}

.back-control-image {
  width: 34px;
  height: 34px;
}

@media (hover: hover) and (pointer: fine) {
.home-back-button:hover,.training-back-button:hover {
  border-color: #8fd2f8;
  background: #edf8ff;
  color: var(--app-blue-dark);
}
}

.category-grid {
  width: 100%;
  max-width: 1180px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(10px, 1.4vw, 17px);
  margin: 0 auto;
}

.module-grid .category-card {
  --category-accent: var(--app-blue);
  min-width: 0;
  min-height: clamp(224px, 26vw, 304px);
  grid-template-rows: minmax(0, 1fr) auto auto;
  align-content: stretch;
  gap: 8px;
  padding: 11px 11px 15px;
  border: 1px solid #dce8f1;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 6px 0 #dbe7ef, var(--app-shadow);
}

.module-grid .category-card:nth-child(2) { --category-accent: var(--app-green); }
.module-grid .category-card:nth-child(3) { --category-accent: var(--app-yellow); }
.module-grid .category-card:nth-child(4) { --category-accent: var(--app-violet); }
.module-grid .category-card:nth-child(5) { --category-accent: var(--app-coral); }

.module-grid .category-card:focus-visible {
  border-color: color-mix(in srgb, var(--category-accent) 55%, #dce8f1);
  box-shadow: 0 8px 0 color-mix(in srgb, var(--category-accent) 22%, #dbe7ef), 0 18px 34px rgba(53, 91, 122, 0.17);
  transform: translateY(-2px);
}
@media (hover: hover) and (pointer: fine) {
.module-grid .category-card:hover {
  border-color: color-mix(in srgb, var(--category-accent) 55%, #dce8f1);
  box-shadow: 0 8px 0 color-mix(in srgb, var(--category-accent) 22%, #dbe7ef), 0 18px 34px rgba(53, 91, 122, 0.17);
  transform: translateY(-2px);
}
}

.module-grid .category-card:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #dbe7ef, var(--app-shadow-soft);
}

.module-grid .category-cover-art {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: color-mix(in srgb, var(--category-accent) 9%, #ffffff);
  box-shadow: none;
}

.module-grid .category-cover-art img {
  border-radius: 12px;
  clip-path: inset(2.8% round 13%);
}

.module-grid .category-card strong {
  width: 100%;
  padding: 2px 3px 0;
  color: var(--app-navy);
  font-size: clamp(0.92rem, 1.35vw, 1.12rem);
  font-weight: 950;
  line-height: 1.12;
}

.module-grid .category-card small {
  width: 100%;
  min-height: 2.4em;
  display: block;
  padding: 0 5px;
  color: var(--app-muted);
  font-size: clamp(0.7rem, 1vw, 0.82rem);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

/* Cartoes de modulos e comandos gerais */
#homeModuleGrid {
  max-width: 1080px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 0 auto;
}

#homeModuleGrid:has(> .module-card[data-module="shadow"]:not([hidden])):not(:has(> .module-card:not([data-module="shadow"]):not([hidden]))) {
  width: min(100%, 340px);
  max-width: 340px;
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
}

#homeModuleGrid .module-card {
  border-radius: 14px;
  box-shadow: 0 5px 0 #dbe7ef, var(--app-shadow-soft);
}

@media (hover: hover) and (pointer: fine) {
#homeModuleGrid .module-card:hover {
  border-color: #9ed8fa;
  box-shadow: 0 7px 0 #c8e7f8, var(--app-shadow);
  transform: translateY(-2px);
}
}

.primary-button,
.sound-toggle.is-on {
  border-color: var(--app-blue-dark);
  border-radius: 12px;
  background: var(--app-blue);
  color: #ffffff;
  box-shadow: inset 0 -5px 0 var(--app-blue-dark), var(--app-shadow-soft);
}

@media (hover: hover) and (pointer: fine) {
.primary-button:hover,.sound-toggle.is-on:hover {
  border-color: #087abb;
  background: #28b2fa;
  transform: translateY(-1px);
}
}

.primary-button:active,
.sound-toggle.is-on:active {
  transform: translateY(3px);
  box-shadow: inset 0 -2px 0 var(--app-blue-dark);
}

.secondary-button,
.ghost-button,
.mini-button {
  border-radius: 10px;
}

select,
input,
textarea {
  border-radius: 10px;
}

.session-panel {
  border-color: var(--app-line);
  background: #ffffff;
}

#stageBadge {
  border-radius: 10px;
  background: var(--app-blue);
  color: #ffffff;
  box-shadow: inset 0 -3px 0 var(--app-blue-dark);
}

.progress-track {
  border-radius: 999px;
  background: #e8eef2;
}

.progress-fill,
body[data-design="dark"] .progress-fill {
  border-radius: 999px;
  background: var(--app-green);
}

/* Tema escuro */
body[data-design="dark"] {
  --app-navy: #f5f8fc;
  --app-muted: #b3c0cf;
  --app-canvas: #101820;
  --app-line: #334656;
  --ink: #f5f8fc;
  --muted: #b3c0cf;
  --paper: #101820;
  --panel: #17232d;
  --soft: #223443;
  --line: #334656;
  --blue: #45bdf9;
  --green: #7add3c;
  --yellow: #ffd45f;
  --white: #17232d;
}

body[data-design="dark"] .topbar {
  border-color: #253847;
  background: rgba(18, 28, 37, 0.98);
}

body[data-design="dark"] .brand h1,
body[data-design="dark"] .home-heading h2 {
  color: #f5f8fc;
}

body[data-design="dark"] .app-home-button,
body[data-design="dark"] .utility-actions .icon-button,
body[data-design="dark"] .design-switcher {
  border-color: #354b5c;
  background: #1b2a35;
  color: #45bdf9;
  box-shadow: 0 5px 0 #0b1116, 0 9px 18px rgba(0, 0, 0, 0.22);
}

body[data-design="dark"] #fullscreenButton {
  border-color: #28627e;
  background: #173446;
  color: #65caff;
}

body[data-design="dark"] #fullscreenButton.is-active {
  border-color: #65caff;
  background: #eaf8ff;
  color: #087fbe;
  box-shadow: 0 5px 0 #087fbe, 0 10px 20px rgba(0, 0, 0, 0.28);
}

body[data-design="dark"] #lockButton {
  border-color: #356b50;
  background: #18392a;
  color: #6ed99d;
}

body[data-design="dark"] #lockButton.is-locked {
  border-color: #8e4a40;
  background: #482721;
  color: #ff9585;
  box-shadow: 0 5px 0 #261512, 0 10px 20px rgba(0, 0, 0, 0.28);
}

body[data-design="dark"] .tabs {
  border-color: #354b5c;
  background: #17232d;
  box-shadow: inset 0 1px 0 #283d4d;
}

body[data-design="dark"] .tabs .tab:focus-visible {
  background: #223b4c;
  color: #75cffb;
}
@media (hover: hover) and (pointer: fine) {
body[data-design="dark"] .tabs .tab:hover {
  background: #223b4c;
  color: #75cffb;
}
}

body[data-design="dark"] .module-grid .category-card,
body[data-design="dark"] #homeModuleGrid .module-card {
  border-color: #354b5c;
  background: #17232d;
  box-shadow: 0 6px 0 #0b1116, 0 14px 28px rgba(0, 0, 0, 0.24);
}

body[data-design="dark"] .module-grid .category-card strong {
  color: #f5f8fc;
}

body[data-design="dark"] .module-grid .category-card small {
  color: #b3c0cf;
}

body[data-design="dark"] .session-panel {
  background: #17232d;
}

/* Tela cheia mantem apenas os controles necessarios. */
body.training-fullscreen main {
  padding-bottom: 0;
}

body.training-fullscreen .app-home-button,
body.training-fullscreen .brand,
body.training-fullscreen .header-brand-group,
body.training-fullscreen .tabs {
  display: none;
}

body.training-fullscreen .topbar {
  min-height: 54px;
  display: flex;
  justify-content: flex-end;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

body.training-fullscreen .top-controls,
body.training-fullscreen .utility-actions {
  pointer-events: auto;
}

body.training-fullscreen #view-treino.is-active > .training-back-button {
  width: 54px;
  height: 54px;
  min-height: 54px;
  position: fixed !important;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: calc(env(safe-area-inset-left, 0px) + 8px);
  z-index: 100;
  visibility: visible !important;
  place-items: center;
  border: 2px solid #b9e3fa;
  border-radius: 14px;
  background: #ffffff;
  color: #0787ca;
  box-shadow: 0 5px 0 #cbe9f8, 0 9px 18px rgba(26, 156, 221, 0.16);
  opacity: 1;
  pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
body.training-fullscreen #view-treino.is-active > .training-back-button:hover {
  border-color: #78cafa;
  background: #edf8ff;
}
}

body.training-fullscreen.app-locked #view-treino.is-active > .training-back-button {
  border-color: #d8e0e6;
  background: #eef2f5;
  color: #8796a2;
  box-shadow: 0 3px 0 #d7dfe5;
  opacity: 0.78;
}

body[data-design="dark"].training-fullscreen #view-treino.is-active > .training-back-button {
  border-color: #28627e;
  background: #173446;
  color: #65caff;
  box-shadow: 0 5px 0 #0b1116, 0 9px 18px rgba(0, 0, 0, 0.24);
}

body[data-design="dark"].training-fullscreen.app-locked #view-treino.is-active > .training-back-button {
  border-color: #3d4b55;
  background: #27333c;
  color: #8797a2;
}

body.modal-open .tabs {
  opacity: 0;
  pointer-events: none;
}

/* Tablet: uma linha de categorias sem rolagem vertical. */
@media (min-width: 701px) and (max-width: 1100px) {
  .topbar {
    grid-template-columns: minmax(200px, 1fr) auto minmax(200px, 1fr);
  }

  

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand p {
    display: none;
  }

  .utility-actions .icon-button,
  .design-switcher {
    width: 46px;
    height: 46px;
    min-height: 46px;
  }

  .header-brand-group {
    gap: 9px;
  }

  .tabs {
    gap: 2px;
    padding: 4px;
  }

  .tabs .tab {
    min-width: 57px;
    min-height: 42px;
    gap: 4px;
    padding: 6px;
    font-size: 0.66rem;
  }

  .tabs .tab-icon {
    font-size: 0.94rem;
  }

  #view-inicio .home-layout {
    min-height: calc(100dvh - 154px);
    gap: 18px;
    padding: 20px 15px 22px;
  }

  .home-heading h2 {
    font-size: clamp(1.65rem, 3.7vw, 2.25rem);
  }

  .category-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 9px;
  }

  .module-grid .category-card {
    min-height: 0;
    gap: 6px;
    padding: 7px 7px 11px;
    border-radius: 13px;
  }

  .module-grid .category-card strong {
    font-size: clamp(0.75rem, 1.7vw, 0.94rem);
  }

  .module-grid .category-card small {
    min-height: 2.3em;
    padding-inline: 1px;
    font-size: clamp(0.62rem, 1.25vw, 0.74rem);
  }
}

@media (max-width: 700px) {
  main {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    flex-direction: initial;
    gap: 8px;
  }

  .app-home-button {
    font-size: 1.7rem;
  }

  .brand {
    justify-self: start;
  }

  .header-brand-group {
    grid-column: 1;
    grid-row: 1;
    gap: 8px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-width: 3px;
    font-size: 0.7rem;
  }

  .brand h1 {
    font-size: 0.92rem;
  }

  .brand p {
    display: none;
  }

  .utility-actions {
    grid-column: 2;
    grid-row: 1;
    gap: 5px;
  }

  .utility-actions .icon-button,
  .design-switcher {
    width: 42px;
    height: 42px;
    min-height: 42px;
    border-radius: 11px;
    font-size: 1.16rem;
  }

  .tabs {
    width: 100%;
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    padding: 4px;
    border-radius: 12px;
  }

  .tabs .tab {
    min-width: 0;
    min-height: 42px;
    flex: initial;
    flex-direction: row;
    padding: 4px 2px;
    border-radius: 8px;
    font-size: 0.64rem;
  }

  .tabs .tab-icon {
    font-size: 1.15rem;
  }

  #view-inicio .home-layout {
    min-height: 0;
    align-content: start;
    padding: 22px 14px 28px;
  }

  .home-heading-row {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
  }

  .home-heading h2 {
    font-size: clamp(1.55rem, 7vw, 2rem);
  }

  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .module-grid .category-card {
    min-height: 0;
    gap: 6px;
    padding: 8px 8px 12px;
  }

  .module-grid .category-card strong {
    font-size: 0.9rem;
  }

  .module-grid .category-card small {
    min-height: 2.4em;
    font-size: 0.7rem;
  }

  #homeModuleGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .utility-actions .icon-button:nth-of-type(1) {
    display: none;
  }

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

/* Conclusao de etapas */
.trainer:has(.block-choice-result) {
  align-content: center;
}

.trainer:has(.block-choice-result) .stage-strip {
  margin-bottom: clamp(28px, 7vh, 64px);
}

.block-choice-host {
  width: 100%;
  max-width: none;
}

/* A tela de Refazer/Prosseguir ocupa a largura toda (em pé, a grade de 2 colunas a deixava no canto). */
body[data-design] .choices.block-choice-host,
.choices.block-choice-host {
  grid-template-columns: minmax(0, 1fr);
}

.block-choice-result {
  width: min(100%, 760px);
  gap: 16px;
  padding: clamp(18px, 3vw, 36px);
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--app-navy);
  box-shadow: none;
}

.block-choice-mark {
  width: 90px;
  height: 90px;
  margin-bottom: 4px;
  border: 6px solid #e7f9ee;
  background: var(--app-green);
  font-size: 2.75rem;
  box-shadow: 0 5px 0 #179354;
}

.block-choice-result h2 {
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  line-height: 1.12;
}

.block-choice-result p {
  color: var(--app-muted);
  font-size: clamp(1rem, 1.7vw, 1.18rem);
  line-height: 1.4;
}

.block-choice-actions {
  width: min(100%, 620px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.block-choice-button {
  min-width: 0;
  min-height: 80px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  border-radius: 16px;
  font-size: 1.2rem;
}

.block-choice-button span {
  font-size: 1.85rem;
  font-weight: 900;
  line-height: 1;
}

.block-choice-repeat {
  border: 2px solid #b8dcf1;
  background: #ffffff;
  color: #087fbe;
  box-shadow: 0 4px 0 #d6e9f4;
}

@media (hover: hover) and (pointer: fine) {
.block-choice-repeat:hover {
  border-color: var(--app-blue);
  background: #f4fbff;
}
}

.block-choice-advance {
  box-shadow: inset 0 -5px 0 var(--app-blue-dark), 0 8px 18px rgba(17, 155, 224, 0.2);
}

body.training-fullscreen .trainer:has(.block-choice-result) {
  width: 100vw;
  min-height: 100dvh;
  height: 100dvh;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  align-content: center;
  justify-content: center;
  gap: 0;
  padding:
    calc(env(safe-area-inset-top, 0px) + clamp(72px, 10vh, 104px))
    calc(env(safe-area-inset-right, 0px) + clamp(20px, 5vw, 72px))
    calc(env(safe-area-inset-bottom, 0px) + clamp(28px, 5vh, 56px))
    calc(env(safe-area-inset-left, 0px) + clamp(20px, 5vw, 72px));
}

body.training-fullscreen .trainer:has(.block-choice-result) .block-choice-host {
  width: min(100%, 900px);
  grid-column: 1;
  grid-row: 1;
  place-self: center;
  margin: 0;
}

body.training-fullscreen .block-choice-result {
  width: min(100%, 860px);
  gap: clamp(16px, 2.4vh, 26px);
  padding: clamp(20px, 3vw, 42px);
}

body.training-fullscreen .block-choice-mark {
  width: clamp(88px, 9vw, 112px);
  height: clamp(88px, 9vw, 112px);
  border-width: 8px;
  font-size: clamp(2.7rem, 4vw, 3.6rem);
  box-shadow: 0 7px 0 #179354;
}

body.training-fullscreen .block-choice-result h2 {
  font-size: clamp(2rem, 4vw, 3.05rem);
}

body.training-fullscreen .block-choice-result p {
  font-size: clamp(1.08rem, 2vw, 1.38rem);
}

body.training-fullscreen .block-choice-actions {
  width: min(100%, 700px);
  gap: clamp(12px, 2vw, 22px);
  margin-top: clamp(18px, 3vh, 30px);
}

body.training-fullscreen .block-choice-button {
  min-height: clamp(72px, 9vh, 92px);
  padding: 18px clamp(16px, 3vw, 34px);
  border-radius: 18px;
  font-size: clamp(1.08rem, 2vw, 1.35rem);
}

body.training-fullscreen .block-choice-button span {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
}

body[data-design="dark"] .block-choice-result {
  border: 0;
  background: transparent;
  color: #f7fbff;
}

body[data-design="dark"] .block-choice-result p {
  color: #b9c7d4;
}

body[data-design="dark"] .block-choice-repeat {
  border-color: #35647d;
  background: #172733;
  color: #8ed8ff;
  box-shadow: 0 4px 0 #0c1820;
}

@media (max-width: 520px) {
  .trainer:has(.block-choice-result) .stage-strip {
    margin-bottom: 22px;
  }

  .block-choice-actions {
    gap: 10px;
    margin-top: 14px;
  }

  .block-choice-button {
    min-height: 66px;
    padding-inline: 12px;
    font-size: 1rem;
  }
}

/* Etapa / Nível (Comparação, Coordenação, Oposição, Distinção, Causalidade):
   botão no formato do botão de Som, em laranja; abre um painel flutuante ao lado. */
body[data-app-view] .session-panel .panel-section select.phase-picker-native {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.phase-picker-button {
  position: relative;
  width: 100%;
  min-height: 46px;
  padding: 8px 40px 8px 14px;
  border: 2px solid #d9700c;
  border-radius: 12px;
  background: #ff9a2e url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6l6 6-6 6' fill='none' stroke='%23fff' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center / 18px 18px;
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  font-size: 0.86rem;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: inset 0 -5px 0 #d9700c, 0 6px 14px rgba(217, 112, 12, 0.18);
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, box-shadow 0.12s ease;
}

.phase-picker-button:active {
  transform: translateY(3px);
  box-shadow: inset 0 -2px 0 #d9700c;
}

.phase-picker-button:focus-visible {
  outline: 3px solid #ffd29e;
  outline-offset: 2px;
}

.phase-picker-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (hover: hover) and (pointer: fine) {
  .phase-picker-button:not(:disabled):hover {
    background-color: #ffab4d;
    transform: translateY(-1px);
  }
}

/* Variante verde (velocidade da Imitação). */
.phase-picker-button.is-green {
  border-color: #17803f;
  background-color: #22a55b;
  box-shadow: inset 0 -5px 0 #17803f, 0 6px 14px rgba(23, 128, 63, 0.18);
}

.phase-picker-button.is-green:active {
  box-shadow: inset 0 -2px 0 #17803f;
}

.phase-picker-button.is-green:focus-visible {
  outline-color: #a6e3bf;
}

@media (hover: hover) and (pointer: fine) {
  .phase-picker-button.is-green:not(:disabled):hover {
    background-color: #2bb866;
  }
}

.phase-picker-panel.is-green .phase-picker-item.is-selected {
  border-color: #22a55b;
  background: #e8f7ee;
  box-shadow: 0 2px 8px rgba(23, 128, 63, 0.12);
}

.phase-picker-panel.is-green .phase-picker-item:focus-visible {
  outline-color: #22a55b;
}

/* Painel flutuante: fundo escurecido como em "Selecionar estímulos", mas o painel
   é pequeno e abre ao lado do botão. */
.phase-picker-modal {
  display: block;
  padding: 0;
}

.phase-picker-modal[hidden] {
  display: none;
}

.phase-picker-modal .phase-picker-panel {
  position: fixed;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100dvh - 24px);
  padding: 16px;
  border: 0;
  border-radius: 20px;
  background: #f8fafc;
  color: #172b45;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  animation: phase-picker-in 0.18s ease-out;
}

@keyframes phase-picker-in {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: none; }
}

.phase-picker-modal .floating-panel-header {
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.phase-picker-modal #phasePickerTitle {
  font-size: 1.2rem;
  color: #172b45;
}

.phase-picker-modal .floating-panel-header p {
  font-size: 0.8rem;
  color: #64748b;
}

.phase-picker-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #e8eef5;
  color: #334155;
}

.phase-picker-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px;
}

/* Título de grupo na janela (ex.: Motor grosso, Vogais). */
.phase-picker-group {
  margin: 6px 2px 0;
  color: #b4600a;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.phase-picker-group:first-child {
  margin-top: 0;
}

.phase-picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  background: #ffffff;
  color: #172b45;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.phase-picker-item:active {
  transform: translateY(2px);
}

.phase-picker-item:focus-visible {
  outline: 3px solid #ff9a2e;
  outline-offset: 2px;
}

.phase-picker-item.is-selected {
  border-color: #ff9a2e;
  background: #fff4e6;
  box-shadow: 0 2px 8px rgba(217, 112, 12, 0.12);
}

.phase-picker-code {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 34px;
  padding: 0 6px;
  border-radius: 10px;
  background: #ffe7cc;
  color: #b85c05;
  font-weight: 900;
  font-size: 0.85rem;
}

.phase-picker-item.is-selected .phase-picker-code {
  background: #ff9a2e;
  color: #ffffff;
}

.phase-picker-name {
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.25;
}

@media (hover: hover) and (pointer: fine) {
  .phase-picker-item:hover {
    border-color: #ffc587;
  }
}

/* Botão de escolher o alvo (Imagem-alvo, Som-alvo, Cor-alvo, Modelo…): mesmo laranja do
   botão de Etapa, com a miniatura num quadrinho branco. */
body[data-app-view] .session-panel .target-picker-open {
  border: 2px solid #d9700c;
  border-radius: 12px;
  padding-right: 34px;
  background: #ff9a2e url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6l6 6-6 6' fill='none' stroke='%23fff' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 18px 18px;
  color: #ffffff;
  box-shadow: inset 0 -5px 0 #d9700c, 0 6px 14px rgba(217, 112, 12, 0.18);
  transition: transform 0.12s ease, background-color 0.15s ease, box-shadow 0.12s ease;
}

body[data-app-view] .session-panel .target-picker-open strong {
  color: #ffffff;
  font-weight: 800;
}

body[data-app-view] .session-panel .target-picker-open small {
  color: rgba(255, 255, 255, 0.86);
}

body[data-app-view] .session-panel .target-picker-open .target-picker-thumb {
  border: 0;
  background: #ffffff;
  color: #d9700c;
  box-shadow: 0 2px 6px rgba(160, 80, 5, 0.18);
}

body[data-app-view] .session-panel .target-picker-open:active {
  transform: translateY(3px);
  box-shadow: inset 0 -2px 0 #d9700c;
}

body[data-app-view] .session-panel .target-picker-open:focus-visible {
  outline: 3px solid #ffd29e;
  outline-offset: 2px;
}

body[data-app-view] .session-panel .target-picker-open:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (hover: hover) and (pointer: fine) {
  body[data-app-view] .session-panel .target-picker-open:not(:disabled):hover {
    border-color: #d9700c;
    background-color: #ffab4d;
    transform: translateY(-1px);
  }
}

/* Janela compacta (tempo do Clicar e segurar): menor e aberta por cima do botão. */
.phase-picker-modal .phase-picker-panel.is-compact {
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
}
.phase-picker-panel.is-compact #phasePickerTitle { font-size: 1.02rem; }
.phase-picker-panel.is-compact .floating-panel-header { padding-bottom: 6px; }
.phase-picker-panel.is-compact .phase-picker-close { width: 34px; height: 34px; border-radius: 10px; }
.phase-picker-panel.is-compact .phase-picker-list { gap: 6px; }
.phase-picker-panel.is-compact .phase-picker-item { min-height: 40px; padding: 6px 12px; border-radius: 12px; font-weight: 800; }

/* Aviso "Abrindo…" enquanto um módulo é baixado (scripts/core/module-loader.js). */
.module-loading {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.18);
}

.module-loading-box {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-width: min(260px, 100%);
  max-width: 420px;
  padding: 22px 26px;
  border-radius: 22px;
  background: #fff;
  color: #1f2937;
  font-weight: 900;
  font-size: 1.15rem;
  text-align: center;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.module-loading-box.is-error {
  background: #fff;
}

.module-loading-box.is-error span {
  color: #475569;
  font-weight: 700;
  font-size: 1rem;
}

.module-loading-spinner {
  width: 40px;
  height: 40px;
  border: 5px solid #dbeafe;
  border-top-color: #18a9ea;
  border-radius: 50%;
  animation: module-loading-spin 0.8s linear infinite;
}

.module-loading-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.module-loading-actions button {
  min-height: 46px;
  padding: 8px 18px;
  border: 2px solid #1f2937;
  border-radius: 999px;
  background: #fff;
  color: #1f2937;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.module-loading-actions [data-module-retry] {
  border-color: #16a34a;
  background: #16a34a;
  color: #fff;
}

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

/* "Esconder os botões" (features/hide-controls.js): só aparece na tela cheia do treino. */
body:not(.training-fullscreen) #hideControlsButton {
  display: none !important;
}

body.training-fullscreen.controls-hidden .top-controls,
body.training-fullscreen.controls-hidden .utility-actions,
body.training-fullscreen.controls-hidden #view-treino.is-active > .training-back-button {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.controls-hidden-hint {
  position: fixed;
  z-index: 9999;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.86);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
  animation: controls-hint 2.6s ease forwards;
}

@keyframes controls-hint {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}
