:root {
  color-scheme: light;
  --ink: #14202a;
  --muted: #657382;
  --line: #d6dde3;
  --panel: #ffffff;
  --gold: #d9a82e;
  --navy: #132d46;
  --teal: #0f7c85;
  --red: #d53c30;
  --bg: #eef3f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 22px;
  background: var(--navy);
  color: #fff;
  border-bottom: 4px solid var(--gold);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 390px;
}

.brand-logos {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.brand img {
  object-fit: contain;
}

.logo-apn {
  width: 126px;
  height: 48px;
}

.logo-esoper {
  width: 48px;
  height: 48px;
}

.brand-text {
  display: grid;
  gap: 1px;
}

.brand-text p,
.eyebrow {
  margin: 0 0 3px;
  color: #d9e2ea;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
}

.brand-text h1,
h2,
h3 {
  margin: 0;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: 0;
}

h3 {
  font-size: 20px;
}

.brand-text h1 {
  font-size: 18px;
  line-height: 1.1;
}

.brand-text .brand-product {
  color: #fff;
  font-size: 21px;
}

.brand-text .brand-subtitle {
  color: #d9e2ea;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

button,
.tab {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--gold);
  color: #17212b;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

.tab {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.tab.active {
  background: #fff;
  color: var(--navy);
}

.secondary {
  background: #e3ebf0;
  color: var(--ink);
}

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

main {
  width: 100%;
  flex: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 18px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 12px;
}

#semaforo.active {
  gap: 16px;
}

#destellos.active {
  height: calc(100vh - 104px);
  max-height: calc(100vh - 104px);
}

.welcome-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  align-items: start;
  gap: 24px;
  min-height: 620px;
}

.welcome-copy {
  display: grid;
  gap: 18px;
}

