:root {
  --bg: #19202f;
  --panel: #222b3f;
  --panel-2: #2a3450;
  --line: #38415c;
  --line-strong: #49546f;
  --ink: #e4e9f5;
  --muted: #9fadc9;
  --accent: #5b86e5;
  --accent-2: #7fa2ee;
  --bad: #ee8098;

  --code-ink: #dbe3f6;
  --code-comment: #7d8cb0;
  --code-keyword: #e58bbb;
  --code-type: #b9a3e3;
  --code-builtin: #8fb6f5;
  --code-const: #b9a3e3;
  --code-string: #e79fc0;
  --code-number: #f0b5a4;
  --code-func: #96c9ef;
  --code-punct: #a6b3d0;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 24px 8px;
}

header .logo {
  height: 64px;
  width: auto;
  display: block;
}

header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 720px;
  line-height: 1.5;
}

.notice {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.notice code {
  background: rgba(91, 134, 229, 0.16);
  color: #cbd9f7;
  border-radius: 4px;
  padding: 1px 5px;
}

.notice a {
  color: var(--accent-2);
  text-decoration: none;
}

.notice a:hover {
  text-decoration: underline;
}

footer {
  padding: 0 24px 18px;
}

main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  padding: 16px 24px;
  min-height: 0;
}

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

select, button {
  font: inherit;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--ink);
  padding: 7px 12px;
  transition: border-color 0.12s ease, background 0.12s ease;
}

select {
  cursor: pointer;
}

select:hover, button:hover {
  border-color: var(--accent);
}

select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button#run {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

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

button#run:disabled {
  opacity: 0.5;
  cursor: default;
}

button.ghost {
  cursor: pointer;
  background: transparent;
  color: var(--muted);
}

button.ghost:hover {
  color: var(--ink);
  background: var(--panel);
}

.status {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.codewrap {
  position: relative;
  flex: 1;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.codewrap:focus-within {
  border-color: var(--accent);
}

.codewrap .highlight,
.codewrap textarea {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 14px 16px;
  border: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.6;
  tab-size: 4;
  white-space: pre;
  overflow: hidden;
}

.codewrap .highlight {
  color: var(--code-ink);
  pointer-events: none;
  z-index: 1;
}

.codewrap textarea {
  color: transparent;
  background: transparent;
  caret-color: var(--accent-2);
  resize: none;
  overflow: auto;
  z-index: 2;
}

.codewrap textarea::selection {
  background: rgba(91, 134, 229, 0.35);
}

.tok-comment { color: var(--code-comment); font-style: italic; }
.tok-keyword { color: var(--code-keyword); }
.tok-type { color: var(--code-type); }
.tok-builtin { color: var(--code-builtin); }
.tok-const { color: var(--code-const); }
.tok-string { color: var(--code-string); }
.tok-number { color: var(--code-number); }
.tok-func { color: var(--code-func); }
.tok-punct { color: var(--code-punct); }

.panes {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 16px;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pane h2 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.output {
  flex: 1;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--code-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.6;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

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

@media (max-width: 860px) {
  main {
    grid-template-columns: minmax(0, 1fr);
  }

  .codewrap {
    min-height: 240px;
  }
}
