:root {
  --bg: #f6efe5;
  --panel: rgba(255, 252, 247, 0.9);
  --ink: #1f2937;
  --muted: #5b6470;
  --accent: #c2410c;
  --accent-2: #0f766e;
  --line: rgba(31, 41, 55, 0.12);
  --shadow: 0 18px 48px rgba(120, 53, 15, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(194, 65, 12, 0.18), transparent 28%),
    linear-gradient(180deg, #fff8ef 0%, #f3eadf 100%);
}

.layout {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--accent-2);
  font-weight: 700;
}

h1,
h2 {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.3rem, 5vw, 4.2rem);
  line-height: 0.92;
  margin-bottom: 16px;
}

.subtitle,
#backend-status,
#serial-status,
pre {
  color: var(--muted);
}

.status-card,
.workspace-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.status-card {
  padding: 20px;
}

.workspace-panel {
  padding: 18px;
}

.quick-start-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  background: linear-gradient(135deg, rgba(255, 247, 237, 0.98), rgba(240, 253, 244, 0.98));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 16px;
}

.quick-start-label {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--accent-2);
  font-weight: 700;
}

.quick-start-card h2 {
  margin-bottom: 8px;
}

.quick-start-copy {
  margin: 0;
  color: var(--muted);
}

.board-badge {
  justify-self: end;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-2);
  font-weight: 700;
  text-align: center;
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar-primary {
  margin-bottom: 12px;
}

.toolbar-primary input {
  min-width: 240px;
}

.advanced-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 250, 0.9);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.advanced-panel summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.advanced-panel[open] summary {
  margin-bottom: 12px;
}

.advanced-copy {
  margin: 0 0 12px;
  color: var(--muted);
}

.toolbar-advanced {
  margin-bottom: 0;
}

.simple-flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.flow-step {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 250, 0.82);
}

.flow-step strong,
.flow-step span {
  display: block;
}

.flow-step strong {
  color: var(--ink);
  margin-bottom: 4px;
}

.flow-step span {
  color: var(--muted);
  font-size: 0.94rem;
}

.progress-panel {
  background: #fff7ed;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.runtime-panel {
  background: #f0fdf4;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.artifacts-panel {
  background: #fffdfa;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.runtime-panel-compact {
  background: #f8fafc;
}

.runtime-panel h2,
.artifacts-panel h2 {
  margin-bottom: 8px;
}

.runtime-panel p,
.artifacts-panel p {
  margin: 6px 0;
  color: var(--muted);
}

.compiler-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}

.compiler-option {
  max-width: 100%;
  padding: 8px 12px;
  background: rgba(15, 118, 110, 0.1);
  color: #0f766e;
  border: 1px solid rgba(15, 118, 110, 0.18);
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compiler-option:hover {
  background: rgba(15, 118, 110, 0.16);
}

.compiler-option-active {
  background: #dbece7;
  color: #0f766e;
}

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

.artifact-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.artifact-badge-idle {
  background: rgba(91, 100, 112, 0.12);
  color: var(--muted);
}

.artifact-badge-ok {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-2);
}

.artifact-badge-error {
  background: rgba(194, 65, 12, 0.12);
  color: var(--accent);
}

.artifact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.downloads-panel {
  width: 100%;
  margin-top: 10px;
}

.downloads-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
}

.artifact-links-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.artifact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.artifact-link {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: white;
  background: linear-gradient(135deg, var(--accent-2), #14b8a6);
  font-weight: 700;
}

.artifact-link:hover {
  filter: saturate(1.06);
}

.artifact-action-button {
  background: linear-gradient(135deg, #0f766e, #14b8a6);
}

.artifact-hint {
  flex-basis: 100%;
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.94rem;
}

.flash-install {
  display: inline-flex;
}

.flash-action-button {
  background: linear-gradient(135deg, #047857, #22c55e);
  box-shadow: 0 12px 24px rgba(4, 120, 87, 0.18);
}

.flash-warning {
  display: inline-flex;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(194, 65, 12, 0.12);
  color: var(--accent);
  font-weight: 700;
}

esp-web-install-button::part(button) {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  cursor: pointer;
}

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

.progress-track {
  width: 100%;
  height: 14px;
  background: rgba(31, 41, 55, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), #22c55e);
  transition: width 0.24s ease;
}

#progress-message {
  margin-bottom: 0;
  color: var(--muted);
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #fb923c);
  color: white;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.primary-action {
  background: linear-gradient(135deg, #0f766e, #22c55e);
}

button:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

input {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 16px;
  background: #fffdfa;
  color: var(--ink);
  min-width: 190px;
}

select {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 16px;
  background: #fffdfa;
  color: var(--ink);
  min-width: 220px;
}

.content-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

#blocklyDiv,
.code-panel {
  min-height: 560px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fffdfa;
}

.code-panel {
  padding: 16px;
}

.debug-panel summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 12px;
}

.debug-panel {
  min-height: unset;
}

.debug-panel:not([open]) {
  align-self: start;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #fff7ed;
  border-radius: 12px;
  padding: 12px;
  min-height: 140px;
}

@media (max-width: 980px) {
  .hero,
  .content-grid,
  .simple-flow {
    grid-template-columns: 1fr;
  }

  .quick-start-card {
    grid-template-columns: 1fr;
  }

  .board-badge {
    justify-self: start;
  }

  #blocklyDiv,
  .code-panel {
    min-height: 420px;
  }
}