.welcome-copy p {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.welcome-copy .eyebrow {
  color: var(--teal);
}

.welcome-points {
  display: grid;
  gap: 12px;
}

.welcome-points div {
  display: grid;
  gap: 4px;
  padding-left: 12px;
  border-left: 4px solid var(--gold);
}

.welcome-points strong {
  color: var(--navy);
  font-size: 15px;
  text-transform: uppercase;
}

.welcome-points span {
  color: var(--ink);
  line-height: 1.45;
}

.credit {
  max-width: 920px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
}

.credit-panel {
  display: grid;
  place-items: center;
  padding: 12px 18px;
}

.downloads-panel {
  display: grid;
  gap: 18px;
}

.downloads-panel .eyebrow {
  color: var(--teal);
}

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

.download-card {
  display: grid;
  align-content: space-between;
  gap: 18px;
  min-height: 220px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.download-card span {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e7eef4;
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.download-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--gold);
  color: #17212b;
  font-weight: 800;
  text-decoration: none;
}

.welcome-start {
  justify-self: start;
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.welcome-visual {
  display: grid;
  place-items: start center;
  min-height: 520px;
  overflow: hidden;
}

.welcome-visual img {
  width: min(420px, 100%);
  max-height: 560px;
  object-fit: contain;
  transform: translateY(-95px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 8px 22px rgba(19, 45, 70, 0.08);
}

.semaphore-card {
  width: 100%;
}

.semaphore-transmit {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  align-items: stretch;
  gap: 14px;
  min-height: 640px;
}

.semaphore-transmit .composer {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-right: 14px;
  border-right: 1px solid var(--line);
}

.semaphore-transmit .signal-stage {
  min-height: 0;
  grid-template-rows: auto 570px auto;
}

.semaphore-transmit .signal-fullscreen-stage {
  height: 570px;
  min-height: 570px;
  padding: 0 24px 8px;
}

.semaphore-transmit .signal-canvas {
  place-items: start center;
}

.semaphore-transmit .real-signal {
  width: auto;
  height: 620px;
  max-width: 100%;
  max-height: none;
  object-fit: contain;
  transform: translateY(-50px);
}

.composer .eyebrow,
.flash-panel .eyebrow,
.flags-panel .eyebrow,
.reference .eyebrow,
.morse-reference .eyebrow {
  color: var(--teal);
}

.composer label {
  display: block;
  margin-bottom: 8px;
  font-weight: 750;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #b9c4cd;
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
  font: inherit;
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 92px;
  text-transform: uppercase;
}

.actions,
.answer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.playback-control {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.duration-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.duration-field select {
  width: 100%;
}

.answer-row input {
  width: 92px;
  text-align: center;
  text-transform: uppercase;
  font-size: 22px;
  font-weight: 800;
}

.exam-controls {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 8px;
  margin-top: 10px;
}

.exam-controls label {
  font-weight: 750;
}

.score-stack {
  display: grid;
  gap: 4px;
  justify-items: end;
}

.score.time {
  font-size: 13px;
}

.score.grade {
  color: var(--navy);
  font-size: 13px;
  font-weight: 850;
}

.exam-answer-row input {
  flex: 1;
  min-width: 220px;
  text-align: left;
  font-size: 16px;
}

.exam-prompt {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.countdown-display {
  display: grid;
  place-items: center;
  min-width: 170px;
  min-height: 170px;
  border: 4px solid var(--gold);
  border-radius: 50%;
  color: var(--navy);
  font-size: 46px;
  font-weight: 900;
  text-align: center;
}

.signal-stage {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.fullscreen-stage {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: stretch;
}

.signal-fullscreen-stage {
  min-height: 0;
}

.fullscreen-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fullscreen-controls button {
  box-shadow: 0 8px 20px rgba(13, 27, 40, 0.16);
}

.fullscreen-play,
.fullscreen-exit {
  display: none;
}

.fullscreen-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  padding: 24px;
  background: #0d1b28;
}

.fullscreen-stage:fullscreen .fullscreen-play,
.fullscreen-stage:fullscreen .fullscreen-exit {
  display: inline-flex;
}

.fullscreen-stage:fullscreen .signal-canvas {
  width: 100%;
  height: 100%;
}

.fullscreen-stage:fullscreen .real-signal {
  max-width: 94vw;
  max-height: 94vh;
}

.fullscreen-stage:fullscreen .signal-svg {
  width: min(94vw, 980px);
  max-height: 94vh;
}

.fullscreen-stage:fullscreen .countdown-display {
  width: min(42vw, 340px);
  height: min(42vw, 340px);
  min-width: 220px;
  min-height: 220px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.fullscreen-stage::backdrop {
  background: #0d1b28;
}

.signal-meta,
.trainer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.signal-meta span,
.score {
  color: var(--muted);
  font-weight: 700;
}

.signal-meta strong {
  font-size: 28px;
  color: var(--navy);
}

.signal-canvas {
  width: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.signal-canvas.compact {
  height: 100%;
}

.signal-svg {
  width: min(520px, 100%);
  height: auto;
}

.real-signal {
  width: auto;
  height: 100%;
  max-width: min(560px, 100%);
  max-height: min(500px, calc(100vh - 228px));
  object-fit: contain;
}

#semaforo .practice-visual-panel .real-signal {
  max-width: 100%;
  max-height: min(650px, calc(100vh - 138px));
}

#semaforo .fullscreen-stage:fullscreen .real-signal {
  max-height: 94vh;
}

.missing-signal {
  display: grid;
  place-items: center;
  width: min(460px, 100%);
  min-height: 360px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 72px;
  overflow: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.chip {
  min-width: 34px;
  padding: 6px 9px;
  border-radius: 6px;
  background: #edf2f5;
  color: var(--ink);
  text-align: center;
  font-weight: 800;
}

.chip.active {
  background: var(--navy);
  color: #fff;
}

.sequence-space {
  display: inline-block;
  width: 24px;
  min-height: 34px;
}

.sequence-space.active {
  border-bottom: 4px solid var(--navy);
}

.trainer {
  width: min(100%, 840px);
  max-width: 840px;
  max-height: 100%;
  margin: 0 auto;
  overflow: hidden;
}

#semaforo .trainer {
  width: 100%;
  max-width: none;
  max-height: none;
  overflow: visible;
}

.practice-panel {
  width: 100%;
  max-width: 1180px;
  height: 100%;
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 14px;
}

.semaphore-receive {
  min-height: 540px;
}

.mode-title {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.practice-control-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.practice-control-panel .actions,
.practice-control-panel .answer-row {
  margin-top: 0;
}

.practice-visual-panel {
  display: grid;
  min-height: 0;
  overflow: hidden;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.semaphore-receive .practice-visual-panel {
  min-height: 490px;
  max-height: 490px;
  padding-top: 0;
  padding-right: 24px;
  padding-bottom: 0;
  padding-left: 24px;
}

.semaphore-receive .signal-canvas {
  place-items: start center;
}

.semaphore-receive .real-signal {
  width: auto;
  height: 590px;
  max-width: 100%;
  max-height: none;
  object-fit: contain;
  transform: translateY(-72px);
}

.pose-camera-panel {
  display: grid;
  gap: 14px;
}

.pose-camera-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pose-camera-actions {
  margin-top: 0;
}

.pose-camera-grid {
  display: grid;
  grid-template-columns: minmax(250px, 0.68fr) minmax(280px, 0.72fr) minmax(360px, 1fr);
  align-items: start;
  gap: 10px;
  min-width: 0;
}

.pose-camera-main {
  display: contents;
}

.pose-camera-stage {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 200px;
  max-height: 250px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1b28;
  aspect-ratio: 4 / 3;
}

.pose-camera-stage video,
.pose-camera-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pose-camera-stage video {
  z-index: 1;
}

.pose-camera-stage video.mirrored {
  transform: scaleX(-1);
}

.pose-camera-stage canvas {
  z-index: 2;
  opacity: 0;
  pointer-events: none;
}

.pose-camera-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 3;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(13, 27, 40, 0.82);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.pose-camera-readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
  min-width: 0;
  position: relative;
  z-index: 4;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.pose-camera-readout label {
  font-weight: 750;
}

.pose-option-group {
  display: grid;
  gap: 6px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  font-weight: 750;
}

.check-row input {
  width: auto;
}

.pose-detection-card {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 5px 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pose-detection-card span,
.pose-detection-card small {
  color: var(--muted);
  font-weight: 800;
}

.pose-detection-card strong {
  color: var(--navy);
  font-size: 32px;
  line-height: 1;
}

.pose-detection-card .pose-confidence,
.pose-detection-card small {
  grid-column: 1 / -1;
}

.pose-eval-card {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pose-eval-prompt {
  display: grid;
  align-items: center;
  min-height: 86px;
  margin: 0;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #eef3f6;
  color: var(--navy);
  font-size: 24px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
}

.pose-eval-prompt.active {
  border-color: #0f7c85;
  background: #e3f5f7;
}

.pose-eval-prompt.ok {
  border-color: #197a45;
  background: #dcf4e7;
  color: #155c37;
}

.pose-eval-prompt.bad {
  border-color: #a92c25;
  background: #fde3df;
  color: #8f231e;
}

.pose-eval-prompt.warn {
  border-color: var(--gold);
  background: #fff4ca;
  color: #71500d;
}

.pose-camera-readout label[for="poseDecoded"] {
  grid-column: 1 / -1;
}

#poseDecoded {
  grid-column: 1 / -1;
  min-height: 56px;
}

.pose-camera-readout > .actions {
  grid-column: 1 / -1;
  margin-top: 0;
}

.pose-camera-readout > .pose-status {
  grid-column: 1 / -1;
}

.pose-status-board {
  display: grid;
  align-items: center;
  min-height: 70px;
  margin: 0;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font-size: 22px;
  font-weight: 900;
  line-height: 1.18;
  text-align: center;
}

.pose-status-board.ok {
  border-color: #197a45;
  background: #dcf4e7;
  color: #155c37;
}

.pose-status-board.bad {
  border-color: #a92c25;
  background: #fde3df;
  color: #8f231e;
}

.pose-status-board.warn {
  border-color: var(--gold);
  background: #fff4ca;
  color: #71500d;
}

.pose-status-board.neutral {
  border-color: #b8c6d0;
  background: #eef3f6;
}

.pose-eval-card .score-stack {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-items: start;
  gap: 6px;
}

.pose-eval-card .actions {
  margin-top: 0;
}

.pose-confidence {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #d8e0e6;
}

.pose-confidence span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--gold);
  transition: width 120ms ease;
}

.pose-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.flash-panel {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.flash-head,
.flash-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.flash-status {
  min-width: 92px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #edf2f5;
  color: var(--navy);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
}

.flash-status.active {
  background: var(--gold);
  color: #17212b;
}

.flash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  min-height: 0;
}

.flash-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.flash-card label {
  font-weight: 750;
}

.flash-workbench {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(280px, 360px);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.flash-projector,
.flash-controls-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.flash-controls-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.flash-controls-panel .actions {
  margin-top: 0;
}

.morse-rule {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.flash-lamp {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: radial-gradient(circle at center, #263847 0, #132d46 52%, #0d1b28 100%);
}

.flash-receive-stage {
  min-height: 320px;
}

.flash-receive-stage .flash-lamp {
  height: 100%;
}

.flash-receive-stage:fullscreen {
  place-items: center;
}

.flash-receive-stage:fullscreen .flash-lamp {
  width: min(92vw, 1280px);
  height: min(78vh, 680px);
}

.lamp-core {
  position: relative;
  z-index: 2;
  width: 92px;
  height: 92px;
  border: 8px solid #273747;
  border-radius: 50%;
  background: #d3dbe2;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.35);
}

.lamp-beam {
  position: absolute;
  z-index: 1;
  width: 70%;
  height: 70%;
  border-radius: 50%;
  background: rgba(217, 168, 46, 0);
  filter: blur(8px);
  transform: scale(0.55);
  transition: 70ms ease;
}

.flash-lamp.on .lamp-core {
  background: #fff7ca;
  box-shadow: 0 0 38px rgba(255, 220, 92, 0.95), inset 0 0 12px rgba(255, 255, 255, 0.7);
}

.flash-lamp.on .lamp-beam {
  background: rgba(255, 214, 84, 0.42);
  transform: scale(1);
}

.morse-readout {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #edf2f5;
}

.morse-readout span {
  color: var(--muted);
  font-weight: 750;
}

.morse-readout strong {
  color: var(--navy);
  font-size: 28px;
  letter-spacing: 4px;
}

.flash-quality {
  min-height: 22px;
  margin: 0;
  font-weight: 800;
}

.flash-quality.ok {
  color: #197a45;
}

.flash-quality.warn {
  color: #9a6916;
}

.flash-quality.bad {
  color: #a92c25;
}

#banderas.active {
  gap: 16px;
}

.flags-panel {
  display: grid;
  gap: 14px;
}

.flags-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.flags-layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.flags-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 14px;
  border-right: 1px solid var(--line);
}

.flags-controls label {
  font-weight: 750;
}

.flag-prompt {
  min-height: 44px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.45;
}

.flag-answer-row {
  margin-top: 0;
}

.flag-answer-row input {
  flex: 1;
  min-width: 220px;
  text-align: left;
  text-transform: uppercase;
  font-size: 16px;
}

.flags-visual-area {
  display: grid;
  min-height: 520px;
}

.flag-visual-card {
  display: grid;
  place-items: center;
  min-height: 520px;
  overflow: hidden;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.flag-visual-card > span {
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
}

.flag-single {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 420px;
}

.flag-svg,
.flag-img {
  width: min(440px, 94%);
  height: auto;
  filter: drop-shadow(0 12px 18px rgba(19, 45, 70, 0.18));
}

.flag-svg.pennant,
.flag-svg.swallow {
  width: min(420px, 92%);
}

.flag-img {
  display: block;
  max-height: 360px;
  object-fit: contain;
}

.flag-mast-card {
  display: grid;
  gap: 14px;
  place-items: center;
  width: 100%;
}

.flag-mast-card strong {
  color: var(--navy);
  font-size: 24px;
}

.flag-mast {
  position: relative;
  width: min(460px, 100%);
  height: 380px;
}

.mast-pole {
  position: absolute;
  top: 18px;
  bottom: 14px;
  left: 82px;
  width: 8px;
  border-radius: 999px;
  background: #243746;
  box-shadow: inset -2px 0 0 rgba(255, 255, 255, 0.18);
}

.mast-pole::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  transform: translateX(-50%);
}

.mast-yard {
  position: absolute;
  left: 92px;
  display: grid;
  width: min(330px, calc(100% - 102px));
  transition: top 160ms ease;
}

.mast-yard::before {
  content: "";
  position: absolute;
  top: 54px;
  left: -8px;
  width: 22px;
  height: 4px;
  border-radius: 999px;
  background: #243746;
}

.mast-yard .flag-svg,
.mast-yard .flag-img {
  width: 100%;
}

.mast-tope {
  top: 22px;
}

.mast-media {
  top: 130px;
}

.mast-arriada {
  top: 244px;
}

.flag-meaning-card {
  display: grid;
  gap: 12px;
  width: min(620px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.flag-meaning-card span {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.flag-meaning-card p {
  margin: 0;
  color: var(--navy);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.35;
}

.trainer .eyebrow {
  color: var(--teal);
}

.result {
  min-height: 22px;
  margin: 8px 0 0;
  font-weight: 800;
}

.result.ok {
  color: #197a45;
}

.result.bad {
  color: #a92c25;
}

.reference img {
  display: block;
  width: min(100%, 568px);
  margin: 18px auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.flag-reference img {
  width: min(100%, 930px);
}

.reference-browser-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reference-browser .eyebrow {
  color: var(--teal);
}

.reference-browser {
  display: grid;
  gap: 14px;
}

.reference-browser-head select {
  width: min(240px, 100%);
}

.reference-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 8px;
  max-height: 460px;
  overflow: auto;
  padding-right: 4px;
}

.reference-item {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 8px;
  background: #f8fafb;
  border-color: var(--line);
  color: var(--ink);
  text-align: left;
}

.reference-item span {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.reference-item strong {
  font-size: 13px;
}

.reference-detail {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 260px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 750;
}

.reference-detail-visual {
  display: grid;
  place-items: center;
  min-height: 170px;
}

.reference-detail-visual img {
  width: min(260px, 90%);
  max-height: 220px;
  object-fit: contain;
}

.reference-detail .flag-img {
  width: min(280px, 92%);
  max-height: 190px;
}

.reference-morse {
  color: var(--navy);
  font-size: 46px;
  letter-spacing: 6px;
}

.morse-table {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.morse-table div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
}

.morse-table strong {
  color: var(--navy);
  font-size: 18px;
}

.morse-table code {
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
}

@media (max-width: 850px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    min-width: 0;
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-logos {
    flex-wrap: wrap;
  }

  .semaphore-transmit {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .semaphore-transmit .composer {
    padding-right: 0;
    padding-bottom: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #destellos.active {
    height: auto;
    max-height: none;
  }

  .welcome-panel {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .welcome-visual {
    min-height: 360px;
  }

  .exam-controls {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .practice-panel {
    height: auto;
    grid-template-columns: 1fr;
  }

  .pose-camera-head {
    align-items: stretch;
    flex-direction: column;
  }

  .pose-camera-grid {
    grid-template-columns: 1fr;
  }

  .pose-camera-main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .pose-camera-main .pose-eval-card {
    order: -1;
  }

  .pose-camera-stage {
    min-height: 240px;
  }

  .flash-grid {
    grid-template-columns: 1fr;
  }

  .flash-workbench {
    grid-template-columns: 1fr;
  }

  .flash-lamp,
  .flash-receive-stage {
    min-height: 260px;
  }

  .reference-layout {
    grid-template-columns: 1fr;
  }

  .downloads-grid {
    grid-template-columns: 1fr;
  }

  .flags-head {
    align-items: stretch;
    flex-direction: column;
  }

  .flags-layout {
    grid-template-columns: 1fr;
  }

  .flags-controls {
    padding-right: 0;
    padding-bottom: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .flags-visual-area,
  .flag-visual-card {
    min-height: 420px;
  }

  .flag-single {
    min-height: 320px;
  }

  .flag-mast {
    height: 330px;
  }

  .mast-media {
    top: 112px;
  }

  .mast-arriada {
    top: 204px;
  }

  .practice-visual-panel {
    min-height: 360px;
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 12px;
  }

  .signal-stage {
    min-height: 0;
  }
}
