/* Simulados — folha de instruções para uma prova longa.
   O relógio é o único instrumento escuro; todo o restante se organiza por
   regras e divisórias, sem a cenografia de um cockpit. */
#view-simulados {
  --sim-ink: #182138;
  --sim-muted: #667188;
  --sim-line: var(--app-border-panel);
  --sim-paper: var(--app-surface);
  --sim-canvas-soft: #f7f9fd;
  --sim-navy: #172342;
  --sim-navy-2: #22345f;
  --sim-cobalt: #5f73d6;
  --sim-cobalt-ink: #4258bd;
  --sim-cobalt-soft: #eef1ff;
  --sim-lime: #baf160;
  --sim-lime-hover: #c6f87a;
  --sim-lime-ink: #334d15;
  --sim-coral: #c94b59;
  --sim-state: var(--sim-cobalt);
}
#view-simulados.app-view { max-width: 1180px; }
.sim-page { width: min(1180px, 100%); margin: 0 auto; color: var(--sim-ink); }
.sim-page[data-sim-state="active"] { --sim-state: #91cf37; }
.sim-page[data-sim-state="expired"],
.sim-page[data-sim-state="unavailable"] { --sim-state: var(--sim-coral); }
.sim-page *, .sim-page *::before, .sim-page *::after { box-sizing: border-box; }

/* Cabeçalho orienta; o formato aparece uma única vez, na abertura da folha. */
.sim-page-head { min-height: 94px; margin-bottom: 20px; align-items: end; }
.sim-page-head > div { min-width: 0; }
.sim-page-head .ep-eyebrow { color: var(--sim-cobalt-ink); }
.sim-page-head h1 { max-width: 18ch; color: var(--sim-ink); letter-spacing: -.045em; }
.sim-page-head p { max-width: 62ch; color: var(--sim-muted); line-height: 1.5; }

/* Uma única folha: abertura, preparação e regras compartilham a mesma borda. */
.sim-stage {
  position: relative;
  overflow: hidden;
  color: var(--sim-ink);
  border: 1px solid #d7deed;
  border-radius: var(--app-radius-card);
  background: var(--sim-paper);
  box-shadow: none;
  animation: none;
}
.sim-stage::before,
.sim-stage::after { content: none; }
.sim-stage-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 258px;
  gap: 42px;
  min-height: 202px;
  padding: var(--app-space-7) 30px 26px;
  align-items: center;
}
.sim-stage-copy { max-width: 690px; }
.sim-run-chip {
  display: inline-flex;
  min-height: 0;
  padding: 0;
  align-items: center;
  gap: 8px;
  color: var(--sim-cobalt-ink);
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: var(--esp-micro, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--esp-type-caption);
  font-weight: var(--esp-weight-bold);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.sim-run-chip i {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--sim-state);
  box-shadow: none;
}
.sim-run-chip--active { color: #4b711b; border-color: transparent; background: transparent; }
.sim-run-chip--active i { box-shadow: none; }
.sim-run-chip--expired,
.sim-run-chip--unavailable { color: #a33f4c; border-color: transparent; background: transparent; }
.sim-run-chip--expired i,
.sim-run-chip--unavailable i { box-shadow: none; }
.sim-stage h2 {
  max-width: 23ch;
  margin: 7px 0 10px;
  color: var(--sim-ink);
  font: var(--esp-weight-bold) var(--esp-type-heading)/1.05 var(--esp-display, Manrope, sans-serif);
  letter-spacing: -.05em;
}
.sim-stage-copy > p {
  max-width: 62ch;
  margin: 0;
  color: var(--sim-muted);
  font-size: var(--esp-type-support);
  line-height: 1.58;
}

/* Instrumento temporal: a única superfície escura da página. */
.sim-clock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  min-width: 0;
  min-height: 108px;
  padding: 19px 20px 17px;
  align-content: center;
  align-items: end;
  color: #fff;
  border: 1px solid var(--sim-navy);
  border-radius: var(--app-radius-inset);
  background: var(--sim-navy);
  box-shadow: none;
  text-align: left;
}
.sim-clock::before,
.sim-clock::after,
.sim-clock b::after { content: none; }
.sim-clock span {
  grid-column: 1 / -1;
  color: #bfc9e8;
  font-family: var(--esp-micro, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--esp-type-caption);
  font-weight: var(--esp-weight-bold);
  letter-spacing: .07em;
  text-transform: uppercase;
}
.sim-clock b {
  grid-column: 1;
  display: block;
  margin: 9px 0 0;
  color: #fff;
  font: var(--esp-weight-bold) var(--esp-type-subhead)/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.055em;
}
.sim-page[data-sim-state="active"] .sim-clock b { color: var(--sim-lime); }
.sim-page[data-sim-state="expired"] .sim-clock b,
.sim-page[data-sim-state="unavailable"] .sim-clock b { color: #ffb6bf; }
.sim-clock small {
  grid-column: 2;
  margin: 0 0 1px 12px;
  color: #d3daf0;
  font-size: var(--esp-type-caption);
  white-space: nowrap;
}

/* A escolha e o início são uma linha da mesma folha, não um card interno. */
.sim-page .sim-launch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(390px, 520px);
  gap: 30px;
  margin: 0;
  padding: 21px 30px;
  align-items: end;
  color: var(--sim-ink);
  border: 0;
  border-top: 1px solid var(--sim-line);
  border-radius: 0;
  background: #fafbfe;
  box-shadow: none;
}
.sim-page[data-sim-state="active"] .sim-launch { border-color: #dfe9cf; background: #f7fbf0; }
.sim-page[data-sim-state="expired"] .sim-launch,
.sim-page[data-sim-state="unavailable"] .sim-launch { border-color: #eedcdf; background: #fff8f9; }
.sim-launch-copy > span {
  color: var(--sim-cobalt-ink);
  font-size: var(--esp-type-caption);
  font-weight: var(--esp-weight-bold);
  letter-spacing: .08em;
}
.sim-page[data-sim-state="active"] .sim-launch-copy > span { color: #4f721e; }
.sim-launch-copy label {
  display: block;
  margin-top: 6px;
  color: var(--sim-ink);
  font-size: var(--esp-type-body);
  font-weight: var(--esp-weight-bold);
}
.sim-launch-copy p {
  max-width: 56ch;
  margin: 4px 0 0;
  color: var(--sim-muted);
  font-size: var(--esp-type-caption);
  line-height: 1.48;
}
.sim-launch-actions {
  display: grid;
  grid-template-columns: minmax(13rem, 1fr) auto;
  gap: 9px;
  align-items: center;
}
.sim-page .sim-area-select {
  width: 100%;
  max-width: none;
  min-height: 48px;
  padding: 0 40px 0 14px;
  color: var(--sim-ink);
  border: 1px solid #cbd4e5;
  border-radius: var(--app-radius-inset);
  background: #fff;
  box-shadow: 0 1px 2px rgba(28, 42, 78, .04);
  font: var(--esp-weight-medium) var(--esp-type-support)/1 var(--esp-ui, Inter, sans-serif);
}
.sim-page .sim-area-select[aria-invalid="true"] { border-color: var(--sim-coral); box-shadow: 0 0 0 3px rgba(201, 75, 89, .14); }
.sim-page .sim-area-select:disabled { cursor: not-allowed; opacity: 1; background: #e9edf4; color: #515d73; }
.sim-page .sim-area-plan {
  cursor: default;
  appearance: none;
  background: #f4f7ef;
  color: var(--sim-ink);
  font-weight: var(--esp-weight-bold);
}
.sim-primary-button {
  display: inline-flex;
  min-height: 48px;
  padding: 0 18px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #263318;
  border: 1px solid #9dcc50;
  border-radius: var(--app-radius-inset);
  background: var(--sim-lime);
  box-shadow: none;
  font: var(--esp-weight-bold) var(--esp-type-support)/1 var(--esp-ui, Inter, sans-serif);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.sim-primary-button span { transition: transform var(--t-fast); }
.sim-primary-button:hover { background: var(--sim-lime-hover); box-shadow: none; transform: none; }
.sim-primary-button:hover span,
.sim-primary-button:focus-visible span { transform: translateX(3px); }
.sim-primary-button:disabled { cursor: not-allowed; opacity: .55; box-shadow: none; transform: none; }
.sim-secondary-button {
  grid-column: 1 / -1;
  justify-self: end;
  min-height: var(--tap-min);
  padding: 0 4px;
  color: #68748a;
  border: 0;
  background: transparent;
  font: var(--esp-weight-medium) var(--esp-type-caption)/1 var(--esp-ui, Inter, sans-serif);
  text-decoration: underline;
  text-decoration-color: #b9c1cf;
  text-underline-offset: 3px;
  cursor: pointer;
}
.sim-field-error { grid-column: 1 / -1; margin: 0; color: #a33f4c; font-size: var(--esp-type-caption); font-weight: var(--esp-weight-bold); }
.sim-action-note,
.sim-storage-warning {
  max-width: 94ch;
  margin: 0;
  padding: 10px 30px 16px;
  color: var(--sim-muted);
  background: #fafbfe;
  font-size: var(--esp-type-caption);
  line-height: 1.5;
}
.sim-storage-warning { color: #96552e; }

/* As quatro regras são uma faixa de apoio, não quatro decisões. */
.sim-page .sim-rules {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  overflow: hidden;
  border: 0;
  border-top: 1px solid var(--sim-line);
  border-radius: 0;
  background: var(--sim-paper);
}
.sim-page .sim-rules > div {
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 3px 10px;
  min-width: 0;
  padding: 18px 17px 20px;
  border: 0;
  border-left: 1px solid var(--sim-line);
  background: transparent;
}
.sim-page .sim-rules > div:first-child { border-left: 0; }
.sim-rule-icon {
  grid-row: 1 / 3;
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  color: var(--sim-cobalt-ink);
  border: 1px solid #dbe1f2;
  border-radius: var(--app-radius-control);
  background: var(--sim-cobalt-soft);
}
.sim-rule-icon svg { width: 16px; height: 16px; }
.sim-page .sim-rules b { color: var(--sim-ink); font: var(--esp-weight-bold) var(--esp-type-caption)/1.25 var(--esp-ui, Inter, sans-serif); }
.sim-page .sim-rules > div > span:last-child { color: var(--sim-muted); font-size: var(--esp-type-caption); line-height: 1.42; }

/* Protocolo e histórico formam um único caderno de apoio. */
.sim-lower-grid {
  display: grid;
  grid-template-columns: minmax(0, .86fr) minmax(0, 1.14fr);
  gap: 0;
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--sim-line);
  border-radius: var(--app-radius-panel);
  background: var(--sim-paper);
  animation: none;
}
.sim-protocol,
.sim-history {
  min-width: 0;
  padding: 25px 26px;
  border: 0;
  border-radius: 0;
  background: var(--sim-paper);
  box-shadow: none;
}
.sim-history { border-left: 1px solid var(--sim-line); }
.sim-panel-head { display: flex; margin-bottom: 18px; align-items: flex-start; justify-content: space-between; gap: 16px; }
.sim-panel-head > div > span { color: var(--sim-cobalt-ink); font-size: var(--esp-type-caption); font-weight: var(--esp-weight-bold); letter-spacing: .08em; }
.sim-panel-head h2 { margin: 5px 0 0; color: var(--sim-ink); font: var(--esp-weight-bold) var(--esp-type-body)/1.2 var(--esp-display, Manrope, sans-serif); letter-spacing: -.025em; }
.sim-panel-head > a {
  display: inline-flex;
  min-height: var(--tap-min);
  margin: -7px 0;
  align-items: center;
  color: var(--sim-cobalt-ink);
  font-size: var(--esp-type-caption);
  font-weight: var(--esp-weight-bold);
  text-decoration: none;
  white-space: nowrap;
}
.sim-protocol-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.sim-protocol-list li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-top: 1px solid #e6e9f1; }
.sim-protocol-list li:first-child { padding-top: 0; border-top: 0; }
.sim-protocol-list li > span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--sim-cobalt-ink);
  border-radius: 9px;
  background: var(--sim-cobalt-soft);
  font: var(--esp-weight-bold) var(--esp-type-caption)/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
}
.sim-protocol-list li > span::before { content: none; }
.sim-protocol-list b { display: block; color: var(--sim-ink); font-size: var(--esp-type-support); }
.sim-protocol-list p { margin: 3px 0 0; color: var(--sim-muted); font-size: var(--esp-type-caption); line-height: 1.5; }

.sim-history-list { overflow: hidden; margin: 0; }
.sim-history-row {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr) auto;
  gap: 11px;
  min-height: 61px;
  padding: 9px 4px;
  align-items: center;
  color: inherit;
  border-top: 1px solid #e6e9f1;
  text-decoration: none;
}
.sim-history-row:first-child { border-top: 0; }
a.sim-history-row { transition: background-color var(--t-fast), padding var(--t-fast); }
a.sim-history-row:hover { padding-right: 10px; padding-left: 10px; border-radius: var(--app-radius-control); background: var(--sim-cobalt-soft); }
.sim-history-date { color: var(--sim-muted); font-size: var(--esp-type-caption); font-weight: var(--esp-weight-medium); }
.sim-history-copy { min-width: 0; }
.sim-history-copy b { display: block; color: var(--sim-ink); font-size: var(--esp-type-support); overflow-wrap: anywhere; }
.sim-history-copy small { display: block; margin-top: 4px; color: var(--sim-muted); font-size: var(--esp-type-caption); }
.sim-history-arrow { color: var(--sim-cobalt-ink); font-size: var(--esp-type-subhead); }
.sim-history-footnote { margin: 13px 0 0; padding-top: 12px; color: var(--sim-muted); border-top: 1px solid #e6e9f1; font-size: var(--esp-type-caption); line-height: 1.5; }
.sim-history-state {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 13px;
  min-height: 122px;
  padding: 18px 0;
  align-items: start;
  border-top: 1px solid #e6e9f1;
  background: transparent;
}
.sim-history-state--error { border-top-color: #edd1d5; }
.sim-state-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--sim-cobalt-ink);
  border-radius: 11px;
  background: var(--sim-cobalt-soft);
}
.sim-history-state--error .sim-state-icon { color: #a33f4c; background: #fff0f2; }
.sim-state-icon svg { width: 19px; height: 19px; }
.sim-history-state b { display: block; margin-top: 1px; color: var(--sim-ink); font-size: var(--esp-type-support); }
.sim-history-state p { margin: 5px 0 0; color: var(--sim-muted); font-size: var(--esp-type-caption); line-height: 1.5; }
.sim-history-loading { min-width: 0; }
.sim-history-loading-copy {
  margin: 0 0 10px;
  color: var(--sim-muted);
  font-size: var(--esp-type-caption);
  line-height: 1.5;
}
.sim-history-skeleton { animation: sim-history-pulse 1.8s ease-in-out infinite; }
.sim-history-skeleton i {
  display: block;
  height: 10px;
  border-radius: 4px;
  background: var(--sim-line);
}
.sim-history-skeleton .sim-history-date i { width: 70%; }
.sim-history-skeleton .sim-history-copy i:first-child { width: 82%; height: 13px; }
.sim-history-skeleton .sim-history-copy i + i { width: 55%; margin-top: 9px; }
.sim-history-skeleton .sim-history-arrow i { width: 15px; }
@keyframes sim-history-pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) {
  .sim-history-skeleton { animation: none; }
}
.sim-text-button {
  min-height: var(--tap-min);
  margin: 5px 0 -5px;
  padding: 0 4px;
  color: var(--sim-cobalt-ink);
  border: 0;
  background: transparent;
  font: var(--esp-weight-bold) var(--esp-type-caption)/1 var(--esp-ui, Inter, sans-serif);
  cursor: pointer;
}

.sim-page button:focus-visible,
.sim-page select:focus-visible,
.sim-page a:focus-visible {
  outline: 3px solid rgba(95, 115, 214, .38);
  outline-offset: 3px;
}
.sim-page [hidden] { display: none !important; }

/* Confirmação destrutiva: coral só no risco real, foco preso pelo JS existente. */
body.sim-dialog-open { overflow: hidden; }
.sim-confirm { position: fixed; z-index: var(--z-modal, 1000); inset: 0; display: grid; padding: 20px; place-items: center; }
.sim-confirm[hidden] { display: none !important; }
.sim-confirm-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(18, 27, 47, .48); backdrop-filter: blur(4px); }
.sim-confirm section {
  position: relative;
  width: min(460px, 100%);
  padding: 27px;
  border: 1px solid var(--sim-line);
  border-top: 4px solid var(--sim-coral);
  border-radius: var(--app-radius-card);
  background: #fff;
  box-shadow: 0 28px 64px -22px rgba(18, 27, 47, .34);
}
.sim-confirm h2 { margin: 8px 0; color: var(--sim-ink); font: var(--esp-weight-bold) var(--esp-type-heading)/1.2 var(--esp-display, Manrope, sans-serif); letter-spacing: -.035em; }
.sim-confirm p { margin: 0; color: var(--sim-muted); font-size: var(--esp-type-support); line-height: 1.55; }
.sim-confirm section > div { display: flex; margin-top: 22px; justify-content: flex-end; gap: 8px; }
.sim-confirm section button {
  min-height: var(--tap-min);
  padding: 0 14px;
  color: var(--sim-ink);
  border: 1px solid var(--sim-line);
  border-radius: 11px;
  background: #fff;
  font: var(--esp-weight-bold) var(--esp-type-support)/1 var(--esp-ui, Inter, sans-serif);
}
.sim-confirm section button[data-sim-confirm-discard] { color: #fff; border-color: var(--sim-coral); background: var(--sim-coral); }
.sim-confirm button:focus-visible { outline: 3px solid rgba(95, 115, 214, .38); outline-offset: 3px; }

@keyframes sim-card-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes sim-support-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1120px) {
  .sim-stage-main { grid-template-columns: minmax(0, 1fr) 238px; gap: 30px; }
  .sim-page .sim-launch { grid-template-columns: 1fr; align-items: start; }
  .sim-launch-actions { grid-template-columns: minmax(0, 1fr) auto; }
  .sim-page .sim-rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sim-page .sim-rules > div:nth-child(3) { border-top: 1px solid var(--sim-line); border-left: 0; }
  .sim-page .sim-rules > div:nth-child(4) { border-top: 1px solid var(--sim-line); }
}

@media (max-width: 880px) {
  .sim-stage-main { grid-template-columns: minmax(0, 1fr) 220px; padding-right: 27px; }
  .sim-lower-grid { grid-template-columns: 1fr; }
  .sim-history { border-top: 1px solid var(--sim-line); border-left: 0; }
}

@media (max-width: 720px) {
  .sim-page-head {
    min-height: 0;
    margin-bottom: 12px;
    padding-right: 0;
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }
  .sim-page-head h1 { max-width: 18ch; font-size: var(--esp-type-heading); }
  .sim-page-head .ep-eyebrow { margin-right: 50px; }
  .sim-page-head p { font-size: var(--esp-type-support); }

  .sim-stage { border-radius: var(--app-radius-panel); }
  .sim-stage-main {
    grid-template-columns: 1fr;
    gap: 13px;
    min-height: 0;
    padding: var(--app-space-4) 18px 14px;
  }
  .sim-run-chip { min-height: 0; padding: 0; }
  .sim-stage h2 { max-width: 20ch; margin-bottom: 6px; font-size: var(--esp-type-heading); }
  .sim-stage-copy > p { display: block; }
  .sim-clock {
    min-height: 70px;
    padding: 10px 16px 9px;
    border-radius: var(--app-radius-control);
  }
  .sim-clock b { margin-top: 6px; }

  .sim-page .sim-launch { gap: 11px; margin: 0; padding: 14px 18px; border-radius: 0; }
  .sim-launch-copy > span { display: block; }
  .sim-launch-actions { grid-template-columns: 1fr; }
  .sim-page .sim-primary-button { width: 100%; margin: 0; white-space: normal; }
  .sim-secondary-button { grid-column: 1; justify-self: center; }
  .sim-field-error { grid-column: 1; }
  .sim-action-note,
  .sim-storage-warning { margin: 0; padding: 10px 18px 15px; }

  .sim-page .sim-rules { margin-top: 0; }
  .sim-page .sim-rules > div { padding: 16px 14px 17px; }
  .sim-lower-grid { gap: 0; margin-top: 20px; }
  .sim-protocol,
  .sim-history { padding: 20px; border-radius: 0; }
  .sim-panel-head { align-items: flex-start; }
  .sim-history-row { grid-template-columns: 77px minmax(0, 1fr) auto; }
}

@media (max-width: 390px) {
  .sim-page .sim-rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sim-page .sim-rules > div {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 6px;
    padding: 14px 12px 16px;
  }
  .sim-page .sim-rules > div:nth-child(2) { border-left: 1px solid var(--sim-line); }
  .sim-page .sim-rules > div:nth-child(3) { border-top: 1px solid var(--sim-line); border-left: 0; }
  .sim-page .sim-rules > div:nth-child(4) { border-top: 1px solid var(--sim-line); border-left: 1px solid var(--sim-line); }
  .sim-rule-icon { grid-row: auto; }
  .sim-panel-head { flex-direction: column; gap: 8px; }
  .sim-history-row { grid-template-columns: minmax(0, 1fr) auto; }
  .sim-history-date { grid-column: 1 / -1; margin-bottom: -7px; }
  .sim-confirm section > div { flex-direction: column; }
  .sim-confirm section button { width: 100%; }
}

@media (max-width: 340px) {
  /* Em 320px, o formato já reaparece no card; a decisão segue acima da barra. */
  .sim-page-head { gap: 0; margin-bottom: 8px; }
  .sim-page-head p { display: none; }
  .sim-stage-main { gap: 9px; padding: 15px 13px var(--app-space-3); }
  .sim-stage h2 { max-width: none; }
  .sim-clock { min-height: 70px; padding: 11px 13px; }
  .sim-page .sim-launch { gap: 8px; margin: 0; padding: 14px 13px; }
  .sim-launch-copy p { display: none; }
  .sim-action-note,
  .sim-storage-warning { margin: 0; padding: 9px 13px 13px; }
  .sim-page .sim-rules { grid-template-columns: 1fr; }
  .sim-page .sim-rules > div:nth-child(n) { border-top: 1px solid var(--sim-line); border-left: 0; }
  .sim-page .sim-rules > div:first-child { border-top: 0; }
  .sim-page .sim-rules > div { grid-template-columns: 31px minmax(0, 1fr); grid-template-rows: auto auto; }
  .sim-rule-icon { grid-row: 1 / 3; }
  .sim-protocol,
  .sim-history { padding: 17px; }
  .sim-history-state { grid-template-columns: 36px minmax(0, 1fr); padding: 14px 0; }
  .sim-state-icon { width: 36px; height: 36px; }
}

/* Em telas baixas, o formato e o resultado já estão explicados na folha.
   Retirar somente essa repetição mantém área + início visíveis, sem reduzir
   o alvo de toque nem esconder instruções do cronômetro. */
@media (max-width: 720px) and (max-height: 740px) {
  .sim-page-head p,
  .sim-launch-copy > span { display: none; }
  .sim-page-head { gap: 0; margin-bottom: 10px; }
  .sim-page-head h1,
  .sim-stage h2 { font-size: var(--esp-type-subhead); line-height: 1.2; }
  .sim-launch-copy label { margin-top: 0; }
}
@media (max-width: 340px) and (max-height: 740px) {
  /* O resultado de 0 a 10 já está no passo "Envie para corrigir" abaixo.
     Não esconder avisos de sessão ativa, expirada ou armazenamento bloqueado. */
  .sim-page[data-sim-state="idle"] .sim-stage-copy > p { display: none; }
}

@media (max-width: 820px) {
  /* Reserva real da barra fixa para navegação por teclado/âncora. */
  html:has(#view-simulados:not([hidden])) {
    scroll-padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .sim-stage,
  .sim-lower-grid { animation: none; }
  .sim-primary-button,
  .sim-primary-button span,
  a.sim-history-row { transition: none; }
  .sim-primary-button:hover { transform: none; }
}

/* Abertura móvel: a sala vira um único instrumento de prova. O título externo
   repetia a mesma promessa do palco e empurrava o início para outra dobra. */
@media (max-width: 720px) {
  #view-simulados .sim-page-head { display: none; }
  #view-simulados .sim-stage {
    overflow: hidden;
    border-color: #25345e;
    border-radius: 19px;
    background: #fff;
    box-shadow: 0 20px 52px -38px rgba(17, 27, 57, .72);
  }
  #view-simulados .sim-stage-main {
    gap: 20px;
    padding: 27px 21px 23px;
    background:
      radial-gradient(360px 260px at 0 0, rgba(99, 123, 231, .28), transparent 72%),
      #182341;
  }
  #view-simulados .sim-stage-copy { max-width: none; }
  #view-simulados .sim-stage-kicker { display: none; }
  #view-simulados .sim-run-chip,
  #view-simulados .sim-run-chip--active {
    color: var(--sim-lime);
    font-size: 10px;
  }
  #view-simulados .sim-run-chip i { background: var(--sim-lime); }
  #view-simulados .sim-stage h2 {
    max-width: 15ch;
    margin: 13px 0 9px;
    color: #fff;
    font-size: clamp(30px, 9.5vw, 39px);
    line-height: .98;
    letter-spacing: -.055em;
  }
  #view-simulados .sim-stage-copy > p {
    max-width: 38ch;
    color: #bcc6df;
    font-size: var(--esp-type-caption);
    line-height: 1.52;
  }
  #view-simulados .sim-clock {
    min-height: 84px;
    padding: 15px 0 0;
    border: 0;
    border-top: 1px solid rgba(199, 209, 239, .16);
    border-radius: 0;
    background: transparent;
  }
  #view-simulados .sim-clock span { color: #8f9dbc; font-size: 9px; }
  #view-simulados .sim-clock b {
    margin-top: 8px;
    color: var(--sim-lime);
    font-size: clamp(25px, 8.2vw, 34px);
    letter-spacing: -.045em;
  }
  #view-simulados .sim-clock small { color: #9ca9c7; }
  #view-simulados .sim-launch {
    gap: 14px;
    padding: 20px;
    border-top: 0;
    background: #fff;
  }
  #view-simulados .sim-launch-copy > span { color: #4058c6; font-size: 9px; }
  #view-simulados .sim-launch-copy label { margin-top: 7px; font-size: var(--esp-type-support); }
  #view-simulados .sim-launch-copy p { margin-top: 5px; font-size: 11px; }
  #view-simulados .sim-launch-actions { gap: 9px; }
  #view-simulados .sim-launch-actions > a {
    justify-self: start;
    color: #405bd7;
    font-size: var(--esp-type-caption);
    font-weight: var(--esp-weight-bold);
  }
  #view-simulados .sim-area-select { min-height: 46px; }
  #view-simulados .sim-primary-button { min-height: 50px; border-radius: 11px; }
  #view-simulados .sim-action-note { padding: 0 20px 18px; background: #fff; font-size: 10px; }
  #view-simulados .sim-rules {
    display: flex;
    overflow-x: auto;
    padding: 0 10px 4px;
    border-top: 1px solid var(--sim-line);
    scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent);
  }
  #view-simulados .sim-rules::-webkit-scrollbar { display: none; }
  #view-simulados .sim-rules > div,
  #view-simulados .sim-rules > div:nth-child(n) {
    grid-template-columns: 28px minmax(132px, 1fr);
    grid-template-rows: auto auto;
    width: 205px;
    flex: 0 0 205px;
    gap: 2px 9px;
    padding: 15px 10px 16px;
    border: 0;
  }
  #view-simulados .sim-rule-icon { grid-row: 1 / 3; width: 28px; height: 28px; }
  #view-simulados .sim-rules b { font-size: 11px; }
  #view-simulados .sim-rules > div > span:last-child { font-size: 10px; line-height: 1.35; }
}

@media (max-width: 340px) and (max-height: 740px) {
  #view-simulados .sim-stage-copy > p { display: block; }
  #view-simulados .sim-launch-copy p { display: block; }
}
