:root {
  color-scheme: dark;
  --ink: #f7f4ee;
  --muted: #a7aaa3;
  --soft: #d8d2c6;
  --line: #30312e;
  --line-strong: #46443f;
  --surface: #171816;
  --surface-raised: #20211e;
  --field: #0f100e;
  --accent: #74d3aa;
  --accent-strong: #a6e7c9;
  --accent-ink: #07110d;
  --gold: #f4bd62;
  --blue: #79c7ff;
  --warn: #f3c36a;
  --danger: #ef6f74;
  --shadow: 0 24px 80px rgb(0 0 0 / 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgb(116 211 170 / 0.09) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgb(244 189 98 / 0.06) 0 1px, transparent 1px 100%),
    linear-gradient(135deg, #11130f 0%, #171712 42%, #0a0b0a 100%);
  background-size: 56px 56px, 56px 56px, auto;
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
}

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

button {
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  font-weight: 800;
  min-height: 42px;
  padding: 0 16px;
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.22) inset;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgb(116 211 170 / 0.74);
  box-shadow: 0 0 0 3px rgb(116 211 170 / 0.14);
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 48vh;
  resize: vertical;
  padding: 20px;
  line-height: 1.55;
}

label {
  display: grid;
  gap: 8px;
  color: var(--soft);
  font-size: 0.88rem;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.locked-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(32px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 35%, rgba(80, 70, 230, 0.16), transparent 32rem),
    #070719;
  color: #f8fafc;
}

.locked-panel {
  width: min(520px, 100%);
  border: 1px solid rgba(99, 102, 241, 0.42);
  border-radius: 28px;
  background: rgba(18, 18, 49, 0.9);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
  padding: clamp(28px, 5vw, 48px);
}

.locked-wordmark {
  display: block;
  width: 220px;
  height: 58px;
  margin-bottom: 34px;
}

.locked-panel .eyebrow {
  display: block;
  margin-bottom: 14px;
  color: #9ca3af;
}

