:root {
  --bg: #fbfaf7;
  --fg: #1d1b18;
  --muted: #6d675e;
  --line: #e2ddd3;
  --panel: #ffffff;
  --accent: #0f6b5c;
  --accent-fg: #ffffff;
  --danger: #b42318;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --fg: #ece8e1;
    --muted: #9d968b;
    --line: #2d2b27;
    --panel: #1c1b19;
    --accent: #3fb8a0;
    --accent-fg: #0b1512;
    --danger: #d9473b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--mono); font-weight: 700; font-size: 18px; color: var(--fg); }
.brand span { color: var(--accent); }
.topbar nav { display: flex; gap: 16px; }

main { max-width: 1400px; margin: 0 auto; padding: 24px 20px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 6px; }
.muted { color: var(--muted); }

.hero { padding: 64px 0; max-width: 640px; }
.hero h1 { font-size: 40px; line-height: 1.15; margin-bottom: 16px; }
.hero p { font-size: 18px; color: var(--muted); }

button, .button {
  display: inline-block;
  font: inherit;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }
button.primary, .button { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.button:hover { text-decoration: none; }
input {
  font: inherit;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.inline-form, .toolbar { display: flex; gap: 8px; align-items: center; }
.new-project p { margin: 4px 0 0; font-size: 13px; }
.form-error { color: #b42318; }
@media (prefers-color-scheme: dark) { .form-error { color: #f97066; } }

.project-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.project-list li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.project-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; }
.delete-project summary { cursor: pointer; color: var(--muted); font-size: 13px; list-style: none; }
.delete-project summary::-webkit-details-marker { display: none; }
.delete-project summary:hover { color: var(--danger); }
.delete-project form { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 320px; margin-top: 6px; font-size: 13px; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.notice { padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }

.editor-grid {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 3fr) minmax(0, 2fr);
  gap: 16px;
}

.files { min-width: 0; }
.files-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.files-head h2 { margin: 0; }
.files-actions { display: flex; gap: 4px; }
.files-actions button { padding: 2px 8px; font-size: 12px; }
.file-tree, .tree-list { list-style: none; margin: 0; padding: 0; }
.file-tree {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 4px 0;
  max-height: 70vh;
  overflow: auto;
  font-family: var(--mono);
  font-size: 13px;
}
.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding-right: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.tree-row:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.tree-row.active { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.tree-row.confirm { cursor: default; padding-left: 8px; font-family: system-ui, sans-serif; font-size: 12px; flex-wrap: wrap; }
.tree-name { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.caret { width: 10px; color: var(--muted); }
.dirty { color: var(--accent); font-size: 10px; }
.tree-actions { display: none; gap: 2px; }
.tree-row:hover .tree-actions, .tree-row:focus-within .tree-actions { display: flex; }
.tree-action { padding: 0 5px; font-size: 12px; line-height: 20px; border: none; background: transparent; color: var(--muted); }
.tree-action:hover { color: var(--fg); background: var(--line); }
.confirm .tree-action { border: 1px solid var(--line); }
.tree-input { flex: 1; min-width: 0; padding: 2px 6px; font: 13px var(--mono); }

.editor-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.current-file { display: flex; gap: 10px; align-items: baseline; font-family: var(--mono); font-size: 13px; min-height: 20px; }
.current-hint { font-size: 12px; }
.log-link { color: var(--accent); text-decoration: underline; }
select {
  font: inherit;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
}
.runner-box { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.runner { display: block; width: 100%; height: 240px; border: 0; }
.artifacts { font-size: 13px; line-height: 1.8; }
.artifacts a { font-family: var(--mono); word-break: break-all; }
.artifact-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.copy-url { padding: 0 6px; font-size: 12px; margin-left: auto; }
.artifact-hint { margin: 6px 0; font-size: 12px; }
/* Monaco sizes itself to this box (automaticLayout). */
.editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  height: 65vh;
  min-height: 320px;
}
.side { display: flex; flex-direction: column; gap: 12px; }
.output {
  margin: 0;
  padding: 10px 12px;
  min-height: 120px;
  max-height: 40vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 13px;
  white-space: pre-wrap;
}
@media (max-width: 800px) {
  main { padding: 16px; }
  .editor-grid { grid-template-columns: 1fr; }
  .file-tree { max-height: 30vh; }
  .tree-actions { display: flex; }
  .hero h1 { font-size: 30px; }
}
