/* Studio Simulado — Design System Studio Apps V5 (85/15 Acromático + Pistachio #D9F99D) */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--kf-surface-canvas);
  color: var(--kf-text-primary);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Scrollbars finas <= 3px (Lei 8 / AC-UI-003) */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--kf-border-focus) transparent;
}
*::-webkit-scrollbar { width: 3px; height: 3px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--kf-border-focus); border-radius: 3px; }

/* Cabeçalho fixo 56px flex-nowrap */
.kf-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 56px;
  min-height: 56px;
  padding: 0 14px;
  background: var(--kf-surface-card);
  border-bottom: 0.8px solid var(--kf-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
}

.kf-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  cursor: pointer;
  user-select: none;
}

.kf-squircle {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 8px;
  background: var(--kf-app-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--kf-brand-ink);
  border: 0.8px solid rgba(17, 24, 39, 0.12);
}

.kf-brand-name {
  font-size: 15px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--kf-text-primary);
}
.kf-brand-name strong { font-weight: 900; }
.kf-brand-name span { font-weight: 300; margin-left: 3px; }

.kf-nav-desktop {
  display: flex;
  align-items: stretch;
  height: 56px;
  gap: 4px;
  overflow-x: auto;
}

.kf-tab {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0 12px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--kf-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.kf-tab:hover { color: var(--kf-text-primary); }
.kf-tab.active {
  color: var(--kf-text-primary);
  font-weight: 600;
  border-bottom-color: var(--kf-app-brand);
}

.kf-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 0.8px solid var(--kf-border-subtle);
  background: var(--kf-surface-card);
  color: var(--kf-text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.icon-btn:hover {
  border-color: var(--kf-app-brand);
  background: var(--kf-surface-subtle);
}

/* Botões padrão Studio Apps */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  border: 0.8px solid var(--kf-border-subtle);
  background: var(--kf-surface-card);
  color: var(--kf-text-primary);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
a.btn { text-decoration: none; }
.btn:hover {
  border-color: var(--kf-app-brand);
  background: var(--kf-surface-subtle);
}
.btn-sm { height: 28px; padding: 0 9px; font-size: 12px; }

.btn-primary {
  background: var(--kf-border-strong);
  border-color: var(--kf-border-strong);
  color: var(--kf-surface-card);
}
.btn-primary:hover {
  background: var(--kf-app-brand);
  border-color: var(--kf-app-brand);
  color: var(--kf-brand-ink);
}

.btn-danger {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--kf-status-crit);
}
.btn-danger:hover {
  background: var(--kf-status-crit);
  border-color: var(--kf-status-crit);
  color: #FFFFFF;
}

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

/* Área principal em 100dvh */
.kf-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px 16px 10px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

.kf-view {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.kf-view.active { display: flex; }

.kf-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

/* Toolbar compacta */
.kf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.kf-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Cards 85/15 (4 bordas simétricas 0.8px, zero border-left espessa) */
.kf-card {
  background: var(--kf-surface-card);
  border: 0.8px solid var(--kf-border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  transition: border-color 0.18s ease;
}
.kf-card-hover:hover { border-color: var(--kf-app-brand); }

.kf-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  flex-shrink: 0;
}
.kf-kpi {
  background: var(--kf-surface-card);
  border: 0.8px solid var(--kf-border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
}
.kf-kpi-label {
  font-size: 11px;
  color: var(--kf-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.kf-kpi-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--kf-text-primary);
  margin-top: 2px;
  letter-spacing: -0.02em;
}
.kf-kpi-sub {
  font-size: 11.5px;
  color: var(--kf-text-secondary);
  margin-top: 2px;
}
.brand-text { color: var(--kf-app-brand-text); font-weight: 600; }

/* Grid de Simulados & Caderno de Erros com altura fixa (AC-PAG-001) */
.kf-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 10px;
  align-content: start;
}

.kf-fixed-card {
  height: 158px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.kf-error-card {
  height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.kf-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--kf-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kf-card-meta {
  font-size: 11.5px;
  color: var(--kf-text-secondary);
  margin-top: 3px;
}
.kf-card-clamp {
  font-size: 12px;
  color: var(--kf-text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Badges semânticos */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  border: 0.8px solid var(--kf-border-subtle);
  background: var(--kf-surface-subtle);
  color: var(--kf-text-secondary);
}
.badge-ok {
  background: rgba(16, 185, 129, 0.09);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.22);
}
.badge-warn {
  background: rgba(245, 158, 11, 0.09);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.22);
}
.badge-crit {
  background: rgba(239, 68, 68, 0.09);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.22);
}
.badge-brand {
  background: var(--kf-app-brand);
  color: var(--kf-brand-ink);
  border-color: rgba(17, 24, 39, 0.14);
}

/* Inputs e formulários */
.kf-input, .kf-select, .kf-textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 0.8px solid var(--kf-border-subtle);
  background: var(--kf-surface-subtle);
  color: var(--kf-text-primary);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s ease;
}
.kf-textarea { height: auto; padding: 8px 10px; resize: vertical; }
.kf-select { overflow: hidden; text-overflow: ellipsis; }
.kf-input:focus, .kf-select:focus, .kf-textarea:focus {
  border-color: var(--kf-app-brand);
  background: var(--kf-surface-card);
}
.kf-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--kf-text-secondary);
  margin-bottom: 4px;
}

