:root {
  color-scheme: dark;
  --bg: #080a0f;
  --surface: #0e1118;
  --surface-raised: #141924;
  --border: #252b38;
  --border-bright: #343c4c;
  --text: #f2f4f8;
  --muted: #8d96a8;
  --accent: #b9f45b;
  --accent-strong: #cbff78;
  --accent-ink: #172108;
  --error: #ff6b75;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% -8%, rgb(185 244 91 / 8%), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

button,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 32px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.site-header {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
  letter-spacing: .08em;
  text-decoration: none;
}

.brand-mark {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 0 28px rgb(185 244 91 / 16%);
}

.header-copy {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-copy::before {
  content: "/";
  color: #454c5a;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 14px;
  font-weight: 650;
}

.preview-badge {
  padding: 4px 7px;
  border: 1px solid var(--border-bright);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.source-link {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  text-underline-offset: 3px;
}

.source-link:hover {
  color: var(--text);
}

.workspace {
  min-height: 0;
  padding: 32px 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
  gap: 16px;
}

.panel {
  min-height: 580px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgb(14 17 24 / 92%);
  box-shadow: 0 20px 60px rgb(0 0 0 / 22%);
}

.editor-panel {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.panel-header {
  min-height: 72px;
  padding: 15px 17px 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sample-picker {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sample-picker > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.sample-picker select {
  min-width: 180px;
  padding: 8px 32px 8px 10px;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}

.sample-picker select:hover:not(:disabled) {
  border-color: var(--muted);
}

.sample-picker select:disabled {
  cursor: wait;
  opacity: .55;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}

h2 {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.run-button,
.format-button,
.clear-button {
  border-radius: 8px;
  cursor: pointer;
}

.run-button {
  min-height: 38px;
  padding: 0 10px 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 6px 22px rgb(185 244 91 / 12%);
}

.run-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.run-button:active:not(:disabled) {
  transform: translateY(1px);
}

.run-button:disabled,
.format-button:disabled {
  cursor: wait;
  opacity: .55;
}

.run-button svg {
  width: 13px;
  fill: currentColor;
}

kbd {
  padding: 2px 5px;
  border: 1px solid rgb(23 33 8 / 24%);
  border-radius: 4px;
  background: rgb(23 33 8 / 10%);
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 700;
}

.format-button,
.clear-button,
.add-file-button {
  padding: 7px 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.format-button:hover:not(:disabled),
.clear-button:hover,
.add-file-button:hover {
  border-color: var(--border-bright);
  color: var(--text);
}

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

.file-bar {
  min-width: 0;
  min-height: 39px;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.file-tabs {
  min-width: 0;
  display: flex;
  overflow-x: auto;
  scrollbar-width: thin;
}

.file-tab-item {
  flex: 0 0 auto;
  display: flex;
  border-right: 1px solid var(--border);
}

.file-tab,
.remove-file-button,
.add-file-button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.file-tab {
  padding: 0 8px 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 11px var(--mono);
}

.file-tab.active {
  background: #0b0e14;
  color: var(--text);
  box-shadow: inset 0 -2px var(--accent);
}

.file-tab:hover,
.remove-file-button:hover {
  color: var(--text);
}

.entry-icon {
  color: var(--accent);
  font-size: 8px;
}

.remove-file-button {
  width: 25px;
  padding: 0 7px 1px 1px;
  font-size: 16px;
}

.add-file-button {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0 13px;
  border-left: 1px solid var(--border);
  font-size: 11px;
}

.editor-wrap {
  min-height: 0;
  background: #0b0e14;
}

#source,
.cm-editor {
  width: 100%;
  height: 100%;
  min-height: 460px;
}

.cm-editor {
  background: transparent;
  color: #dce2ec;
  font: 14px/1.75 var(--mono);
}

.cm-editor.cm-focused {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.cm-editor .cm-scroller {
  overflow: auto;
  font-family: inherit;
  line-height: inherit;
  tab-size: 2;
}

.cm-editor .cm-content {
  padding: 24px 0;
  caret-color: var(--accent);
}

.cm-editor .cm-line {
  padding: 0 24px 0 12px;
}

.cm-editor .cm-gutters {
  border-right: 1px solid var(--border);
  background: #0b0e14;
  color: #566074;
}

.cm-editor .cm-activeLine,
.cm-editor .cm-activeLineGutter {
  background: rgb(185 244 91 / 5%);
}

.cm-editor .cm-selectionBackground,
.cm-editor.cm-focused .cm-selectionBackground,
.cm-editor ::selection {
  background: rgb(185 244 91 / 18%);
}

.cm-editor .cm-cursor {
  border-left-color: var(--accent);
}

.console {
  min-height: 0;
  padding: 24px;
  overflow: auto;
  background: #090c11;
  color: #dce2ec;
  font: 14px/1.7 var(--mono);
  white-space: pre-wrap;
}

.console-empty {
  display: flex;
  gap: 10px;
  color: #697285;
}

.console-loading {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--text);
  white-space: normal;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 3px solid var(--border-bright);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loading-spin .8s linear infinite;
}

.loading-content {
  width: min(360px, 100%);
}

.loading-title {
  font-family: var(--sans);
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 750;
  line-height: 1.2;
}

.loading-message {
  margin-top: 7px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
}

.loading-progress {
  height: 7px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.loading-progress span {
  width: 0;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--accent);
  box-shadow: 0 0 16px rgb(185 244 91 / 28%);
  transition: width .15s ease-out;
}

.loading-detail {
  margin-top: 8px;
  color: #697285;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.4;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation-duration: 1.6s;
  }
}

.prompt {
  color: var(--accent);
  font-weight: 800;
}

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

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

.panel-footer {
  min-height: 36px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

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

.console-footer {
  justify-content: flex-start;
  gap: 8px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #687184;
}

.status-ready {
  background: var(--accent);
}

.status-running {
  background: #e6b95c;
}

.status-error {
  background: var(--error);
}

.site-footer {
  min-height: 58px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  color: #687184;
  font-size: 11px;
}

@media (max-width: 850px) {
  .app-shell {
    padding: 0 18px;
  }

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

  .panel {
    min-height: 480px;
  }

  .console-panel {
    min-height: 360px;
  }
}

@media (max-width: 520px) {
  .site-header {
    gap: 10px;
  }

  .preview-badge,
  .source-link,
  kbd,
  .site-footer p:last-child {
    display: none;
  }

  .workspace {
    padding: 18px 0;
  }

  .panel-header {
    padding-left: 15px;
    gap: 10px;
  }

  .sample-picker > span {
    display: none;
  }

  .sample-picker select {
    min-width: 0;
    width: 145px;
  }

  .cm-editor {
    font-size: 13px;
  }

  .cm-editor .cm-content {
    padding-top: 20px;
  }

  .cm-editor .cm-line {
    padding-right: 16px;
  }
}
