:root {
  --ink: #16203a;
  --muted: #5d6781;
  --line: #e1e5ee;
  --surface: #ffffff;
  --stage: #f1f5fd;
  --accent: #4f6bd8;
  --accent-strong: #3f58bd;
  --bar: #151d3b;
  --ok: #3ecf8e;
  --warn: #f5b84a;
  --bad: #d93a40;
  font:
    15px/1.5 Inter,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--surface);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
}

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

/* Top bar */

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(90deg, var(--bar), #1e3350);
  color: #fff;
}

.bar-inner,
main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

.bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand img {
  padding: 2px;
  border-radius: 7px;
  background: #fff;
}

.bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

.chip i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8a93ab;
}

.chip.ready i {
  background: var(--ok);
}

.chip.busy i {
  background: var(--warn);
  animation: pulse 1.2s ease-in-out infinite;
}

.chip.error i {
  background: var(--bad);
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* Buttons */

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.primary {
  padding: 8px 16px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s;
}

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

.bar .primary {
  background: rgb(255 255 255 / 16%);
}

.bar .primary:hover:not(:disabled) {
  background: rgb(255 255 255 / 26%);
}

.bar .primary:disabled {
  color: rgb(255 255 255 / 45%);
  background: rgb(255 255 255 / 8%);
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.link:hover:not(:disabled) {
  color: var(--accent);
}

.link:disabled {
  color: #a3abbe;
}

.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted,
small {
  color: var(--muted);
}

/* Model notice */

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  margin-top: 20px;
  padding: 14px 16px;
  border: 1px solid #d5ddf5;
  border-radius: 8px;
  background: #f5f7fe;
}

.notice-text {
  display: flex;
  flex: 1 1 320px;
  flex-direction: column;
}

.notice-text span {
  color: var(--muted);
}

.notice.error {
  border-color: #f3c6c8;
  background: #fef6f6;
}

.notice.error .notice-text span {
  color: var(--bad);
}

.meter {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  order: 3;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

progress {
  appearance: none;
  height: 6px;
  border: 0;
  border-radius: 3px;
  background: #dfe4f1;
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: #dfe4f1;
}

progress::-webkit-progress-value {
  background: var(--accent);
  transition: width 0.2s;
}

progress:indeterminate {
  background: linear-gradient(90deg, #dfe4f1 0 35%, var(--accent) 50%, #dfe4f1 65% 100%) 0 0 / 300%
    100%;
  animation: slide 1.4s linear infinite;
}

progress:indeterminate::-webkit-progress-bar {
  background: transparent;
}

@keyframes slide {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: 0 0;
  }
}

.meter progress {
  flex: 1 1 260px;
}

/* Settings */

.settings {
  margin-top: 8px;
  border-bottom: 1px solid var(--line);
}

.settings summary {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 16px 0;
  cursor: pointer;
  list-style: none;
}

.settings summary::-webkit-details-marker {
  display: none;
}

.settings summary::before {
  content: "";
  align-self: center;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

.settings[open] summary::before {
  transform: rotate(45deg);
}

.settings-title {
  font-size: 16px;
  font-weight: 500;
}

#settings-summary {
  font-size: 13px;
}

.settings-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px 40px;
  padding: 4px 0 22px 20px;
}

.field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.field > span {
  font-weight: 500;
}

.field output {
  margin-left: 6px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.field input[type="range"] {
  width: 100%;
  max-width: 260px;
  accent-color: var(--accent);
}

.field input[type="number"] {
  width: 120px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* Two panes */

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  padding: 28px 0 64px;
}

.pane {
  min-width: 0;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
}

h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.actions {
  display: flex;
  gap: 18px;
}

.tabs {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  margin-bottom: -1px;
  padding: 8px 0 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
}

.tabs button[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--ink);
}

.stage {
  position: relative;
  aspect-ratio: 6 / 5;
  margin-top: 10px;
  background: linear-gradient(135deg, #f4f6fe, var(--stage) 60%, #eef9fb);
  overflow: hidden;
}

.stage.over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.stage img,
.stage pre {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
}

.stage img {
  object-fit: contain;
}

.stage .preview {
  background: #fff;
}

.stage pre {
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--surface);
  font:
    12px/1.5 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.stage .placeholder {
  position: static;
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
  opacity: 0.55;
  mix-blend-mode: multiply;
}

.example {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.example:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgb(79 107 216 / 15%);
}

.stage .example img {
  position: static;
  width: 132px;
  height: 132px;
}

.run-bar {
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 0;
}

.caption-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.caption-row .caption {
  min-width: 0;
}

.caption-row .primary {
  margin-top: 12px;
}

.primary.large {
  padding: 10px 20px;
  font-size: 15px;
}

.primary:disabled {
  background: #c3cae0;
}

.primary.stop {
  background: var(--ink);
}

.caption {
  display: flex;
  flex-direction: column;
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
}

.caption strong {
  font-weight: 500;
}

.caption span {
  color: var(--muted);
  font-size: 14px;
}

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

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

  .chip {
    display: none;
  }
}
