:root {
  color-scheme: light;
  --bg: #eef3f7;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #627083;
  --line: #d8e0e8;
  --accent: #006d77;
  --accent-strong: #0a5964;
  --accent-soft: #dff4f2;
  --warning: #b45309;
  --danger: #b42318;
  --success: #157347;
  --shadow: 0 18px 48px rgba(31, 50, 68, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(20px, 5vw, 56px) 18px;
}

.topbar h1,
.section-heading h2,
.step-title h2 {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.05;
}

.topbar-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.language-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.language-switch select {
  width: auto;
  min-height: 36px;
  padding: 6px 32px 6px 10px;
}

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

.browser-status {
  max-width: 360px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 14px;
}

.browser-status.ok {
  border-color: rgba(21, 115, 71, 0.28);
  background: #e8f6ef;
  color: var(--success);
}

.browser-status.warn {
  border-color: rgba(180, 83, 9, 0.32);
  background: #fff7ed;
  color: var(--warning);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 20px;
  padding: 0 clamp(20px, 5vw, 56px) 40px;
}

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

.controls-panel,
.preview-panel,
.progress-panel {
  padding: 22px;
}

.controls-panel {
  display: grid;
  gap: 22px;
  align-self: start;
}

.workspace {
  display: grid;
  gap: 20px;
  min-width: 0;
}

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

.advanced-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 0;
}

.advanced-step summary {
  display: grid;
  grid-template-columns: 26px auto 1fr;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  cursor: pointer;
  list-style: none;
  padding: 14px;
}

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

.advanced-step summary span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.advanced-step summary strong {
  font-size: 18px;
}

.advanced-step summary em {
  justify-self: end;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
}

.advanced-step[open] {
  padding-bottom: 14px;
}

.advanced-step[open] .settings-grid,
.advanced-step[open] #customResetLabel,
.advanced-step[open] .checkline {
  margin-left: 14px;
  margin-right: 14px;
}

.step-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-title span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.step-title h2 {
  font-size: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input[type="text"],
input[type="file"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}

.board-card,
.firmware-meta {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.board-card strong,
.firmware-meta strong {
  color: var(--ink);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 4px;
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.segmented button.active {
  background: var(--accent);
  color: white;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 14px;
}

.checkline input {
  width: 18px;
  height: 18px;
}

.primary,
.secondary {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 850;
}

.primary {
  background: var(--accent);
  color: white;
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent-strong);
}

.hidden {
  display: none;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

#localFiles {
  display: grid;
  gap: 10px;
}

.local-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 120px 42px;
  gap: 8px;
}

.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--danger);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h2 {
  font-size: 22px;
}

.markdown-body {
  color: #243241;
  line-height: 1.68;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 22px 0 10px;
  line-height: 1.2;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body img {
  width: min(100%, 760px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.markdown-body code {
  border-radius: 4px;
  background: #edf2f7;
  padding: 2px 5px;
}

.markdown-body ul {
  padding-left: 22px;
}

.markdown-body ol {
  padding-left: 24px;
}

.table-scroll {
  overflow-x: auto;
  margin: 14px 0;
}

.markdown-body table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 14px;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.markdown-body th {
  background: #f1f5f9;
  color: var(--ink);
}

.progress-wrap {
  display: grid;
  gap: 10px;
}

.progress-track {
  overflow: hidden;
  height: 14px;
  border-radius: 999px;
  background: #e6edf3;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.progress-text {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.log {
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
  margin: 18px 0 0;
  border-radius: 8px;
  background: #111827;
  color: #d1fae5;
  padding: 14px;
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  .topbar,
  .app-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    justify-items: stretch;
  }

  .language-switch {
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .settings-grid,
  .local-file-row {
    grid-template-columns: 1fr;
  }
}
