:root {
  color-scheme: dark;
  --ink: #f4f7fb;
  --muted: #8f9db3;
  --muted-strong: #b7c1d0;
  --panel: #0d1728;
  --panel-soft: #111e32;
  --line: rgba(151, 172, 204, 0.16);
  --accent: #ffbf47;
  --accent-soft: rgba(255, 191, 71, 0.14);
  --blue: #5b9cff;
  --success: #48d7a3;
  --danger: #ff7f73;
  --font-size: 42px;
  --line-height: 1.65;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-width: 320px;
  height: 100%;
  overflow: hidden;
  background: #07101f;
  color: var(--ink);
}

button,
input,
textarea { font: inherit; }

button { color: inherit; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  height: 100dvh;
  background:
    radial-gradient(circle at 75% -20%, rgba(50, 95, 163, 0.16), transparent 38%),
    #07101f;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 31, 0.9);
}

.brand-block { display: flex; align-items: center; gap: 11px; }
.brand-block h1 { margin: 0; font-size: 18px; line-height: 1.1; letter-spacing: .06em; }
.brand-block p { margin: 4px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.brand-mark { display: flex; align-items: flex-end; gap: 3px; width: 30px; height: 30px; padding: 6px; border-radius: 9px; background: var(--accent); }
.brand-mark span { flex: 1; border-radius: 3px; background: #10192a; }
.brand-mark span:nth-child(1) { height: 45%; }
.brand-mark span:nth-child(2) { height: 100%; }
.brand-mark span:nth-child(3) { height: 68%; }

.topbar-note { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.topbar-note > span { width: 1px; height: 13px; margin: 0 4px; background: var(--line); }
kbd { padding: 3px 7px; border: 1px solid rgba(151, 172, 204, .22); border-bottom-color: rgba(151, 172, 204, .38); border-radius: 5px; background: #101a2a; color: var(--muted-strong); font-size: 11px; box-shadow: 0 2px 0 #040a13; }

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(330px, 35%) minmax(0, 65%);
  gap: 12px;
  padding: 12px;
}

.setup-panel,
.stage-panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(15, 27, 46, .98), rgba(10, 20, 35, .98));
  box-shadow: 0 22px 50px rgba(0, 0, 0, .18);
}

.setup-panel { display: grid; grid-template-rows: minmax(180px, 1fr) auto auto; overflow: auto; }
.editor-section,
.settings-section { padding: 18px; }
.editor-section { display: flex; min-height: 0; flex-direction: column; border-bottom: 1px solid var(--line); }
.settings-section { border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.compact-heading { margin-bottom: 13px; }
.eyebrow { display: block; margin-bottom: 4px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.section-heading h2 { margin: 0; font-size: 16px; font-weight: 650; }
.text-button { padding: 7px 0; border: 0; background: none; color: var(--blue); cursor: pointer; font-size: 13px; }
.text-button:hover { color: #8bbaff; }
.mode-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: rgba(4, 11, 22, .5); }
.mode-switch button { padding: 5px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.mode-switch button.active { background: var(--accent); color: #111827; font-weight: 750; }

textarea {
  flex: 1;
  width: 100%;
  min-height: 118px;
  resize: none;
  padding: 14px;
  border: 1px solid rgba(151, 172, 204, .15);
  border-radius: 11px;
  background: rgba(4, 11, 22, .66);
  color: #e8edf5;
  font-size: 15px;
  line-height: 1.7;
  caret-color: var(--accent);
}
textarea::placeholder { color: #59677d; }

.time-and-type { display: grid; grid-template-columns: minmax(170px, .9fr) minmax(140px, 1.1fr); gap: 18px; }
.time-fieldset { display: flex; align-items: flex-end; gap: 7px; min-width: 0; margin: 0; padding: 0; border: 0; }
.time-fieldset legend { margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.time-fieldset label { display: flex; align-items: center; min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: rgba(4, 11, 22, .55); }
.time-fieldset input { width: 58px; min-width: 0; padding: 9px 4px 9px 10px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 20px; font-variant-numeric: tabular-nums; }
.time-fieldset label span { padding-right: 9px; color: var(--muted); font-size: 12px; }
.time-fieldset b { padding-bottom: 9px; color: var(--muted); font-size: 18px; }
.pace-control { align-self: end; min-width: 0; }
.pace-control > label { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.pace-control output { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.pace-control input { margin-bottom: 3px; }
.pace-scale { display: flex; justify-content: space-between; color: #66758b; font-size: 9px; }
.mode-panel[hidden] { display: none; }

.type-controls { display: grid; grid-template-columns: 1fr; gap: 4px; }
.type-controls label { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.type-controls output { color: var(--muted-strong); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 4px; margin: 2px 0 8px; appearance: none; border-radius: 999px; background: #24344d; accent-color: var(--accent); }
input[type="range"]::-webkit-slider-thumb { width: 15px; height: 15px; appearance: none; border: 3px solid #07101f; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px rgba(255, 191, 71, .55); cursor: pointer; }

.pace-report { display: grid; grid-template-columns: 132px 1fr; column-gap: 15px; padding: 16px 18px 17px; background: linear-gradient(135deg, rgba(255, 191, 71, .10), rgba(255, 191, 71, .025)); }
.pace-primary { display: flex; flex-direction: column; justify-content: center; padding-right: 15px; border-right: 1px solid rgba(255, 191, 71, .2); }
.pace-primary > span { color: var(--muted); font-size: 11px; }
.pace-primary strong { display: flex; align-items: baseline; gap: 5px; margin: 4px 0 2px; color: var(--accent); font-size: 31px; font-variant-numeric: tabular-nums; }
.pace-primary small { font-size: 11px; }
.pace-primary em { color: var(--muted-strong); font-size: 12px; font-style: normal; }
.pace-details { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-items: center; }
.pace-details div { min-width: 0; }
.pace-details span { display: block; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.pace-details b { display: block; margin-top: 4px; color: #dfe6f0; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pace-report p { grid-column: 2; margin: 10px 0 0; color: var(--muted-strong); font-size: 11px; line-height: 1.5; }

.stage-panel { display: grid; grid-template-rows: 54px minmax(0, 1fr) 88px; overflow: hidden; }
.stage-topline { display: flex; align-items: center; justify-content: space-between; padding: 0 16px 0 18px; border-bottom: 1px solid var(--line); }
.stage-title { display: flex; align-items: center; gap: 10px; }
.stage-title > div { display: flex; flex-direction: column; gap: 3px; }
.stage-title span { font-size: 13px; font-weight: 650; }
.stage-title small { color: var(--muted); font-size: 10px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #647189; box-shadow: 0 0 0 5px rgba(100, 113, 137, .1); transition: .2s; }
.is-playing .live-dot { background: var(--success); box-shadow: 0 0 0 5px rgba(72, 215, 163, .1); }
.is-complete .live-dot { background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.icon-button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #111d30; color: var(--muted-strong); cursor: pointer; font-size: 12px; }
.icon-button:hover { border-color: rgba(91, 156, 255, .45); color: #fff; }
.icon-button svg { width: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

.prompter { --focus-y: 29%; position: relative; min-height: 0; overflow: hidden; background: #03070d; }
.prompter::before { content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 42%, rgba(34, 56, 88, .16), transparent 68%); }
.script-track { position: absolute; top: 0; left: 50%; z-index: 1; width: min(82%, 880px); will-change: transform; transform: translate(-50%, var(--focus-y)); }
.script-text { color: #f7f8fa; font-size: var(--font-size); font-weight: 570; line-height: var(--line-height); letter-spacing: .035em; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; text-wrap: pretty; text-shadow: 0 2px 12px rgba(0, 0, 0, .35); }
.focus-guide { position: absolute; top: var(--focus-y); left: 0; right: 0; z-index: 3; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; pointer-events: none; transform: translateY(calc(var(--font-size) * var(--line-height) * .56)); }
.focus-guide span { height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 191, 71, .62)); }
.focus-guide span:last-child { background: linear-gradient(90deg, rgba(255, 191, 71, .62), transparent); }
.focus-guide i { padding: 3px 7px; border-radius: 999px; background: rgba(255, 191, 71, .13); color: rgba(255, 209, 124, .8); font-size: 9px; font-style: normal; letter-spacing: .12em; }
.prompter-shade { position: absolute; left: 0; right: 0; z-index: 2; height: 14%; pointer-events: none; }
.shade-top { top: 0; background: linear-gradient(#03070d, transparent); }
.shade-bottom { bottom: 0; height: 24%; background: linear-gradient(transparent, #03070d); }
.empty-script { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; color: var(--muted); font-size: 15px; }

.transport { display: grid; grid-template-columns: 82px minmax(0, 1fr) 82px; align-items: center; gap: 16px; padding: 14px 18px; border-top: 1px solid var(--line); background: rgba(8, 16, 28, .82); }
.timer-block,
.elapsed-block { display: flex; flex-direction: column; gap: 3px; }
.elapsed-block { text-align: right; }
.timer-block span,
.elapsed-block span { color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.timer-block strong,
.elapsed-block strong { font-size: 19px; font-variant-numeric: tabular-nums; letter-spacing: .03em; }
.transport-center { display: flex; min-width: 0; flex-direction: column; gap: 10px; }
.progress-track { width: 100%; height: 3px; overflow: hidden; border-radius: 999px; background: #24324a; }
.progress-track div { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #4c8ef7, var(--accent)); }
.transport-buttons { display: flex; justify-content: center; gap: 8px; }
.primary-button,
.secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 34px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 650; }
.primary-button { min-width: 132px; padding: 8px 16px; border: 1px solid #f4ad2f; background: var(--accent); color: #111827; }
.primary-button:hover { background: #ffcb69; }
.secondary-button { padding: 8px 13px; border: 1px solid var(--line); background: #121e31; color: var(--muted-strong); }
.secondary-button:hover { border-color: rgba(151, 172, 204, .35); color: #fff; }
.primary-button svg,
.secondary-button svg { width: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.primary-button .play-icon { fill: currentColor; stroke: none; }
.pause-icon { display: none; }
.is-playing .primary-button .play-icon { display: none; }
.is-playing .primary-button .pause-icon { display: block; }

.stage-panel:fullscreen { width: 100vw; height: 100vh; border: 0; border-radius: 0; grid-template-rows: 56px minmax(0, 1fr) 92px; }

@media (max-width: 900px) {
  .topbar-note { display: none; }
  .workspace { grid-template-columns: minmax(285px, 40%) minmax(0, 60%); }
  .pace-report { grid-template-columns: 110px 1fr; }
  .pace-primary strong { font-size: 26px; }
  .time-and-type { grid-template-columns: 1fr; gap: 13px; }
}

@media (max-width: 680px) {
  .app-shell { grid-template-rows: 52px minmax(0, 1fr); }
  .topbar { padding: 0 12px; }
  .brand-mark { width: 27px; height: 27px; }
  .brand-block h1 { font-size: 16px; }
  .brand-block p { display: none; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: minmax(230px, 42%) minmax(0, 58%); gap: 8px; padding: 8px; }
  .setup-panel { grid-template-columns: 1.25fr .9fr; grid-template-rows: 1fr auto; }
  .editor-section { grid-row: 1 / 3; padding: 12px; border-right: 1px solid var(--line); border-bottom: 0; }
  .settings-section { padding: 12px; }
  .section-heading { margin-bottom: 8px; }
  .section-heading h2 { font-size: 13px; }
  .eyebrow { font-size: 9px; }
  textarea { min-height: 0; padding: 10px; font-size: 13px; line-height: 1.5; }
  .time-and-type { gap: 8px; }
  .time-fieldset legend { margin-bottom: 3px; }
  .time-fieldset input { width: 42px; padding: 6px 2px 6px 7px; font-size: 16px; }
  .time-fieldset label span { padding-right: 5px; }
  .time-fieldset b { padding-bottom: 6px; }
  .mode-switch button { padding: 4px 6px; font-size: 9px; }
  .pace-control > label { margin-bottom: 3px; font-size: 10px; }
  .type-controls label { font-size: 10px; }
  .type-controls input { margin-bottom: 4px; }
  .pace-report { grid-column: 2; grid-template-columns: 1fr; padding: 9px 12px; }
  .pace-primary { padding: 0 0 7px; border-right: 0; border-bottom: 1px solid rgba(255, 191, 71, .2); }
  .pace-primary > span { display: none; }
  .pace-primary strong { margin: 0; font-size: 23px; }
  .pace-primary em { font-size: 10px; }
  .pace-details { grid-template-columns: repeat(2, 1fr); margin-top: 7px; }
  .pace-details div:first-child { display: none; }
  .pace-details b { font-size: 11px; }
  .pace-report p { display: none; }
  .stage-panel { grid-template-rows: 40px minmax(0, 1fr) 66px; }
  .stage-topline { padding: 0 10px; }
  .icon-button { padding: 6px 8px; }
  .icon-button span { display: none; }
  .prompter { --focus-y: 25%; }
  .script-track { width: 88%; }
  .transport { grid-template-columns: 58px minmax(0, 1fr) 58px; gap: 7px; padding: 8px 10px; }
  .timer-block strong, .elapsed-block strong { font-size: 15px; }
  .transport-center { gap: 7px; }
  .primary-button, .secondary-button { min-height: 30px; padding: 5px 9px; font-size: 11px; }
  .primary-button { min-width: 105px; }
}

@media (max-width: 460px) {
  .workspace { grid-template-rows: minmax(236px, 46%) minmax(0, 54%); }
  .setup-panel { grid-template-columns: minmax(0, 1.22fr) minmax(120px, .78fr); }
  .editor-section, .settings-section { padding: 10px; }
  .settings-section .section-heading { justify-content: flex-end; }
  .settings-section .section-heading > div:first-child { display: none; }
  .time-fieldset { flex-wrap: wrap; }
  .time-fieldset legend { width: 100%; }
  .time-fieldset b { display: none; }
  .pace-report { padding: 8px 10px; }
  .pace-details { grid-template-columns: 1fr; }
  .pace-details div:nth-child(2) { display: none; }
  .stage-title small { display: none; }
  .transport { grid-template-columns: 52px minmax(0, 1fr) 52px; }
  .secondary-button { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