/* Campo de senha com olho (AC-UI-003) */
.kf-pass-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.kf-pass-wrap .kf-input { padding-right: 34px; }
.kfw-eye {
  position: absolute;
  right: 4px;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--kf-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
}
.kfw-eye:hover { color: var(--kf-text-primary); background: var(--kf-surface-hover); }

/* Layout 2 colunas (Prova, OMR, Lab TRI) */
.kf-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.95fr);
  gap: 12px;
  overflow: hidden;
}

.kf-panel {
  background: var(--kf-surface-card);
  border: 0.8px solid var(--kf-border-subtle);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Alternativas da Prova */
.alt-list { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.alt-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.alt-btn {
  flex: 1;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  border: 0.8px solid var(--kf-border-subtle);
  background: var(--kf-surface-card);
  color: var(--kf-text-primary);
  cursor: pointer;
  font-size: 12.5px;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.alt-btn:hover { border-color: var(--kf-app-brand); background: var(--kf-surface-subtle); }
.alt-btn.selected {
  background: var(--kf-app-brand);
  border-color: var(--kf-brand-ink);
  color: var(--kf-brand-ink);
  font-weight: 600;
}
.alt-btn.struck {
  opacity: 0.45;
  text-decoration: line-through;
}
.alt-letter {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 999px;
  border: 0.8px solid var(--kf-border-focus);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
}
.alt-btn.selected .alt-letter {
  background: var(--kf-brand-ink);
  color: var(--kf-app-brand);
  border-color: var(--kf-brand-ink);
}

/* Mapa de Questões */
.q-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.q-pill {
  height: 32px;
  border-radius: 6px;
  border: 0.8px solid var(--kf-border-subtle);
  background: var(--kf-surface-subtle);
  color: var(--kf-text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
}
.q-pill.current { border-color: var(--kf-border-strong); box-shadow: 0 0 0 1.5px var(--kf-app-brand); }
.q-pill.answered { background: var(--kf-app-brand); color: var(--kf-brand-ink); border-color: rgba(17, 24, 39, 0.2); }
.q-pill.flagged::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--kf-status-warn);
}

/* OMR Canvas Stage */
.omr-stage {
  position: relative;
  flex: 1;
  min-height: 220px;
  background: var(--kf-surface-subtle);
  border: 0.8px solid var(--kf-border-subtle);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.omr-stage canvas, .omr-stage video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* Paginação */
.kf-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 0.8px solid var(--kf-border-subtle);
  flex-shrink: 0;
  font-size: 12px;
  color: var(--kf-text-secondary);
}

/* Rodapé ancorado na base */
.kf-footer {
  height: 32px;
  min-height: 32px;
  padding: 0 16px;
  background: var(--kf-surface-card);
  border-top: 0.8px solid var(--kf-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--kf-text-tertiary);
  flex-shrink: 0;
}

/* Barra inferior mobile */
.kf-nav-mobile {
  display: none;
  background: var(--kf-surface-card);
  border-top: 0.8px solid var(--kf-border-subtle);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  justify-content: space-around;
  flex-shrink: 0;
}
.kf-mob-tab {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--kf-text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 56px;
  min-height: 42px;
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
}
.kf-mob-tab.active { color: var(--kf-app-brand-text); font-weight: 700; }

/* Gaveta lateral 440px */
.kf-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(9, 9, 11, 0.55);
  backdrop-filter: blur(2px);
  display: none;
  justify-content: flex-end;
}
.kf-drawer-backdrop.open { display: flex; }
.kf-drawer {
  width: 440px;
  max-width: 100vw;
  height: 100%;
  background: var(--kf-surface-card);
  border-left: 0.8px solid var(--kf-border-subtle);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

/* Modal proprietário (AC-MODAL-001) */
.kf-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(9, 9, 11, 0.55);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.kf-modal-backdrop.open { display: flex; }
.kf-modal {
  background: var(--kf-surface-card);
  border: 0.8px solid var(--kf-border-subtle);
  border-radius: 10px;
  width: 560px;
  max-width: 92vw;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.kf-modal-lg { width: 720px; }
.kf-modal-head {
  padding: 12px 16px;
  border-bottom: 0.8px solid var(--kf-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 14px;
}
.kf-modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  scrollbar-width: none;
}
.kf-modal-body::-webkit-scrollbar { display: none; }
.kf-modal-foot {
  padding: 10px 16px;
  border-top: 0.8px solid var(--kf-border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast (4 bordas simétricas 0.8px, zero border-left espessa) */
.kf-toast-stack {
  position: fixed;
  right: 16px;
  bottom: 42px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.kf-toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  background: var(--kf-surface-card);
  border: 0.8px solid var(--kf-border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--kf-text-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Lab TRI Simulator pills */
.sim-bubble-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  border: 0.8px solid var(--kf-border-subtle);
  background: var(--kf-surface-subtle);
  gap: 8px;
}
.sim-toggle {
  width: 58px;
  height: 24px;
  border-radius: 5px;
  border: 0.8px solid var(--kf-border-subtle);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.sim-toggle.hit { background: var(--kf-app-brand); color: var(--kf-brand-ink); border-color: rgba(17, 24, 39, 0.25); }
.sim-toggle.miss { background: var(--kf-surface-card); color: var(--kf-text-tertiary); }

/* Tabela compacta */
.kf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.kf-table th, .kf-table td {
  padding: 6px 8px;
  border-bottom: 0.8px solid var(--kf-border-subtle);
  text-align: left;
}
.kf-table th {
  background: var(--kf-surface-subtle);
  font-weight: 600;
  color: var(--kf-text-secondary);
}

@media (max-width: 767px) {
  .kf-nav-desktop { display: none; }
  .kf-nav-mobile { display: flex; }
  .kf-footer { display: none; }
  .icon-btn { width: 40px; height: 40px; }
  .kf-input, .kf-select, .kf-textarea { font-size: 16px; height: 38px; }
  .kf-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kf-split { grid-template-columns: 1fr; overflow-y: auto; }
  .kf-panel { overflow: visible; }
  .kf-toast-stack { top: 62px; bottom: auto; right: 10px; left: 10px; }
  .kf-toast { max-width: 100%; }
}

/* v5.2.0 — Matriz de Confiança, Radar de Ritmo Anti-Trava & Mapa de Calor */
.conf-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 0.8px solid var(--kf-border-subtle);
  flex-wrap: wrap;
}
.conf-pill {
  height: 26px;
  padding: 0 9px;
  border-radius: 5px;
  border: 0.8px solid var(--kf-border-subtle);
  background: var(--kf-surface-subtle);
  color: var(--kf-text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.conf-pill.active-certain { background: rgba(16, 185, 129, 0.14); color: #059669; border-color: rgba(16, 185, 129, 0.4); }
.conf-pill.active-doubt   { background: rgba(245, 158, 11, 0.14); color: #d97706; border-color: rgba(245, 158, 11, 0.4); }
.conf-pill.active-guess   { background: rgba(239, 68, 68, 0.14); color: #dc2626; border-color: rgba(239, 68, 68, 0.4); }

.pace-track {
  height: 5px;
  width: 100%;
  background: var(--kf-surface-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
.pace-fill { height: 100%; transition: width 0.4s ease, background 0.25s ease; }

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.heat-cell {
  padding: 7px 9px;
  border-radius: 6px;
  border: 0.8px solid var(--kf-border-subtle);
  background: var(--kf-surface-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
}
