* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: #05070d;
}

body {
  margin: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  color: #f8fafc;
  background:
    radial-gradient(circle at top left, rgba(18, 132, 255, 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(255, 112, 24, 0.13), transparent 32%),
    #05070d;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  border: 0;
}

/* DISPLAY */
.display-page {
  min-height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.display-shell {
  width: min(92vw, 1400px);
  margin: 0 auto;
}

.display-script {
  white-space: pre-wrap;
  line-height: 1.28;
  font-weight: 760;
  text-align: center;
  letter-spacing: -0.025em;
  color: #ffffff;
  text-shadow: 0 5px 34px rgba(0, 0, 0, 0.82);
  will-change: font-size;
}

.center-guide,
.preview-center-guide {
  position: fixed;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 10;
  height: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 138, 0, 0.12), rgba(255, 138, 0, 0.84), rgba(255, 138, 0, 0.12), transparent);
  box-shadow: 0 0 18px rgba(255, 138, 0, 0.36);
}

.display-info-btn {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 40;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(12, 18, 30, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  backdrop-filter: blur(16px);
}

.display-info-panel {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(12px);
}

.display-info-panel[hidden] {
  display: none;
}

.info-card {
  position: relative;
  width: min(360px, 100%);
  padding: 24px;
  border-radius: 24px;
  background: rgba(12, 18, 30, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
  text-align: center;
}

.info-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.info-card p {
  margin: 0 0 16px;
  color: #a8b3c7;
}

.close-info {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}

.qr-box {
  display: inline-block;
  padding: 12px;
  border-radius: 18px;
  background: #fff;
}

.hint {
  margin-top: 14px !important;
  font-size: 14px;
}

/* REMOTE */
.remote-page {
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

.remote-app {
  height: 100dvh;
  max-height: 100dvh;
  display: grid;
  grid-template-rows: minmax(145px, 34dvh) auto auto auto auto auto;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.remote-preview-row {
  min-height: 0;
}

.preview-box {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 150px;
  overflow: hidden;
  border-radius: 18px;
  background: #05070d;
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  touch-action: none;
  cursor: grab;
}

.preview-box.dragging {
  cursor: grabbing;
}

.preview-center-guide {
  position: absolute;
  z-index: 5;
}

.preview-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  overflow: hidden;
  transform-origin: center center;
  background:
    radial-gradient(circle at top left, rgba(18, 132, 255, 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(255, 112, 24, 0.13), transparent 32%),
    #05070d;
}

.preview-script {
  white-space: pre-wrap;
  line-height: 1.28;
  font-weight: 760;
  text-align: center;
  letter-spacing: -0.025em;
  color: #fff;
  text-shadow: 0 5px 34px rgba(0, 0, 0, 0.82);
  will-change: transform, font-size;
}

.remote-slider-row,
.remote-options-row {
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: #dbe5f4;
  font-size: 13px;
  font-weight: 800;
}

.slider-head strong {
  color: #ffb668;
}

input[type="range"] {
  display: block;
  width: 100%;
  height: 26px;
  margin: 0;
  accent-color: #ff8a00;
}

.remote-buttons-row {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 10px;
}

.nav-btn,
.play-btn,
.small-btn,
.primary-small,
.editor-actions button {
  min-height: 48px;
  border-radius: 16px;
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.play-btn,
.primary-small {
  background: linear-gradient(135deg, #ff922b, #ff3d00);
  box-shadow: 0 10px 26px rgba(255, 94, 0, 0.22);
}

.nav-btn.active-dir {
  outline: 2px solid rgba(255, 138, 0, 0.9);
  background: rgba(255, 138, 0, 0.22);
}

.remote-options-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
}

.select-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #dbe5f4;
  font-size: 13px;
  font-weight: 800;
  min-width: 0;
}

.select-pill select {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  outline: none;
}

.small-btn {
  min-height: 38px;
  padding: 0 14px;
}

.editor-dialog {
  width: min(680px, calc(100vw - 22px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: #fff;
  background: transparent;
}

.editor-dialog::backdrop {
  background: rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(10px);
}

.editor-card {
  padding: 18px;
  background: #0b1120;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.editor-card h2 {
  margin: 0 0 12px;
}

.editor-card textarea {
  width: 100%;
  resize: vertical;
  min-height: 280px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  outline: none;
  font-size: 16px;
  line-height: 1.5;
  user-select: text;
  -webkit-user-select: text;
}

.editor-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.missing {
  display: grid;
  place-items: center;
  text-align: center;
}

@media (max-height: 700px) {
  .remote-app {
    grid-template-rows: minmax(112px, 29dvh) auto auto auto auto auto;
    gap: 7px;
    padding: 7px;
  }

  .remote-slider-row,
  .remote-options-row {
    padding: 7px 10px;
  }

  .nav-btn,
  .play-btn {
    min-height: 42px;
  }

  .small-btn {
    min-height: 34px;
  }
}

/* DISPLAY FLOATING PANELS */
.display-float-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 45;
  display: grid;
  gap: 10px;
}

.display-float-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(12, 18, 30, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
}

.display-info-btn {
  position: static;
}

.display-pop-panel {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(12px);
}

.display-pop-panel[hidden] {
  display: none;
}

.display-pop-card {
  position: relative;
  width: min(560px, 100%);
  padding: 22px;
  border-radius: 24px;
  background: rgba(12, 18, 30, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
}

.display-pop-card h2 {
  margin: 0 0 16px;
  font-size: 22px;
}

.display-control-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
  margin-bottom: 16px;
  color: #dbe5f4;
  font-weight: 800;
}

.display-control-row input {
  grid-column: 1 / -1;
}

.display-control-row strong,
.autosave-status {
  color: #ffb668;
}

.display-button-row {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.display-step-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #dbe5f4;
  font-weight: 800;
}

.display-step-row select {
  flex: 1;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  outline: none;
}

.display-edit-card {
  width: min(820px, 100%);
}

.display-edit-card textarea {
  width: 100%;
  min-height: min(56vh, 520px);
  resize: vertical;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  outline: none;
  font-size: 18px;
  line-height: 1.5;
}

.autosave-status {
  margin: -6px 0 12px;
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 640px) {
  .display-pop-card {
    padding: 18px;
  }

  .display-button-row {
    grid-template-columns: 1fr;
  }
}


.script-paragraph {
  margin: 0 0 1.28em;
  white-space: pre-wrap;
}

.script-paragraph:last-child {
  margin-bottom: 0;
}

/* DARK THEME + MULTI SCRIPT UPDATE */
html,
body {
  background: #05070d !important;
  color: #f8fafc !important;
}

body {
  background:
    radial-gradient(circle at top left, rgba(18, 132, 255, 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(255, 112, 24, 0.13), transparent 32%),
    #05070d !important;
}

.display-page {
  background:
    radial-gradient(circle at top left, rgba(18, 132, 255, 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(255, 112, 24, 0.13), transparent 32%),
    #05070d !important;
  color: #ffffff !important;
}

.display-script,
.preview-script {
  color: #ffffff !important;
  text-shadow: 0 5px 34px rgba(0, 0, 0, 0.82) !important;
}

.preview-stage,
.preview-box {
  background:
    radial-gradient(circle at top left, rgba(18, 132, 255, 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(255, 112, 24, 0.13), transparent 32%),
    #05070d !important;
}

.center-guide,
.preview-center-guide {
  background: linear-gradient(90deg, transparent, rgba(255, 138, 0, 0.12), rgba(255, 138, 0, 0.84), rgba(255, 138, 0, 0.12), transparent) !important;
  box-shadow: 0 0 18px rgba(255, 138, 0, 0.36) !important;
}

.remote-page,
.remote-app {
  background:
    radial-gradient(circle at top left, rgba(18, 132, 255, 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(255, 112, 24, 0.13), transparent 32%),
    #05070d !important;
  color: #f8fafc !important;
}

.remote-slider-row,
.remote-options-row,
.remote-script-row {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.09) !important;
  box-shadow: none !important;
}

.slider-head,
.select-pill,
.display-control-row,
.display-step-row {
  color: #dbe5f4 !important;
}

.slider-head strong,
.display-control-row strong,
.autosave-status {
  color: #ffb668 !important;
}

.display-float-btn,
.display-info-btn {
  background: rgba(12, 18, 30, 0.72) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #ffffff !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28) !important;
}

.info-card,
.display-pop-card,
.editor-card {
  background: rgba(12, 18, 30, 0.96) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.info-card p {
  color: #a8b3c7 !important;
}

.close-info,
.nav-btn,
.play-btn,
.small-btn,
.primary-small,
.editor-actions button {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.play-btn,
.primary-small {
  background: linear-gradient(135deg, #ff922b, #ff3d00) !important;
  color: #ffffff !important;
  box-shadow: 0 10px 26px rgba(255, 94, 0, 0.22) !important;
}

.nav-btn.active-dir {
  outline: 2px solid rgba(255, 138, 0, 0.9) !important;
  background: rgba(255, 138, 0, 0.22) !important;
}

.select-pill select,
.display-step-row select,
.script-title-label input,
.editor-card textarea,
.display-edit-card textarea {
  background: rgba(0, 0, 0, 0.28) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
}

.script-manager {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.script-manager-actions,
.remote-script-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.remote-script-row {
  grid-template-columns: 1fr auto auto;
  align-items: center;
  border-radius: 16px;
  padding: 10px 12px;
  min-height: 52px;
}

.script-title-label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-weight: 800;
}

.script-title-label input {
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  outline: none;
}

.danger-btn {
  color: #ff9b9b !important;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-height: 760px) {
  .remote-app {
    grid-template-rows: minmax(112px, 29dvh) auto auto auto auto auto !important;
    gap: 6px !important;
  }

  .remote-script-row,
  .remote-options-row,
  .remote-slider-row {
    padding: 7px 9px !important;
  }
}

.editor-script-manager {
  margin-top: 8px;
  margin-bottom: 14px;
}