.locked-panel h1 {
  max-width: 11ch;
  margin: 0 0 18px;
  color: #f8fafc;
  font-size: clamp(2.4rem, 9vw, 4.4rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.locked-panel p {
  color: #cbd5e1;
  font-size: 1.05rem;
  line-height: 1.55;
}

.locked-detail {
  margin-top: 18px;
  color: #64e3a1 !important;
  font-weight: 800;
}

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

.locked-actions button {
  min-height: 54px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.locked-actions .unlock-button {
  grid-column: 1 / -1;
}

.app-shell {
  min-height: 100vh;
}

.signin-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.signin-panel {
  width: min(480px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(23 24 22 / 0.9);
  box-shadow: var(--shadow);
  padding: 32px;
}

.signin-panel h1 {
  margin: 0 0 24px;
  font-size: clamp(2rem, 5vw, 3.7rem);
  line-height: 0.95;
}

.signin-form {
  display: grid;
  gap: 16px;
}

.auth-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.auth-status {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0;
  min-height: 22px;
}

.auth-status.warn {
  color: var(--warn);
}

.text-button {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
  justify-self: center;
  min-height: 0;
  padding: 4px 8px;
}

.text-button:hover {
  background: transparent;
  color: var(--text);
}

.reset-password-panel {
  display: grid;
  gap: 14px;
}

.workspace {
  min-height: 100vh;
  padding: 18px 22px 22px;
}

.topbar {
  align-items: center;
  background: rgb(12 13 11 / 0.88);
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin: 0 auto 18px;
  max-width: 1420px;
  min-height: 58px;
  padding: 12px 14px;
}

.account-pill {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  min-width: 220px;
}

.account-pill span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  line-height: 1.1;
}

.app-shell[data-mode="live"] .topbar > div {
  display: none;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.mode-switch {
  align-items: center;
  background: #090a09;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 8px;
  display: flex;
  padding: 4px;
}

.mode-button {
  background: transparent;
  color: var(--muted);
  min-width: 86px;
  min-height: 36px;
}

.mode-button.active {
  background: linear-gradient(180deg, #f8f4e8, #d8d0bd);
  color: #10110e;
}

.edit-view {
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  margin: 0 auto;
  max-width: 1420px;
}

.editor-panel,
.settings-panel {
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 8px;
  background: rgb(18 19 16 / 0.92);
  box-shadow: var(--shadow);
  min-width: 0;
  padding: 22px;
}

.editor-panel {
  display: grid;
  gap: 16px;
  position: relative;
}

.editor-panel::before {
  background: linear-gradient(180deg, var(--accent), var(--gold));
  border-radius: 8px 0 0 8px;
  bottom: -1px;
  content: "";
  left: -1px;
  position: absolute;
  top: -1px;
  width: 5px;
}

.panel-heading {
  align-items: start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.panel-heading h2 {
  font-size: 1.45rem;
  letter-spacing: 0;
  margin: 0 0 4px;
}

.panel-heading p,
.cue-tools p,
.deepgram-box p {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  margin: 0;
}

.quiet-button {
  background: transparent;
  border-color: rgb(255 255 255 / 0.14);
  color: var(--ink);
  box-shadow: none;
}

.quiet-button:hover {
  background: rgb(255 255 255 / 0.06);
  border-color: var(--line-strong);
}

.stacked-label.stretch {
  align-self: stretch;
}

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

.talk-manager {
  background: #0c0d0b;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 2px;
  padding: 12px;
  position: relative;
}

.talk-name-field {
  min-width: 0;
}

.talk-input-wrap {
  display: flex;
  min-width: 0;
  position: relative;
}

.talk-input-wrap input {
  background: #171914;
  border-bottom-right-radius: 0;
  border-top-right-radius: 0;
  border-color: rgb(255 255 255 / 0.13);
  font-size: 1.08rem;
  font-weight: 850;
  min-height: 48px;
}

.saved-toggle {
  background: #262821;
  border-color: rgb(255 255 255 / 0.13);
  border-bottom-left-radius: 0;
  border-top-left-radius: 0;
  min-width: 54px;
  padding: 0 10px;
}

.talk-actions {
  align-items: end;
  display: flex;
  gap: 10px;
}

.talk-actions button {
  min-height: 48px;
}

.saved-talks-menu {
  background: #11120f;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  box-shadow: var(--shadow);
  left: 0;
  overflow: hidden;
  position: absolute;
  right: 0;
  top: calc(100% - 1px);
  z-index: 5;
}

.saved-talks-menu select {
  border: 0;
  border-radius: 0;
  min-height: 150px;
}

.saved-talks-menu option {
  padding: 8px 10px;
}

.save-status {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  margin: -8px 0 0;
  min-height: 20px;
}

.stretch textarea {
  background:
    linear-gradient(90deg, rgb(116 211 170 / 0.11), transparent 4px),
    #080908;
  border-color: rgb(255 255 255 / 0.12);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.05) inset;
  font-size: clamp(1.05rem, 1.4vw, 1.25rem);
}

.script-context {
  background: rgb(244 189 98 / 0.05);
  border: 1px solid rgb(244 189 98 / 0.18);
  border-radius: 8px;
  padding: 13px 14px;
}

.script-context summary {
  cursor: pointer;
  font-weight: 900;
  list-style-position: outside;
}

.script-context summary span {
  background: rgb(116 211 170 / 0.12);
  border: 1px solid rgb(116 211 170 / 0.24);
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  margin-left: 8px;
  padding: 2px 8px;
  text-transform: uppercase;
}

.script-context p {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  margin: 10px 0;
}

.script-context textarea {
  margin-top: 10px;
  min-height: 160px;
}

.script-tools {
  align-items: center;
  display: flex;
  gap: 10px;
}

.cue-strength-legend {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-top: 2px;
}

.cue-strength-legend span {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.weak-cue-label {
  color: #f59e0b;
}

.strong-cue-label {
  color: var(--pace-on, #34d399);
}

.manual-cue-label {
  color: var(--text, #e2e8f0);
}

.script-tools input[type="file"] {
  display: none;
}

.file-button {
  align-items: center;
  background: var(--accent);
  border-radius: 6px;
  color: var(--accent-ink);
  cursor: pointer;
  display: inline-flex;
  font-weight: 900;
  min-height: 42px;
  padding: 0 16px;
}

.script-status {
  min-height: 20px;
}

.settings-panel {
  align-self: start;
  display: grid;
  gap: 18px;
  position: sticky;
  top: 18px;
  background:
    linear-gradient(180deg, rgb(121 199 255 / 0.08), transparent 220px),
    rgb(18 19 16 / 0.92);
}

.settings-grid {
  display: grid;
  gap: 16px;
}

.wpm-control,
.settings-grid > label {
  background: rgb(255 255 255 / 0.035);
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: 8px;
  padding: 14px;
}

.settings-grid label span {
  color: var(--muted);
  font-size: 0.78rem;
}

.wpm-control {
  display: grid;
  gap: 10px;
}

.wpm-heading,
.wpm-scale {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.wpm-heading label,
.wpm-scale span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.wpm-heading strong {
  color: var(--accent-strong);
  font-size: 1.7rem;
}

.wpm-control input[type="range"] {
  accent-color: var(--accent);
  min-height: 38px;
  padding: 0;
}

.wpm-scale .quiet-button {
  min-height: 34px;
}

.deepgram-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.deepgram-box summary {
  cursor: pointer;
  font-weight: 800;
}

.deepgram-box label {
  margin-top: 14px;
}

.deepgram-box p {
  font-size: 0.82rem;
  margin-top: 10px;
}

.preview {
  align-items: center;
  aspect-ratio: 16 / 9;
  background: #050505;
  border: 1px solid rgb(116 211 170 / 0.28);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.55), 0 24px 60px rgb(0 0 0 / 0.25);
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-content: center;
  overflow: hidden;
  padding: 18px;
}

.preview > span {
  color: #f8fafc;
  display: block;
  font-size: clamp(2rem, 9vw, 5.6rem);
  font-weight: 900;
  line-height: 0.92;
  max-width: 100%;
  text-align: center;
  white-space: nowrap;
}

.preview-note {
  color: #f8fafc !important;
  font-family: inherit;
  font-size: clamp(18px, 3.5vw, 30px) !important;
  font-weight: 750 !important;
  line-height: 1.16 !important;
  max-width: 92%;
  opacity: 0.9;
  text-align: center;
  text-shadow: none !important;
  white-space: normal !important;
}

.live-view {
  min-height: calc(100vh - 94px);
}

.live-stage {
  align-items: center;
  background: #050505;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.05), var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  min-height: calc(100vh - 94px);
  overflow: hidden;
  padding: 18px;
  position: relative;
}

.live-status,
.progress-text,
.pace-text {
  color: rgb(247 244 238 / 0.58);
  font-size: 0.82rem;
  font-weight: 800;
  margin: 0;
  text-align: center;
}

.cue-display {
  align-items: center;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: clamp(34px, 9vh, 120px);
  font-weight: 950;
  height: 100%;
  justify-content: center;
  line-height: 0.9;
  padding: 5vh 4vw;
  text-align: center;
  width: 100%;
  white-space: nowrap;
}

.live-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

.live-controls button {
  background: rgb(255 255 255 / 0.06);
  border-color: rgb(255 255 255 / 0.14);
  color: var(--ink);
  min-width: 120px;
}

.live-meta {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: center;
  min-height: 28px;
}

.transcript-text {
  color: rgb(248 250 252 / 0.72);
  font-size: 0.86rem;
  font-weight: 700;
  margin: 6px auto 0;
  max-width: min(760px, 90vw);
  min-height: 22px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 840px) {
  .workspace {
    padding: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .app-shell[data-mode="live"] .topbar {
    align-items: center;
  }

  .account-pill {
    justify-content: space-between;
    min-width: 0;
  }

  .mode-switch {
    width: 100%;
  }

  .app-shell[data-mode="live"] .mode-switch {
    width: auto;
  }

  .mode-button {
    flex: 1;
  }

  .app-shell[data-mode="live"] .mode-button {
    flex: 0 0 auto;
  }

  .edit-view {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    position: static;
  }

  .talk-manager {
    grid-template-columns: 1fr;
  }

  .talk-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .live-controls {
    width: 100%;
  }

  .live-controls button {
    flex: 1;
    min-width: 0;
    padding-inline: 8px;
  }
}

@media (max-width: 560px) {
  .signin-panel,
  .editor-panel,
  .settings-panel {
    padding: 16px;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .script-tools {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Strong visual redesign: editing is a bright workspace; live mode remains dark. */
.app-shell {
  background:
    linear-gradient(90deg, rgb(25 25 22 / 0.045) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgb(25 25 22 / 0.045) 0 1px, transparent 1px 100%),
    #f2efe6;
  background-size: 48px 48px, 48px 48px, auto;
  color: #20221d;
}

.signin-view {
  background:
    linear-gradient(135deg, rgb(116 211 170 / 0.22), transparent 34%),
    #f2efe6;
}

.signin-panel {
  background: #fffdf7;
  border-color: rgb(32 34 29 / 0.12);
  box-shadow: 0 30px 90px rgb(32 34 29 / 0.16);
}

.signin-panel h1,
.topbar h1,
.panel-heading h2 {
  color: #181a16;
}

.signin-panel input,
.signin-panel select,
.signin-panel textarea {
  background: #f7f4eb;
  border-color: rgb(32 34 29 / 0.16);
  color: #181a16;
}

.signin-panel label,
.signin-form label,
.auth-status,
.account-pill span {
  color: #5e6258;
}

.auth-status.warn {
  color: #996b13;
}

.workspace {
  background: transparent;
}

.topbar {
  background: rgb(255 253 247 / 0.92);
  border-color: rgb(32 34 29 / 0.1);
  box-shadow: 0 18px 50px rgb(32 34 29 / 0.1);
}

.eyebrow {
  color: #13815d;
}

.mode-switch {
  background: #ebe6d8;
  border-color: rgb(32 34 29 / 0.12);
}

.mode-button {
  color: #62665d;
  box-shadow: none;
}

.mode-button.active {
  background: #20221d;
  color: #fffdf7;
}

.editor-panel,
.settings-panel {
  background: #fffdf7;
  border-color: rgb(32 34 29 / 0.1);
  box-shadow: 0 28px 80px rgb(32 34 29 / 0.12);
}

.editor-panel::before {
  background: linear-gradient(180deg, #23b17e, #f0a840);
}

.panel-heading p,
.cue-tools p,
.deepgram-box p,
.save-status,
.script-context p,
.wpm-heading label,
.wpm-scale span,
.settings-grid label span,
.transcript-text {
  color: #686b62;
}

label {
  color: #454941;
}

input,
select,
textarea {
  background: #f7f4eb;
  border-color: rgb(32 34 29 / 0.16);
  color: #181a16;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #23a777;
  box-shadow: 0 0 0 4px rgb(35 167 119 / 0.16);
}

button {
  background: #22b47f;
  color: #07110d;
}

button:hover {
  background: #41c996;
}

.quiet-button {
  background: transparent;
  border-color: rgb(32 34 29 / 0.18);
  color: #20221d;
}

.quiet-button:hover {
  background: rgb(32 34 29 / 0.06);
  border-color: rgb(32 34 29 / 0.28);
}

.talk-manager {
  background: #f5f1e7;
  border-color: rgb(32 34 29 / 0.1);
}

.talk-input-wrap input {
  background: #fffdf7;
  border-color: rgb(32 34 29 / 0.16);
}

.saved-toggle {
  background: #20221d;
  border-color: #20221d;
  color: #fffdf7;
}

.saved-talks-menu {
  background: #fffdf7;
  border-color: rgb(32 34 29 / 0.16);
  box-shadow: 0 24px 70px rgb(32 34 29 / 0.18);
}

.saved-talks-menu select {
  background: #fffdf7;
  color: #20221d;
}

.stretch textarea {
  background:
    linear-gradient(90deg, rgb(35 177 126 / 0.2), transparent 5px),
    #fffdf7;
  border-color: rgb(32 34 29 / 0.14);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.8);
}

.script-context {
  background: #fff6e6;
  border-color: rgb(240 168 64 / 0.34);
}

.script-context summary span {
  background: rgb(240 168 64 / 0.14);
  border-color: rgb(240 168 64 / 0.28);
  color: #8a5b0f;
}

.file-button {
  background: #20221d;
  color: #fffdf7;
}

.settings-panel {
  background:
    linear-gradient(180deg, rgb(121 199 255 / 0.16), transparent 230px),
    #fffdf7;
}

.wpm-control,
.settings-grid > label {
  background: #f5f1e7;
  border-color: rgb(32 34 29 / 0.1);
}

.wpm-heading strong {
  color: #14845f;
}

.preview {
  border-color: rgb(32 34 29 / 0.18);
  box-shadow: 0 20px 56px rgb(32 34 29 / 0.16);
}

.app-shell[data-mode="live"] {
  background: #050505;
  color: #f8fafc;
}

.app-shell[data-mode="live"] .workspace {
  background: #050505;
}

.app-shell[data-mode="live"] .topbar {
  background: #050505;
  border-color: rgb(255 255 255 / 0.08);
  box-shadow: none;
}

.app-shell[data-mode="live"] .mode-switch {
  background: rgb(255 255 255 / 0.05);
  border-color: rgb(255 255 255 / 0.12);
}

.app-shell[data-mode="live"] .mode-button {
  color: rgb(248 250 252 / 0.68);
}

.app-shell[data-mode="live"] .mode-button.active {
  background: #f8fafc;
  color: #050505;
}

.app-shell[data-mode="live"] .account-pill span,
.app-shell[data-mode="live"] .live-status,
.app-shell[data-mode="live"] .progress-text,
.app-shell[data-mode="live"] .pace-text {
  color: rgb(248 250 252 / 0.58);
}

.app-shell[data-mode="live"] .quiet-button,
.app-shell[data-mode="live"] .live-controls button {
  background: rgb(255 255 255 / 0.06);
  border-color: rgb(255 255 255 / 0.14);
  color: #f8fafc;
}

/* Reference-inspired interface: soft frosted edit mode, restrained dark live mode. */
:root {
  --ai-ink: #0d1320;
  --ai-muted: #667085;
  --ai-subtle: #98a2b3;
  --ai-line: rgb(15 23 42 / 0.08);
  --ai-panel: rgb(255 255 255 / 0.68);
  --ai-panel-solid: #fbfcff;
  --ai-blue: #4d6c9d;
  --ai-blue-soft: #dce8ff;
  --ai-green: #51c69a;
  --ai-shadow: 0 28px 90px rgb(55 70 105 / 0.17);
}

body {
  background: #d7dcea;
}

.app-shell {
  background:
    radial-gradient(circle at 18% 0%, rgb(255 255 255 / 0.88), transparent 32rem),
    radial-gradient(circle at 86% 16%, rgb(168 180 214 / 0.55), transparent 34rem),
    linear-gradient(180deg, #eef3fb 0%, #d9dfed 48%, #cfd7e8 100%);
  color: var(--ai-ink);
}

.signin-view {
  background: transparent;
}

.signin-panel,
.topbar,
.editor-panel,
.settings-panel {
  background: var(--ai-panel);
  backdrop-filter: blur(26px) saturate(1.25);
  border: 1px solid rgb(255 255 255 / 0.72);
  box-shadow: var(--ai-shadow);
}

.signin-panel,
.editor-panel,
.settings-panel,
.topbar,
.talk-manager,
.script-context,
.wpm-control,
.settings-grid > label,
.preview {
  border-radius: 8px;
}

.signin-panel h1,
.topbar h1,
.panel-heading h2 {
  color: var(--ai-ink);
  font-weight: 850;
}

.signin-panel h1 {
  font-size: clamp(2.25rem, 5vw, 4rem);
  line-height: 0.94;
}

.eyebrow {
  color: var(--ai-blue);
}

.workspace {
  padding: 22px;
}

.topbar {
  min-height: 70px;
  padding: 14px 16px;
}

.topbar h1 {
  font-size: clamp(1.45rem, 2.2vw, 2rem);
}

.account-pill span,
.panel-heading p,
.cue-tools p,
.deepgram-box p,
.save-status,
.script-context p,
.wpm-heading label,
.wpm-scale span,
.settings-grid label span,
.transcript-text,
label,
.signin-panel label,
.signin-form label,
.auth-status {
  color: var(--ai-muted);
}

.mode-switch {
  background: rgb(255 255 255 / 0.56);
  border: 1px solid rgb(255 255 255 / 0.8);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.92);
}

.mode-button {
  border: 1px solid rgb(13 19 32 / 0.1);
  color: var(--ai-muted);
  min-height: 40px;
}

.mode-button.active {
  background: var(--ai-ink);
  border-color: var(--ai-ink);
  color: white;
}

.edit-view {
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 370px);
}

.editor-panel,
.settings-panel {
  padding: 24px;
}

.editor-panel {
  gap: 18px;
}

.editor-panel::before {
  display: none;
}

.panel-heading h2 {
  font-size: 1.7rem;
  line-height: 1.05;
}

.panel-heading p {
  font-size: 0.96rem;
}

button {
  background: var(--ai-ink);
  border: 0;
  box-shadow: 0 12px 28px rgb(13 19 32 / 0.16);
  color: white;
  min-height: 44px;
}

button:hover {
  background: #1b2435;
}

.quiet-button {
  background: rgb(255 255 255 / 0.58);
  border: 1px solid rgb(13 19 32 / 0.09);
  box-shadow: none;
  color: var(--ai-ink);
}

.quiet-button:hover {
  background: white;
  border-color: rgb(13 19 32 / 0.12);
}

input,
select,
textarea,
.signin-panel input,
.signin-panel select,
.signin-panel textarea {
  background: rgb(255 255 255 / 0.68);
  border: 1px solid rgb(13 19 32 / 0.09);
  color: var(--ai-ink);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgb(77 108 157 / 0.42);
  box-shadow: 0 0 0 4px rgb(77 108 157 / 0.16);
}

.talk-manager {
  background: rgb(255 255 255 / 0.42);
  border: 1px solid rgb(255 255 255 / 0.7);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.78);
  padding: 14px;
}

.talk-input-wrap input {
  background: rgb(255 255 255 / 0.74);
  border-color: rgb(13 19 32 / 0.08);
}

.saved-toggle {
  background: rgb(13 19 32 / 0.06);
  border: 1px solid rgb(13 19 32 / 0.08);
  box-shadow: none;
  color: var(--ai-ink);
}

.talk-actions button {
  min-width: 88px;
}

.saved-talks-menu {
  background: rgb(255 255 255 / 0.92);
  border-color: rgb(13 19 32 / 0.08);
  box-shadow: 0 24px 70px rgb(55 70 105 / 0.18);
}

.stretch textarea {
  background: rgb(255 255 255 / 0.72);
  border-color: rgb(13 19 32 / 0.08);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.9);
  font-size: clamp(1.05rem, 1.25vw, 1.18rem);
}

.script-context {
  background: rgb(255 255 255 / 0.42);
  border: 1px solid rgb(255 255 255 / 0.68);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.72);
}

.script-context summary {
  color: var(--ai-ink);
}

.script-context summary span {
  background: rgb(77 108 157 / 0.1);
  border-color: rgb(77 108 157 / 0.14);
  color: var(--ai-blue);
}

.file-button {
  background: var(--ai-ink);
  color: white;
}

.settings-panel {
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.7), rgb(255 255 255 / 0.46)),
    var(--ai-panel);
}

.wpm-control,
.settings-grid > label {
  background: rgb(255 255 255 / 0.46);
  border: 1px solid rgb(255 255 255 / 0.72);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.76);
}

.wpm-heading strong {
  color: var(--ai-blue);
}

.wpm-control input[type="range"] {
  accent-color: var(--ai-blue);
}

.preview {
  background: radial-gradient(circle at 50% 10%, #15233a, #020307 66%);
  border: 1px solid rgb(255 255 255 / 0.64);
  box-shadow: 0 20px 60px rgb(55 70 105 / 0.2);
}

.auth-status.warn {
  color: #9b6417;
}

.app-shell[data-mode="live"] {
  background:
    radial-gradient(circle at 50% -14%, rgb(77 108 157 / 0.34), transparent 32rem),
    #020307;
  color: #f8fafc;
}

.app-shell[data-mode="live"] .workspace {
  background: transparent;
}

.app-shell[data-mode="live"] .topbar {
  background: rgb(2 3 7 / 0.72);
  backdrop-filter: blur(22px);
  border-color: rgb(255 255 255 / 0.08);
  box-shadow: none;
}

.app-shell[data-mode="live"] .mode-switch {
  background: rgb(255 255 255 / 0.07);
  border-color: rgb(255 255 255 / 0.12);
}

.app-shell[data-mode="live"] .mode-button.active {
  background: white;
  color: #020307;
}

.app-shell[data-mode="live"] .live-stage {
  background: #020307;
  box-shadow: none;
}

@media (max-width: 840px) {
  .workspace {
    padding: 12px;
  }

  .editor-panel,
  .settings-panel {
    padding: 18px;
  }
}

/* Mobile-first corrections for phone use. */
@media (max-width: 760px) {
  html,
  body,
  .app-shell {
    min-height: 100svh;
  }

  .signin-view {
    align-items: start;
    padding: 18px 12px;
  }

  .signin-panel {
    margin-top: 4svh;
    padding: 22px 18px;
  }

  .signin-panel h1 {
    font-size: clamp(2rem, 11vw, 3rem);
  }

  .workspace {
    min-height: 100svh;
    padding: 10px;
  }

  .topbar {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
    margin-bottom: 10px;
    min-height: 0;
    padding: 10px;
  }

  .topbar h1 {
    font-size: clamp(1.2rem, 7vw, 1.65rem);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .eyebrow {
    font-size: 0.68rem;
    margin-bottom: 3px;
  }

  .mode-switch {
    order: -1;
    width: 100%;
  }

  .mode-button {
    flex: 1 1 0;
    min-height: 42px;
    min-width: 0;
  }

  .account-pill {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
    min-width: 0;
  }

  .account-pill span {
    max-width: none;
  }

  .account-pill .quiet-button {
    min-height: 38px;
    padding: 0 12px;
  }

  .edit-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: none;
  }

  .editor-panel {
    order: 1;
  }

  .settings-panel {
    order: 2;
    position: static;
  }

  .editor-panel,
  .settings-panel {
    border-radius: 8px;
    padding: 14px;
  }

  .panel-heading {
    align-items: center;
    flex-direction: row;
    gap: 10px;
  }

  .panel-heading h2 {
    font-size: 1.25rem;
  }

  .panel-heading p {
    display: none;
  }

  .panel-heading .quiet-button {
    min-height: 38px;
    padding: 0 12px;
  }

  .talk-manager {
    gap: 10px;
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .talk-name-field {
    font-size: 0.78rem;
  }

  .talk-input-wrap input {
    font-size: 1rem;
    min-height: 44px;
  }

  .saved-toggle {
    min-height: 44px;
    min-width: 48px;
  }

  .talk-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .talk-actions button {
    min-height: 44px;
    min-width: 0;
  }

  .save-status {
    margin: -4px 0 0;
  }

  .stretch textarea {
    font-size: 1rem;
    min-height: 42svh;
    padding: 14px;
  }

  .script-context {
    padding: 11px 12px;
  }

  .script-context p,
  .script-status {
    font-size: 0.8rem;
  }

  .script-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .file-button,
  .script-tools button {
    justify-content: center;
    min-height: 42px;
  }

  .script-cue-view {
    max-height: 42svh;
  }

  .settings-panel .panel-heading {
    margin-bottom: -4px;
  }

  .settings-grid {
    gap: 10px;
  }

  .wpm-control,
  .settings-grid > label {
    padding: 12px;
  }

  .wpm-heading strong {
    font-size: 1.35rem;
  }

  .wpm-scale {
    gap: 8px;
  }

  .wpm-scale span {
    font-size: 0.76rem;
  }

  .wpm-scale .quiet-button {
    min-height: 32px;
    padding: 0 12px;
  }

  .preview {
    display: none;
  }

  .app-shell[data-mode="live"] .workspace {
    padding: 6px;
  }

  .app-shell[data-mode="live"] .topbar {
    display: flex;
    justify-content: center;
    margin-bottom: 6px;
    padding: 6px;
  }

  .app-shell[data-mode="live"] .account-pill {
    display: none;
  }

  .app-shell[data-mode="live"] .mode-switch {
    order: 0;
    width: auto;
  }

  .app-shell[data-mode="live"] .mode-button {
    flex: 0 0 auto;
    min-height: 34px;
    min-width: 68px;
  }

  .live-view {
    min-height: calc(100svh - 58px);
  }

  .live-stage {
    border-radius: 8px;
    min-height: calc(100svh - 58px);
    padding: 10px;
  }

  .cue-display {
    padding: 3svh 2vw;
  }

  .live-controls {
    margin-bottom: 10px;
  }

  .transcript-text {
    max-width: 94vw;
  }
}

@media (max-width: 390px) {
  .workspace {
    padding: 6px;
  }

  .editor-panel,
  .settings-panel {
    padding: 12px;
  }

  .auth-actions,
  .talk-actions {
    grid-template-columns: 1fr;
  }

  .stretch textarea {
    min-height: 39svh;
  }
}

.saved-talks-list {
  display: grid;
  gap: 4px;
  max-height: min(260px, 42svh);
  overflow-y: auto;
  padding: 6px;
  -webkit-overflow-scrolling: touch;
}

.saved-talk-button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  box-shadow: none;
  color: var(--ai-ink);
  display: block;
  font-weight: 750;
  min-height: 42px;
  overflow: hidden;
  padding: 0 10px;
  text-align: left;
  text-overflow: ellipsis;
  touch-action: manipulation;
  white-space: nowrap;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.saved-talk-button:hover,
.saved-talk-button[aria-selected="true"] {
  background: rgb(77 108 157 / 0.12);
  color: var(--ai-ink);
  transform: none;
}

.saved-talks-empty {
  color: var(--ai-muted);
  display: block;
  font-size: 0.9rem;
  font-weight: 750;
  padding: 12px 10px;
}

.wpm-control input[type="range"] {
  appearance: none;
  border: 0;
  border-radius: 999px;
  height: 8px;
  min-height: 8px;
  padding: 0;
}

.wpm-control input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  background: white;
  border: 3px solid var(--wpm-thumb-color, #22c55e);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgb(13 19 32 / 0.22);
  height: 24px;
  width: 24px;
}

.wpm-control input[type="range"]::-moz-range-thumb {
  background: white;
  border: 3px solid var(--wpm-thumb-color, #22c55e);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgb(13 19 32 / 0.22);
  height: 18px;
  width: 18px;
}

.wpm-control input[type="range"]::-moz-range-track {
  background: transparent;
  border: 0;
}

.script-cue-view {
  background: rgb(255 255 255 / 0.72);
  border: 1px solid rgb(13 19 32 / 0.08);
  border-radius: 8px;
  color: var(--ai-ink);
  line-height: 1.7;
  margin-top: 10px;
  max-height: 34svh;
  overflow-y: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}

.script-word {
  background: transparent;
  border: 0;
  border-radius: 4px;
  box-shadow: none;
  color: inherit;
  display: inline;
  font-weight: 500;
  line-height: inherit;
  min-height: 0;
  padding: 1px 2px;
}

.script-word:hover {
  background: rgb(77 108 157 / 0.1);
  color: inherit;
  transform: none;
}

.script-word[aria-pressed="true"] {
  background: rgb(81 198 154 / 0.16);
  color: #0f5138;
  font-weight: 900;
}

.script-word[aria-pressed="true"].cue-weak {
  background: rgb(245 158 11 / 0.18);
  color: #f59e0b;
}

.script-word[aria-pressed="true"].cue-strong {
  background: rgb(52 211 153 / 0.18);
  color: var(--pace-on, #34d399);
}

.script-tools .quiet-button.active {
  background: var(--ai-ink);
  color: white;
}

.cue-script-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(260px, 0.8fr) minmax(340px, 1.2fr);
  align-items: start;
  min-width: 0;
}

.cue-list-panel,
.script-context {
  min-width: 0;
}

.cue-list-heading {
  display: grid;
  gap: 6px;
  margin: 0;
}

.cue-list-heading strong {
  color: var(--ai-ink);
  font-size: 1.7rem;
  font-weight: 850;
  line-height: 1.05;
}

.cue-list-heading span {
  color: var(--ai-muted);
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.35;
}

.script-context h2 {
  color: var(--ai-ink);
  font-size: 1.7rem;
  font-weight: 850;
  line-height: 1.05;
  margin: 0;
}

.script-context h2 span {
  background: rgb(77 108 157 / 0.1);
  border: 1px solid rgb(77 108 157 / 0.14);
  border-radius: 999px;
  color: var(--ai-blue);
  font-size: 0.78rem;
  margin-left: 8px;
  padding: 2px 8px;
  text-transform: uppercase;
  vertical-align: middle;
}

.cue-script-grid .script-context p {
  color: var(--ai-muted);
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 6px 0 0;
}

.cue-script-grid .stretch textarea,
.cue-script-grid .script-context textarea {
  min-height: 52svh;
}

.cue-script-grid .script-cue-view {
  max-height: 52svh;
}

.cue-script-grid .script-context {
  align-self: stretch;
  display: grid;
  gap: 12px;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}

.cue-script-grid .script-tools {
  flex-wrap: wrap;
  margin-top: 0;
}

.cue-script-grid .script-context textarea {
  margin-top: 0;
}

.cue-script-grid .cue-list-panel {
  gap: 12px;
}

.danger-button {
  color: #9f1d2f;
}

.danger-button:hover {
  background: rgb(159 29 47 / 0.08);
  border-color: rgb(159 29 47 / 0.18);
  color: #7f1524;
}

@media (max-width: 1180px) {
  .cue-script-grid {
    grid-template-columns: 1fr;
  }

  .cue-script-grid .stretch textarea,
  .cue-script-grid .script-context textarea {
    min-height: 34svh;
  }

  .cue-script-grid .script-cue-view {
    max-height: 38svh;
  }
}

@media (max-width: 760px) {
  .saved-talks-menu {
    border-radius: 0 0 8px 8px;
    left: 0;
    right: 0;
    top: calc(100% - 1px);
  }

  .saved-talk-button {
    font-size: 1rem;
    min-height: 46px;
  }

  .cue-script-grid {
    gap: 10px;
    grid-template-columns: 1fr;
  }

  .cue-script-grid .stretch textarea {
    min-height: 36svh;
  }

  .cue-script-grid .script-context textarea,
  .cue-script-grid .script-cue-view {
    min-height: 0;
    max-height: 42svh;
  }
}

@media (max-width: 840px) {
  .mode-switch {
    justify-self: center;
    width: auto;
  }

  .mode-button {
    flex: 0 0 auto;
    min-width: 68px;
  }
}

@media (max-width: 760px) {
  .mode-switch {
    order: 0;
  }

  .mode-button {
    min-height: 34px;
  }
}

/* Indigo Glass Mobile refresh */
:root {
  --bg: #0a0a1a;
  --surface: #141432;
  --surface-2: #1e1e5a;
  --border: #1e1e5a;
  --border-soft: rgba(255,255,255,0.06);
  --primary: #4f46e5;
  --primary-hover: #6366f1;
  --primary-soft: rgba(79,70,229,0.20);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-faint: #475569;
  --pace-on: #34d399;
  --pace-slow: #e0f7ff;
  --pace-fast: #f43f5e;
  --danger: #f43f5e;
  --listening-dot: #10b981;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-full: 9999px;
  --glow-on: 0 0 15px rgba(52,211,153,0.40);
  --glow-slow:
    0 0 7px rgba(224,247,255,0.95),
    0 0 22px rgba(56,189,248,0.65),
    1px 1px 0 rgba(255,255,255,0.72),
    -1px -1px 0 rgba(125,211,252,0.62);
  --glow-fast: 0 0 15px rgba(244,63,94,0.45);
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

.app-shell,
.signin-view,
.workspace {
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea,
label {
  font-family: var(--font-body);
}

.eyebrow,
.talk-name-field > .eyebrow,
.preview-label,
.wpm-heading label,
.settings-grid > label,
.account-pill::before {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.signin-panel,
.editor-panel,
.settings-panel,
.topbar {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.signin-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
  width: min(400px, 100%);
}

.signin-panel h1,
.topbar h1,
.talk-input-wrap input,
.wpm-heading strong,
.cue-display,
.preview > span {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.signin-panel h1 {
  color: var(--text);
  font-size: clamp(2rem, 10vw, 3.25rem);
}

.signin-panel input,
input,
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--text);
  padding: 12px 16px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
  outline: none;
}

button {
  border-radius: var(--r-full);
  min-height: 0;
  transform: none;
}

button:hover {
  transform: none;
}

.workspace {
  margin: 0 auto;
  max-width: 400px;
  min-height: 100svh;
  padding: 16px;
}

.topbar {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr auto;
  margin: 0 0 32px;
  max-width: none;
  min-height: 0;
  padding: 0;
}

.topbar > div:first-child {
  grid-column: 1 / -1;
  order: 2;
}

.topbar .eyebrow {
  display: none;
}

.topbar h1 {
  color: var(--text);
  font-size: 18px;
  margin: 0;
}

.mode-switch {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  box-shadow: none;
  display: flex;
  justify-self: start;
  order: 1;
  padding: 4px;
  width: auto;
}

.mode-button {
  background: transparent;
  border: 0;
  border-radius: var(--r-full);
  box-shadow: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  min-height: 30px;
  min-width: 70px;
  padding: 0 14px;
  text-transform: uppercase;
}

.mode-button.active {
  background: var(--primary);
  border: 0;
  color: white;
}

.account-pill {
  align-items: center;
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
  justify-content: space-between;
  min-width: 0;
  order: 99;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.account-pill::before {
  content: 'Account';
  display: block;
}

.account-pill span {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  max-width: 190px;
}

.account-pill .quiet-button {
  background: transparent;
  border: 0;
  color: var(--danger);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 0;
  text-transform: uppercase;
}

.edit-view {
  display: grid;
  gap: 32px;
  grid-template-columns: 1fr;
  margin: 0;
  max-width: none;
}

.editor-panel,
.settings-panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  display: grid;
  gap: 32px;
  padding: 0;
}

.talk-manager {
  background: transparent;
  border: 0;
  box-shadow: none;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
  padding: 0;
}

.talk-name-field {
  gap: 8px;
}

.talk-input-wrap {
  display: flex;
  position: relative;
}

.talk-input-wrap input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg) 0 0 var(--r-lg);
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  min-height: 48px;
}

.saved-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
  box-shadow: none;
  color: var(--text-muted);
  min-width: 46px;
}

.talk-actions {
  align-items: end;
  display: flex;
  gap: 8px;
}

.talk-actions button,
#saveCueCardButton,
#deleteCueCardButton {
  align-items: center;
  border-radius: var(--r-md);
  box-shadow: none;
  display: inline-flex;
  font-size: 0;
  height: 36px;
  justify-content: center;
  min-height: 36px;
  min-width: 36px;
  padding: 0;
  width: 36px;
}

#saveCueCardButton {
  background: rgba(79,70,229,0.12);
  border: 1px solid var(--primary-soft);
  color: var(--primary-hover);
}

#saveCueCardButton::before {
  content: '✓';
  font-size: 18px;
  font-weight: 700;
}

#deleteCueCardButton {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
}

#deleteCueCardButton::before {
  content: '×';
  font-size: 22px;
  font-weight: 700;
}

.save-status,
.cue-tools p,
.script-status {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  margin: -20px 0 0;
}

.saved-talks-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 18px 50px rgba(0,0,0,0.28);
}

.saved-talk-button {
  color: var(--text-muted);
}

.saved-talk-button:hover,
.saved-talk-button[aria-selected='true'] {
  background: var(--primary-soft);
  color: var(--text);
}

.cue-script-grid {
  display: grid;
  gap: 32px;
  grid-template-columns: 1fr;
}

.cue-list-panel,
.script-context {
  background: transparent;
  border: 0;
  box-shadow: none;
  display: grid;
  gap: 12px;
  padding: 0;
}

.cue-list-heading,
.script-context h2 {
  display: grid;
  gap: 8px;
  margin: 0;
}

.panel-mode-row {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-width: 0;
}

.panel-mode-row h2 {
  min-width: 0;
}

.panel-title-tabs {
  align-items: center;
  color: var(--text-dim);
  display: inline-flex;
  flex-wrap: wrap;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  gap: 8px;
  letter-spacing: 0.18em;
  line-height: 1.2;
  text-transform: uppercase;
}

.panel-title-tab {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  opacity: 0.5;
  padding: 0;
  text-transform: uppercase;
}

.panel-title-tab.active {
  color: var(--text-dim);
  opacity: 1;
}

.panel-title-tab:focus-visible {
  border-radius: 4px;
  outline: 2px solid rgb(110 231 183 / 0.6);
  outline-offset: 4px;
}

.panel-mode-toggle {
  background: rgb(255 255 255 / 0.045);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  display: inline-grid;
  flex: 0 0 auto;
  gap: 3px;
  grid-template-columns: repeat(2, minmax(72px, 1fr));
  padding: 3px;
}

.panel-mode-toggle button {
  background: transparent;
  border: 0;
  border-radius: var(--r-full);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  min-height: 30px;
  padding: 0 14px;
  text-transform: uppercase;
}

.panel-mode-toggle button.active {
  background: var(--primary);
  color: #fff;
}

.cue-list-heading strong {
  display: none;
}

.cue-list-heading .eyebrow,
.script-context h2 .eyebrow {
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.cue-list-heading > span:last-child,
.script-context p {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  margin: 0;
}

.script-context h2 > span:last-child {
  background: var(--surface-2);
  border: 0;
  border-radius: var(--r-full);
  color: var(--text-muted);
  display: inline-block;
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-left: 8px;
  padding: 2px 8px;
  text-transform: uppercase;
}

#cueInput,
.script-cue-view,
#scriptInput {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
  padding: 12px 16px;
}

.cue-editor-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.cue-editor-box .cue-strength-legend {
  border-bottom: 1px solid var(--border);
  margin: 0;
  padding: 10px 16px 8px;
}

#cueInput {
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.7;
  min-height: 160px;
  overflow-y: auto;
  resize: vertical;
  text-transform: capitalize;
}

