/* ============================================================
 *  esp.blkbox.work  —  fresh light theme
 *  Tokens, base type, layout, components, animations.
 * ============================================================ */

:root {
  /* Surfaces */
  --bg:      #f6f8fc;        /* page background */
  --bg-2:    #eef2f8;        /* subtler surface */
  --surface: #ffffff;        /* cards, panels */
  --surface-2:#fafbff;       /* nested surface */
  --surface-3:#f1f4fa;
  --border:  #e2e7ef;
  --border-strong: #c8d0dc;

  /* Text */
  --fg:        #1a2233;
  --fg-2:      #475063;
  --muted:     #7a8294;
  --on-accent: #ffffff;

  /* Brand */
  --accent:        #4f7cff;
  --accent-soft:   #eaf0ff;
  --accent-strong: #335ee0;
  --accent-glow:   rgba(79,124,255,.32);

  --warm:          #ff8a4c;
  --warm-soft:     #fff1e6;

  --ok:            #1ec28b;
  --ok-soft:       #e3faf0;
  --warn:          #f0a020;
  --err:           #ef4d57;
  --err-soft:      #ffe5e6;

  /* Code surface (dark, on purpose) */
  --code-bg:   #0f1626;
  --code-fg:   #e7ecf7;
  --code-fg-2: #98a3bd;

  /* Effects */
  --radius:     12px;
  --radius-lg:  16px;
  --radius-sm:  8px;
  --shadow-sm:  0 1px 2px rgba(20,30,60,.05), 0 1px 1px rgba(20,30,60,.04);
  --shadow:     0 6px 16px rgba(20,30,60,.06), 0 2px 4px rgba(20,30,60,.04);
  --shadow-lg:  0 14px 40px rgba(20,30,60,.10), 0 4px 12px rgba(20,30,60,.05);
  --shadow-glow:0 0 0 4px var(--accent-glow);

  /* Motion */
  --t-fast: 120ms cubic-bezier(.4,.14,.3,1);
  --t-med:  220ms cubic-bezier(.4,.14,.3,1);
  --t-slow: 380ms cubic-bezier(.34,1.56,.64,1);

  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(79,124,255,.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(255,138,76,.08), transparent 55%),
    var(--bg);
  color: var(--fg);
  font: 14.5px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}

a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-strong); text-decoration: underline; }

::selection { background: var(--accent-soft); color: var(--accent-strong); }

/* ----- Topbar ------------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px;
  background: rgba(255,255,255,.78);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 5;
}
.brand a { color: var(--fg); display: flex; align-items: center; gap: 9px; text-decoration: none; }
.brand strong { font-weight: 700; letter-spacing: -.01em; }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--warm));
  box-shadow: 0 0 0 4px var(--accent-glow);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono  { font-family: var(--mono); }

.nav { display: flex; gap: 4px; margin-left: 6px; }
.nav a {
  color: var(--muted); padding: 6px 12px; border-radius: 8px;
  font-weight: 500; transition: color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  position: relative;
}
.nav a:hover  { color: var(--fg); background: var(--bg-2); text-decoration: none; transform: translateY(-1px); }
.nav a.active { color: var(--accent-strong); background: var(--accent-soft); }
.nav a.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -3px; height: 2px;
  background: var(--accent); border-radius: 2px;
}

/* Pills (status, badges) */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted);
  font-size: 12px; font-weight: 500; border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.pill.ok   { color: #0d8a5f; background: var(--ok-soft);   border-color: #b6ecd6; }
.pill.warn { color: #b56705; background: var(--warm-soft); border-color: #ffd9be; }
.pill.err  { color: #b3232a; background: var(--err-soft);  border-color: #ffc8cb; }
.status { display: flex; gap: 6px; }

.user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user .who { color: var(--muted); font-size: 13px; }

/* ----- Buttons & inputs --------------------------------------------------- */

button { font-family: inherit; }

button.primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: var(--on-accent); border: none; border-radius: 10px;
  padding: 8px 16px; font-weight: 600; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 4px 14px var(--accent-glow);
  transition: transform var(--t-fast), box-shadow var(--t-fast), filter var(--t-fast);
}
button.primary:hover  { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 8px 22px var(--accent-glow); }
button.primary:active { transform: translateY(0); filter: brightness(.96); }

button.ghost {
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 14px; font-weight: 500; cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
button.ghost:hover  { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
button.ghost:active { transform: translateY(0); }

button.danger {
  background: var(--surface); color: var(--err);
  border: 1px solid #f7c4c8; border-radius: 10px;
  padding: 8px 14px; cursor: pointer; font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast);
}
button.danger:hover { background: var(--err-soft); border-color: var(--err); }

input, select, textarea {
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; font-family: inherit; font-size: 13.5px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--shadow-glow);
}
textarea { width: 100%; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; min-height: 200px; }

/* ----- Layout shells ------------------------------------------------------ */

.route { flex: 1; overflow: auto; animation: fadeUp var(--t-slow); }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.content { max-width: 1280px; margin: 0 auto; padding: 24px 24px 64px; }
.content h1 {
  margin: 0 0 14px; font-size: 26px; font-weight: 700; letter-spacing: -.02em;
}
.content h2 {
  margin: 22px 0 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted); font-weight: 700;
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-med), transform var(--t-fast), border-color var(--t-fast);
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }

.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }

.empty {
  color: var(--muted); font-style: italic; padding: 36px;
  text-align: center; border: 1.5px dashed var(--border);
  border-radius: var(--radius); background: var(--surface-2);
}

/* ----- Auth pages --------------------------------------------------------- */

.auth {
  max-width: 440px; margin: 8vh auto; padding: 28px 26px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  animation: fadeUp var(--t-slow);
}
.auth h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.auth p.muted { margin-top: 0; }
.auth .field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.auth .field label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.auth .actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.auth .alt { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; color: var(--muted); }
.auth .err { color: var(--err); background: var(--err-soft); border: 1px solid #ffc8cb;
             padding: 8px 12px; border-radius: 8px; margin: 12px 0; font-size: 13.5px; }
.auth .ok  { color: #0d8a5f; background: var(--ok-soft); border: 1px solid #b6ecd6;
             padding: 8px 12px; border-radius: 8px; margin: 12px 0; font-size: 13.5px; }

/* ----- Tiles (dashboard, library, etc.) ----------------------------------- */

.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-med), transform var(--t-fast), border-color var(--t-fast);
  animation: fadeUp var(--t-slow);
}
.tile:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--border-strong); }
.tile .title { font-weight: 600; font-size: 15px; }
.tile .desc  { color: var(--fg-2); font-size: 13px; flex: 1; min-height: 28px; }
.tile .meta  { color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.tile .acts  { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.tile .acts button { padding: 6px 11px; font-size: 13px; border-radius: 8px; }

/* ----- List items (builds, etc.) ------------------------------------------ */

.list { display: flex; flex-direction: column; gap: 8px; }
.list .item {
  display: flex; align-items: center; gap: 14px; padding: 13px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-med);
}
.list .item:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.list .item .meta { color: var(--muted); font-size: 12px; font-family: var(--mono); }

.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted); border: 1px solid var(--border);
}
.badge.remix { color: #b56705; background: var(--warm-soft); border-color: #ffd9be; }

/* ----- Project page (tabs) ------------------------------------------------ */

.proj-page { display: flex; flex-direction: column; height: calc(100vh - 56px); }
.proj-tabs {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.proj-tabs .tab {
  padding: 7px 16px; color: var(--muted); border-radius: 10px;
  font-weight: 500; transition: all var(--t-fast);
}
.proj-tabs .tab:hover  { color: var(--fg); background: var(--bg-2); text-decoration: none; }
.proj-tabs .tab.active { color: var(--accent-strong); background: var(--accent-soft); }
.tab-body { flex: 1; min-height: 0; overflow: hidden; }

/* ----- Code editor (Code tab) -------------------------------------------- */

.editor-grid { display: grid; grid-template-columns: 280px 1fr; gap: 14px; height: 100%; padding: 14px; }
.editor-side {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; overflow: auto; display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow-sm);
}
.file {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; cursor: pointer; font-family: var(--mono); font-size: 12.5px;
  transition: all var(--t-fast);
}
.file:hover  { border-color: var(--accent); background: var(--accent-soft); }
.file.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.editor-main { display: flex; flex-direction: column; min-width: 0; gap: 10px; }
.editor-main textarea {
  flex: 1; resize: none; min-height: 200px;
  background: var(--code-bg); color: var(--code-fg); border-color: #2a324a;
}
.editor-main textarea:focus { box-shadow: 0 0 0 4px rgba(79,124,255,.25); }

/* ----- Visual board editor ------------------------------------------------ */

.board-shell { display: grid; grid-template-columns: 260px 1fr; height: 100%; }
.board-side {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 10px;
}
.board-side h2 { margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.board-title { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }

.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.palette-item {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 8px; cursor: grab; display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: all var(--t-fast);
}
.palette-item:hover  { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.palette-item:active { cursor: grabbing; transform: translateY(0); }
.palette-glyph svg { width: 64px; height: 30px; display: block; }
.palette-label { font-size: 11.5px; color: var(--fg-2); font-weight: 500; text-align: center; }

.board-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.board-actions button { width: 100%; }
.board-actions button.dirty {
  background: linear-gradient(180deg, var(--warm), #d96f25);
  box-shadow: 0 4px 14px rgba(255,138,76,.35);
  animation: nudge 1.4s ease-in-out infinite;
}
@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}

.wirelist { display: flex; flex-direction: column; gap: 4px; }
.wireitem {
  display: flex; gap: 6px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 8px; font-size: 11.5px;
  transition: border-color var(--t-fast);
}
.wireitem:hover { border-color: var(--accent); }
.wireitem .mono { font-family: var(--mono); flex: 1; word-break: break-all; color: var(--fg-2); }
.wireitem .x { background: transparent; border: none; color: var(--err); cursor: pointer; font-size: 16px; padding: 0 4px; }

.board-main {
  background:
    radial-gradient(800px 500px at 30% 20%, rgba(79,124,255,.08), transparent 60%),
    radial-gradient(700px 400px at 80% 80%, rgba(255,138,76,.06), transparent 60%),
    #f0f4fa;
  min-height: 0; overflow: hidden; position: relative;
}
svg.canvas {
  width: 100%; height: 100%; display: block; cursor: default;
  user-select: none; -webkit-user-select: none;
}
svg.canvas defs pattern circle { fill: #cdd6e4; }
/* IMPORTANT: do not transition `transform` on SVG <g>. The position lives in
 * the SVG `transform="translate(x,y)"` attribute, but browsers will animate
 * between the CSS-default (no transform → 0,0) and the attribute value on
 * style recomputations (e.g. :hover), causing parts to fly to the top-left.
 * Only filter/opacity are safe to transition here. */
svg.canvas .comp { cursor: grab; transition: filter var(--t-fast), opacity var(--t-fast); }
svg.canvas .comp:hover { filter: drop-shadow(0 6px 14px rgba(20,30,60,.12)); }
svg.canvas .comp.dragging { opacity: 0.92; cursor: grabbing; }
svg.canvas .pin { cursor: crosshair; }
svg.canvas .pin .pin-dot {
  fill: #ffffff; stroke: var(--accent); stroke-width: 2;
  transition: fill var(--t-fast), r var(--t-fast);
}
svg.canvas .pin:hover .pin-dot { fill: var(--accent); r: 7; }
svg.canvas .pin .pin-label {
  fill: var(--muted); font-size: 9.5px; font-family: var(--mono); pointer-events: none;
  transition: fill var(--t-fast);
}
svg.canvas .pin:hover .pin-label { fill: var(--accent-strong); font-weight: 600; }
svg.canvas .wire {
  fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(79,124,255,.35));
  stroke-dasharray: 1000; stroke-dashoffset: 1000;
  animation: wireDraw 600ms ease-out forwards;
}
@keyframes wireDraw { to { stroke-dashoffset: 0; } }
svg.canvas .wire.pending {
  stroke: var(--warm); stroke-dasharray: 6 6; animation: dashScroll 800ms linear infinite;
  filter: drop-shadow(0 0 4px rgba(255,138,76,.5));
}
@keyframes dashScroll { to { stroke-dashoffset: -24; } }
svg.canvas .del { cursor: pointer; opacity: 0; transition: opacity var(--t-fast); }
svg.canvas .comp:hover .del { opacity: 1; }

/* ----- Simulator UI ------------------------------------------------------- */

.sim-grid {
  display: grid; grid-template-columns: 1.0fr 1.2fr 1fr; gap: 12px;
  /* Inside the project tab: fill the tab body. As a stand-alone /sim page,
   * the parent .route stretches to fill the viewport so this still works. */
  height: 100%; min-height: calc(100vh - 110px); padding: 12px;
}
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; overflow: auto; display: flex; flex-direction: column; min-height: 0;
  box-shadow: var(--shadow-sm);
}
.panel h2 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.m-top { margin-top: 16px !important; }

/* time controls */
.time-controls { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.time-controls button, .time-controls select {
  background: var(--surface); color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 11px; cursor: pointer; font-family: var(--mono); font-size: 13px;
  transition: all var(--t-fast);
}
.time-controls button:hover, .time-controls select:hover { border-color: var(--accent); background: var(--accent-soft); }

/* breadboard panel */
.breadboard {
  background:
    radial-gradient(500px 320px at 30% 20%, rgba(79,124,255,.08), transparent 60%),
    #f7faff;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; min-height: 220px; display: flex; flex-wrap: wrap; gap: 14px;
  align-content: flex-start;
}
/* Simulator-panel tiles only — must NOT cascade onto the editor's SVG <g class="comp">,
 * or `transform: translateY` will shift it out from under the cursor and cause hover
 * jitter. We scope to direct children of the HTML .breadboard panel. */
.breadboard > .comp {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 10px; min-width: 110px; display: flex; flex-direction: column;
  align-items: center; gap: 8px; user-select: none;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-med), transform var(--t-fast);
  animation: fadeUp var(--t-med);
}
.breadboard > .comp:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.breadboard > .comp .label {
  font-size: 11.5px; color: var(--muted); font-family: var(--mono); text-align: center;
  font-weight: 500; line-height: 1.3;
}

/* LED bulb */
.led-bulb {
  width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5e6573, #2a2f3a 65%);
  border: 1px solid #1a1d24;
  transition: box-shadow var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.led-bulb.on {
  background: radial-gradient(circle at 35% 30%, #fff8c0, var(--led-color, #ff8a4c) 70%);
  box-shadow: 0 0 22px var(--led-color, #ff8a4c), 0 0 6px var(--led-color, #ff8a4c) inset;
  animation: ledPulse 1.6s ease-in-out infinite;
}
@keyframes ledPulse {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.18); }
}

/* Button */
.btn-cap {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(180deg, #687389, #3d465a);
  border: 2px solid #2a2f3a; cursor: pointer;
  box-shadow: 0 5px 0 #1a1d24, 0 7px 14px rgba(20,30,60,.18);
  transition: all 80ms ease;
}
.btn-cap:hover { filter: brightness(1.06); }
.btn-cap.pressed {
  box-shadow: 0 1px 0 #1a1d24, 0 1px 2px rgba(20,30,60,.18);
  transform: translateY(4px);
  background: linear-gradient(180deg, #3d465a, #2a2f3a);
}

/* Pot */
.pot-knob {
  width: 48px; height: 48px; border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #7a8398, #3d465a 60%);
  position: relative; cursor: ns-resize;
  border: 1px solid #2a2f3a;
  box-shadow: 0 3px 8px rgba(20,30,60,.18);
  transition: filter var(--t-fast);
}
.pot-knob:hover { filter: brightness(1.07); }
.pot-knob::after {
  content: ""; position: absolute; top: 4px; left: 50%; width: 3px; height: 18px;
  background: var(--warm); border-radius: 2px;
  transform-origin: 1.5px 20px; transform: translateX(-1.5px) rotate(var(--rot, 0deg));
  transition: transform var(--t-fast);
}

/* OLED */
.oled {
  width: 220px; min-height: 100px; background: linear-gradient(180deg, #0c1a36, #061025);
  border: 1px solid #001428; border-radius: 6px;
  font-family: var(--mono); color: #7ed4ff; padding: 8px 10px; font-size: 12.5px; line-height: 1.45;
  box-shadow: inset 0 0 18px rgba(0,40,90,.6), 0 4px 10px rgba(20,30,60,.2);
  letter-spacing: .02em;
}

/* MCU cards */
.mcus { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mcu {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; font-family: var(--mono); font-size: 12px; box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast);
}
.mcu:hover { border-color: var(--accent); }
.mcu .title { font-weight: 700; color: var(--fg); margin-bottom: 4px; }
.mcu .pins { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.mcu .pin { color: var(--muted); }
.mcu .pin.high { color: var(--ok); font-weight: 600; }
.mcu .pin.low  { color: var(--fg-2); }

/* Serial monitor & code preview (dark on purpose for legibility) */
.serial {
  background: var(--code-bg); border: 1px solid #1f2a45; border-radius: 10px;
  padding: 10px; font-family: var(--mono); font-size: 12.5px;
  color: var(--code-fg); max-height: 36vh; min-height: 140px; overflow: auto; flex: 1;
  scroll-behavior: smooth;
}
.serial .line { white-space: pre-wrap; padding: 1px 0; }
.serial .line:hover { background: rgba(255,255,255,.04); }
.serial .t { color: #6aa9ff; }
.serial .m { color: var(--warm); font-weight: 600; }

/* Network panel */
.net {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; font-family: var(--mono); font-size: 12px; color: var(--fg-2);
}
.net .row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }

/* MQTT */
.mqtt-pub { display: flex; gap: 6px; margin-bottom: 8px; }
.mqtt-pub input { flex: 1; }
.mqtt {
  background: var(--code-bg); border: 1px solid #1f2a45; border-radius: 10px;
  padding: 10px; font-family: var(--mono); font-size: 12.5px;
  max-height: 30vh; overflow: auto; color: var(--code-fg);
}
.mqtt > div { padding: 2px 0; }
.mqtt .topic   { color: var(--warm); font-weight: 600; }
.mqtt .payload { color: var(--code-fg); }

.events {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  max-height: 18vh; overflow: auto;
}

/* ----- Scrollbars (subtle) ----------------------------------------------- */

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 999px;
  border: 2px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* ----- Reduced motion ---------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
