:root {
  color-scheme: dark;
  --bg: #070b10;
  --panel: #101722;
  --panel-2: #131d2a;
  --line: #29405d;
  --line-soft: rgba(91, 135, 185, 0.28);
  --text: #ecf4ff;
  --muted: #91a5ba;
  --green: #38d996;
  --yellow: #ffd166;
  --red: #ff5c7a;
  --blue: #62b6ff;
  --violet: #a68cff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(64, 119, 175, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(64, 119, 175, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 42% -10%, rgba(98, 182, 255, 0.16), transparent 34%),
    var(--bg);
  background-size: 28px 28px, 28px 28px, auto;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #162335;
  color: var(--text);
  border-radius: 8px;
  min-height: 38px;
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
}

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

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

.topbar,
.talk-panel,
.blueprint-panel,
.inspector-panel,
.timeline-panel {
  border: 1px solid var(--line-soft);
  background: rgba(12, 19, 29, 0.92);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  padding: 12px 16px;
  border-radius: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border: 2px solid var(--blue);
  border-radius: 50%;
  box-shadow: 0 0 26px rgba(98, 182, 255, 0.6), inset 0 0 18px rgba(98, 182, 255, 0.24);
}

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

h1 {
  font-size: 20px;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 13px;
  color: var(--muted);
}

p {
  color: var(--muted);
  font-size: 13px;
}

.session-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

input[type="text"],
input:not([type]),
select {
  width: 220px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #08111c;
  color: var(--text);
  padding: 7px 10px;
}

select {
  width: 150px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1724;
}

.icon-btn {
  width: 38px;
  padding: 0;
  font-size: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(440px, 1fr) minmax(300px, 380px);
  gap: 14px;
  margin-top: 14px;
}

.talk-panel,
.blueprint-panel,
.inspector-panel,
.timeline-panel {
  border-radius: 10px;
  padding: 14px;
}

.panel-head,
.blueprint-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #0a1420;
  font-size: 12px;
  white-space: nowrap;
}

.badge.idle {
  color: var(--muted);
}

.badge.green {
  border-color: rgba(56, 217, 150, 0.5);
  color: var(--green);
}

.badge.yellow {
  border-color: rgba(255, 209, 102, 0.5);
  color: var(--yellow);
}

.badge.red {
  border-color: rgba(255, 92, 122, 0.5);
  color: var(--red);
}

.orb-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 28px 0 20px;
}