#scriptInput {
  height: 128px;
  min-height: 128px;
  resize: none;
}

.script-cue-view {
  max-height: 260px;
  min-height: 128px;
}

.script-tools {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, 1fr);
}

.right-panel-workspace {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.right-panel-workspace.hidden {
  display: none !important;
}

.slides-tools {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#slidesFileInput {
  display: none;
}

.slides-box {
  align-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--text-muted);
  display: grid;
  gap: 20px;
  min-height: 128px;
  overflow-y: auto;
  padding: 22px;
}

.slides-empty-message {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 750;
  line-height: 1.4;
  margin: 0;
  text-align: center;
}

.slide-placeholder-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  user-select: none;
}

.slide-placeholder-grid.has-slides {
  align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}

.slide-placeholder-card {
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 0.10), transparent 48%),
    rgb(255 255 255 / 0.045);
  border: 1px solid rgb(255 255 255 / 0.09);
  border-radius: var(--r-md);
  display: block;
  min-height: 72px;
}

.slide-card {
  appearance: none;
  background: rgb(255 255 255 / 0.045);
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: var(--r-md);
  color: var(--text);
  cursor: grab;
  display: grid;
  gap: 8px;
  padding: 8px;
  text-align: left;
  user-select: none;
  -webkit-user-select: none;
}

.slide-card:active {
  cursor: grabbing;
}

.slide-card img {
  aspect-ratio: 16 / 9;
  background: #050505;
  border-radius: 6px;
  display: block;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  width: 100%;
}

.slide-card span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  user-select: none;
}

.file-button,
.script-tools .quiet-button,
.slides-tools .quiet-button {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--primary-soft);
  border-radius: var(--r-sm);
  box-shadow: none;
  color: var(--text);
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  justify-content: center;
  letter-spacing: 0.08em;
  min-height: 36px;
  padding: 8px 10px;
  text-align: center;
  text-transform: uppercase;
}

.talk-time-control {
  appearance: none;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--primary-soft);
  border-radius: var(--r-sm);
  box-shadow: none;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  justify-content: center;
  letter-spacing: 0.08em;
  min-height: 36px;
  min-width: 126px;
  outline: 0;
  padding: 8px 18px;
  text-align: center;
  text-align-last: center;
  text-transform: uppercase;
}

.script-word[aria-pressed='true'] {
  background: var(--primary-soft);
  color: var(--pace-on);
  font-weight: 900;
}

.script-word[aria-pressed='true'].cue-weak {
  background: rgb(245 158 11 / 0.18);
  color: #f59e0b;
}

.script-word[aria-pressed='true'].cue-strong {
  background: rgb(52 211 153 / 0.18);
  color: var(--pace-on);
}

.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  gap: 24px;
  padding: 16px;
}

.settings-panel .panel-heading {
  display: none;
}

.settings-grid {
  display: grid;
  gap: 24px;
}

.wpm-control,
.settings-grid > label {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.wpm-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.wpm-heading label,
.settings-grid > label {
  gap: 8px;
}

.wpm-heading strong {
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 18px;
}

.wpm-control input[type='range'] {
  border: 0;
  height: 6px;
  min-height: 6px;
}

.wpm-control input[type='range']::-webkit-slider-thumb {
  background: var(--primary);
  border: 0;
  box-shadow: 0 0 8px var(--primary-soft);
  height: 18px;
  width: 18px;
}

.wpm-control input[type='range']::-moz-range-thumb {
  background: var(--primary);
  border: 0;
  box-shadow: 0 0 8px var(--primary-soft);
  height: 18px;
  width: 18px;
}

.wpm-scale {
  display: flex;
  justify-content: space-between;
}

.wpm-scale span {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.wpm-scale .quiet-button {
  display: none;
}

.control-help {
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  margin: -4px 0 0;
}

.control-help strong {
  color: var(--text);
  font-weight: 800;
}

.settings-grid select {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--text);
  min-height: 44px;
}

.preview-label {
  margin: 0 0 -12px;
}

.preview {
  aspect-ratio: 3 / 2;
  background: #000;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-xl);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-content: center;
  overflow: hidden;
  padding: 18px;
}

.preview > span {
  color: var(--pace-on) !important;
  font-family: var(--font-display);
  font-size: clamp(40px, 9vw, 56px);
  font-weight: 700;
  line-height: 1.08;
  text-align: center;
  text-shadow: var(--glow-on);
  white-space: pre-line;
}

.preview .preview-note {
  color: #f8fafc !important;
  font-size: clamp(18px, 4vw, 32px) !important;
  font-weight: 650 !important;
  line-height: 1.12 !important;
  opacity: 0.95;
  text-shadow: none;
}

.preview-slide {
  align-items: center;
  align-self: center;
  aspect-ratio: 16 / 9;
  background: #f8fafc;
  border: 2px solid rgb(255 255 255 / 0.92);
  border-radius: 3px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.32);
  display: grid;
  gap: 8px 10px;
  grid-template-columns: 1fr 1.1fr;
  grid-template-rows: auto 1fr;
  max-width: 74%;
  padding: 10px;
  width: 210px;
}

.preview-slide-title {
  background: #111827;
  border-radius: 999px;
  grid-column: 1 / -1;
  height: 8px;
  opacity: 0.9;
  width: 52%;
}

.preview-pie {
  align-self: center;
  aspect-ratio: 1;
  background: conic-gradient(#10b981 0 42%, #60a5fa 42% 72%, #f59e0b 72% 100%);
  border-radius: 50%;
  justify-self: center;
  width: 48px;
}

.preview-bars {
  display: grid;
  gap: 6px;
  width: 100%;
}

.preview-bars span {
  background: #cbd5e1 !important;
  border-radius: 999px;
  display: block;
  height: 8px;
}

.preview-bars span:nth-child(1) {
  width: 90%;
}

.preview-bars span:nth-child(2) {
  width: 72%;
}

.preview-bars span:nth-child(3) {
  width: 82%;
}

.app-shell[data-mode='live'],
.app-shell[data-mode='live'] .workspace {
  background: #000;
  max-width: none;
  padding: 0;
}

.app-shell[data-mode='live'] .topbar {
  display: none;
}

.live-view {
  min-height: 100svh;
}

.live-stage {
  --cue-progress: 0%;
  background: #000;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  min-height: 100svh;
  padding: 16px 24px 24px;
  position: relative;
}

.live-stage::before {
  background: linear-gradient(to bottom, rgba(52,211,153,0.05), transparent 40%, rgba(52,211,153,0.05));
  content: '';
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.orientation-gate {
  align-items: center;
  background: #000;
  color: #f8fafc;
  display: none;
  flex-direction: column;
  gap: 10px;
  inset: 0;
  justify-content: center;
  padding: 28px;
  position: absolute;
  text-align: center;
  z-index: 20;
}

.orientation-gate strong {
  font-family: var(--font-display);
  font-size: clamp(2rem, 10vw, 4.25rem);
  line-height: 1;
}

.orientation-gate span {
  color: rgba(248,250,252,0.72);
  font-size: 1rem;
  font-weight: 700;
}

.live-stage[data-orientation-blocked='true'] .orientation-gate {
  display: flex;
}

.live-stage[data-orientation-blocked='true'] .live-status,
.live-stage[data-orientation-blocked='true'] .cue-display,
.live-stage[data-orientation-blocked='true'] .live-controls,
.live-stage[data-orientation-blocked='true'] .live-meta,
.live-stage[data-orientation-blocked='true'] .live-time-progress,
.live-stage[data-orientation-blocked='true'] .transcript-text {
  visibility: hidden;
}

.live-stage[data-pace='slow']::before {
  background:
    radial-gradient(circle at 18% 12%, rgba(224,247,255,0.12), transparent 22%),
    linear-gradient(to bottom, rgba(125,211,252,0.12), transparent 42%, rgba(224,247,255,0.08));
}

.live-stage[data-pace='fast']::before {
  background: linear-gradient(to bottom, rgba(244,63,94,0.05), transparent 40%, rgba(244,63,94,0.05));
}

.live-status {
  align-items: center;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--r-full);
  color: white;
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  gap: 12px;
  justify-self: start;
  letter-spacing: 0.18em;
  margin: 0;
  min-height: 50px;
  padding: 0 18px;
  text-transform: uppercase;
  z-index: 1;
}

.cue-display-text {
  color: inherit;
  display: block;
  line-height: 1.08;
  white-space: pre-line;
}

.cue-display-note {
  color: #f8fafc !important;
  display: block;
  font-family: inherit;
  font-size: calc(var(--live-cue-size, 64px) * 0.8);
  font-weight: 750;
  letter-spacing: 0.02em;
  line-height: 1.2;
  max-width: min(980px, 84vw);
  opacity: 0.92;
  text-shadow: none;
  white-space: normal;
}

.live-slide-preview {
  border: 2px solid rgba(255,255,255,0.94);
  border-radius: 2px;
  box-sizing: border-box;
  box-shadow: 0 20px 70px rgb(0 0 0 / 0.38);
  display: block;
  height: auto;
  max-width: min(760px, 72vw);
  width: auto;
}

.live-status::before {
  animation: pulse 1.6s infinite;
  background: var(--listening-dot);
  border-radius: 50%;
  content: '';
  height: 16px;
  width: 16px;
}

.cue-display {
  color: var(--cue-pace-color, #fff);
  font-family: var(--font-display);
  font-size: clamp(56px, 14vw, 112px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
  padding: 32px;
  position: relative;
  text-shadow: none;
  transform-origin: center;
  transition: color 2600ms ease, text-shadow 1200ms ease, transform 250ms ease;
  overflow-wrap: normal;
  text-align: center;
  white-space: pre-line;
  word-break: normal;
  z-index: 1;
}

.live-stage[data-pace='on'] .cue-display {
  color: var(--cue-pace-color, var(--pace-on)) !important;
  text-shadow: var(--glow-on);
}

.live-stage[data-pace='slow'] .cue-display {
  animation: hurryPulse 720ms ease-in-out infinite;
  color: var(--cue-pace-color, var(--pace-slow)) !important;
  -webkit-text-stroke: 1px rgba(255,255,255,0.36);
  text-shadow: var(--glow-slow);
}

.live-stage[data-pace='fast'] .cue-display {
  animation: slowPulse 1800ms ease-in-out infinite;
  color: var(--cue-pace-color, var(--pace-fast)) !important;
  text-shadow: var(--glow-fast);
}

.live-controls {
  display: none;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  position: relative;
  z-index: 1;
}

.live-controls button {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  min-width: 0;
  padding: 8px;
  text-transform: uppercase;
}

.live-meta {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-top: 6px;
  position: relative;
  z-index: 1;
}

.progress-text,
.pace-text {
  color: rgba(255,255,255,0.62);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}

.pace-text {
  text-align: right;
}

.transcript-text {
  color: var(--text-dim);
  display: none !important;
  font-size: 11px;
  margin-top: 10px;
  max-width: 100%;
  position: relative;
  z-index: 1;
}

.live-stage::after {
  content: none;
}

.live-time-progress {
  --talk-time-progress: 0%;
  background: rgba(255,255,255,0.04);
  border: clamp(2px, 0.35dvh, 4px) solid rgba(255,255,255,0.92);
  border-radius: var(--r-full);
  bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 10px));
  box-shadow: 0 0 18px rgba(255,255,255,0.08);
  height: clamp(18px, 2.7dvh, 28px);
  left: max(16px, calc(env(safe-area-inset-left, 0px) + 14px));
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  right: max(16px, calc(env(safe-area-inset-right, 0px) + 14px));
  z-index: 4;
}

.live-time-progress.hidden {
  display: none !important;
}

.live-time-progress span {
  background: var(--cue-pace-color, var(--pace-on));
  border-radius: inherit;
  display: block;
  height: 100%;
  transition: width 300ms linear, background-color 2600ms ease;
  width: var(--talk-time-progress);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes hurryPulse {
  0%, 100% {
    filter: brightness(1);
    transform: scale(1);
  }
  50% {
    filter: brightness(1.18);
    transform: scale(1.012);
  }
}

@keyframes slowPulse {
  0%, 100% {
    filter: brightness(1);
    transform: scale(1);
  }
  50% {
    filter: brightness(0.86);
    transform: scale(0.992);
  }
}

@media (min-width: 860px) {
  .workspace {
    max-width: 1180px;
  }

  .edit-view {
    grid-template-columns: minmax(0, 1fr) 330px;
  }

  .cue-script-grid {
    grid-template-columns: minmax(260px, 0.8fr) minmax(340px, 1.2fr);
  }
}

.signin-form button,
.auth-actions button {
  background: var(--primary);
  border: 0;
  border-radius: var(--r-full);
  box-shadow: none;
  color: white;
  font-weight: 700;
  min-height: 42px;
}

.signin-form .text-button {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--text-muted);
  min-height: 0;
  padding: 4px 8px;
}

.signin-form .text-button:hover {
  background: transparent;
  color: var(--text);
}

.signin-form .quiet-button,
.auth-actions .quiet-button {
  background: var(--surface-2);
  border: 1px solid var(--primary-soft);
  color: var(--text);
}

.app-shell[data-mode='live'] .topbar {
  align-items: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  display: flex;
  justify-content: center;
  left: 50%;
  margin: 0;
  max-width: none;
  min-height: 0;
  padding: 0;
  position: fixed;
  top: 14px;
  transform: translateX(-50%);
  width: auto;
  z-index: 5;
}

.app-shell[data-mode='live'] .topbar > div:first-child,
.app-shell[data-mode='live'] .account-pill {
  display: none;
}

.app-shell[data-mode='live'] .mode-switch {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(8px);
  justify-self: center;
}

.app-shell[data-mode='live'] .mode-button {
  color: rgba(226,232,240,0.72);
}

.app-shell[data-mode='live'] .mode-button.active {
  background: var(--primary);
  color: white;
}

/* UI polish after indigo refresh */
.eyebrow,
.talk-name-field > .eyebrow,
.preview-label,
.wpm-heading label,
.settings-grid > label,
.cue-list-heading .eyebrow,
.script-context h2 .eyebrow,
.account-pill::before {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.14em;
}

.script-context h2 > span:last-child {
  display: none;
}

.cue-list-heading > span:last-child,
.script-context p {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

#cueInput,
#scriptInput,
.script-cue-view {
  color: var(--text);
  min-height: 240px;
}

#scriptInput {
  height: 240px;
  resize: vertical;
}

.script-cue-view {
  max-height: 420px;
}

.talk-input-wrap input,
.saved-toggle,
.talk-actions button,
#saveCueCardButton,
#deleteCueCardButton {
  height: 50px;
  min-height: 50px;
}

#saveCueCardButton,
#deleteCueCardButton {
  width: 50px;
}

.settings-grid select {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  min-height: 48px;
}

.account-pill {
  justify-content: flex-end;
}

.account-pill::before {
  margin-right: auto;
}

.account-pill span {
  max-width: 240px;
}

.account-pill .quiet-button {
  margin-left: 8px;
}

@media (min-width: 860px) {
  #cueInput,
  #scriptInput,
  .script-cue-view {
    min-height: 420px;
  }

  #scriptInput {
    height: 420px;
  }
}

.cue-list-heading > span:last-child,
.cue-script-grid .script-context p {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  margin: 0;
}

.script-context h2 {
  display: block;
}

.script-context h2 .eyebrow {
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--text-muted);
  display: inline;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  margin: 0;
  padding: 0;
  text-transform: uppercase;
}

/* Talk title workflow polish */
.talk-manager {
  grid-template-columns: minmax(160px, 0.72fr) auto;
  align-items: end;
}

.saved-toggle {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  min-width: 72px;
  padding: 0 14px;
  text-transform: uppercase;
}

.talk-actions {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 8px;
}

.talk-actions button,
#saveCueCardButton,
#newCueCardButton,
#deleteCueCardButton {
  border-radius: var(--r-md);
  font-size: 11px;
  font-weight: 700;
  height: 50px;
  letter-spacing: 0.08em;
  min-height: 50px;
  min-width: 72px;
  padding: 0 10px;
  text-transform: uppercase;
  width: 72px;
}

#saveCueCardButton {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: white;
}

#saveCueCardButton::before,
#deleteCueCardButton::before {
  content: none;
}

#newCueCardButton,
#deleteCueCardButton {
  background: transparent;
  border: 1px solid var(--border);
  box-shadow: none;
}

#newCueCardButton {
  color: var(--text);
}

#deleteCueCardButton {
  color: var(--danger);
}

@media (max-width: 760px) {
  .talk-manager {
    grid-template-columns: 1fr;
  }

  .talk-actions {
    grid-template-columns: repeat(3, 1fr);
  }

  .talk-actions button,
  #saveCueCardButton,
  #newCueCardButton,
  #deleteCueCardButton {
    min-width: 0;
    width: 100%;
  }
}

/* Larger centered mode toggle */
.topbar {
  display: flex;
  justify-content: center;
}

.mode-switch {
  justify-self: center;
  margin: 0 auto;
}

.mode-button {
  min-height: 50px;
  min-width: 96px;
  padding: 0 22px;
}

.app-shell[data-mode='live'] .topbar {
  justify-content: center;
}

.app-shell[data-mode='live'] .mode-button {
  min-height: 50px;
  min-width: 96px;
}

.app-shell[data-mode='edit'] .topbar > div:first-child {
  display: none;
}

