:root {
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-2: rgba(255, 255, 255, 0.08);
  --text: #e7ecff;
  --muted: rgba(231, 236, 255, 0.7);
  --border: rgba(255, 255, 255, 0.14);
  --primary: #7c5cff;
  --danger: #ff4d6d;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(1200px 800px at 20% 10%, rgba(124, 92, 255, 0.22), transparent 60%),
    radial-gradient(1000px 700px at 80% 20%, rgba(255, 77, 109, 0.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
}

/* Fullscreen play mode */
body.is-playing {
  overflow: hidden;
}

body.is-playing .sidebar,
body.is-playing .editor {
  display: none;
}

body.is-playing .app {
  grid-template-columns: 1fr;
}

body.is-playing .main {
  padding: 0;
  gap: 0;
}

body.is-playing .prompter {
  position: fixed;
  inset: 0;
  z-index: 1000;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  border-bottom: none;
  /* Put toolbar at bottom while playing */
  grid-template-rows: 1fr auto;
}

body.is-playing .prompter__body {
  grid-row: 1;
  grid-template-columns: 1fr;
}

body.is-playing .prompter__toolbar {
  grid-row: 2;
  border-bottom: none;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

body.is-playing .prompter__viewport {
  /* Don't reserve extra top space for the focus marker */
  padding: 32px 80px;
}

body.is-playing .status {
  position: fixed;
  left: 14px;
  /* Keep clear of bottom controls (Play/Pause/Stop) */
  bottom: 112px;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  backdrop-filter: blur(10px);
}

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar__title {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.sidebar__user-name {
  font-size: 12px;
  color: var(--muted);
}

.hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* Login overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
}

.login-overlay.is-open {
  display: flex;
}

.login-card {
  width: min(520px, 100%);
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(10, 14, 28, 0.88);
  box-shadow: var(--shadow);
  padding: 16px;
}

.login-title {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.login-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.text-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.text-item {
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.text-item:hover {
  background: var(--panel-2);
}

.text-item[aria-current="true"] {
  border-color: rgba(124, 92, 255, 0.7);
  background: rgba(124, 92, 255, 0.18);
}

.text-item__title {
  font-weight: 650;
  font-size: 14px;
  margin-bottom: 4px;
}

.text-item__meta {
  font-size: 12px;
  color: var(--muted);
}

.main {
  padding: 16px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  min-width: 0;
}

.editor {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.editor__row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.editor__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.field {
  flex: 1;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field__label {
  font-size: 12px;
  color: var(--muted);
}

.input,
.textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

.select {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

.select:focus {
  border-color: rgba(124, 92, 255, 0.85);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.2);
}

.textarea {
  min-height: 120px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  line-height: 1.45;
}

.input:focus,
.textarea:focus {
  border-color: rgba(124, 92, 255, 0.85);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.2);
}

.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
}

.btn--sm {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

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

.btn--primary {
  border-color: rgba(124, 92, 255, 0.75);
  background: rgba(124, 92, 255, 0.22);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.badge--controller {
  border-color: rgba(124, 92, 255, 0.75);
  background: rgba(124, 92, 255, 0.18);
  color: rgba(231, 236, 255, 0.92);
}

.btn--danger {
  border-color: rgba(255, 77, 109, 0.7);
  background: rgba(255, 77, 109, 0.16);
}

.btn--ghost {
  background: transparent;
}

.prompter {
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.prompter__toolbar {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.inline-field input[type="range"] {
  width: 180px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: var(--text);
  opacity: 0.85;
}

.prompter__body {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  height: 100%;
}

.prompter__viewport-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.focus-marker {
  display: none; /* only in play mode */
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  width: 0;
  height: 0;
  border-left: 22px solid transparent;
  border-right: 22px solid transparent;
  border-top: 28px solid rgba(124, 92, 255, 0.95);
  filter: drop-shadow(0 10px 18px rgba(124, 92, 255, 0.25)) drop-shadow(0 2px 10px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}

body.is-playing .focus-marker {
  display: block;
}

.prompter__viewport {
  height: 100%;
  max-height: 100%;
  overflow: auto;
  scroll-behavior: auto;
  padding: 32px 34px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.16));
}

.prompter__text {
  white-space: pre-wrap;
  line-height: 1.55;
  font-weight: 600;
  font-size: 38px; /* JS updates this */
  color: rgba(231, 236, 255, 0.94);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  max-width: var(--tele-text-width, 100%);
  margin-left: auto;
  margin-right: auto;
  /* Extra blank runway before wrap-to-top */
  padding-bottom: 1000px;
}

.countdown {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}

.countdown.is-active {
  display: flex;
}

.countdown__value {
  font-weight: 900;
  font-size: clamp(96px, 18vw, 240px);
  line-height: 1;
  letter-spacing: -0.02em;
  color: rgba(231, 236, 255, 0.96);
  text-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  transform: scale(0.9);
  opacity: 0;
}

.countdown__value.is-pop {
  animation: countdown-pop 650ms ease-out both;
}

@keyframes countdown-pop {
  0% {
    transform: scale(0.75);
    opacity: 0;
    filter: blur(2px);
  }
  35% {
    transform: scale(1.05);
    opacity: 1;
    filter: blur(0px);
  }
  100% {
    transform: scale(1);
    opacity: 0.9;
  }
}


.status {
  padding: 6px 2px;
}

.status__text {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 260px 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .prompter__body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .prompter__viewport-wrap {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

