:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151b23;
  --panel-soft: #1b232e;
  --border: #303a46;
  --text: #e6edf3;
  --muted: #96a3b1;
  --accent: #f2b84b;
  --accent-2: #4ea1ff;
  --danger: #ff716b;
  --input: #0f151d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  border-color: #607082;
}

.app-shell {
  min-height: 100vh;
  padding: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(360px, 1fr) 430px;
  gap: 16px;
  min-height: calc(100vh - 32px);
}

.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
}

.controls-panel {
  padding: 16px;
  overflow: auto;
}

.brand-row,
.preview-header,
.code-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
}

p,
.field span,
.check-row,
.summary {
  color: var(--muted);
}

.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 20px;
}

.field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.field span {
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 10px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(78, 161, 255, 0.35);
  border-color: var(--accent-2);
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.segment,
.view-segment {
  border: 0;
  border-radius: 0;
  background: var(--input);
  min-height: 36px;
}

.segment.active,
.view-segment.active {
  background: #24364a;
  color: #ffffff;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.extra-pass {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.summary {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 12px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.summary strong {
  color: var(--text);
  font-weight: 600;
}

.preview-column {
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr);
  gap: 12px;
  min-width: 0;
}

.preview-header {
  min-height: 58px;
  align-items: center;
  padding: 0 2px;
}

.metric-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.metric {
  min-width: 96px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

#preview {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #080c10;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#preview:active {
  cursor: grabbing;
}

.code-panel {
  display: grid;
  grid-template-rows: auto minmax(300px, 1fr);
  min-width: 0;
  padding: 14px;
}

.code-header {
  align-items: center;
  margin-bottom: 12px;
}

.code-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(64px, 1fr));
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.code-tab {
  min-height: 30px;
  border: 0;
  border-radius: 0;
  background: var(--input);
  font-size: 12px;
}

.code-tab.active {
  background: #24364a;
}

.code-actions {
  display: flex;
  gap: 8px;
}

#copyButton,
#downloadExtraButton {
  min-width: 72px;
  min-height: 34px;
}

#gcode,
#extraGcode {
  resize: none;
  min-height: 100%;
  font: 12px/1.5 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  white-space: pre;
}

.hidden {
  display: none;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 340px minmax(360px, 1fr);
  }

  .code-panel {
    grid-column: 1 / -1;
    min-height: 420px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

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

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

  .preview-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-strip {
    justify-content: flex-start;
  }
}
