.view { height: 100dvh; display: flex; flex-direction: column; }
.spacer { flex: 1; }

/* ---------- main view: editor + prompter in one ---------- */

#mainView { background: #000; overflow: hidden; position: relative; }

.stage {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.stage::-webkit-scrollbar { display: none; }

.scroller {
  margin: 0 auto;
  padding-top: 33dvh;
  padding-bottom: 80dvh;
  font-weight: 600;
  line-height: 1.5;
  color: #fff;
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  outline: none;
  cursor: text;
  caret-color: var(--accent);
  min-height: 40dvh;
}
/* Current sentence tracks the reading line; the rest dims while playing. */
::highlight(current-sentence) { color: #ffd75e; }
body.playing .scroller { color: rgba(255, 255, 255, 0.65); }
.scroller { transition: color 0.3s; }

.scroller:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  white-space: pre-wrap;
  cursor: text;
}

.reading-line {
  position: absolute;
  top: 33dvh;
  left: 0;
  right: 0;
  pointer-events: none;
  border-top: 2px solid rgba(79, 156, 255, 0.55);
  opacity: 0;
  transition: opacity 0.3s;
}
body.playing .reading-line { opacity: 1; }
.reading-line::before {
  content: "";
  position: absolute;
  left: 8px;
  top: -8px;
  border: 7px solid transparent;
  border-left: 11px solid rgba(79, 156, 255, 0.9);
}

/* ---------- countdown before a take ---------- */

.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22vh;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  z-index: 8;
  pointer-events: none;
  text-shadow: 0 0 40px rgba(79, 156, 255, 0.6);
}

/* ---------- top bar (overlays the stage) ---------- */

.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(rgba(0, 0, 0, 0.92) 55%, transparent);
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 5;
}
.top-bar.faded { opacity: 0; visibility: hidden; }
.top-bar .back {
  font-size: 20px;
  padding: 4px 10px;
  color: var(--muted);
}
.top-bar .back:hover { color: var(--text); text-decoration: none; }
#titleInput {
  max-width: 300px;
  font-weight: 600;
  background: transparent;
  border-color: transparent;
}
#titleInput:hover { border-color: var(--border); }
#titleInput:focus { border-color: var(--accent); background: var(--panel); }
.sync { font-size: 13px; white-space: nowrap; }
.sync.saved { color: #5dbb63; }
.peers { font-size: 13px; white-space: nowrap; }
.wc { font-size: 13px; white-space: nowrap; }

@media (max-width: 640px) {
  .top-bar { flex-wrap: wrap; }
  #titleInput { max-width: none; flex: 1 1 100%; order: 5; }
  .wc { display: none; }
  .top-bar button { font-size: 13px; padding: 8px 10px; }
}

/* ---------- prompter controls ---------- */

.prompter-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.92) 30%);
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 5;
}
.prompter-controls.faded { opacity: 0; visibility: hidden; }
.pc-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.pc-row.transport { justify-content: center; gap: 8px; }
.pc-row.transport button { font-size: 17px; min-width: 52px; }
.pc-row.transport button.big { min-width: 84px; }
.pc-row button.big { font-size: 20px; padding: 10px 26px; }
.pc-row button.active { border-color: var(--accent); color: var(--accent); }
.pc-row.sliders { gap: 18px; }
.pc-row.sliders label {
  flex: 1;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pc-row.sliders label span { color: var(--text); }

@media (max-width: 640px) {
  .pc-row.sliders { flex-direction: column; align-items: stretch; gap: 4px; }
  .pc-row.transport { gap: 6px; }
  .pc-row.transport button { padding: 9px 10px; min-width: 44px; }
  .pc-row.transport button.big { min-width: 64px; }
}

/* Very narrow phones: drop the paragraph jumps from the transport row
   (still on the remote and Shift+arrows) so it can't overflow. */
@media (max-width: 400px) {
  #pcPrevPara, #pcNextPara { display: none; }
  .pc-row.transport { gap: 5px; }
  .pc-row.transport button { min-width: 42px; padding: 9px 8px; }
}

/* ---------- remote ---------- */

#remoteView { background: var(--bg); }

.remote-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.remote-header h1 {
  font-size: 17px;
  margin: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.remote-header .back { font-size: 20px; color: var(--muted); }

.remote-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  max-width: 460px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.progress-wrap {
  height: 14px;
  border-radius: 7px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 7px;
  transition: width 0.25s linear;
}

.rm-play { font-size: 22px; padding: 18px; }
.rm-go { grid-template-columns: 1fr 1fr; }
.rm-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.rm-grid button { padding: 14px 6px; font-size: 14px; }
.rm-grid button.active { border-color: var(--accent); color: var(--accent); }
.rm-jumps { grid-template-columns: repeat(2, 1fr); }
.rm-jumps button { padding: 16px 6px; font-size: 15px; }

.rm-slider {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  color: var(--muted);
  gap: 2px;
}
.rm-slider span { color: var(--text); font-weight: 600; }
.rm-hint { font-size: 13px; text-align: center; margin: 4px 0 0; }

/* Narrow phones: the remote is the primary phone surface — keep every
   control comfortably tappable without overflowing the viewport. */
@media (max-width: 480px) {
  .remote-body {
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
    gap: 14px;
  }
  .rm-play { font-size: 18px; padding: 15px 6px; }
  .rm-grid { gap: 8px; }
  .rm-grid button { font-size: 13px; padding: 13px 4px; }
  .rm-jumps button { font-size: 14px; padding: 15px 4px; }
}

/* ---------- connection banner ---------- */

.conn-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #6b3d00;
  color: #ffd9a0;
  border: 1px solid #a86500;
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 13px;
  z-index: 100;
}