@media (min-width: 860px) {
  .cue-script-grid {
    align-items: stretch;
  }

  .cue-list-panel,
  .script-context {
    display: grid;
    gap: 12px;
    grid-template-rows: auto 38px 44px minmax(0, 1fr) auto;
  }

  .cue-list-heading,
  .script-context h2 {
    min-height: 16px;
  }

  .cue-tools,
  .cue-script-grid .script-tools {
    min-height: 44px;
  }

  .cue-list-heading > span:last-child,
  .cue-script-grid .script-context p {
    min-height: 38px;
  }

  #cueInput,
  #scriptInput,
  .script-cue-view {
    height: 420px;
    min-height: 420px;
    resize: none;
  }
}

#cueInput,
#scriptInput,
.script-cue-view,
.stretch textarea,
.cue-script-grid .stretch textarea,
.cue-script-grid .script-context textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: none;
}

/* Desktop three-column edit layout */
@media (min-width: 1100px) {
  .workspace {
    max-width: 1420px;
    padding: 16px 40px 48px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    margin: 0 auto 40px;
    width: 100%;
  }

  .app-shell[data-mode='edit'] .topbar > div:first-child {
    display: none;
  }

  .mode-switch {
    grid-column: 2;
    justify-self: center;
  }

  .account-pill {
    border-top: 1px solid var(--border);
    grid-column: 3;
    justify-self: end;
    max-width: 360px;
    order: 0;
    padding: 16px 0 0;
    width: 100%;
  }

  .edit-view {
    display: grid;
    gap: 28px;
    grid-template-columns: minmax(320px, 0.9fr) minmax(470px, 1.35fr) minmax(310px, 0.85fr);
    max-width: none;
    width: 100%;
  }

  .editor-panel {
    display: contents;
  }

  .talk-manager,
  .save-status {
    grid-column: 1 / 3;
  }

  .talk-manager {
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(360px, 480px) repeat(3, 88px);
    margin-bottom: 42px;
  }

  .talk-name-field {
    grid-column: 1;
  }

  .talk-actions {
    align-self: end;
    display: grid;
    gap: 10px;
    grid-column: 2 / 5;
    grid-template-columns: repeat(3, 88px);
  }

  .talk-actions button,
  #saveCueCardButton,
  #newCueCardButton,
  #deleteCueCardButton {
    width: 88px;
  }

  .cue-script-grid {
    display: contents;
  }

  .cue-list-panel {
    grid-column: 1;
  }

  .script-context {
    grid-column: 2;
  }

  .settings-panel {
    align-self: start;
    grid-column: 3;
    margin-top: 172px;
  }

  .cue-tools {
    grid-column: 1;
    margin-top: -20px;
  }

  .cue-list-panel,
  .script-context {
    display: grid;
    gap: 18px;
    grid-template-rows: 74px 520px auto;
  }

  .script-context {
    grid-template-rows: 74px auto 520px auto;
  }

  .cue-list-heading,
  .script-context h2 {
    align-self: start;
  }

  .cue-list-heading > span:last-child,
  .cue-script-grid .script-context p {
    min-height: 42px;
  }

  .script-tools {
    align-self: start;
    grid-template-columns: repeat(2, 1fr);
    margin-top: 0;
  }

  #cueInput,
  #scriptInput,
  .script-cue-view {
    height: 520px;
    min-height: 520px;
    resize: none;
  }

  .script-cue-view {
    max-height: 520px;
  }

  .script-status {
    margin: 0;
  }
}

/* Desktop three-column correction */
@media (min-width: 1100px) {
  .workspace {
    max-width: 1500px;
    padding: 16px 40px 48px;
  }

  .topbar {
    align-items: center;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    justify-content: center;
    margin: 0 auto 44px;
    max-width: none;
    padding: 0;
    position: static;
    transform: none;
    width: 100%;
  }

  .mode-switch {
    grid-column: 2;
    justify-self: center;
  }

  .account-pill {
    display: flex;
    grid-column: 3;
    justify-self: end;
  }

  .edit-view {
    display: grid;
    gap: 28px;
    grid-template-columns: 350px 540px 330px;
    justify-content: center;
    margin: 0 auto;
    max-width: none;
    width: 100%;
  }

  .editor-panel {
    display: grid;
    grid-column: 1 / 3;
    grid-template-columns: 350px 540px;
    column-gap: 28px;
    row-gap: 44px;
    padding: 0;
    position: relative;
  }

  .talk-manager {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 480px repeat(3, 88px);
    gap: 10px;
    margin: 0;
  }

  .talk-name-field {
    grid-column: 1;
  }

  .talk-actions {
    align-self: end;
    display: grid;
    grid-column: 2 / 5;
    grid-template-columns: repeat(3, 88px);
    gap: 10px;
  }

  .save-status {
    grid-column: 1 / -1;
    left: 0;
    margin: 0;
    position: absolute;
    top: 84px;
  }

  .cue-script-grid {
    display: contents;
  }

  .cue-list-panel {
    grid-column: 1;
    grid-row: 2;
    position: relative;
  }

  .script-context {
    grid-column: 2;
    grid-row: 2;
  }

  .cue-list-panel,
  .script-context {
    display: grid;
    grid-template-rows: 92px 520px auto;
    gap: 14px;
  }

  .cue-list-panel {
    grid-template-rows: 92px 616px auto;
  }

  .script-context {
    grid-template-rows: 92px 24px 44px 520px auto;
  }

  .cue-list-heading,
  .script-context h2 {
    align-self: start;
    margin: 0;
  }

  .cue-list-heading > span:last-child,
  .cue-script-grid .script-context p {
    margin: 10px 0 0;
    min-height: 44px;
  }

  .script-tools {
    align-self: start;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  #scriptInput,
  .script-cue-view {
    height: 520px;
    min-height: 520px;
    resize: none;
  }

  #cueInput {
    height: 616px;
    font-size: 20px;
    line-height: 1.75;
    min-height: 616px;
    padding-bottom: 54px;
    resize: none;
  }

  .cue-count {
    bottom: 18px;
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
    left: 18px;
    letter-spacing: 0;
    position: absolute;
  }

  .script-cue-view {
    max-height: 520px;
  }

  .cue-tools {
    grid-column: 1;
    grid-row: 3;
    margin: -22px 0 0;
  }

  .settings-panel {
    align-self: start;
    grid-column: 3;
    margin: 128px 0 0;
    width: 330px;
  }
}

/* Mobile landscape live toggle safety */
@media (max-width: 920px) and (orientation: landscape) {
  .topbar,
  .app-shell[data-mode='live'] .topbar {
    display: flex;
    left: 50%;
    margin: 0;
    padding: 0;
    pointer-events: auto;
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    transform: translate3d(-50%, 0, 0);
    width: auto;
    z-index: 9999;
  }

  .topbar > div:first-child,
  .account-pill,
  .app-shell[data-mode='live'] .topbar > div:first-child,
  .app-shell[data-mode='live'] .account-pill {
    display: none;
  }

  .mode-switch,
  .app-shell[data-mode='live'] .mode-switch {
    height: 52px;
    margin: 0;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
  }

  .mode-button,
  .app-shell[data-mode='live'] .mode-button {
    height: 44px;
    min-height: 44px;
    min-width: 88px;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .workspace {
    padding-top: calc(env(safe-area-inset-top, 0px) + 74px);
  }

  .app-shell[data-mode='live'] .live-stage {
    padding-top: calc(env(safe-area-inset-top, 0px) + 74px);
  }
}
/* Practice cues flow */
.practice-overlay {
  align-items: center;
  background: rgb(4 5 16 / 0.72);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: max(18px, env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) max(18px, env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  position: fixed;
  z-index: 850;
}

.practice-panel {
  background: #11112a;
  border: 1px solid rgb(83 77 243 / 0.42);
  border-radius: 18px;
  box-sizing: border-box;
  box-shadow: 0 30px 90px rgb(0 0 0 / 0.48);
  display: grid;
  gap: 18px;
  max-height: calc(100dvh - max(36px, env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px) + 36px));
  max-width: 620px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  width: min(620px, 100%);
  -webkit-overflow-scrolling: touch;
}

.practice-heading {
  display: block;
}

.practice-heading > div:first-child {
  min-width: 0;
}

.practice-heading h2 {
  color: var(--pace-on);
  font-size: clamp(2.2rem, 5.4vw, 4.2rem);
  line-height: 1;
  margin: 0;
  overflow-wrap: normal;
  padding-top: 44px;
  text-shadow: var(--glow-on);
  word-break: normal;
}

.practice-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  position: absolute;
  right: 24px;
  top: 24px;
}

.practice-actions button {
  min-height: 42px;
  white-space: nowrap;
}

.practice-progress,
.practice-instruction,
.practice-status {
  color: var(--muted);
  font-weight: 800;
  margin: 0;
}

.practice-instruction {
  color: #f8fafc;
  font-size: 1rem;
}

.practice-heard {
  background: rgb(0 0 0 / 0.36);
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 14px;
  box-sizing: border-box;
  display: grid;
  gap: 8px;
  min-height: 108px;
  min-width: 0;
  padding: 18px;
}

.practice-heard span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.practice-heard strong {
  color: #fff;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.practice-heard small {
  color: var(--muted);
  font-weight: 800;
}

.slide-picker-overlay {
  align-items: center;
  background: rgb(4 5 16 / 0.78);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: max(18px, env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) max(18px, env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  position: fixed;
  z-index: 860;
}

.slide-picker-panel {
  background: #11112a;
  border: 1px solid rgb(83 77 243 / 0.42);
  border-radius: 18px;
  box-shadow: 0 30px 90px rgb(0 0 0 / 0.48);
  box-sizing: border-box;
  display: grid;
  gap: 18px;
  max-height: calc(100dvh - max(36px, env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px) + 36px));
  max-width: 820px;
  overflow: auto;
  padding: 22px;
  width: min(820px, 100%);
  -webkit-overflow-scrolling: touch;
}

.slide-picker-heading {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.slide-picker-heading h2 {
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  line-height: 1;
  margin: 0;
}

.slide-picker-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.slide-picker-card {
  appearance: none;
  background: rgb(255 255 255 / 0.045);
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 12px;
  box-shadow: none;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 10px;
  min-height: 0;
  padding: 10px;
  text-align: left;
}

.slide-picker-card.selected {
  border-color: var(--pace-on);
  box-shadow: 0 0 0 3px rgb(52 211 153 / 0.14);
}

.slide-picker-card img {
  aspect-ratio: 16 / 10;
  background: rgb(0 0 0 / 0.22);
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 8px;
  display: block;
  object-fit: contain;
  width: 100%;
}

.slide-picker-card span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* First-use help screen */
.help-overlay {
  align-items: center;
  background: rgb(4 5 16 / 0.72);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 22px;
  position: fixed;
  z-index: 35;
}

.help-panel {
  background: #11112a;
  border: 1px solid rgb(83 77 243 / 0.42);
  border-radius: 18px;
  box-shadow: 0 30px 90px rgb(0 0 0 / 0.48);
  color: #f8fafc;
  display: grid;
  gap: 24px;
  max-height: min(760px, calc(100svh - 44px));
  max-width: 760px;
  overflow: auto;
  padding: 24px;
  width: min(760px, 100%);
}

.help-heading {
  align-items: start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.help-heading h2 {
  color: #fff;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
  margin: 0;
}

.help-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.welcome-copy {
  color: #d9e1f0;
  display: grid;
  font-size: clamp(1rem, 2.4vw, 1.14rem);
  gap: 16px;
  line-height: 1.55;
  max-width: 660px;
}

.welcome-copy p {
  margin: 0;
}

.welcome-copy p:nth-last-child(2) {
  color: #fff;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 800;
  line-height: 1.1;
  margin-top: 4px;
}

.welcome-copy p:last-child {
  color: var(--pace-on);
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin-top: 4px;
  text-transform: uppercase;
}

.help-grid section {
  background: rgb(255 255 255 / 0.045);
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: var(--r-lg);
  padding: 18px;
}

.help-grid h3 {
  color: var(--pace-on);
  font-size: 15px;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.help-grid p {
  color: #cbd5e1;
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

.account-pill #helpButton {
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 999px;
  color: var(--pace-on);
  min-height: 28px;
  padding: 0 11px;
}

.account-pill #helpButton:hover {
  background: rgba(52, 211, 153, 0.18);
  border-color: rgba(52, 211, 153, 0.58);
  color: #d1fae5;
}

@media (max-width: 640px) {
  .slide-picker-overlay {
    align-items: stretch;
    background: #11112a;
    justify-content: stretch;
    padding: 0;
  }

  .slide-picker-panel {
    background: #11112a;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    max-height: 100dvh;
    padding: calc(env(safe-area-inset-top, 0px) + 18px) 18px calc(env(safe-area-inset-bottom, 0px) + 18px);
    width: 100%;
  }

  .slide-picker-grid {
    grid-template-columns: 1fr;
  }

  .help-overlay {
    align-items: stretch;
    background: #11112a;
    justify-content: stretch;
    padding: 0;
  }

  .help-panel {
    background: #11112a;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    box-sizing: border-box;
    max-height: 100dvh;
    max-width: none;
    min-height: 100dvh;
    padding: max(18px, env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) max(22px, env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
    width: 100%;
  }

  .help-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .practice-panel {
    gap: 14px;
    padding: 18px;
  }

  .practice-heading {
    display: grid;
    gap: 18px;
    grid-template-columns: 1fr;
  }

  .practice-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-content: stretch;
    position: static;
  }

  .practice-actions button {
    min-width: 0;
    padding-inline: 12px;
  }

  .practice-heading h2 {
    font-size: clamp(2.45rem, 11vw, 4rem);
    padding-top: 0;
  }

  .practice-instruction {
    font-size: clamp(1.05rem, 4.4vw, 1.45rem);
  }
}

.talk-actions {
  grid-template-columns: repeat(3, 72px);
}

.cue-tools {
  align-items: center;
  display: flex;
  gap: 10px;
}

#practiceCueButton.file-button {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  min-height: 44px;
  width: auto;
}

@media (max-width: 720px) {
  .talk-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .talk-actions button {
    width: 100%;
  }
}

/* Final cue/script alignment pass */
.cue-list-panel .cue-tools {
  grid-column: auto;
  grid-row: auto;
  margin: 0;
}

.cue-list-panel #practiceCueButton.file-button {
  min-height: 44px;
}

@media (min-width: 860px) {
  .cue-list-panel,
  .script-context {
    display: grid;
    gap: 12px;
    grid-template-rows: auto 38px 44px minmax(420px, 1fr) auto;
  }

  .cue-list-heading,
  .script-context h2 {
    grid-row: 1;
  }

  .cue-list-heading > span:last-child,
  .script-context > p {
    grid-row: 2;
  }

  .cue-list-panel .cue-tools,
  .script-context .script-tools {
    grid-row: 3;
    min-height: 44px;
  }

  .cue-editor-box,
  #scriptInput,
  .script-cue-view {
    grid-row: 4;
  }
}

/* Edit screen layout reset: keep the three desktop columns stable. */
@media (min-width: 1100px) {
  .edit-view {
    align-items: start;
    display: grid;
    gap: 28px;
    grid-template-columns: 360px 560px 330px;
    justify-content: center;
    max-width: none;
    width: 100%;
  }

  .editor-panel {
    background: transparent;
    border: 0;
    box-shadow: none;
    display: grid;
    grid-column: 1 / 3;
    grid-template-columns: 360px 560px;
    column-gap: 28px;
    row-gap: 44px;
    padding: 0;
  }

  .editor-panel::before {
    content: none;
  }

  .talk-manager {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) 88px 88px 88px;
    margin: 0;
    min-width: 0;
  }

  .talk-name-field {
    grid-column: 1;
    min-width: 0;
  }

  .talk-actions {
    display: contents;
  }

  .talk-actions button,
  #saveCueCardButton,
  #newCueCardButton,
  #deleteCueCardButton {
    box-sizing: border-box;
    font-size: 11px;
    height: 50px;
    min-height: 50px;
    min-width: 88px;
    padding: 0 8px;
    width: 88px;
  }

  #saveCueCardButton {
    grid-column: 2;
  }

  #newCueCardButton {
    grid-column: 3;
  }

  #deleteCueCardButton {
    grid-column: 4;
  }

  .save-status {
    grid-column: 1 / -1;
    margin: -34px 0 0;
    min-height: 20px;
    position: static;
  }

  .cue-script-grid {
    display: contents;
  }

  .cue-list-panel,
  .script-context {
    align-self: start;
    background: transparent;
    border: 0;
    box-shadow: none;
    display: grid;
    gap: 12px;
    min-width: 0;
    padding: 0;
  }

  .cue-list-panel {
    grid-column: 1;
    grid-row: 3;
    grid-template-rows: auto 48px 24px 44px 520px auto;
  }

  .script-context {
    grid-column: 2;
    grid-row: 3;
    grid-template-rows: auto 48px 24px 44px 520px auto;
    width: 560px;
  }

  .cue-list-heading {
    display: contents;
  }

  .cue-list-heading .eyebrow,
  .script-context h2 {
    grid-row: 1;
    margin: 0;
    min-height: 0;
  }

  .cue-list-heading > span:last-child,
  .script-context > p {
    align-self: start;
    grid-row: 2;
    margin: 0;
    min-height: 0;
  }

  .cue-strength-legend {
    grid-row: 3;
    margin: 0;
  }

  .cue-list-panel .cue-tools {
    grid-row: 4;
    margin: 0;
    min-height: 44px;
  }

  .script-context .script-tools {
    display: grid;
    gap: 8px;
    grid-row: 4;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0;
    min-height: 44px;
    width: 100%;
  }

  .file-button,
  .script-tools .quiet-button,
  .talk-time-control,
  #practiceCueButton.file-button {
    box-sizing: border-box;
    font-family: var(--font-body);
    font-size: 11px;
    height: 44px;
    justify-content: center;
    min-height: 44px;
    padding: 0 10px;
    white-space: nowrap;
  }

  #cueInput,
  #scriptInput,
  .script-cue-view {
    box-sizing: border-box;
    font-family: var(--font-body);
    grid-row: 5;
    height: 520px;
    min-height: 520px;
    resize: none;
    width: 100%;
  }

  #cueInput {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.65;
    padding-bottom: 54px;
  }

  #scriptInput,
  .script-cue-view {
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.55;
    max-height: 520px;
  }

  .cue-count,
  .script-status {
    grid-row: 6;
    margin: 0;
    position: static;
  }

  .cue-count {
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
  }

  .settings-panel {
    grid-column: 3;
    margin-top: 128px;
    width: 330px;
  }
}

/* Match script edit and cue-selection typography exactly. */
#scriptInput,
.script-cue-view {
  font-family: var(--font-body);
  font-kerning: normal;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.6;
  overflow-wrap: normal;
  padding: 18px 20px;
  white-space: pre-wrap;
  word-break: normal;
}

.script-cue-view {
  margin-top: 0;
}

.script-word {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  padding: 0;
  white-space: inherit;
}

.script-word[aria-pressed="true"],
.script-word[aria-pressed='true'] {
  font-weight: inherit;
}

@media (min-width: 1100px) {
  #scriptInput,
  .script-cue-view {
    font-size: 16px;
    height: 520px;
    line-height: 1.6;
    max-height: 520px;
    min-height: 520px;
    padding: 18px 20px;
  }
}

@media (max-width: 1099px) {
  .talk-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .talk-actions button,
  #saveCueCardButton,
  #newCueCardButton,
  #deleteCueCardButton {
    min-width: 0;
    width: 100%;
  }

  .cue-strength-legend {
    margin-top: 0;
  }
}

