:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --panel: #ffffff;
  --ink: #162022;
  --muted: #5f6f73;
  --line: #d7e0e2;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --console: #101718;
  --console-text: #d6f0ec;
}

* {
  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,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 16px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

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

#connect-device,
#upload-firmware {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

#connect-device:hover:not(:disabled),
#upload-firmware:hover:not(:disabled) {
  background: var(--accent-dark);
}

select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

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

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

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

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 20px;
}

.status-pill {
  min-width: 168px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 14px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.status-pill.ok {
  border-color: #bbf7d0;
  color: var(--ok);
}

.status-pill.warn {
  border-color: #fed7aa;
  color: var(--warn);
}

.status-pill.danger {
  border-color: #fecaca;
  color: var(--danger);
}

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

.action-panel {
  margin-bottom: 16px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.quick-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfb;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.quick-status span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.quick-status strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.details-stack {
  display: grid;
  gap: 12px;
}

.detail-panel {
  padding: 0;
}

.detail-panel summary {
  cursor: pointer;
  padding: 16px 20px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
}

.detail-panel[open] summary {
  border-bottom: 1px solid var(--line);
}

.detail-panel > :not(summary) {
  margin: 20px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.info-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.info-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.info-grid strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(130px, 170px) auto 120px repeat(3, minmax(0, auto));
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.controls label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.progress-wrap {
  margin-bottom: 16px;
}

.inline-log {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

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

.inline-log-header h3 {
  margin: 0;
  font-size: 16px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

progress {
  width: 100%;
  height: 14px;
  border: 0;
}

progress::-webkit-progress-bar {
  border-radius: 999px;
  background: #e8eef0;
}

progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent);
}

progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--accent);
}

.image-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.image-list li {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 14px;
}

.image-list strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.console-log {
  min-height: 180px;
  max-height: 300px;
  overflow: auto;
  margin: 0;
  border-radius: 6px;
  background: var(--console);
  color: var(--console-text);
  padding: 14px;
  font-family: "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

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

  .toolbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .quick-status {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pill {
    width: 100%;
  }

  .image-list li {
    grid-template-columns: 1fr;
  }
}