.record-orb {
  width: 126px;
  height: 126px;
  border-radius: 50%;
  border: 1px solid rgba(98, 182, 255, 0.8);
  background: radial-gradient(circle, #203955, #0d1826 68%);
  box-shadow: 0 0 48px rgba(98, 182, 255, 0.32), inset 0 0 34px rgba(98, 182, 255, 0.18);
}

.record-orb span {
  display: block;
  width: 38px;
  height: 38px;
  margin: auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 24px rgba(56, 217, 150, 0.7);
}

.record-orb.recording {
  border-color: var(--red);
  animation: pulse 1.2s infinite;
}

.record-orb.recording span {
  border-radius: 8px;
  background: var(--red);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.orb-caption {
  color: var(--muted);
  font-size: 13px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.danger {
  border-color: rgba(255, 92, 122, 0.65);
  background: rgba(255, 92, 122, 0.12);
}

.file-picker {
  margin-top: 12px;
}

.file-picker input {
  max-width: 100%;
}

.transcript,
.playback,
.diagnostic-panel {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.diagnostic-panel .panel-head {
  align-items: center;
}

.diagnostic-panel button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.diagnostic-text {
  min-height: 118px;
  max-height: 220px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #07101b;
  color: #cfe0f3;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.answer-text {
  min-height: 92px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #08111c;
  color: #dcecff;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.answer-text.compact {
  min-height: 44px;
  max-height: 128px;
  overflow: auto;
  font-size: 13px;
}

.queue-item {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0b1521;
  font-size: 12px;
  color: var(--muted);
}

.blueprint-panel {
  min-height: 620px;
  overflow: hidden;
}

.blueprint {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 28px 34px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background:
    linear-gradient(rgba(98, 182, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(98, 182, 255, 0.08) 1px, transparent 1px),
    rgba(5, 10, 17, 0.65);
  background-size: 22px 22px;
}

.node {
  position: relative;
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #152236, #0d1724);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}

.node::after {
  content: "";
  position: absolute;
  right: -28px;
  top: 45px;
  width: 24px;
  height: 2px;
  background: var(--line);
  box-shadow: 0 0 12px rgba(98, 182, 255, 0.35);
}

.node.break::after,
.node:nth-child(4n)::after {
  display: none;
}

.node.active {
  border-color: var(--blue);
  box-shadow: 0 0 28px rgba(98, 182, 255, 0.24);
}

.node.error {
  border-color: var(--red);
}

.node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.node-title {
  font-weight: 700;
  font-size: 14px;
}

.node-sub {
  margin-top: 8px;
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.lamp {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #526070;
  box-shadow: 0 0 12px rgba(82, 96, 112, 0.4);
  flex: 0 0 auto;
}

.lamp.green {
  background: var(--green);
  box-shadow: 0 0 16px rgba(56, 217, 150, 0.75);
}

.lamp.yellow {
  background: var(--yellow);
  box-shadow: 0 0 16px rgba(255, 209, 102, 0.75);
}

.lamp.red {
  background: var(--red);
  box-shadow: 0 0 16px rgba(255, 92, 122, 0.75);
}

.module-inspector {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 640px;
  overflow: auto;
  padding-right: 3px;
}

.module-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0a1420;
}

.compact-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  cursor: pointer;
}

.compact-card.selected {
  border-color: var(--blue);
  box-shadow: 0 10px 24px rgba(36, 107, 254, 0.12);
}

.module-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.module-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.json-block {
  margin: 0;
  padding: 10px;
  max-height: 240px;
  overflow: auto;
  border-top: 1px solid var(--line-soft);
  color: #cfe2ff;
  background: #06101b;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pipeline-details {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #08111c;
}

.details-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.process-panel {
  display: grid;
  gap: 8px;
  margin: 0 10px 10px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #07101b;
}

.tts-progress-panel {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #07101b;
}

.tts-progress-head,
.tts-row-main,
.tts-row-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tts-progress-head {
  justify-content: space-between;
}

.tts-segment-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.tts-segment-row {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0b1521;
}

.tts-segment-row.done {
  border-color: rgba(56, 217, 150, 0.35);
}

.tts-segment-row.error {
  border-color: rgba(255, 92, 122, 0.45);
}

.tts-row-main {
  justify-content: space-between;
}

.tts-row-main span,
.tts-row-metrics span,
.tts-row-text {
  color: var(--muted);
  font-size: 12px;
}

.tts-row-text {
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.tts-row-metrics span {
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(98, 182, 255, 0.08);
}

.compact-process {
  margin: 8px 0 0;
  padding: 8px;
}

.muted-panel {
  color: var(--muted);
  font-size: 12px;
}

.process-meta,
.process-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.process-meta {
  color: var(--muted);
  font-size: 12px;
}

.process-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.log-block {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #050b12;
  color: #cfe0f3;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.timeline-panel {
  margin-top: 14px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  max-height: 230px;
  overflow: auto;
  margin-top: 12px;
}

.event-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 9px;
  background: #0b1521;
}

.event-card strong {
  display: block;
  font-size: 13px;
}

.event-card span {
  color: var(--muted);
  font-size: 12px;
}

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

  .blueprint {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .node:nth-child(2n)::after {
    display: none;
  }
}

@media (max-width: 680px) {
  .shell {
    padding: 10px;
  }

  .topbar,
  .session-strip {
    align-items: stretch;
    flex-direction: column;
  }

  input[type="text"],
  input:not([type]),
  select {
    width: 100%;
  }

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

  .node::after {
    display: none;
  }
}

/* Light storyboard view: simple, scrollable, and turn-log friendly. */
:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-2: #f9fbff;
  --line: #d7dee8;
  --line-soft: #e8edf4;
  --text: #162033;
  --muted: #66758a;
  --green: #16a36a;
  --yellow: #c98900;
  --red: #d93655;
  --blue: #246bfe;
  --violet: #6f54d9;
  --shadow: 0 12px 34px rgba(29, 45, 68, 0.10);
}

body {
  background: linear-gradient(180deg, #f9fbff, #eef3f9);
  color: var(--text);
}

.topbar,
.talk-panel,
.blueprint-panel,
.inspector-panel,
.timeline-panel {
  background: rgba(255, 255, 255, 0.94);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.brand-mark {
  border-color: var(--blue);
  box-shadow: 0 0 0 6px rgba(36, 107, 254, 0.10), inset 0 0 0 8px rgba(36, 107, 254, 0.08);
}

button,
.switch,
input[type="text"],
input:not([type]),
select,
.answer-text,
.queue-item,
.module-card,
.event-card,
.badge,
.process-panel,
.tts-progress-panel,
.tts-segment-row,
.tts-row-metrics span,
.pipeline-details,
.diagnostic-text,
.log-block {
  background: #ffffff;
  color: var(--text);
  border-color: var(--line);
}

button {
  background: #f4f7fb;
}

button:hover {
  background: #eef4ff;
  border-color: var(--blue);
}

.danger {
  background: #fff2f4;
  border-color: rgba(217, 54, 85, 0.35);
  color: #a91d38;
}

.workspace {
  grid-template-columns: minmax(280px, 340px) minmax(520px, 1fr);
  align-items: start;
}

.inspector-panel {
  grid-column: 1 / -1;
}

.blueprint-panel {
  min-height: auto;
}

.blueprint {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 18px 18px 24px;
  background: #f8fbff;
  border-color: var(--line);
}

.node {
  min-width: 280px;
  min-height: 180px;
  scroll-snap-align: center;
  background: #ffffff;
  border-color: var(--line);
  box-shadow: 0 10px 28px rgba(29, 45, 68, 0.08);
}

.node::after {
  right: -17px;
  top: 88px;
  width: 16px;
  height: 3px;
  background: #c7d3e4;
}

.node:nth-child(4n)::after,
.node.break::after {
  display: block;
}

.node:last-child::after {
  display: none;
}

.node.active {
  transform: translateY(-4px);
  border-color: var(--blue);
  box-shadow: 0 16px 40px rgba(36, 107, 254, 0.18);
}

.node.error {
  border-color: var(--red);
  box-shadow: 0 16px 40px rgba(217, 54, 85, 0.14);
}

.node-title {
  font-size: 18px;
}

.node-sub {
  min-height: 70px;
  font-size: 14px;
  color: var(--muted);
}

.record-orb {
  background: #ffffff;
  border-color: var(--blue);
  box-shadow: 0 18px 48px rgba(36, 107, 254, 0.18), inset 0 0 0 12px #f0f5ff;
}

.record-orb span {
  background: var(--blue);
  box-shadow: 0 0 0 8px rgba(36, 107, 254, 0.12);
}

.record-orb.recording {
  border-color: var(--red);
}

.record-orb.recording span {
  background: var(--red);
}

.module-inspector {
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  max-height: 520px;
}

.module-card[open] {
  border-color: #b8c7dc;
  box-shadow: 0 10px 24px rgba(29, 45, 68, 0.08);
}

.json-block {
  background: #f8fafc;
  color: #172033;
  border-color: var(--line-soft);
  max-height: 280px;
  resize: vertical;
}

.timeline {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  max-height: none;
}

@media (max-width: 900px) {
  .details-grid {
    grid-template-columns: 1fr;
  }
}

.event-card {
  min-width: 280px;
  scroll-snap-align: start;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .inspector-panel {
    grid-column: auto;
  }
  .node:nth-child(2n)::after {
    display: block;
  }
}
