.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  font-family: Arial, sans-serif;
}

.footer-credit {
  background: #151719;
  color: #7289da;
  text-align: center;
  padding: 5px 0;
  font-size: 12px;
  font-weight: bold;
  border-top: 2px solid #7289da;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

.controls {
  padding: 10px;
  display: flex;
  gap: 10px;
  background: #23272a;
  color: #fff;
  border-bottom: 1px solid #555;
}

.controls input,
.controls button {
  padding: 5px 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.controls button {
  background: #7289da;
  color: white;
}

.controls button:hover {
  background: #5a6eb5;
}

.workspace {
  display: grid;
  flex: 1;
  overflow: hidden;
  background: #1e2124;
  grid-template-areas:
    "editor video"
    "timeline timeline";
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 200px;
  /* Altura inicial da timeline */
  position: relative;
}

.workspace.layout-916 {
  grid-template-areas:
    "editor video"
    "timeline video";
  grid-template-columns: 1fr 350px;
  grid-template-rows: 1fr 200px;
}

.preview {
  grid-area: editor;
  padding: 20px;
  background: #f9f9f9;
  border-right: 1px solid #ddd;
  border-bottom: 1px solid #ccc;
  overflow-y: auto;
}

.video-preview {
  grid-area: video;
  background: #000;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.video-preview video {
  max-width: 100%;
  max-height: 100%;
}

.timeline-container {
  grid-area: timeline;
  overflow-x: auto;
  overflow-y: hidden;
  background: #1e2124;
  padding: 10px 20px;
  border-top: 2px solid #333;
}

/* --- Resizers --- */
.resizer-h {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12px;
  cursor: ew-resize;
  background: transparent;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 14px;
  user-select: none;
  transition: color 0.2s;
}

.resizer-h::after {
  content: "";
  width: 2px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  transition: background 0.2s, height 0.2s;
}

.resizer-h:hover::after,
.resizer-h.active::after {
  background: #7289da;
  height: 100%;
}

.resizer-h:hover {
  color: #fff;
}

.resizer-v {
  position: absolute;
  left: 0;
  right: 0;
  height: 12px;
  cursor: ns-resize;
  background: transparent;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 14px;
  user-select: none;
  transition: color 0.2s;
}

.resizer-v::after {
  content: "";
  height: 2px;
  width: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  transition: background 0.2s, width 0.2s;
}

.resizer-v:hover::after,
.resizer-v.active::after {
  background: #7289da;
  width: 100%;
}

.resizer-v:hover {
  color: #fff;
}

.video-preview video {
  max-width: 100%;
  max-height: 100%;
}

.video-placeholder {
  color: #fff;
  text-align: center;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.subtitle-text {
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 16px;
  text-align: center;
  max-width: 80%;
  word-wrap: break-word;
}

.subtitle-overlay {
  position: absolute;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 16px;
  text-align: center;
  max-width: 80%;
  word-wrap: break-word;
}

.timeline-container {
  flex: 1;
  min-height: 150px;
  overflow-x: auto;
  overflow-y: hidden;
  background: #1e2124;
  padding: 10px 20px;
}

.timeline-frame {
  position: relative;
  height: 260px;
  background: #2c2f33;
}

.timeline-ruler {
  height: 15px;
  background: #23272a;
  border-bottom: 1px solid #555;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  overflow: hidden;
}

.waveform-canvas {
  position: absolute;
  top: 15px;
  left: 0;
  height: 60px;
  background: rgba(35, 39, 42, 0.5);
  border-bottom: 1px solid #555;
  pointer-events: none;
  z-index: 5;
}

.timeline-content {
  height: calc(260px - 75px);
  position: absolute;
  top: 75px;
  left: 0;
  right: 0;
}

.time-marker {
  position: absolute;
  top: 1px;
  height: 13px;
  border-left: 1px solid #555;
  font-size: 10px;
  color: #fff;
  text-align: center;
  transform: translateX(-50%);
}

.cursor {
  position: absolute;
  top: -15px;
  width: 2px;
  height: 275px;
  background: #ff4444;
  z-index: 10;
  cursor: ew-resize;
}

.cursor-head {
  width: 10px;
  height: 10px;
  background: #ff4444;
  border-radius: 50%;
  position: absolute;
  top: -5px;
  left: -4px;
}

.subtitle-block {
  position: absolute;
  height: 40px;
  background: #7289da;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  user-select: none;
}

.subtitle-block.selected {
  border: 2px solid #ffffff;
}

.drag-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: move;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 10px;
}

.resize-handle {
  width: 6px;
  height: 100%;
  background: #4e5d94;
  cursor: ew-resize;
  position: absolute;
  top: 0;
  transition: background 0.2s;
}

.resize-handle:hover {
  background: #99aab5;
}

.resize-handle.left {
  left: 0;
}

.resize-handle.right {
  right: 0;
}

.context-menu {
  position: absolute;
  background: #23272a;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 5px 0;
  z-index: 100;
}

.context-menu div {
  padding: 5px 10px;
  color: #fff;
  cursor: pointer;
}

.context-menu div:hover {
  background: #7289da;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code {
  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
    monospace;
}

/* --- Estilos para Edição de Palavras (Adicionados) --- */

.subtitle-block .drag-area {
  width: 100%;
  height: 100%;
}

.word-container {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: flex-start;
}

.word {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0 5px;
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
  /* Borda sutil que servirá como o separador visual */
  border-right: 1px solid rgba(255, 255, 255, 0.3);
}

/* O último 'word' não precisa de uma borda à direita */
.word:last-child {
  border-right: none;
}

.word-handle {
  position: absolute;
  top: 0;
  right: -3px;
  /* Centralizado sobre a borda */
  bottom: 0;
  width: 6px;
  /* Área de clique maior */
  cursor: ew-resize;
  z-index: 15;
  /* Acima do bloco, mas abaixo do cursor principal */
  /* background: rgba(255,0,0,0.2); */
  /* Descomente para depurar a área de clique */
}

.plain-text {
  padding: 0 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.char-container {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: flex-start;
}

.char {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
  white-space: pre;
  /* Importante para renderizar o caractere de espaço */
  font-size: 14px;
  font-weight: bold;
  color: #fff;
  /* Borda para ver os limites, mesmo para espaços em branco */
  border-right: 1px dotted rgba(255, 255, 255, 0.4);
}

.char:last-child {
  border-right: none;
}

/* O handle do caractere é idêntico ao da palavra */
.char-handle {
  position: absolute;
  top: 0;
  right: -3px;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
  z-index: 16;
  /* Acima do handle da palavra */
}

/* --- Estilos para Camadas (Tracks) --- */
.track-bg {
  position: absolute;
  left: 0;
  right: 0;
  border-bottom: 1px solid #444;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: background 0.2s;
}

.track-bg:hover {
  background: rgba(255, 255, 255, 0.05);
}

.track-bg.active {
  background: rgba(114, 137, 218, 0.1);
  border-left: 4px solid #7289da;
}

.track-label {
  position: sticky;
  left: 0;
  padding: 4px 12px;
  background: rgba(35, 39, 42, 0.9);
  color: #bbb;
  font-size: 11px;
  font-weight: bold;
  border-bottom-right-radius: 6px;
  border-right: 1px solid #444;
  z-index: 15;
  /* Acima dos blocos mas abaixo do cursor */
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3);
}

.track-label::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #444;
  /* Inativo */
  transition: background 0.3s, box-shadow 0.3s;
}

.track-bg.active {
  background: rgba(114, 137, 218, 0.15);
  border-left: 4px solid #7289da;
}

.track-bg.active .track-label {
  background: #7289da;
  color: #fff;
}

.track-bg.active .track-label::before {
  background: #fff;
  /* Bolinha branca quando a tarja é azul */
  box-shadow: 0 0 8px #fff;
}

.subtitle-block {
  z-index: 7;
}

.cursor {
  z-index: 20;
}

/* --- Modais --- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: #2f3136;
  width: 400px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: white;
  padding: 0;
  overflow: hidden;
  animation: modalAppear 0.3s ease-out;
}

@keyframes modalAppear {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content h3 {
  margin: 0;
  padding: 15px 20px;
  background: #202225;
  font-size: 18px;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-group label {
  font-size: 13px;
  color: #b9bbbe;
}

.option-group select {
  background: #202225;
  color: white;
  border: 1px solid #444;
  padding: 8px;
  border-radius: 4px;
  outline: none;
}

.modal-footer {
  padding: 15px 20px;
  background: #2f3136;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid #444;
}

.btn-primary {
  background: #5865f2;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

.btn-primary:hover {
  background: #4752c4;
}

.btn-secondary {
  background: transparent;
  color: white;
  border: 1px solid #444;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Garante que modais começam escondidos */
.modal {
  display: none;
}

/* Destaque para texto encontrado na busca */
.search-highlight {
  background-color: yellow;
  color: black;
  font-weight: bold;
  padding: 2px 0;
}