:root {
  color-scheme: light;
  --bg: #effbff;
  --panel: #ffffff;
  --ink: #263b55;
  --muted: #667d98;
  --line: #ccecf5;
  --mint: #25D5FE;
  --mint-dark: #00a8cb;
  --sky: #e6f2ff;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 20px;
  color: var(--ink);
  background: #25D5FE;
  border-bottom: 2px solid #00a8cb;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  display: block;
  width: 128px;
  height: 128px;
  object-fit: contain;
}
.brand h1 { margin: 0; font-size: 1.4rem; font-weight: 800; }
.brand h1 span { color: #005b75; }
.brand small { color: #174b60; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.board-picker { display: flex; align-items: center; gap: 8px; font-weight: 800; }

select, input[type="text"] {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}

.btn {
  font: inherit;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 8px 16px;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
}
.btn:hover { background: #e8faff; }
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--mint); border-color: var(--mint); color: var(--ink); }
.btn.primary:hover { background: var(--mint-dark); }
.btn.small { padding: 5px 12px; font-size: 0.9rem; }

.workbench {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 12px;
  padding: 12px;
}

#blocklyDiv {
  flex: 1;
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fbfdff;
}

.side {
  width: 400px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.tabs { display: flex; background: #e8f8fc; }
.tab {
  flex: 1;
  font: inherit;
  font-weight: 800;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 12px;
  cursor: pointer;
}
.tab.active { color: var(--ink); border-bottom-color: var(--mint); background: #fff; }

.panel { display: none; flex: 1; min-height: 0; flex-direction: column; padding: 10px; gap: 8px; }
.panel.active { display: flex; }

.panel-actions { display: flex; align-items: center; gap: 8px; }
.status { margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.status.error { color: #bd4038; }

.code {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 12px;
  overflow: auto;
  background: #f5f9ff;
  border: 2px solid var(--line);
  border-radius: 12px;
  font: 13px/1.5 "Cascadia Code", Consolas, monospace;
  color: #263b55;
  white-space: pre;
}
.code.serial { white-space: pre-wrap; word-break: break-all; }

.serial-form { display: flex; gap: 8px; }
.serial-form input { flex: 1; }

dialog {
  max-width: 440px;
  border: 0;
  border-radius: var(--radius);
  padding: 24px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 12px 40px rgba(38, 59, 85, 0.2);
}
dialog::backdrop { background: rgba(38, 59, 85, 0.38); }
dialog h2 { margin-top: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 280px;
  padding: 14px 20px;
  background: #fff;
  border: 2px solid var(--mint);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(38, 59, 85, 0.2);
  z-index: 50;
}
.toast[hidden] { display: none; }
.toast progress { width: 100%; accent-color: var(--mint-dark); }

/* Keep Blockly text readable on the colourful blocks. */
.blocklyDiv .blocklyText,
.blocklyDiv .blocklyDropdownText { fill: #263b55 !important; }
.blocklyToolboxDiv { font-family: "Nunito", sans-serif; font-weight: 800; }

@media (max-width: 900px) {
  .workbench { flex-direction: column; }
  .side { width: 100%; height: 280px; }
}
