:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --text: #e8eaed;
  --muted: #8b93a7;
  --accent: #6ea8fe;
  --accent-2: #4a8fe7;
  --border: #262b36;
  --danger: #e76f6f;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 24px 32px 8px;
  border-bottom: 1px solid var(--border);
}
header h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
header .sub { margin: 4px 0 16px; color: var(--muted); font-size: 13px; }

main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px 32px 32px;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 500px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.toolbar label { margin-right: -4px; }

select, button, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  outline: none;
}

select:focus, textarea:focus { border-color: var(--accent-2); }

textarea {
  flex: 1;
  resize: none;
  padding: 12px;
  font-size: 14px;
  line-height: 1.55;
  min-height: 260px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

button {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button:hover:not(:disabled) { background: #252b37; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

#run { background: var(--accent-2); border-color: var(--accent-2); }
#run:hover:not(:disabled) { background: var(--accent); }
#stop { background: transparent; border-color: var(--danger); color: var(--danger); }

.status {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

#progress-wrap {
  height: 3px;
  background: var(--panel-2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
  display: none;
}
#progress-wrap.active { display: block; }
#progress {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s;
}

.output-panel { position: relative; }

.output-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.output-head h2 { margin: 0; font-size: 14px; color: var(--muted); font-weight: 500; }
#wordcount { font-size: 12px; color: var(--muted); }

.output {
  flex: 1;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-y: auto;
  min-height: 260px;
}
.output:empty::before {
  content: "Output will appear here…";
  color: var(--muted);
}
.output.streaming::after {
  content: "▍";
  color: var(--accent);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { to { opacity: 0; } }

footer {
  padding: 12px 32px 24px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}