/* Wider script column and non-disruptive script status. */
@media (min-width: 1100px) {
  .edit-view {
    grid-template-columns: 340px 680px 330px;
  }

  .editor-panel {
    grid-template-columns: 340px 680px;
  }

  .script-context {
    grid-template-rows: auto 46px 24px 44px 520px 0;
    width: 680px;
  }

  .script-context .script-tools {
    grid-template-columns: 132px 112px minmax(160px, 1fr);
  }

  .script-context .script-tools:has(#commitScriptButton:not(.hidden)) {
    grid-template-columns: 132px 112px minmax(160px, 1fr);
  }

  #commitScriptButton:not(.hidden) {
    grid-column: 2;
  }

  #commitScriptButton:not(.hidden) + #selectCueWordsButton {
    grid-column: 3;
  }

  .script-status {
    height: 0;
    margin: 0;
    min-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
  }
}

/* Final script text parity: make selectable word buttons occupy plain-text space only. */
#scriptInput,
.script-cue-view {
  appearance: none;
  box-sizing: border-box;
  font-family: var(--font-body);
  font-kerning: normal;
  font-size: 16px;
  font-variant-ligatures: normal;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.6;
  overflow-y: auto;
  padding: 18px 20px;
  scrollbar-gutter: stable;
  tab-size: 4;
  text-rendering: auto;
  white-space: pre-wrap;
  word-break: normal;
  word-spacing: 0;
}

.script-cue-view {
  margin: 0;
}

.script-word,
.script-word:hover,
.script-word[aria-pressed="true"],
.script-word[aria-pressed='true'] {
  appearance: none;
  background-clip: padding-box;
  border: 0;
  box-shadow: none;
  display: inline;
  font: inherit;
  height: auto;
  letter-spacing: inherit;
  margin: 0;
  min-height: 0;
  min-width: 0;
  padding: 0;
  text-align: inherit;
  text-transform: none;
  transform: none;
  vertical-align: baseline;
  white-space: inherit;
  width: auto;
  word-spacing: inherit;
}

@media (min-width: 1100px) {
  #scriptInput,
  .script-cue-view {
    height: 520px;
    max-height: 520px;
    min-height: 520px;
  }
}

/* Desktop edit grid system: one source of truth for alignment. */
.script-status {
  display: none;
}

@media (min-width: 1100px) {
  .workspace {
    max-width: none;
    padding: 16px clamp(28px, 4vw, 64px) 56px;
  }

  .edit-view {
    --cue-col: 320px;
    --script-col: minmax(700px, 820px);
    --controls-col: 330px;
    --edit-gap: 28px;
    --heading-row: 18px;
    --help-row: 50px;
    --legend-row: 24px;
    --tools-row: 44px;
    --box-row: 560px;
    align-items: start;
    column-gap: var(--edit-gap);
    display: grid;
    grid-template-columns: var(--cue-col) var(--script-col) var(--controls-col);
    grid-template-rows: auto 22px auto;
    justify-content: center;
    margin: 0 auto;
    max-width: 1540px;
    row-gap: 0;
    width: 100%;
  }

  .editor-panel {
    display: contents;
  }

  .editor-panel::before {
    content: none;
  }

  .talk-manager {
    align-items: end;
    background: transparent;
    border: 0;
    box-shadow: none;
    display: grid;
    gap: 10px;
    grid-column: 1 / 3;
    grid-row: 1;
    grid-template-columns: minmax(360px, 1fr) 88px 88px 88px;
    margin: 0;
    min-width: 0;
    padding: 0;
  }

  .talk-name-field {
    grid-column: 1;
    min-width: 0;
  }

  .talk-actions {
    display: contents;
  }

  #saveCueCardButton,
  #newCueCardButton,
  #deleteCueCardButton {
    align-self: end;
    box-sizing: border-box;
    font-size: 11px;
    height: 50px;
    justify-self: stretch;
    min-height: 50px;
    min-width: 88px;
    padding: 0 8px;
    width: 88px;
  }

  #saveCueCardButton {
    grid-column: 2;
  }

  #newCueCardButton {
    grid-column: 3;
  }

  #deleteCueCardButton {
    grid-column: 4;
  }

  .save-status {
    grid-column: 1 / 3;
    grid-row: 2;
    margin: 6px 0 0;
    min-height: 16px;
    position: static;
  }

  .cue-script-grid {
    display: contents;
  }

  .cue-list-panel,
  .script-context {
    align-self: start;
    background: transparent;
    border: 0;
    box-shadow: none;
    display: grid;
    gap: 12px;
    grid-row: 3;
    grid-template-rows:
      var(--heading-row)
      var(--help-row)
      var(--legend-row)
      var(--tools-row)
      var(--box-row)
      auto;
    min-width: 0;
    padding: 0;
  }

  .cue-list-panel {
    grid-column: 1;
  }

  .script-context {
    grid-column: 2;
    width: 100%;
  }

  .cue-list-heading {
    display: contents;
  }

  .cue-list-heading .eyebrow,
  .script-context h2 {
    align-self: start;
    display: block;
    grid-row: 1;
    margin: 0;
    min-height: 0;
  }

  .cue-list-heading > span:last-child,
  .script-context > p {
    align-self: start;
    grid-row: 2;
    line-height: 1.45;
    margin: 0;
    min-height: 0;
  }

  .cue-strength-legend {
    align-self: start;
    grid-row: 3;
    margin: 0;
  }

  .cue-list-panel .cue-tools,
  .script-context .script-tools {
    align-self: start;
    grid-row: 4;
    margin: 0;
    min-height: var(--tools-row);
  }

  .cue-list-panel .cue-tools {
    display: flex;
  }

  .script-context .script-tools {
    display: grid;
    gap: 8px;
    grid-template-columns: 132px 112px minmax(180px, 1fr);
    width: 100%;
  }

  .script-context .script-tools:has(#commitScriptButton:not(.hidden)) {
    grid-template-columns: 132px 112px minmax(180px, 1fr);
  }

  #commitScriptButton:not(.hidden) {
    grid-column: 2;
  }

  #commitScriptButton:not(.hidden) + #selectCueWordsButton {
    grid-column: 3;
  }

  .file-button,
  .script-tools .quiet-button,
  .talk-time-control,
  #practiceCueButton.file-button {
    box-sizing: border-box;
    font-family: var(--font-body);
    font-size: 11px;
    height: var(--tools-row);
    justify-content: center;
    letter-spacing: 0.08em;
    min-height: var(--tools-row);
    padding: 0 10px;
    white-space: nowrap;
  }

  #cueInput,
  #scriptInput,
  .script-cue-view {
    box-sizing: border-box;
    grid-row: 5;
    height: var(--box-row);
    max-height: var(--box-row);
    min-height: var(--box-row);
    resize: none;
    width: 100%;
  }

  #cueInput {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.65;
    padding-bottom: 54px;
  }

  #scriptInput,
  .script-cue-view {
    font-size: 16px;
    line-height: 1.6;
    padding: 18px 20px;
  }

  .cue-count {
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
    grid-row: 6;
    margin: 0;
    position: static;
  }

  .settings-panel {
    align-self: start;
    grid-column: 3;
    grid-row: 3;
    margin: 0;
    position: sticky;
    top: 18px;
    width: 100%;
  }
}

@media (min-width: 1100px) and (max-width: 1399px) {
  .edit-view {
    --cue-col: 300px;
    --script-col: minmax(620px, 1fr);
    --controls-col: 310px;
    --edit-gap: 22px;
  }
}

@media (max-width: 1099px) {
  .script-status {
    display: none;
  }
}

/* Keep tool buttons visually steady on hover. */
.file-button:hover,
#practiceCueButton.file-button:hover,
.script-tools .quiet-button:hover {
  background: var(--surface-2);
  border-color: var(--primary-soft);
  color: var(--text);
  transform: none;
}

/* Script text and highlighted cue view share one fixed box. */
.script-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.script-box .cue-strength-legend {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px 8px;
}

.script-box #scriptInput,
.script-box .script-cue-view {
  background: transparent;
  border: 0;
  border-radius: 0;
  height: 100%;
  max-height: none;
  min-height: 0;
}

@media (min-width: 1100px) {
  .cue-list-panel,
  .script-context {
    grid-template-rows:
      var(--heading-row)
      var(--help-row)
      var(--tools-row)
      var(--box-row)
      auto;
  }

  .cue-list-panel .cue-tools,
  .script-context .script-tools {
    grid-row: 3;
  }

  #cueInput,
  .script-box {
    grid-row: 4;
  }

  .cue-count {
    grid-row: 5;
  }

  .script-box {
    height: var(--box-row);
    max-height: var(--box-row);
    min-height: var(--box-row);
  }

  .script-box #scriptInput,
  .script-box .script-cue-view {
    grid-row: 2;
  }
}

/* Precision alignment pass for edit columns. */
@media (min-width: 1100px) {
  .edit-view {
    --heading-row: 16px;
    --help-row: 86px;
    --tools-row: 44px;
    --box-row: 560px;
  }

  .cue-list-panel,
  .script-context {
    gap: 10px;
    grid-template-rows:
      var(--heading-row)
      var(--help-row)
      var(--tools-row)
      var(--box-row)
      auto;
  }

  .cue-list-heading .eyebrow,
  .script-context h2,
  .script-context h2 .eyebrow {
    align-self: start;
    display: block;
    font-size: 11px;
    line-height: 16px;
    margin: 0;
    padding: 0;
  }

  .script-context h2 > span:last-child {
    display: none;
  }

  .cue-list-heading > span:last-child,
  .script-context > p {
    align-self: start;
    font-size: 13px;
    line-height: 1.42;
    margin: 0;
    padding: 0;
  }

  .cue-list-panel .cue-tools,
  .script-context .script-tools {
    align-items: stretch;
    align-self: start;
    height: var(--tools-row);
    margin: 0;
    min-height: var(--tools-row);
  }

  .cue-list-panel .cue-tools {
    display: flex;
    gap: 10px;
  }

  .file-button,
  .script-tools .quiet-button,
  .talk-time-control,
  #practiceCueButton.file-button {
    align-self: stretch;
    height: var(--tools-row);
    line-height: 1;
    min-height: var(--tools-row);
  }

  #cueInput,
  .script-box {
    align-self: start;
    grid-row: 4;
    margin: 0;
  }

  .script-box #scriptInput,
  .script-box .script-cue-view {
    grid-row: 1 !important;
  }
}

/* Desktop save/cloud status: keep it beside the title actions, away from Cue Keywords. */
@media (min-width: 1100px) {
  .save-status {
    align-items: center;
    align-self: end;
    display: flex;
    grid-column: 3;
    grid-row: 1;
    justify-self: start;
    margin: 0;
    min-height: 50px;
    padding: 0;
    position: static;
  }
}

/* Calmer edit grid after moving helper text into the help screen. */
@media (min-width: 1100px) {
  .edit-view {
    --cue-col: 420px;
    --help-row: 0px;
    grid-template-columns: var(--cue-col) var(--script-col) var(--controls-col);
    grid-template-rows: auto 6px auto;
  }

  .cue-list-panel,
  .script-context {
    grid-template-rows:
      var(--heading-row)
      var(--tools-row)
      var(--box-row)
      auto;
  }

  .cue-list-heading .eyebrow,
  .script-context h2 {
    grid-row: 1;
  }

  .cue-list-panel .cue-tools,
  .script-context .script-tools {
    grid-row: 2;
  }

  .cue-list-panel .cue-tools {
    display: flex;
    justify-content: flex-start;
    width: 100%;
  }

  .cue-list-panel #practiceCueButton.file-button {
    justify-self: start;
    min-width: 0;
    width: auto;
  }

  #cueInput,
  .script-box {
    grid-row: 3;
    width: 100%;
  }

  .cue-count {
    grid-row: 4;
  }
}

/* Hard desktop alignment reset for the cue/script columns. */
@media (min-width: 1100px) {
  .cue-list-panel {
    display: grid !important;
    gap: 10px !important;
    grid-column: 1 !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: var(--heading-row) var(--tools-row) var(--box-row) auto !important;
    width: 100% !important;
  }

  .cue-list-heading {
    display: block !important;
    grid-column: 1 !important;
    grid-row: 1 !important;
    margin: 0 !important;
  }

  .cue-list-heading .eyebrow {
    display: block !important;
    line-height: var(--heading-row) !important;
    margin: 0 !important;
  }

  .cue-list-panel .cue-tools {
    align-items: stretch !important;
    display: flex !important;
    grid-column: 1 !important;
    grid-row: 2 !important;
    justify-content: flex-start !important;
    margin: 0 !important;
    width: 100% !important;
  }

  .cue-list-panel #practiceCueButton.file-button {
    height: var(--tools-row) !important;
    flex: 0 0 auto !important;
    justify-self: start !important;
    margin: 0 !important;
    min-height: var(--tools-row) !important;
    min-width: 0 !important;
    width: auto !important;
  }

  .cue-editor-box {
    grid-column: 1 !important;
    grid-row: 3 !important;
    height: var(--box-row) !important;
    max-width: none !important;
    min-height: var(--box-row) !important;
    width: 100% !important;
  }

  #cueInput {
    height: 100% !important;
    min-height: 0 !important;
  }

  .cue-count {
    grid-column: 1 !important;
    grid-row: 4 !important;
  }
}

/* Unified edit-screen label style, matching Cue Keywords. */
.talk-name-field > .eyebrow,
.cue-list-heading .eyebrow,
.script-context h2 .eyebrow,
.settings-grid > label > span,
.wpm-heading label,
.preview-label {
  color: var(--text-muted) !important;
  display: block;
  font-family: var(--font-body);
  font-size: 12px !important;
  font-weight: 800 !important;
  letter-spacing: 0.16em !important;
  line-height: 16px !important;
  margin: 0 !important;
  padding: 0 !important;
  text-transform: uppercase !important;
}

.script-context h2 {
  line-height: 16px !important;
  margin: 0 !important;
}

.wpm-heading {
  align-items: start;
}

.preview-label {
  margin-bottom: 10px !important;
}

/* Mobile edit controls: keep Live Preview visible and uncropped on iPhone. */
@media (max-width: 760px) {
  .app-shell[data-mode='edit'] .settings-panel {
    display: grid;
    gap: 14px;
    overflow: visible;
  }

  .app-shell[data-mode='edit'] .preview-label {
    display: block;
    margin: 2px 0 -6px;
  }

  .app-shell[data-mode='edit'] .preview {
    align-items: center;
    aspect-ratio: 16 / 9;
    display: flex;
    justify-content: center;
    min-height: clamp(150px, 42vw, 210px);
    overflow: hidden;
    padding: 16px;
    width: 100%;
  }

  .app-shell[data-mode='edit'] .preview > span {
    display: block;
    line-height: 1;
    max-width: 100%;
    overflow-wrap: normal;
    text-align: center;
    white-space: pre-line;
  }
}

/* Mobile sign-in: make the entry screen fill the viewport without page scroll. */
@media (max-width: 760px) {
  html:has(.signin-view:not(.hidden)),
  body:has(.signin-view:not(.hidden)) {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
  }

  .app-shell:has(.signin-view:not(.hidden)) {
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
  }

  .signin-view {
    align-items: center;
    background: var(--bg);
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
    padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  .signin-panel {
    margin: 0;
    max-height: calc(100svh - 36px);
    overflow: hidden;
    padding: clamp(18px, 5svh, 28px) 18px;
  }

  .signin-panel h1 {
    font-size: clamp(1.9rem, 9vw, 2.85rem);
    margin-bottom: 18px;
  }

  .signin-form {
    gap: 12px;
  }

  .signin-panel input,
  .signin-panel button {
    font-size: 16px;
  }
}

/* Mobile edit viewport: prevent startup overflow before content is loaded. */
@media (max-width: 760px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
    width: 100%;
  }

  .app-shell,
  .workspace,
  .edit-view,
  .editor-panel,
  .settings-panel,
  .talk-manager,
  .cue-script-grid,
  .cue-list-panel,
  .script-context {
    max-width: 100%;
    min-width: 0;
    overflow-x: clip;
    width: 100%;
  }

  .workspace {
    margin: 0;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .topbar {
    max-width: 100%;
    min-width: 0;
    overflow: visible;
    width: 100%;
  }

  .account-pill {
    display: grid;
    gap: 8px 12px;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    justify-content: stretch;
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }

  .account-pill::before {
    min-width: 0;
  }

  .account-pill span {
    max-width: none;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .account-pill .quiet-button {
    min-width: 0;
    white-space: nowrap;
  }

  .talk-input-wrap,
  .talk-actions,
  .cue-tools,
  .script-tools {
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }

  #practiceCueButton.file-button {
    max-width: 100%;
  }

  .talk-input-wrap {
    overflow: visible;
    z-index: 40;
  }

  .saved-talks-menu {
    box-sizing: border-box;
    left: 0 !important;
    max-height: min(260px, 42svh);
    max-width: 100%;
    min-width: 0;
    overflow-y: auto;
    position: absolute;
    right: 0 !important;
    width: auto;
    z-index: 150;
    pointer-events: auto;
    -webkit-overflow-scrolling: touch;
  }

  .saved-talks-list {
    max-height: none;
    overflow: visible;
  }

  .saved-talks-list,
  .saved-talk-button,
  .saved-talks-empty {
    max-width: 100%;
    min-width: 0;
  }

  .saved-talk-button {
    min-height: 56px;
    pointer-events: auto;
    position: relative;
    z-index: 1;
  }
}

/* Final phone edit layout: draw from the viewport, not inherited desktop widths. */
@media (max-width: 760px) {
  .app-shell[data-mode='edit'] {
    inline-size: 100%;
    max-inline-size: 100%;
    overflow-x: hidden;
  }

  .app-shell[data-mode='edit'] .workspace {
    inline-size: 100%;
    margin-inline: 0;
    max-inline-size: none;
    overflow-x: hidden;
    padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
  }

  .app-shell[data-mode='edit'] .topbar,
  .app-shell[data-mode='edit'] .edit-view,
  .app-shell[data-mode='edit'] .editor-panel,
  .app-shell[data-mode='edit'] .settings-panel,
  .app-shell[data-mode='edit'] .talk-manager,
  .app-shell[data-mode='edit'] .cue-script-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    inline-size: 100%;
    max-inline-size: 100%;
    min-inline-size: 0;
  }

  .app-shell[data-mode='edit'] .topbar {
    gap: 14px;
    margin: 0 0 28px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 84px);
  }

  .app-shell[data-mode='edit'] .mode-switch {
    backdrop-filter: blur(12px);
    box-shadow: 0 14px 38px rgb(0 0 0 / 0.24);
    left: 50%;
    margin: 0;
    max-inline-size: calc(100vw - 32px);
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 14px);
    transform: translateX(-50%);
    z-index: 50;
    justify-self: center;
  }

  .app-shell[data-mode='edit'] .mode-button {
    min-height: 44px;
    min-width: 88px;
  }

  .app-shell[data-mode='edit'] .topbar > div:first-child {
    display: none;
  }

  .app-shell[data-mode='edit'] .account-pill {
    margin-top: 0;
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .app-shell[data-mode='edit'] .account-pill::before {
    display: none;
  }

  .app-shell[data-mode='edit'] .talk-input-wrap,
  .app-shell[data-mode='edit'] .talk-actions,
  .app-shell[data-mode='edit'] .cue-tools,
  .app-shell[data-mode='edit'] .script-tools,
  .app-shell[data-mode='edit'] .cue-editor-box,
  .app-shell[data-mode='edit'] .script-box,
  .app-shell[data-mode='edit'] .preview {
    inline-size: 100%;
    max-inline-size: 100%;
    min-inline-size: 0;
  }

  .app-shell[data-mode='edit'] .talk-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .app-shell[data-mode='edit'] .topbar {
    padding-top: calc(env(safe-area-inset-top, 0px) + 66px);
  }

  .app-shell[data-mode='edit'] .mode-switch {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    max-inline-size: calc(100vw - 32px);
  }
}

/* Controls drawer: available from both Edit and Live without living in the page flow. */
.controls-toggle {
  align-self: center;
  background: var(--surface-2);
  border: 1px solid var(--primary-soft);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  min-height: 40px;
  padding: 0 16px;
  text-transform: uppercase;
  white-space: nowrap;
}

