:root {
  --bg: #050814;
  --panel: rgba(11, 18, 37, 0.9);
  --panel-strong: rgba(15, 26, 54, 0.96);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f7f9ff;
  --muted: #aeb8cc;
  --accent: #2d8cff;
  --accent-2: #d7b15a;
  --danger: #ff5d73;
  --success: #45d98f;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
  --prompt-size: 78px;
  --prompt-line-height: 1.28;
  --prompt-padding: clamp(48px, 10vw, 180px);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(45, 140, 255, 0.22), transparent 38%),
    radial-gradient(circle at 88% 14%, rgba(215, 177, 90, 0.15), transparent 30%),
    linear-gradient(135deg, #03050d 0%, #071126 48%, #04060d 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.top-bar {
  position: relative;
  z-index: 10;
  min-height: 88px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(3, 8, 20, 0.94), rgba(13, 31, 67, 0.9), rgba(3, 8, 20, 0.94));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

.top-bar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  opacity: 0.95;
}

.brand-block,
.status-block,
.toolbar-group,
.editor-actions,
.panel-heading,
.bottom-controls {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 16px;
}

.logo-wrap {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(135deg, rgba(45, 140, 255, 0.35), rgba(215, 177, 90, 0.24));
  box-shadow: 0 15px 34px rgba(45, 140, 255, 0.22);
}

.brand-logo,
.logo-fallback {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-logo {
  object-fit: cover;
}

.logo-fallback {
  display: none;
  place-items: center;
  color: white;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: radial-gradient(circle at 30% 20%, #4ab2ff, #0c2a66 55%, #08132b);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(22px, 2vw, 34px);
  line-height: 1;
  letter-spacing: -0.03em;
}

.status-block {
  gap: 12px;
}

.status-pill,
.clock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  min-height: 34px;
  padding: 0 14px;
  font-weight: 800;
}

.status-pill.playing {
  color: #06150d;
  background: var(--success);
}

.status-pill.paused {
  color: white;
  background: rgba(255, 93, 115, 0.34);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  min-height: 0;
}

.editor-panel {
  position: relative;
  z-index: 6;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  overflow: auto;
}

.panel-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

textarea {
  width: 100%;
  min-height: 44vh;
  resize: vertical;
  padding: 18px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;
  outline: none;
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.24);
  line-height: 1.55;
}

textarea:focus {
  border-color: rgba(45, 140, 255, 0.76);
  box-shadow: 0 0 0 4px rgba(45, 140, 255, 0.16), inset 0 2px 12px rgba(0, 0, 0, 0.24);
}

.editor-actions {
  gap: 12px;
  margin: 16px 0;
}

.primary-button,
.secondary-button,
.ghost-button,
.control-button {
  border-radius: 999px;
  font-weight: 850;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.control-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  color: #031123;
  padding: 13px 18px;
  background: linear-gradient(135deg, #7ec2ff, #2d8cff 56%, #d7b15a);
  box-shadow: 0 16px 34px rgba(45, 140, 255, 0.26);
}

.secondary-button,
.ghost-button,
.control-button {
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
}

.secondary-button {
  padding: 13px 18px;
}

.ghost-button {
  padding: 10px 14px;
  color: #dbe7ff;
}

.help-card {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.045);
}

.help-card h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 27px;
  min-height: 24px;
  margin-right: 6px;
  padding: 0 6px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 900;
}

.prompt-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  background:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    #02040a;
  background-size: 42px 42px;
  overflow: hidden;
}

.stage-toolbar {
  position: relative;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(1, 5, 15, 0.78);
  backdrop-filter: blur(16px);
}

.toolbar-group {
  gap: 9px;
}

.control-button {
  min-height: 38px;
  padding: 0 14px;
}

.control-button.active {
  color: #071126;
  background: var(--accent-2);
}

.sliders {
  flex: 1;
  justify-content: center;
  min-width: 320px;
}

.sliders label {
  display: grid;
  grid-template-columns: auto minmax(120px, 220px) 40px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input[type="range"] {
  accent-color: var(--accent);
}

.progress-shell {
  position: relative;
  z-index: 8;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(45, 140, 255, 0.7);
}

.reader-frame {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, rgba(15, 36, 78, 0.22), transparent 48%);
}

.reader-frame::before,
.reader-frame::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 16%;
  z-index: 3;
  pointer-events: none;
}

