:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #181b1f;
  --panel-2: #20242a;
  --border: #343a43;
  --text: #f4f0e8;
  --muted: #aaa39a;
  --accent: #4fb7a7;
  --accent-2: #f2c14e;
  --danger: #e56b6f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --script-width: 42%;
  --ruler-height: 4em;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 12px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  border-color: #59616c;
}

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

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #061311;
  font-weight: 800;
}

button[aria-pressed="true"] {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.app {
  height: 100dvh;
  min-height: 620px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(420px, 1fr);
  grid-template-areas:
    "brand controls"
    "actions controls";
  gap: 10px 18px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 18, 20, 0.96);
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
  font-weight: 800;
}

h2 {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
}

.version {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 8px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}

.actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.control-grid {
  grid-area: controls;
  display: grid;
  grid-template-columns: repeat(3, minmax(175px, 1fr));
  gap: 8px;
  align-items: center;
}

.range-control {
  min-width: 0;
  display: grid;
  grid-template-columns: 62px minmax(80px, 1fr) 42px;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
}

.range-control span,
.range-control output {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.range-control output {
  text-align: right;
  color: var(--text);
}

.range-control input {
  min-width: 0;
  width: 100%;
}

.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, var(--script-width)) 10px minmax(280px, 1fr);
  gap: 0;
  padding: 14px;
}

.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.script-pane {
  border-radius: 8px 0 0 8px;
}

.tele-pane {
  border-radius: 0 8px 8px 0;
}

.pane-header {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

textarea {
  flex: 1;
  min-height: 0;
  width: 100%;
  resize: none;
  border: 0;
  padding: 18px;
  background: #111417;
  color: var(--text);
  line-height: 1.55;
  font-size: 17px;
}

.gutter {
  width: 10px;
  min-width: 10px;
  cursor: col-resize;
  background:
    linear-gradient(90deg, transparent 0 3px, var(--border) 3px 7px, transparent 7px 10px);
}

.tele-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #090a0b;
  overscroll-behavior: contain;
  cursor: grab;
}

.tele-shell.dragging {
  cursor: grabbing;
  user-select: none;
}

.tele-content {
  min-height: 100%;
  padding: calc(50% - 0.725em) clamp(28px, 5vw, 82px) 70vh;
  color: var(--text);
  font-size: 46px;
  line-height: 1.45;
}

.tele-content p {
  margin: 0 0 1.15em;
  transition: opacity 150ms ease, color 150ms ease, background-color 150ms ease;
}

.ruler-on .tele-content p {
  opacity: 0.42;
}

.ruler-on .tele-content p.active {
  opacity: 1;
  color: #fff9eb;
}

.ruler-band {
  display: none;
  position: sticky;
  top: calc(50% - (var(--ruler-height) / 2));
  z-index: 2;
  height: var(--ruler-height);
  margin-bottom: calc(var(--ruler-height) * -1);
  pointer-events: none;
  border-top: 1px solid rgba(242, 193, 78, 0.55);
  border-bottom: 1px solid rgba(242, 193, 78, 0.55);
  background: rgba(242, 193, 78, 0.08);
  box-shadow:
    0 -80vh 0 80vh rgba(0, 0, 0, 0.34),
    0 80vh 0 80vh rgba(0, 0, 0, 0.34);
}

.ruler-on .ruler-band {
  display: block;
}

.tele-only .stage {
  display: block;
  min-height: 0;
}

.tele-only .script-pane,
.tele-only .gutter {
  display: none;
}

.tele-only .tele-pane {
  height: 100%;
  min-height: 0;
  border-radius: 8px;
}

.file-input {
  display: none;
}

@media (max-width: 1180px) {
  .toolbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "actions"
      "controls";
  }
}

@media (max-width: 920px) {
  .control-grid {
    grid-template-columns: minmax(175px, 1fr) minmax(175px, 1fr);
  }

  .range-control:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  .range-control:nth-child(3) {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

@media (max-width: 620px) {
  .app {
    min-height: 720px;
  }

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

  .range-control:nth-child(n) {
    grid-column: auto;
    grid-row: auto;
  }

  .stage {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 36%) 10px minmax(260px, 1fr);
  }

  .gutter {
    width: auto;
    min-width: 0;
    height: 10px;
    min-height: 10px;
    cursor: row-resize;
    background:
      linear-gradient(0deg, transparent 0 3px, var(--border) 3px 7px, transparent 7px 10px);
  }

  .script-pane,
  .tele-pane {
    border-radius: 8px;
  }

  .tele-content {
    padding-inline: 24px;
  }

  .tele-only .stage {
    display: block;
  }
}