.settings-backdrop {
  background: rgb(0 0 0 / 0.45);
  inset: 0;
  position: fixed;
  z-index: 80;
}

.settings-drawer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl) 0 0 var(--r-xl);
  box-shadow: 0 30px 90px rgb(0 0 0 / 0.45);
  display: grid;
  gap: 18px;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  height: 100svh;
  max-width: min(420px, calc(100vw - 20px));
  overflow-y: auto;
  padding: max(22px, env(safe-area-inset-top)) 22px max(22px, env(safe-area-inset-bottom));
  position: fixed;
  right: 0;
  top: 0;
  transform: translateX(105%);
  transition: transform 180ms ease;
  width: 420px;
  z-index: 90;
}

.settings-drawer.open {
  transform: translateX(0);
}

.settings-drawer .panel-heading {
  align-items: start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.drawer-close {
  flex: 0 0 auto;
  min-height: 38px;
}

@media (min-width: 1100px) {
  .edit-view {
    grid-template-columns: minmax(320px, 420px) minmax(620px, 820px) !important;
    max-width: 1260px !important;
  }

  .topbar {
    grid-template-columns: 1fr auto auto 1fr !important;
  }

  .controls-toggle {
    grid-column: 3;
    justify-self: end;
  }

  .account-pill {
    grid-column: 4;
  }
}

@media (min-width: 1100px) {
  .app-shell[data-mode='edit'] .edit-view {
    --cue-col: minmax(320px, 420px);
    --script-col: minmax(620px, 820px);
    --edit-gap: 28px;
    grid-template-columns: var(--cue-col) var(--script-col) !important;
    justify-content: center;
  }

  .app-shell[data-mode='edit'] .talk-manager,
  .app-shell[data-mode='edit'] .save-status {
    grid-column: 1 / 3;
  }

  .app-shell[data-mode='edit'] .cue-list-panel {
    grid-column: 1;
  }

  .app-shell[data-mode='edit'] .script-context {
    grid-column: 2;
  }
}

@media (max-width: 760px) {
  .controls-toggle {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
    box-shadow: 0 14px 34px rgb(0 0 0 / 0.32);
    min-height: 46px;
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    z-index: 55;
  }

  .settings-drawer {
    border-radius: var(--r-xl) 0 0 var(--r-xl);
    max-width: calc(100vw - 18px);
    padding: max(18px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
    width: min(390px, calc(100vw - 18px));
  }

  .settings-drawer .preview {
    min-height: clamp(150px, 42vw, 210px);
  }
}

.app-shell .settings-drawer {
  display: grid;
  max-width: min(420px, calc(100vw - 20px));
  overflow-y: auto;
  position: fixed;
  right: 0;
  top: 0;
  transform: translateX(105%);
  width: 420px;
}

.app-shell .settings-drawer.open {
  transform: translateX(0);
}

.save-toast {
  background: var(--surface-2);
  border: 1px solid var(--primary-soft);
  border-radius: var(--r-full);
  box-shadow: 0 16px 42px rgb(0 0 0 / 0.36);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  left: 50%;
  margin: 0;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  position: fixed;
  text-align: center;
  top: calc(env(safe-area-inset-top, 0px) + 82px);
  transform: translateX(-50%);
  z-index: 85;
}

.save-toast[data-tone='success'] {
  border-color: rgb(16 185 129 / 0.42);
  color: var(--pace-on);
}

.save-toast[data-tone='warn'] {
  border-color: rgb(251 191 36 / 0.52);
  color: var(--warn);
}

.save-toast[data-tone='pending'] {
  color: var(--text-muted);
}

.save-status[data-tone='success'] {
  color: var(--pace-on);
}

.save-status[data-tone='warn'] {
  color: var(--warn);
}

.reset-practice-button {
  justify-self: auto;
  width: auto;
}

/* Floating mode and controls cluster, shared by desktop and mobile. */
.mode-switch {
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 38px rgb(0 0 0 / 0.24);
  left: 50%;
  margin: 0 !important;
  position: fixed !important;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  transform: translateX(-50%) !important;
  z-index: 70;
}

.mode-switch .mode-button,
.mode-switch .controls-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--text-muted);
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  height: 44px;
  justify-content: center;
  letter-spacing: 0.08em;
  min-height: 44px;
  min-width: 104px;
  padding: 0 14px;
  text-transform: uppercase;
}

.mode-switch .mode-button.active,
.mode-switch .controls-toggle[aria-expanded='true'] {
  background: var(--primary);
  color: white;
}

.topbar {
  padding-top: calc(env(safe-area-inset-top, 0px) + 72px) !important;
}

.app-shell[data-mode='live'] .topbar {
  pointer-events: none;
}

.app-shell[data-mode='live'] .mode-switch,
.mode-switch .mode-button,
.mode-switch .controls-toggle {
  pointer-events: auto;
}

.app-shell[data-mode='live'] .controls-toggle {
  display: inline-flex;
}

@media (max-width: 760px) {
  .save-toast {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 76px);
    top: auto;
  }

  .mode-switch {
    max-width: calc(100vw - 24px);
    top: calc(env(safe-area-inset-top, 0px) + 10px);
  }

  .mode-switch .mode-button,
  .mode-switch .controls-toggle {
    min-width: min(30vw, 108px);
    padding: 0 10px;
  }

  .controls-toggle {
    bottom: auto;
    position: static;
    right: auto;
  }

  .app-shell[data-mode='edit'] .topbar {
    padding-top: calc(env(safe-area-inset-top, 0px) + 78px) !important;
  }
}

@media (max-width: 920px) and (orientation: landscape) {
  .mode-switch {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
  }

  .topbar,
  .app-shell[data-mode='live'] .topbar {
    left: auto;
    position: static;
    transform: none;
    width: 100%;
  }
}

/* Separate Controls action from the Edit/Live state toggle. */
.floating-controls {
  align-items: center;
  display: flex;
  gap: 10px;
  left: 50%;
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  transform: translateX(-50%);
  z-index: 70;
}

.workspace > .floating-controls {
  display: flex !important;
  left: 50% !important;
  position: fixed !important;
  top: calc(env(safe-area-inset-top, 0px) + 14px) !important;
  transform: translateX(-50%) !important;
  z-index: 120;
}

.floating-controls .mode-switch {
  left: auto;
  position: static !important;
  top: auto;
  transform: none !important;
}

.floating-controls .controls-toggle {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--primary-soft);
  border-radius: var(--r-full);
  box-shadow: 0 14px 38px rgb(0 0 0 / 0.24);
  color: var(--text);
  display: inline-flex;
  height: 52px;
  justify-content: center;
  line-height: 1;
  min-height: 52px;
  min-width: 104px;
}

.floating-controls .controls-toggle[aria-expanded='true'] {
  background: var(--surface-2);
  border-color: var(--primary);
  color: var(--text);
}

.rotate-hint {
  display: none;
}

.rotate-hint-dismissed .rotate-hint {
  display: none !important;
}

.app-shell[data-mode='live'] .topbar {
  display: block !important;
}

.app-shell[data-mode='live'] .floating-controls {
  display: flex !important;
  pointer-events: auto;
}

.app-shell[data-mode='live'] .workspace > .floating-controls {
  display: flex !important;
  pointer-events: auto;
}

.app-shell[data-mode='live'] .floating-controls .controls-toggle {
  color: white;
  line-height: 1;
  pointer-events: auto;
}

body:has(.app-shell[data-mode='live']),
.app-shell[data-mode='live'] {
  overflow: hidden;
}

.app-shell[data-mode='live'] .workspace,
.app-shell[data-mode='live'] .live-view,
.app-shell[data-mode='live'] .live-stage {
  height: 100svh;
  max-height: 100svh;
  min-height: 100svh;
  overflow: hidden;
}

.app-shell[data-mode='live'] .live-stage {
  padding-top: calc(env(safe-area-inset-top, 0px) + 64px) !important;
  padding-bottom: max(14px, env(safe-area-inset-bottom, 0px)) !important;
}

@media (min-width: 1100px) {
  .floating-controls {
    grid-column: 1 / -1;
    justify-self: center;
  }
}

/* iOS landscape live view: keep the cue centred in the visible area. */
@media (max-width: 920px) and (orientation: landscape) {
  body:has(.app-shell[data-mode='live']),
  .app-shell[data-mode='live'],
  .app-shell[data-mode='live'] .workspace,
  .app-shell[data-mode='live'] .live-view {
    height: 100svh;
    max-height: 100svh;
    min-height: 100svh;
    overflow: hidden;
  }

  .app-shell[data-mode='live'] .live-stage {
    align-items: stretch;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    height: 100svh;
    max-height: 100svh;
    min-height: 100svh;
    overflow: hidden;
    padding:
      calc(env(safe-area-inset-top, 0px) + 76px)
      max(28px, env(safe-area-inset-right, 0px))
      calc(env(safe-area-inset-bottom, 0px) + 18px)
      max(28px, env(safe-area-inset-left, 0px)) !important;
  }

  .app-shell[data-mode='live'] .live-status {
    margin: 0;
    min-height: 42px;
  }

  .app-shell[data-mode='live'] .cue-display {
    align-self: center;
    display: grid;
    min-height: 0;
    padding: 6px 18px 0;
    place-items: center;
    transform: translateY(-2vh);
  }

  .app-shell[data-mode='live'] .live-stage[data-has-slide] .cue-display {
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 3.5svh, 28px);
    justify-content: center;
    padding: 8px 22px 0;
    transform: none;
  }

  .app-shell[data-mode='live'] .live-stage[data-has-slide] .live-slide-preview {
    max-height: 32svh;
    max-width: min(46svw, 380px);
    width: auto;
  }

  .app-shell[data-mode='live'] .live-stage[data-has-slide] .cue-display-note {
    margin-top: clamp(6px, 1.8svh, 16px);
  }

  .app-shell[data-mode='live'] .live-controls {
    gap: 16px;
    margin: 0 0 8px;
  }

  .app-shell[data-mode='live'] .live-controls button {
    min-height: 44px;
    padding: 8px 12px;
  }

  .app-shell[data-mode='live'] .live-meta {
    margin: 0;
  }

  .app-shell[data-mode='live'] .transcript-text {
    display: none;
  }
}

@media (max-width: 760px) {
  .floating-controls {
    gap: 8px;
    max-width: calc(100vw - 24px);
    top: calc(env(safe-area-inset-top, 0px) + 10px);
  }

  .workspace > .floating-controls {
    top: calc(env(safe-area-inset-top, 0px) + 10px) !important;
  }

  .floating-controls .mode-button,
  .floating-controls .controls-toggle {
    min-width: min(28vw, 104px);
  }
}

.saved-talks-portal {
  background: rgb(20 20 48 / 0.98);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.42);
  box-sizing: border-box;
  display: grid;
  gap: 2px;
  max-height: min(260px, 42svh);
  overflow-y: auto;
  padding: 6px;
  pointer-events: auto;
  position: fixed;
  z-index: 640;
  -webkit-overflow-scrolling: touch;
}

.saved-talks-portal .saved-talk-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 10px;
  box-shadow: none;
  color: var(--text);
  display: flex;
  font-size: 1.08rem;
  font-weight: 800;
  justify-content: flex-start;
  letter-spacing: 0.01em;
  min-height: 58px;
  padding: 0 16px;
  text-align: left;
  touch-action: manipulation;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.saved-talks-portal .saved-talk-button:active {
  background: var(--primary-soft);
}

.saved-talks-portal .saved-talks-empty {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-size: 0.95rem;
  font-weight: 750;
  min-height: 54px;
  padding: 0 16px;
}

/* Controls drawer must sit above the floating Edit/Live/Controls cluster on iOS. */
.settings-backdrop {
  z-index: 650 !important;
}

.app-shell .settings-drawer,
.settings-drawer {
  z-index: 700 !important;
}

.help-overlay {
  z-index: 800 !important;
}

@media (max-width: 760px) {
  .app-shell[data-mode='edit'] .topbar {
    margin-bottom: 18px !important;
    padding-top: calc(env(safe-area-inset-top, 0px) + 58px) !important;
  }

  .app-shell[data-mode='edit'] .topbar > div:first-child {
    display: none !important;
  }
}

.signin-logo {
  border-radius: 22px;
  box-shadow: 0 18px 48px rgb(0 0 0 / 0.32);
  display: block;
  height: 82px;
  margin: 0 0 18px;
  width: 82px;
}

.signin-panel > .eyebrow {
  margin-bottom: 12px;
}

.signin-panel h1 {
  max-width: 11ch;
}

@media (max-width: 760px) {
  .signin-logo {
    border-radius: 18px;
    height: 68px;
    margin-bottom: 14px;
    width: 68px;
  }

  .signin-panel h1 {
    max-width: 12ch;
  }

  .app-shell[data-mode='edit'] .topbar > div:first-child {
    display: block;
  }

}

/* Cicero sign-in direction. */
.signin-view {
  background: #090817;
}

.signin-panel {
  background: #171735;
  border: 1px solid rgb(91 79 255 / 0.28);
  border-radius: 18px;
  box-shadow: 0 28px 90px rgb(0 0 0 / 0.36);
  padding: 28px;
  width: min(388px, 100%);
}

.signin-wordmark {
  display: block;
  height: auto;
  margin: 0 auto 26px;
  max-width: 292px;
  width: 86%;
}

.signin-panel h1 {
  color: #eef2ff;
  font-size: clamp(2.55rem, 6.2vw, 3.9rem);
  line-height: 0.88;
  margin: 0 0 30px;
  max-width: 8.4ch;
}

.signin-panel label,
.signin-form label,
.auth-status {
  color: #85879e;
}

.signin-panel input {
  background: #151633;
  border-color: rgb(91 79 255 / 0.34);
  color: #f4f6ff;
}

.signin-panel input::placeholder {
  color: #8b8da4;
}

.signin-panel button {
  min-height: 46px;
}

.signin-panel #signInButton {
  background: #5748f5;
}

.signin-panel #signUpButton {
  background: #232260;
  border-color: rgb(91 79 255 / 0.36);
  color: #f4f6ff;
}

.signin-panel #forgotPasswordButton {
  color: #a9abc0;
  margin-top: 6px;
}

.signin-panel .auth-status:not(.warn) {
  color: var(--accent);
  font-size: 1rem;
  font-weight: 850;
}

@media (max-width: 760px) {
  .signin-panel {
    border-radius: 18px;
    max-height: calc(100svh - 36px);
    padding: clamp(20px, 4svh, 28px) 18px;
    width: min(388px, 100%);
  }

  .signin-wordmark {
    margin-bottom: 20px;
    max-width: 250px;
  }

  .signin-panel h1 {
    font-size: clamp(2.35rem, 11vw, 3.1rem);
    margin-bottom: 22px;
    max-width: 8.5ch;
  }
}

/* iOS/mobile sign-in: use the Cicero panel colour as the full screen. */
@media (max-width: 760px) {
  .app-shell:has(.signin-view:not(.hidden)) {
    background: #171735;
  }

  .signin-view {
    align-items: stretch;
    background: #171735;
    padding: max(20px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  }

  .signin-panel {
    align-content: start;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    display: grid;
    justify-self: center;
    max-height: none;
    min-height: calc(100svh - max(20px, env(safe-area-inset-top)) - max(20px, env(safe-area-inset-bottom)));
    overflow: visible;
    padding: 0;
    width: min(388px, 100%);
  }

  .signin-wordmark {
    margin-bottom: 18px;
    max-width: min(270px, 82vw);
  }

  .signin-panel h1 {
    font-size: clamp(2.35rem, 11vw, 3.25rem);
    margin-bottom: 22px;
  }

  .signin-form {
    gap: 11px;
  }

  .signin-panel #forgotPasswordButton {
    margin-top: 0;
  }

  .signin-panel .auth-status {
    line-height: 1.25;
    margin-top: 4px;
    min-height: 44px;
  }
}

@media (max-width: 920px) and (orientation: portrait) {
  .app-shell[data-mode='edit'] .floating-controls {
    display: grid !important;
    gap: 8px;
    grid-template-columns: 1fr auto;
    left: 50% !important;
    max-width: calc(100dvw - 32px);
    top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
    transform: translateX(-50%) !important;
    width: min(460px, calc(100dvw - 32px));
  }

  .app-shell[data-mode='edit'] .mode-switch {
    display: none !important;
  }

  .app-shell[data-mode='edit'] .rotate-hint {
    align-items: center;
    align-self: center;
    color: var(--text-muted);
    display: inline-flex;
    font-size: 10px;
    font-weight: 800;
    height: 46px;
    letter-spacing: 0.08em;
    margin: 0;
    padding: 0 2px;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .app-shell[data-mode='edit'] .rotate-hint > span {
    color: var(--text-muted);
  }

  .app-shell[data-mode='edit'] .floating-controls .controls-toggle {
    height: 46px;
    min-height: 46px;
    min-width: 112px;
  }

  .rotate-hint-dismissed .app-shell[data-mode='edit'] .floating-controls {
    display: flex !important;
    justify-content: center;
    width: auto;
  }
}

/* Final iOS landscape live correction: remove inherited page offsets. */
@media (max-width: 920px) and (orientation: landscape) {
  body:has(.app-shell[data-mode='live']) {
    background: #000;
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell[data-mode='live'] .live-close-button {
    display: none !important;
  }

  .app-shell[data-mode='live'] .floating-controls {
    display: none !important;
  }

  .app-shell[data-mode='live'] .workspace > .floating-controls,
  .app-shell[data-mode='live'] .controls-toggle {
    display: none !important;
  }

  .app-shell[data-mode='live'] .mode-switch {
    display: none !important;
  }

  .app-shell[data-mode='live'] .workspace,
  .app-shell[data-mode='live'] .live-view {
    height: 100dvh !important;
    margin: 0 !important;
    max-height: 100dvh !important;
    min-height: 100dvh !important;
    padding: 0 !important;
    position: fixed;
    inset: 0;
  }

  .app-shell[data-mode='live'] .live-stage {
    display: block;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 100dvh;
    padding: 0 !important;
    position: fixed;
    inset: 0;
  }

  .app-shell[data-mode='live'] .live-status {
    left: max(28px, env(safe-area-inset-left, 0px));
    min-height: 52px;
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 16px);
  }

  .app-shell[data-mode='live'] .cue-display {
    bottom: 0 !important;
    display: block !important;
    left: 0 !important;
    max-width: none !important;
    padding: 0 !important;
    pointer-events: none !important;
    position: absolute;
    right: 0 !important;
    text-align: center !important;
    top: 0 !important;
    transform: none !important;
    width: 100dvw !important;
    z-index: 1 !important;
  }

  .app-shell[data-mode='live'] .cue-display-text {
    display: block !important;
    left: 50% !important;
    line-height: 1.08 !important;
    max-width: calc(100dvw - max(96px, env(safe-area-inset-left, 0px) + env(safe-area-inset-right, 0px) + 96px)) !important;
    position: absolute !important;
    text-align: center !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    white-space: pre-line !important;
    width: max-content !important;
  }

  .app-shell[data-mode='live'] .cue-display-note {
    display: block !important;
    font-size: calc(var(--live-cue-size, 56px) * 0.8);
    left: 50% !important;
    margin: 0 !important;
    max-width: calc(100dvw - max(120px, env(safe-area-inset-left, 0px) + env(safe-area-inset-right, 0px) + 120px)) !important;
    position: absolute !important;
    text-align: center !important;
    top: calc(50% + clamp(72px, 15dvh, 116px)) !important;
    transform: translateX(-50%) !important;
    width: max-content !important;
  }

  .app-shell[data-mode='live'] .live-stage[data-has-slide] .live-slide-preview {
    display: block !important;
    left: 50% !important;
    max-height: 30dvh !important;
    max-width: min(420px, 48dvw) !important;
    position: absolute !important;
    top: clamp(72px, 18dvh, 136px) !important;
    transform: translateX(-50%) !important;
    width: auto !important;
  }

  .app-shell[data-mode='live'] .live-controls {
    bottom: max(58px, calc(env(safe-area-inset-bottom, 0px) + 42px));
    left: max(28px, env(safe-area-inset-left, 0px));
    margin-bottom: 0;
    position: absolute;
    right: max(28px, env(safe-area-inset-right, 0px));
  }

  .app-shell[data-mode='live'] .live-meta,
  .app-shell[data-mode='live'] .transcript-text {
    display: none !important;
  }
}

/* Signed-out iOS auth screens are portrait-only. */
.auth-orientation-gate {
  display: none;
}

#cueInput {
  caret-color: var(--text);
  display: block;
  line-height: 1.32;
  white-space: normal;
}