.reader-frame::before {
  top: 0;
  background: linear-gradient(#02040a 0%, rgba(2, 4, 10, 0.64), transparent);
}

.reader-frame::after {
  bottom: 0;
  background: linear-gradient(transparent, rgba(2, 4, 10, 0.64), #02040a 100%);
}

.safe-zone {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 4;
  height: 1px;
  background: rgba(215, 177, 90, 0.55);
  box-shadow: 0 0 18px rgba(215, 177, 90, 0.42);
  pointer-events: none;
}

.top-safe {
  top: 30%;
}

.bottom-safe {
  bottom: 30%;
}

.prompt-text {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 2;
  transform: translateY(0);
  padding: 0 var(--prompt-padding) 58vh;
  color: #fff;
  font-size: var(--prompt-size);
  line-height: var(--prompt-line-height);
  letter-spacing: 0.006em;
  font-weight: 800;
  text-wrap: pretty;
  will-change: transform;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.88);
}

.prompt-text p {
  margin: 0 0 1.1em;
}

.prompt-text .empty-message {
  color: var(--muted);
  font-size: clamp(34px, 5vw, 64px);
  text-align: center;
}

.bottom-controls {
  position: relative;
  z-index: 10;
  justify-content: space-around;
  gap: 12px;
  padding: 12px 24px;
  border-top: 1px solid var(--line);
  background: rgba(2, 6, 16, 0.92);
  backdrop-filter: blur(16px);
}

.metric {
  display: grid;
  gap: 2px;
  text-align: center;
}

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

.metric strong {
  font-size: 15px;
}

body.prompt-focused .editor-panel,
body.prompt-focused .bottom-controls {
  display: none;
}

body.prompt-focused .workspace {
  grid-template-columns: 1fr;
}

body.prompt-focused .top-bar {
  min-height: 68px;
  padding-top: 10px;
  padding-bottom: 10px;
}

body.prompt-focused .logo-wrap {
  width: 48px;
  height: 48px;
  flex-basis: 48px;
  border-radius: 14px;
}

body.prompt-focused .prompt-stage,
body.prompt-focused .reader-frame {
  background: #000;
}

body.prompt-focused .prompt-stage {
  grid-template-rows: 5px 1fr;
}

body.prompt-focused .stage-toolbar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 30;
  width: min(1180px, calc(100% - 32px));
  transform: translateX(-50%);
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  background: rgba(0, 0, 0, 0.82);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(18px);
}

body.prompt-focused .reader-frame::before,
body.prompt-focused .reader-frame::after {
  height: 10%;
}

body.prompt-focused .reader-frame::before {
  background: linear-gradient(#000 0%, rgba(0, 0, 0, 0.64), transparent);
}

body.prompt-focused .reader-frame::after {
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.64), #000 100%);
}

body.prompt-focused .prompt-text {
  top: 48%;
  padding-left: clamp(56px, 12vw, 220px);
  padding-right: clamp(56px, 12vw, 220px);
  padding-bottom: 68vh;
  font-weight: 850;
  letter-spacing: 0.012em;
  text-shadow: none;
}

body.prompt-focused .top-safe {
  top: 34%;
}

body.prompt-focused .bottom-safe {
  bottom: 34%;
}

body.hide-chrome .top-bar,
body.hide-chrome .stage-toolbar,
body.hide-chrome .bottom-controls,
body.hide-chrome .progress-shell {
  opacity: 0;
  pointer-events: none;
}

body.hide-chrome .editor-panel {
  display: none;
}

body.hide-chrome .workspace {
  grid-template-columns: 1fr;
}

body.mirror-mode .prompt-text {
  transform: scaleX(-1) translateY(0);
}

body.mirror-mode .prompt-text.moved {
  transform: scaleX(-1) translateY(var(--scroll-offset));
}

.prompt-text.moved {
  transform: translateY(var(--scroll-offset));
}

body.high-contrast .reader-frame,
body.high-contrast .prompt-stage {
  background: #000;
}

body.high-contrast .prompt-text {
  font-weight: 850;
  text-shadow: none;
}

@media (max-width: 1000px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .editor-panel {
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  textarea {
    min-height: 22vh;
  }

  .top-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  body.prompt-focused .top-bar {
    flex-direction: row;
    align-items: center;
  }

  .stage-toolbar {
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  :root {
    --prompt-padding: clamp(28px, 6vw, 72px);
  }

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

  .sliders {
    min-width: 100%;
  }

  .sliders label {
    grid-template-columns: 48px 1fr 34px;
    width: 100%;
  }

  .toolbar-group {
    width: 100%;
    flex-wrap: wrap;
  }

  .control-button {
    flex: 1;
  }

  body.prompt-focused .stage-toolbar {
    bottom: 10px;
    width: calc(100% - 18px);
    border-radius: 18px;
  }

  body.prompt-focused .prompt-text {
    padding-left: 8vw;
    padding-right: 8vw;
  }

  .bottom-controls {
    flex-wrap: wrap;
  }
}
