:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #66665f;
  --border: #dcdcd6;
  --accent: #2f5d50;
  --accent-text: #ffffff;
  --warn-bg: #fff4d6;
  --warn-text: #5c4300;
  --error: #a3261b;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #1f1f1d;
    --text: #ececea;
    --muted: #a3a39b;
    --border: #3a3a36;
    --accent: #7fb8a6;
    --accent-text: #0f1f1a;
    --warn-bg: #3b3011;
    --warn-text: #f3dc9b;
    --error: #ff8a7d;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.brand {
  font-weight: 600;
}

.file-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

button,
.button,
select,
input {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  text-decoration: none;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

button[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.panel {
  max-width: 560px;
  margin: 48px auto;
  padding: 0 16px;
}

.panel h2 {
  font-size: 18px;
  margin: 0 0 8px;
}

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

.open-form {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.open-form input {
  flex: 1;
  min-width: 0;
  cursor: text;
}

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

.error {
  color: var(--error);
}

.warning {
  margin: 0;
  padding: 6px 16px;
  background: var(--warn-bg);
  color: var(--warn-text);
}

.stage {
  flex: 1;
  display: flex;
  min-height: 0;
}

.stage iframe {
  flex: 1;
  border: 0;
  width: 100%;
  background: #ffffff;
}

.source {
  flex: 1;
  margin: 0;
  padding: 16px;
  overflow: auto;
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
