*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Arial', sans-serif;
  background: #111;
  color: #fff;
  height: 100dvh;
  overflow: hidden;
}

/* ── Editor View ── */
#editor-view {
  display: flex;
  height: 100dvh;
}

/* ── Script Library (left panel) ── */
#script-library {
  width: 220px;
  min-width: 180px;
  background: #0d0d0d;
  border-right: 1px solid #222;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 12px;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}

.library-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #555;
}

#btn-new-script {
  background: #1e1e1e;
  border: 1px solid #333;
  color: #4f8ef7;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
#btn-new-script:hover { background: #2a2a2a; }

#script-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
#script-list::-webkit-scrollbar { width: 4px; }
#script-list::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.script-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.script-item:hover { background: #181818; }
.script-item.active {
  background: #181818;
  border-left-color: #4f8ef7;
}

.script-item-name {
  flex: 1;
  font-size: 0.88rem;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.script-item.active .script-item-name { color: #fff; }

.script-item-del {
  background: none;
  border: none;
  color: #444;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}
.script-item:hover .script-item-del { opacity: 1; }
.script-item-del:hover { color: #e06060; }

/* ── Editor Panel (right) ── */
#editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 14px;
  min-width: 0;
}

.editor-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

#script-title-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid #2a2a2a;
  color: #eee;
  font-size: 1.15rem;
  font-weight: 600;
  padding: 4px 2px;
  outline: none;
  transition: border-color 0.2s;
}
#script-title-input:focus { border-bottom-color: #4f8ef7; }
#script-title-input::placeholder { color: #333; }

#btn-delete-script {
  background: none;
  border: none;
  color: #444;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
#btn-delete-script:hover { color: #e06060; background: #1e1212; }

.text-area-wrapper {
  flex: 1;
  display: flex;
}

#script-input {
  width: 100%;
  resize: none;
  background: #1c1c1c;
  color: #f0f0f0;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 20px;
  font-size: 1.1rem;
  line-height: 1.7;
  outline: none;
  transition: border-color 0.2s;
}
#script-input:focus { border-color: #555; }

.editor-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding-bottom: 4px;
}

.btn {
  padding: 12px 36px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #4f8ef7; color: #fff; }
.btn-primary:hover { opacity: 0.88; }
.btn-secondary { background: #2c2c2c; color: #ccc; border: 1px solid #444; }
.btn-secondary:hover { background: #383838; }

/* ── Settings Modal ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal.hidden { display: none; }

.modal-box {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 14px;
  padding: 28px;
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-box h2 { font-size: 1.2rem; color: #eee; }

.modal-box label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9rem;
  color: #aaa;
}

.modal-box input[type="range"] { accent-color: #4f8ef7; cursor: pointer; }
.modal-box select {
  background: #2c2c2c; color: #eee; border: 1px solid #444;
  border-radius: 6px; padding: 6px 10px; font-size: 1rem;
}

.colour-modes {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.colour-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  outline: 3px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s;
}
.colour-btn.active { outline-color: #4f8ef7; }

.custom-colours {
  display: flex;
  gap: 16px;
}
.colour-custom-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: #aaa;
  flex: 1;
}
.colour-custom-label input[type="color"] {
  width: 100%;
  height: 38px;
  border: 1px solid #444;
  border-radius: 8px;
  background: #2c2c2c;
  cursor: pointer;
  padding: 2px 4px;
}

/* ── Prompter View ── */
#prompter-view {
  position: fixed; inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#prompter-view.hidden { display: none; }

#prompter-scroll-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

#prompter-text {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(900px, 90vw);
  text-align: center;
  padding: 0;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  will-change: transform;
}

/* ── Countdown overlay ── */
#countdown-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  pointer-events: none;
}
#countdown-overlay.hidden { display: none; }

#countdown-num {
  font-size: min(40vw, 40vh);
  font-weight: 900;
  line-height: 1;
  color: rgba(255,255,255,0.18);
  animation: countPulse 1s ease-out forwards;
}

@keyframes countPulse {
  0%   { transform: scale(1.5); opacity: 0.9; }
  100% { transform: scale(0.7); opacity: 0;   }
}

/* ── Back button ── */
#btn-back {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 110;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
  opacity: 0.25;
  transition: opacity 0.3s;
}
#btn-back:hover { opacity: 1; }

/* scroll hint cursor on container when paused */
#prompter-scroll-container.paused { cursor: ns-resize; }

/* ── Prompter Controls ── */
#prompter-controls {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  z-index: 100;
  opacity: 0.2;
  transition: opacity 0.3s;
}
#prompter-controls:hover { opacity: 1; }

.ctrl-btn {
  padding: 10px 20px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
}
.ctrl-btn:hover { background: rgba(255,255,255,0.25); }