.cue-editor-row {
  align-content: center;
  box-sizing: border-box;
  color: var(--text);
  column-gap: 16px;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  grid-template-rows: auto auto;
  line-height: 1.2;
  margin: 0;
  min-height: 1.32em;
  outline: none;
  overflow-wrap: break-word;
  padding: 1px 0 3px;
  white-space: pre-wrap;
  word-break: normal;
}

.cue-editor-row + .cue-editor-row {
  margin-top: 28px;
}

.cue-editor-row[data-editing="true"] {
  display: grid;
}

.cue-editor-row[data-cue-strength="strong"] {
  color: var(--pace-on, #34d399);
}

.cue-editor-row[data-cue-strength="weak"] {
  color: #f59e0b;
}

.cue-editor-row:focus {
  text-shadow: 0 0 16px rgb(255 255 255 / 0.12);
}

.cue-editor-text {
  color: inherit;
  display: block;
}

.cue-editor-main {
  align-self: end;
  align-items: end;
  column-gap: 14px;
  display: grid;
  grid-column: 2;
  grid-row: 1;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
}

.cue-editor-edit-text {
  align-self: end;
  color: inherit;
  display: block;
  grid-column: 2;
  grid-row: 1;
  outline: none;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  word-break: normal;
}

.cue-slide-slot {
  align-self: center;
  background-color: rgb(255 255 255 / 0.025);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  border: 1.5px dotted rgb(248 250 252 / 0.38);
  border-radius: 6px;
  box-sizing: border-box;
  cursor: pointer;
  display: block;
  grid-column: 1;
  grid-row: 1 / span 2;
  height: 54px;
  margin-top: 0;
  opacity: 0.85;
  position: relative;
  width: 84px;
}

.cue-slide-upload-input {
  cursor: pointer;
  height: 100%;
  inset: 0;
  opacity: 0;
  position: absolute;
  width: 100%;
  z-index: 2;
}

.cue-slide-slot::before {
  color: rgb(248 250 252 / 0.32);
  content: "+";
  font-family: var(--font-body);
  font-size: 26px;
  font-weight: 700;
  left: 50%;
  line-height: 1;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -54%);
}

.cue-slide-slot.has-slide {
  border-style: solid;
  border-color: rgb(110 231 183 / 0.58);
  opacity: 1;
}

.cue-slide-slot.has-slide::before {
  content: none;
}

.cue-slide-slot.drag-over {
  border-color: var(--pace-on, #34d399);
  box-shadow: 0 0 0 3px rgb(52 211 153 / 0.18);
}

.dragging-slide,
.dragging-slide * {
  user-select: none !important;
  -webkit-user-select: none !important;
}

.cue-editor-note {
  color: #f8fafc;
  display: block;
  font-family: var(--font-body);
  font-size: 0.78em;
  font-weight: 700;
  grid-column: 2;
  grid-row: 2;
  line-height: 1.25;
  margin-top: 1px;
  opacity: 0.9;
  text-transform: none;
}

.cue-editor-note-placeholder {
  cursor: pointer;
  opacity: 0.28;
}

.cue-note-editor {
  color: #f8fafc;
  display: block;
  font-family: var(--font-body);
  font-size: 0.78em;
  font-weight: 700;
  grid-column: 2;
  grid-row: 2;
  line-height: 1.25;
  margin-top: 1px;
  min-height: 1.25em;
  outline: none;
  text-transform: none;
}

.cue-note-editor:empty::before {
  color: #f8fafc;
  content: attr(data-placeholder);
  opacity: 0.38;
}

.cue-editor-row:empty::before {
  color: var(--text-faint, #475569);
  content: "New cue";
}

.cue-editor-row[data-cue-raw=""] .cue-editor-text::before {
  color: var(--text-faint, #475569);
  content: "New cue";
}

.cue-editor-box #cueInput {
  grid-column: auto !important;
  grid-row: auto !important;
  height: 100% !important;
  max-width: none !important;
  min-height: 0 !important;
  width: 100% !important;
}

.cue-editor-box {
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
}

.cue-editor-box > .cue-strength-legend {
  flex: 0 0 auto !important;
  order: 0 !important;
}

.cue-editor-box > #cueInput {
  display: block !important;
  flex: 1 1 auto !important;
  gap: 0 !important;
  order: 1 !important;
}

.cue-editor-box .cue-editor-row {
  column-gap: 16px !important;
  display: grid !important;
  grid-template-columns: 86px minmax(0, 1fr) !important;
  grid-template-rows: auto auto !important;
  line-height: 1.2 !important;
  margin: 0 !important;
  overflow-wrap: break-word !important;
  padding-bottom: 3px !important;
}

.cue-editor-box .cue-editor-row[data-editing="true"] {
  display: grid !important;
}

.cue-editor-box .cue-editor-row + .cue-editor-row {
  margin-top: 28px !important;
}

.preview .preview-note {
  color: #f8fafc !important;
  font-family: inherit !important;
  font-size: clamp(18px, 3.5vw, 30px) !important;
  font-weight: 750 !important;
  line-height: 1.16 !important;
  opacity: 0.9;
  text-shadow: none !important;
  white-space: normal !important;
}

.script-box {
  grid-template-rows: minmax(0, 1fr) !important;
}

.script-box > #scriptInput:not(.hidden),
.script-box > .script-cue-view:not(.hidden) {
  display: block;
  grid-column: 1 !important;
  grid-row: 1 !important;
  height: 100% !important;
  max-height: none !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  transform: none !important;
  width: 100% !important;
}

@media (max-width: 920px) and (orientation: landscape) {
  .signin-view:not(.hidden) {
    background: #171735;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    padding: max(22px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
    place-items: center;
  }

  .signin-view:not(.hidden) .signin-panel {
    display: none !important;
  }

  .signin-view:not(.hidden) .auth-orientation-gate--portrait {
    align-items: center;
    border: 1px solid rgb(83 77 243 / 0.34);
    border-radius: 22px;
    color: #eef2ff;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
    max-width: min(460px, calc(100dvw - 64px));
    min-height: 190px;
    padding: 24px;
    text-align: center;
  }

  .signin-view:not(.hidden) .auth-orientation-gate--portrait strong {
    color: #eef2ff;
    font-size: clamp(1.9rem, 6vw, 3.2rem);
    line-height: 0.95;
  }

  .signin-view:not(.hidden) .auth-orientation-gate--portrait span {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.02em;
  }
}

/* Tablets use landscape and the sign-in surface should feel full-screen, not card-in-card. */
@media (min-width: 700px) and (max-width: 1400px) {
  .tablet-device .app-shell:has(.signin-view:not(.hidden)) {
    background: #171735;
    min-height: 100dvh;
    overflow: hidden;
  }

  .tablet-device .signin-view:not(.hidden) {
    align-items: center;
    background: #171735;
    min-height: 100dvh;
    overflow: hidden;
    padding: clamp(28px, 5dvh, 56px) clamp(32px, 6dvw, 72px);
  }

  .tablet-device .signin-view:not(.hidden) .signin-panel {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    width: min(430px, 46dvw);
  }

  .tablet-device .signin-view:not(.hidden) .signin-wordmark {
    max-width: min(330px, 34dvw);
  }

  .tablet-device .signin-view:not(.hidden) .signin-panel h1 {
    font-size: clamp(3rem, 5.2dvw, 4.5rem);
  }
}

@media (min-width: 700px) and (max-width: 1180px) and (orientation: portrait) {
  .tablet-device .signin-view:not(.hidden) {
    place-items: center;
  }

  .tablet-device .signin-view:not(.hidden) .signin-panel {
    display: none !important;
  }

  .tablet-device .signin-view:not(.hidden) .auth-orientation-gate--landscape {
    align-items: center;
    border: 1px solid rgb(83 77 243 / 0.34);
    border-radius: 22px;
    color: #eef2ff;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
    max-width: min(520px, calc(100dvw - 80px));
    min-height: 210px;
    padding: 28px;
    text-align: center;
  }

  .tablet-device .signin-view:not(.hidden) .auth-orientation-gate--landscape strong {
    color: #eef2ff;
    font-size: clamp(2.25rem, 7dvw, 4rem);
    line-height: 0.95;
  }

  .tablet-device .signin-view:not(.hidden) .auth-orientation-gate--landscape span {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
  }
}

/* Cicero navigation refresh: logo/menu header, cue Live action, and clean Live close. */
.workspace {
  padding: 28px clamp(24px, 5vw, 72px) 56px !important;
}

.topbar {
  align-items: center !important;
  background: transparent !important;
  border: 0 !important;
  box-sizing: border-box !important;
  box-shadow: none !important;
  display: flex !important;
  justify-content: space-between !important;
  margin: 0 auto 10px !important;
  max-width: 1260px !important;
  padding: 0 !important;
  position: relative !important;
  width: 100% !important;
  z-index: 130 !important;
}

.app-wordmark {
  align-items: center;
  background-image: url("assets/cicero-wordmark-header.png");
  background-position: left center;
  background-repeat: no-repeat;
  background-size: contain;
  color: #fff;
  display: inline-flex;
  font-family: var(--font-display);
  font-size: 0;
  font-weight: 400;
  height: 46px;
  isolation: isolate;
  letter-spacing: 0.34em;
  line-height: 1;
  position: relative;
  text-shadow: 0 8px 18px rgb(83 77 243 / 0.28);
  width: 218px;
}

.app-wordmark::after {
  content: "";
  display: none;
}

.menu-toggle {
  align-items: center;
  background: transparent !important;
  border: 0 !important;
  border-radius: var(--r-md);
  box-shadow: none !important;
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  height: 48px;
  justify-content: center;
  padding: 0;
  width: 48px;
}

.menu-toggle span {
  background: #f8fafc;
  border-radius: var(--r-full);
  display: block;
  height: 5px;
  width: 32px;
}

.menu-toggle:hover {
  background: rgb(255 255 255 / 0.08) !important;
}

.legacy-mode-switch,
.floating-controls {
  display: none !important;
}

.rotate-hint {
  display: none;
}

.rotate-hint-dismissed .rotate-hint {
  display: none !important;
}

.app-shell[data-mode='live'] .live-meta,
.app-shell[data-mode='live'] .progress-text,
.app-shell[data-mode='live'] .pace-text {
  display: none !important;
}

.app-shell[data-mode='edit'] .edit-view {
  margin-top: 0 !important;
}

.app-shell[data-mode='edit'] .talk-manager {
  margin-top: 0 !important;
}

.cue-list-panel .cue-tools {
  align-items: center !important;
  display: grid !important;
  gap: 14px !important;
  grid-template-columns: repeat(3, 132px) !important;
  justify-content: flex-start !important;
  width: auto !important;
}

.cue-list-panel #practiceCueButton.file-button,
.cue-list-panel .talk-time-control,
.live-action-button {
  align-items: center;
  border-radius: var(--r-md);
  display: inline-flex;
  font-size: 11px;
  font-weight: 900;
  height: 48px;
  justify-content: center;
  letter-spacing: 0.08em;
  min-height: 48px;
  padding: 0 18px;
  text-transform: uppercase;
  width: 132px;
}

.live-action-button {
  background: #9b0008 !important;
  border: 1px solid rgb(255 255 255 / 0.08) !important;
  box-shadow: none !important;
  color: #fff !important;
}

.live-action-button:hover {
  background: #b5000a !important;
}

.settings-account {
  background: rgb(255 255 255 / 0.045);
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: var(--r-lg);
  display: grid;
  gap: 12px;
  padding: 16px;
}

.settings-account .eyebrow {
  margin: 0;
}

.settings-account #signedInEmail {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-entitlement {
  color: var(--pace-on);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.35;
  margin: 0;
  text-transform: uppercase;
}

.account-entitlement.is-paid {
  color: #d1fae5;
}

.account-entitlement.is-ended {
  color: #ff6678;
}

.settings-account button {
  font-size: 11px;
  font-weight: 900;
  justify-content: center;
  letter-spacing: 0.08em;
  min-height: 42px;
  text-transform: uppercase;
  width: 100%;
}

.unlock-button {
  background: rgba(52, 211, 153, 0.18) !important;
  border: 1px solid rgba(52, 211, 153, 0.45) !important;
  border-radius: var(--r-full) !important;
  color: var(--pace-on) !important;
  font-size: 11px;
  font-weight: 950;
  justify-content: center;
  letter-spacing: 0.1em;
  min-height: 42px;
  text-transform: uppercase;
}

.unlock-button:hover {
  background: rgba(52, 211, 153, 0.26) !important;
  border-color: rgba(52, 211, 153, 0.65) !important;
  color: #d1fae5 !important;
}

.settings-help-button {
  background: rgba(52, 211, 153, 0.12) !important;
  border: 1px solid rgba(52, 211, 153, 0.35) !important;
  border-radius: var(--r-full) !important;
  color: var(--pace-on) !important;
  font-size: 11px;
  font-weight: 900;
  justify-content: center;
  letter-spacing: 0.08em;
  min-height: 42px;
  text-transform: uppercase;
  width: 100%;
}

.settings-help-button:hover {
  background: rgba(52, 211, 153, 0.18) !important;
  border-color: rgba(52, 211, 153, 0.58) !important;
  color: #d1fae5 !important;
}

.app-shell[data-mode='live'] .topbar {
  display: none !important;
}

.app-shell[data-mode='live'] .workspace {
  padding: 0 !important;
}

.live-close-button {
  align-items: center;
  background: rgb(255 255 255 / 0.08) !important;
  border: 1px solid rgb(255 255 255 / 0.12) !important;
  border-radius: var(--r-full);
  box-shadow: 0 16px 42px rgb(0 0 0 / 0.34) !important;
  color: #f8fafc !important;
  display: inline-flex;
  font-size: 11px;
  font-weight: 900;
  justify-content: center;
  letter-spacing: 0.12em;
  height: 52px;
  min-height: 52px;
  padding: 0 22px;
  position: absolute;
  right: max(24px, env(safe-area-inset-right, 0px));
  text-transform: uppercase;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  z-index: 8;
}

.app-shell[data-mode='live'] .live-status {
  height: 52px !important;
  min-height: 52px !important;
  top: calc(env(safe-area-inset-top, 0px) + 16px) !important;
}

@media (min-width: 1100px) {
  .app-shell[data-mode='edit'] .edit-view {
    max-width: 1260px !important;
  }

  .app-shell[data-mode='edit'] .cue-script-grid {
    gap: 28px !important;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: calc(env(safe-area-inset-top, 0px) + 98px) max(18px, env(safe-area-inset-right, 0px)) 36px max(18px, env(safe-area-inset-left, 0px)) !important;
  }

  .topbar {
    align-items: center !important;
    background: #080718 !important;
    border-bottom: 1px solid rgb(83 77 243 / 0.22) !important;
    box-sizing: border-box !important;
    justify-content: space-between !important;
    left: 0;
    margin: 0 !important;
    max-width: none !important;
    min-height: calc(env(safe-area-inset-top, 0px) + 72px);
    padding: calc(env(safe-area-inset-top, 0px) + 10px) max(18px, env(safe-area-inset-right, 0px)) 10px max(18px, env(safe-area-inset-left, 0px)) !important;
    position: fixed !important;
    right: 0;
    top: 0;
    width: 100% !important;
  }

  .app-wordmark {
    height: 36px;
    margin: 0 !important;
    width: 170px;
  }

  .menu-toggle {
    height: 42px;
    margin-left: auto !important;
    width: 42px;
  }

  .menu-toggle span {
    height: 4px;
    width: 28px;
  }

  .cue-list-panel .cue-tools {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .cue-list-panel #practiceCueButton.file-button,
  .cue-list-panel .talk-time-control {
    height: 48px !important;
    min-height: 48px !important;
    width: 100%;
  }

  .cue-list-panel #cueLiveButton {
    display: none !important;
  }

  .app-shell[data-mode='edit'] .rotate-hint:not(.hidden) {
    align-items: center;
    background: rgb(83 77 243 / 0.14);
    border: 1px solid rgb(83 77 243 / 0.28);
    border-radius: var(--r-full);
    color: var(--text-muted);
    display: inline-flex;
    font-size: 11px;
    font-weight: 900;
    justify-content: center;
    letter-spacing: 0.1em;
    line-height: 1;
    margin: -6px 0 24px;
    min-height: 42px;
    padding: 0 18px;
    text-align: center;
    text-transform: uppercase;
    width: 100%;
  }

  .app-shell[data-mode='live'] .rotate-hint,
  .rotate-hint-dismissed .app-shell[data-mode='edit'] .rotate-hint {
    display: none !important;
  }
}

/* Final mobile header lock: keep Cicero left and the menu right on one compact row. */
@media (max-width: 760px) {
  .app-shell[data-mode='edit'] .workspace {
    padding-top: calc(env(safe-area-inset-top, 0px) + 94px) !important;
  }

  .app-shell[data-mode='edit'] .workspace > .topbar {
    align-items: center !important;
    background: #080718 !important;
    border: 0 !important;
    border-bottom: 1px solid rgb(83 77 243 / 0.22) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 18px !important;
    height: calc(env(safe-area-inset-top, 0px) + 72px) !important;
    justify-content: space-between !important;
    left: 0 !important;
    margin: 0 !important;
    max-height: calc(env(safe-area-inset-top, 0px) + 72px) !important;
    max-width: none !important;
    min-height: calc(env(safe-area-inset-top, 0px) + 72px) !important;
    overflow: hidden !important;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) max(20px, env(safe-area-inset-right, 0px)) 10px max(20px, env(safe-area-inset-left, 0px)) !important;
    position: fixed !important;
    right: 0 !important;
    top: 0 !important;
    transform: none !important;
    width: 100% !important;
    z-index: 140 !important;
  }

  .app-shell[data-mode='edit'] .workspace > .topbar .app-wordmark {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    font-size: 0 !important;
    height: 34px !important;
    letter-spacing: 0.32em !important;
    line-height: 1 !important;
    margin: 0 !important;
    width: 162px !important;
  }

  .app-shell[data-mode='edit'] .workspace > .topbar .app-wordmark::after {
    bottom: 1px !important;
    height: 6px !important;
    width: 34px !important;
  }

  .app-shell[data-mode='edit'] .workspace > .topbar .menu-toggle {
    align-self: center !important;
    display: inline-flex !important;
    flex: 0 0 42px !important;
    height: 42px !important;
    margin: 0 0 0 auto !important;
    position: static !important;
    transform: none !important;
    width: 42px !important;
  }
}

