:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #171a21;
  --panel-raised: #1d2028;
  --editor: #15171d;
  --border: #30343e;
  --border-strong: #424754;
  --text: #e6e9ef;
  --muted: #9399a5;
  --faint: #686e7a;
  --blue: #73a8ff;
  --blue-strong: #3978d6;
  --green: #72d49b;
  --yellow: #e6c875;
  --red: #f07d86;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100vh;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 13px;
}

button,
select {
  color: inherit;
  font: inherit;
}

button:focus-visible,
select:focus-visible,
a:focus-visible,
.cm-editor.cm-focused {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.app-header {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: #14161b;
}

.project-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.project-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 6px;
  color: #101318;
  background: var(--yellow);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-title p {
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.runtime-actions,
.pane-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.button,
.text-button {
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--panel-raised);
  cursor: pointer;
}

.button {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
}

.button:hover:not(:disabled),
.text-button:hover:not(:disabled) {
  border-color: #626977;
  background: #272b34;
}

.button:disabled,
.text-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-primary {
  border-color: var(--blue-strong);
  color: white;
  background: var(--blue-strong);
}

.button-primary:hover:not(:disabled) {
  border-color: #548ee4;
  background: #4684df;
}

.button-danger:not(:disabled) {
  color: #ffd7da;
}

kbd {
  padding: 1px 4px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 3px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(0, 0, 0, 0.18);
  font-family: var(--mono);
  font-size: 9px;
}

.runtime-bar {
  position: relative;
  display: flex;
  min-height: 34px;
  align-items: center;
  padding: 5px 14px 7px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.runtime-state {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
}

.runtime-state strong {
  flex: 0 0 auto;
  font-weight: 600;
}

#status-detail {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.is-loading {
  background: var(--yellow);
  animation: pulse 1.1s ease-in-out infinite alternate;
}

.status-dot.is-ready {
  background: var(--green);
}

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

@keyframes pulse {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

.progress-track {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  overflow: hidden;
  background: transparent;
}

.progress-track span {
  display: block;
  height: 100%;
  background: var(--blue);
  transition: width 250ms ease;
}

.workspace {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(420px, 1.65fr) minmax(300px, 1fr);
  gap: 1px;
  overflow: hidden;
  background: var(--border);
}

.pane {
  display: grid;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
}

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

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

.pane-toolbar {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 9px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-raised);
}

.pane-toolbar > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.pane-toolbar h2,
.pane-toolbar label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

select {
  max-width: 230px;
  height: 28px;
  padding: 2px 28px 2px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: #15181e;
  font-family: var(--mono);
  font-size: 11px;
}

.text-button {
  min-height: 26px;
  padding: 3px 8px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.file-tabbar {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: #13161b;
}

.file-tab {
  display: inline-flex;
  height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  border-right: 1px solid var(--border);
  color: var(--muted);
  background: var(--editor);
  font-family: var(--mono);
  font-size: 11px;
}

.file-tab.is-active {
  border-top: 2px solid var(--blue);
  color: var(--text);
}

.python-mark {
  color: var(--yellow);
  font-size: 9px;
  font-weight: 700;
}

.editor-help {
  padding: 0 10px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  white-space: nowrap;
}

.editor-help kbd {
  color: var(--muted);
}

.editor {
  min-height: 0;
  overflow: hidden;
  background: var(--editor);
}

.cm-editor {
  height: 100%;
  font-family: var(--mono);
  font-size: 13px;
}

.cm-editor .cm-scroller {
  line-height: 1.65;
  overflow: auto;
}

.cm-editor .cm-content {
  padding: 10px 0 80px;
}

.cm-editor .cm-gutters {
  border-right: 1px solid var(--border);
  color: var(--faint);
  background: #13151a;
}

.cm-editor .cm-activeLine,
.cm-editor .cm-activeLineGutter {
  background: rgba(115, 168, 255, 0.07);
}

.cm-tooltip.cm-tooltip-hover {
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: #1a1d24;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.42);
}

.cm-doc-tooltip {
  display: grid;
  width: min(520px, calc(100vw - 32px));
  max-height: 340px;
  gap: 8px;
  padding: 11px 12px;
  overflow: auto;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
}

.cm-doc-tooltip strong {
  color: var(--blue);
  font-family: var(--mono);
}

.cm-doc-tooltip code {
  padding: 6px 8px;
  overflow: auto hidden;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: #d7e5ff;
  background: #11141a;
  font-family: var(--mono);
  white-space: pre-wrap;
}

.cm-doc-tooltip p {
  max-height: 190px;
  overflow: auto;
  color: #c3c8d2;
  white-space: pre-wrap;
}

.cm-doc-tooltip a {
  color: var(--blue);
  text-decoration: none;
}

.cm-doc-tooltip a:hover {
  text-decoration: underline;
}

.execution-state {
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--muted);
  background: #12151a;
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
}

.execution-state.is-running {
  color: var(--yellow);
}

.execution-state.is-error {
  color: var(--red);
}

#output {
  min-height: 0;
  margin: 0;
  padding: 13px 14px 80px;
  overflow: auto;
  color: #d8dce5;
  background: #101217;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

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

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

.output-result {
  color: var(--green);
}

.statusbar {
  display: flex;
  min-height: 26px;
  align-items: center;
  gap: 16px;
  padding: 4px 10px;
  overflow: auto hidden;
  border-top: 1px solid #2b5eaa;
  color: #d8e5f8;
  background: #234f8c;
  font-family: var(--mono);
  font-size: 9px;
  white-space: nowrap;
}

.statusbar span span,
.statusbar a span {
  color: #a9c4e8;
}

.statusbar strong {
  font-weight: 600;
}

.statusbar a {
  color: inherit;
  text-decoration: none;
}

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

.source-link {
  margin-left: auto;
}

@media (max-width: 760px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .runtime-actions {
    width: 100%;
  }

  .runtime-actions .button {
    flex: 1;
  }

  .button-primary kbd,
  .button-primary span {
    display: none;
  }

  .runtime-state {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  #status-detail {
    width: 100%;
    padding-left: 15px;
    white-space: normal;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(560px, 65vh) minmax(360px, 40vh);
    overflow: visible;
  }

  .statusbar {
    position: sticky;
    bottom: 0;
  }
}

@media (max-width: 430px) {
  .project-title p {
    display: none;
  }

  .runtime-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .pane-toolbar {
    align-items: flex-start;
  }

  .example-control {
    align-items: flex-start !important;
    flex-direction: column;
    gap: 3px !important;
  }

  select {
    max-width: 190px;
  }

  .editor-help {
    display: none;
  }
}
