:root {
  color-scheme: light;
  --paper: #f7f5ef;
  --ink: #1c2427;
  --muted: #627070;
  --line: #d8d3c6;
  --panel: #ffffff;
  --accent: #b01b2e;
  --blue: #16407a;
  --blue-soft: #8fc4e8;
  --rose-soft: #f0a6a0;
  --shadow: 0 16px 40px rgba(29, 34, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 52px) 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.95;
}

h2 {
  font-size: 18px;
}

.runtime {
  min-width: 132px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fffaf2;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.runtime[data-state="ready"] {
  background: #e9f6f8;
  color: var(--blue);
  border-color: var(--blue-soft);
}

.runtime[data-state="error"] {
  background: #fff0ed;
  color: var(--accent);
  border-color: var(--rose-soft);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(360px, 1fr);
  gap: 18px;
  padding: 22px clamp(18px, 4vw, 52px) 44px;
}

.panel,
.preview {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.editor-panel {
  min-height: 330px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea,
select,
button,
.button {
  font: inherit;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
}

textarea {
  min-height: 148px;
  padding: 12px;
  resize: vertical;
  line-height: 1.45;
}

select {
  min-height: 42px;
  padding: 0 10px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  align-items: end;
  gap: 10px;
  margin-top: 14px;
}

button,
.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
}

button:disabled,
.button.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.button.secondary {
  border-color: var(--blue);
  background: var(--blue);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.stats span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  background: #f3f6f5;
  border: 1px solid #dde4e1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.preview {
  min-height: 500px;
  display: grid;
  place-items: center;
  padding: 20px;
}

.svg-preview {
  width: min(100%, 720px);
  display: grid;
  place-items: center;
}

.svg-preview svg {
  width: 100%;
  height: auto;
  max-height: 72vh;
}

.error-text {
  color: var(--accent);
  font-weight: 700;
}

.runner-panel {
  grid-column: 1 / -1;
}

.runner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

#pythonCode {
  min-height: 190px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
}

#pythonOutput {
  min-height: 92px;
  margin: 12px 0 0;
  padding: 12px;
  overflow: auto;
  background: #151b1e;
  color: #eaf3f3;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

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

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

  .controls button,
  .controls .button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .preview {
    min-height: 360px;
    padding: 12px;
  }
}