/* Final mobile controls drawer order: prevent Font and Live Preview from colliding. */
@media (max-width: 760px) {
  .app-shell .settings-drawer,
  .app-shell[data-mode='edit'] .settings-drawer {
    align-content: start !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 22px !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow-y: auto !important;
    padding: max(28px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) max(28px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px)) !important;
    -webkit-overflow-scrolling: touch;
  }

  .settings-drawer .panel-heading {
    align-items: center !important;
    display: flex !important;
    flex: 0 0 auto !important;
    justify-content: space-between !important;
    order: 0 !important;
  }

  .settings-drawer .panel-heading h2 {
    color: var(--text) !important;
  }

  .settings-drawer .settings-account {
    flex: 0 0 auto !important;
    order: 1 !important;
  }

  .settings-drawer .settings-help-button {
    flex: 0 0 auto !important;
    order: 2 !important;
  }

  .settings-drawer .settings-grid {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-direction: column !important;
    gap: 24px !important;
    order: 3 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  .settings-drawer .control-field,
  .settings-drawer .settings-grid > label,
  .settings-drawer .wpm-control {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-direction: column !important;
    gap: 10px !important;
    min-height: 0 !important;
    order: initial !important;
    overflow: visible !important;
    width: 100% !important;
  }

  .settings-drawer .language-control {
    order: 1 !important;
  }

  .settings-drawer .wpm-control-field {
    order: 2 !important;
  }

  .settings-drawer .detection-control {
    order: 3 !important;
  }

  .settings-drawer .font-control {
    order: 4 !important;
  }

  .settings-drawer .font-control select,
  .settings-drawer #fontInput {
    display: block !important;
    min-height: 58px !important;
    opacity: 1 !important;
    visibility: visible !important;
    width: 100% !important;
  }

  .settings-drawer .preview-label {
    flex: 0 0 auto !important;
    margin: 2px 0 -12px !important;
    order: 4 !important;
  }

  .settings-drawer .preview {
    flex: 0 0 auto !important;
    margin-top: 0 !important;
    min-height: clamp(210px, 54vw, 300px) !important;
    order: 5 !important;
    width: 100% !important;
  }
}

/* Final iPad app tuning: fixed edit canvas, scrollable controls, aligned live pills. */
@media (min-width: 700px) and (max-width: 1400px) and (orientation: landscape) {
  .tablet-device body:has(.app-shell[data-mode='edit']),
  .tablet-device .app-shell[data-mode='edit'] {
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .workspace {
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    padding: 18px clamp(22px, 3dvw, 38px) max(18px, env(safe-area-inset-bottom, 0px)) !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .topbar {
    margin-bottom: 8px !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .edit-view {
    --box-row: clamp(390px, calc(100dvh - 245px), 530px) !important;
    column-gap: clamp(18px, 2.2dvw, 28px) !important;
    max-height: calc(100dvh - 88px) !important;
    overflow: visible !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .cue-list-panel,
  .tablet-device .app-shell[data-mode='edit'] .script-context {
    gap: 10px !important;
    grid-template-rows: var(--heading-row, 18px) var(--tools-row, 48px) var(--box-row) 24px !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .cue-list-heading,
  .tablet-device .app-shell[data-mode='edit'] .script-context h2 {
    grid-row: 1 !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .cue-list-panel .cue-tools,
  .tablet-device .app-shell[data-mode='edit'] .script-context .script-tools {
    grid-row: 2 !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .cue-list-panel .cue-tools {
    display: grid !important;
    gap: 8px !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    justify-content: stretch !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .cue-list-panel #practiceCueButton.file-button,
  .tablet-device .app-shell[data-mode='edit'] .cue-list-panel .talk-time-control,
  .tablet-device .app-shell[data-mode='edit'] .cue-list-panel #cueLiveButton {
    box-sizing: border-box !important;
    font-size: 10px !important;
    height: 48px !important;
    line-height: 1 !important;
    min-height: 48px !important;
    min-width: 0 !important;
    padding-inline: 6px !important;
    width: 100% !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .cue-editor-box,
  .tablet-device .app-shell[data-mode='edit'] .script-box {
    grid-row: 3 !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .cue-editor-box,
  .tablet-device .app-shell[data-mode='edit'] .script-box,
  .tablet-device .app-shell[data-mode='edit'] #cueInput,
  .tablet-device .app-shell[data-mode='edit'] #scriptInput,
  .tablet-device .app-shell[data-mode='edit'] .script-cue-view {
    height: var(--box-row) !important;
    max-height: var(--box-row) !important;
    min-height: var(--box-row) !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .script-box > #scriptInput:not(.hidden),
  .tablet-device .app-shell[data-mode='edit'] .script-box > .script-cue-view:not(.hidden),
  .tablet-device .app-shell[data-mode='edit'] .cue-editor-box > #cueInput {
    flex: 1 1 auto !important;
    min-height: 0 !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .cue-count {
    align-self: end !important;
    display: block !important;
    font-size: 16px !important;
    grid-row: 4 !important;
    line-height: 20px !important;
    margin: 0 !important;
    min-height: 20px !important;
  }

  .tablet-device .settings-drawer {
    align-content: start !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow-y: auto !important;
    padding: max(24px, env(safe-area-inset-top, 0px)) 22px max(24px, env(safe-area-inset-bottom, 0px)) !important;
    -webkit-overflow-scrolling: touch;
  }

  .tablet-device .settings-drawer .settings-grid {
    display: flex !important;
    flex-direction: column !important;
    flex: 0 0 auto !important;
    gap: 22px !important;
    width: 100% !important;
  }

  .tablet-device .settings-drawer .control-field,
  .tablet-device .settings-drawer .settings-grid > label,
  .tablet-device .settings-drawer .wpm-control {
    display: flex !important;
    flex-direction: column !important;
    flex: 0 0 auto !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .tablet-device .settings-drawer .language-control {
    order: 1 !important;
  }

  .tablet-device .settings-drawer .wpm-control-field {
    order: 2 !important;
  }

  .tablet-device .settings-drawer .detection-control {
    order: 3 !important;
  }

  .tablet-device .settings-drawer .font-control {
    order: 4 !important;
  }

  .tablet-device .settings-drawer #fontInput {
    display: block !important;
    min-height: 52px !important;
    opacity: 1 !important;
    visibility: visible !important;
    width: 100% !important;
  }

  .tablet-device .settings-drawer .preview-label {
    flex: 0 0 auto !important;
    order: 4 !important;
  }

  .tablet-device .settings-drawer .preview {
    flex: 0 0 auto !important;
    min-height: 220px !important;
    order: 5 !important;
  }

  .tablet-device .app-shell[data-mode='live'] .live-close-button,
  .tablet-device .app-shell[data-mode='live'] .live-status {
    display: inline-flex !important;
    height: 52px !important;
    min-height: 52px !important;
    position: absolute !important;
    top: calc(env(safe-area-inset-top, 0px) + 18px) !important;
  }

  .tablet-device .app-shell[data-mode='live'] .live-status {
    left: max(28px, env(safe-area-inset-left, 0px)) !important;
  }

  .tablet-device .app-shell[data-mode='live'] .live-close-button {
    right: max(28px, env(safe-area-inset-right, 0px)) !important;
  }

  .tablet-device .app-shell[data-mode='live'] .live-controls {
    bottom: max(58px, calc(env(safe-area-inset-bottom, 0px) + 48px)) !important;
    left: max(28px, env(safe-area-inset-left, 0px)) !important;
    margin: 0 !important;
    position: absolute !important;
    right: max(28px, env(safe-area-inset-right, 0px)) !important;
    z-index: 5 !important;
  }

  .tablet-device .app-shell[data-mode='live'] .cue-display {
    bottom: 0 !important;
    display: block !important;
    left: 0 !important;
    max-width: none !important;
    padding: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    right: 0 !important;
    text-align: center !important;
    top: 0 !important;
    transform: none !important;
    width: 100dvw !important;
    z-index: 1 !important;
  }

  .tablet-device .app-shell[data-mode='live'] .cue-display-text {
    display: block !important;
    left: 50% !important;
    line-height: 1.08 !important;
    max-width: calc(100dvw - 128px) !important;
    position: absolute !important;
    text-align: center !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    white-space: pre-line !important;
    width: max-content !important;
  }

  .tablet-device .app-shell[data-mode='live'] .cue-display-note {
    display: block !important;
    left: 50% !important;
    margin: 0 !important;
    max-width: calc(100dvw - 180px) !important;
    position: absolute !important;
    text-align: center !important;
    top: calc(50% + clamp(96px, 14dvh, 164px)) !important;
    transform: translateX(-50%) !important;
    width: max-content !important;
  }

  .tablet-device .app-shell[data-mode='live'] .live-stage[data-has-slide] .live-slide-preview {
    display: block !important;
    left: 50% !important;
    max-height: 36dvh !important;
    max-width: min(760px, 52dvw) !important;
    position: absolute !important;
    top: clamp(150px, 30dvh, 260px) !important;
    transform: translate(-50%, -50%) !important;
    width: auto !important;
  }

  .tablet-device .app-shell[data-mode='live'] .live-stage[data-has-slide] .cue-display-text {
    top: clamp(58dvh, 64dvh, 68dvh) !important;
  }

  .tablet-device .app-shell[data-mode='live'] .live-stage[data-has-slide] .cue-display-note {
    top: clamp(74dvh, 78dvh, 82dvh) !important;
  }

  .tablet-device .app-shell[data-mode='live'] .live-meta {
    bottom: max(18px, calc(env(safe-area-inset-bottom, 0px) + 12px)) !important;
    left: max(28px, env(safe-area-inset-left, 0px)) !important;
    margin: 0 !important;
    position: absolute !important;
    right: max(28px, env(safe-area-inset-right, 0px)) !important;
    z-index: 5 !important;
  }
}

@media (min-width: 921px) {
  .app-shell[data-mode='live'] .live-stage {
    display: block !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: relative !important;
  }

  .app-shell[data-mode='live'] .live-close-button,
  .app-shell[data-mode='live'] .live-status {
    height: 52px !important;
    min-height: 52px !important;
    position: absolute !important;
    top: calc(env(safe-area-inset-top, 0px) + 18px) !important;
    z-index: 6 !important;
  }

  .app-shell[data-mode='live'] .live-status {
    left: max(28px, env(safe-area-inset-left, 0px)) !important;
  }

  .app-shell[data-mode='live'] .live-close-button {
    right: max(28px, env(safe-area-inset-right, 0px)) !important;
  }

  .app-shell[data-mode='live'] .cue-display {
    bottom: 0 !important;
    display: block !important;
    left: 0 !important;
    max-width: none !important;
    padding: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    right: 0 !important;
    text-align: center !important;
    top: 0 !important;
    transform: none !important;
    width: 100dvw !important;
    z-index: 1 !important;
  }

  .app-shell[data-mode='live'] .cue-display-text {
    display: block !important;
    left: 50% !important;
    line-height: 1.08 !important;
    max-width: calc(100dvw - 128px) !important;
    position: absolute !important;
    text-align: center !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    white-space: pre-line !important;
    width: max-content !important;
  }

  .app-shell[data-mode='live'] .cue-display-note {
    display: block !important;
    left: 50% !important;
    margin: 0 !important;
    max-width: calc(100dvw - 180px) !important;
    position: absolute !important;
    text-align: center !important;
    top: calc(50% + clamp(96px, 14dvh, 164px)) !important;
    transform: translateX(-50%) !important;
    width: max-content !important;
  }

  .app-shell[data-mode='live'] .live-stage[data-has-slide] .live-slide-preview {
    display: block !important;
    left: 50% !important;
    max-height: 35dvh !important;
    max-width: min(760px, 54dvw) !important;
    position: absolute !important;
    top: clamp(140px, 30dvh, 250px) !important;
    transform: translate(-50%, -50%) !important;
    width: auto !important;
  }

  .app-shell[data-mode='live'] .live-stage[data-has-slide] .cue-display-text {
    top: clamp(58dvh, 64dvh, 68dvh) !important;
  }

  .app-shell[data-mode='live'] .live-stage[data-has-slide] .cue-display-note {
    top: clamp(74dvh, 78dvh, 82dvh) !important;
  }

  .app-shell[data-mode='live'] .live-controls {
    bottom: max(58px, calc(env(safe-area-inset-bottom, 0px) + 48px)) !important;
    left: max(28px, env(safe-area-inset-left, 0px)) !important;
    margin: 0 !important;
    position: absolute !important;
    right: max(28px, env(safe-area-inset-right, 0px)) !important;
    z-index: 5 !important;
  }

  .app-shell[data-mode='live'] .live-meta {
    bottom: max(18px, calc(env(safe-area-inset-bottom, 0px) + 12px)) !important;
    left: max(28px, env(safe-area-inset-left, 0px)) !important;
    margin: 0 !important;
    position: absolute !important;
    right: max(28px, env(safe-area-inset-right, 0px)) !important;
    z-index: 5 !important;
  }
}

.app-shell[data-mode='live'] .live-controls {
  display: none !important;
}

/* Slides panel prototype: isolated right-panel mode switch and placeholder workspace. */
.script-context .panel-mode-row {
  min-width: 0;
}

.script-context .panel-mode-row h2 {
  min-width: 0;
}

.slides-tools .file-button,
.slides-tools .quiet-button {
  box-sizing: border-box;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 900;
  justify-content: center;
  letter-spacing: 0.08em;
  min-height: 44px;
  padding: 0 10px;
  white-space: nowrap;
}

.slides-tools .file-button:hover,
.slides-tools .quiet-button:hover {
  background: var(--surface-2);
  border-color: var(--primary-soft);
  color: var(--text);
  transform: none;
}

@media (max-width: 720px) {
  .panel-mode-row {
    align-items: stretch;
    display: grid;
    gap: 12px;
  }

  .slides-tools {
    grid-template-columns: 1fr;
  }

  .slide-placeholder-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 860px) {
  .script-context .panel-mode-row {
    grid-row: 1;
  }

  .script-context .right-panel-workspace:not(.hidden) {
    display: contents;
  }

  .script-context .script-tools,
  .script-context .slides-tools {
    grid-row: 3;
  }

  .script-context .script-box,
  .script-context .slides-box {
    grid-row: 4;
  }
}

@media (min-width: 1100px) {
  .script-context .panel-mode-row {
    align-self: start;
    grid-row: 1;
  }

  .script-context .panel-mode-row h2 {
    display: block;
    margin: 0;
  }

  .script-context .script-tools,
  .script-context .slides-tools {
    align-self: start;
    grid-row: 4;
    min-height: var(--tools-row);
  }

  .script-context .slides-tools {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(150px, 1fr));
    width: 100%;
  }

  .script-context .script-box,
  .script-context .slides-box {
    box-sizing: border-box;
    grid-row: 5;
    height: var(--box-row);
    max-height: var(--box-row);
    min-height: var(--box-row);
    width: 100%;
  }
}

@media (min-width: 700px) and (max-width: 1400px) and (orientation: landscape) {
  .tablet-device .app-shell[data-mode='edit'] .script-context .panel-mode-row {
    grid-row: 1 !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .script-context .right-panel-workspace:not(.hidden) {
    display: contents !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .script-context .script-tools,
  .tablet-device .app-shell[data-mode='edit'] .script-context .slides-tools {
    grid-row: 2 !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .script-context .slides-tools {
    display: grid !important;
    gap: 8px !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .script-context .slides-tools .file-button,
  .tablet-device .app-shell[data-mode='edit'] .script-context .slides-tools .quiet-button {
    font-size: 10px !important;
    height: 48px !important;
    line-height: 1 !important;
    min-height: 48px !important;
    min-width: 0 !important;
    padding-inline: 6px !important;
    width: 100% !important;
  }

  .tablet-device .app-shell[data-mode='edit'] .script-context .script-box,
  .tablet-device .app-shell[data-mode='edit'] .script-context .slides-box {
    grid-row: 3 !important;
    height: var(--box-row) !important;
    max-height: var(--box-row) !important;
    min-height: var(--box-row) !important;
  }
}

@media (min-width: 1100px) {
  html:not(.tablet-device) .app-shell[data-mode='edit'] .cue-list-panel,
  html:not(.tablet-device) .app-shell[data-mode='edit'] .script-context {
    grid-template-rows: var(--heading-row) var(--tools-row) var(--box-row) auto !important;
  }

  html:not(.tablet-device) .app-shell[data-mode='edit'] .cue-list-heading .eyebrow,
  html:not(.tablet-device) .app-shell[data-mode='edit'] .script-context .panel-mode-row {
    align-self: start !important;
    grid-row: 1 !important;
    margin: 0 !important;
  }

  html:not(.tablet-device) .app-shell[data-mode='edit'] .panel-title-tabs {
    align-items: center !important;
    color: var(--text) !important;
    display: inline-flex !important;
    gap: 8px !important;
    margin: 0 !important;
  }

  html:not(.tablet-device) .app-shell[data-mode='edit'] .panel-title-tab {
    color: var(--text) !important;
  }

  html:not(.tablet-device) .app-shell[data-mode='edit'] .cue-list-panel .cue-tools,
  html:not(.tablet-device) .app-shell[data-mode='edit'] .script-context .script-tools,
  html:not(.tablet-device) .app-shell[data-mode='edit'] .script-context .slides-tools {
    align-self: start !important;
    grid-row: 2 !important;
    margin: 0 !important;
    min-height: var(--tools-row) !important;
  }

  html:not(.tablet-device) .app-shell[data-mode='edit'] .cue-editor-box,
  html:not(.tablet-device) .app-shell[data-mode='edit'] .script-context .script-box,
  html:not(.tablet-device) .app-shell[data-mode='edit'] .script-context .slides-box {
    grid-row: 3 !important;
    height: var(--box-row) !important;
    max-height: var(--box-row) !important;
    min-height: var(--box-row) !important;
  }

  html:not(.tablet-device) .app-shell[data-mode='edit'] .cue-count,
  html:not(.tablet-device) .app-shell[data-mode='edit'] .script-status {
    grid-row: 4 !important;
  }

  html:not(.tablet-device) .app-shell[data-mode='edit'] .script-context .script-tools,
  html:not(.tablet-device) .app-shell[data-mode='edit'] .script-context .slides-tools {
    margin-top: -2px !important;
  }

  html:not(.tablet-device) .app-shell[data-mode='edit'] .script-context .script-box,
  html:not(.tablet-device) .app-shell[data-mode='edit'] .script-context .slides-box {
    margin-top: -4px !important;
  }
}

@media (max-width: 760px) {
  html:not(.tablet-device) .app-shell[data-mode='edit'] .panel-title-tabs {
    color: var(--text-muted) !important;
    display: inline-flex !important;
    flex-wrap: nowrap !important;
    font-family: var(--font-body) !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    gap: 7px !important;
    letter-spacing: 0.16em !important;
    line-height: 16px !important;
    margin: 0 !important;
    text-transform: uppercase !important;
  }

  html:not(.tablet-device) .app-shell[data-mode='edit'] .panel-title-tab {
    color: var(--text-muted) !important;
    opacity: 0.52 !important;
  }

  html:not(.tablet-device) .app-shell[data-mode='edit'] .panel-title-tab.active {
    color: var(--text-muted) !important;
    opacity: 1 !important;
  }
}

/* Final touch guard: avoid accidental double-tap zoom and keep tablet edit fixed. */
html,
body,
.app-shell {
  touch-action: manipulation;
}

@media (min-width: 700px) and (max-width: 1400px) and (orientation: landscape) {
  html.tablet-device:has(.app-shell[data-mode='edit']),
  html.tablet-device:has(.app-shell[data-mode='edit']) body {
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    overscroll-behavior: none !important;
  }

  html.tablet-device:has(.app-shell[data-mode='edit']) body {
    inset: 0 !important;
    position: fixed !important;
    width: 100% !important;
  }

  html.tablet-device .app-shell[data-mode='edit'],
  html.tablet-device .app-shell[data-mode='edit'] .workspace,
  html.tablet-device .app-shell[data-mode='edit'] .edit-view {
    overflow: hidden !important;
  }

  html.tablet-device .app-shell[data-mode='edit'] .cue-editor-box,
  html.tablet-device .app-shell[data-mode='edit'] .script-box,
  html.tablet-device .app-shell[data-mode='edit'] .slides-box,
  html.tablet-device .app-shell[data-mode='edit'] #cueInput,
  html.tablet-device .app-shell[data-mode='edit'] #scriptInput,
  html.tablet-device .app-shell[data-mode='edit'] .script-cue-view,
  html.tablet-device .app-shell[data-mode='edit'] .slide-deck-grid {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain !important;
  }
}
