@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;700&family=Space+Mono:wght@400;700&display=swap');

:root {
  color-scheme: light;
  --bg-sand: #eceae0;
  --bg-panel: #ffffff;
  --ink-black: #1a1a1a;
  --ink-gray: #4a4a4a;
  --muted: #757368;
  --primary-blue: #020722;
  --primary-blue-light: rgba(19, 37, 140, 0.1);
  --neon-lime: #84f202;
  --neon-lime-light: rgba(132, 242, 2, 0.15);
  --orange-accent: #f03a17;
  --orange-accent-light: rgba(240, 58, 23, 0.1);
  --red: #ff2233;
  --amber: #f8a100;
  --border-thick: 3px solid var(--ink-black);
  --border-thin: 2px solid var(--ink-black);
  --shadow-double: 4px 4px 0px 0px var(--neon-lime), 8px 8px 0px 0px var(--ink-black);
  --shadow-double-small: 3px 3px 0px 0px var(--neon-lime), 6px 6px 0px 0px var(--ink-black);
  --shadow-double-blue: 4px 4px 0px 0px var(--primary-blue), 8px 8px 0px 0px var(--ink-black);
  --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Space Mono', 'Consolas', monospace;
  
  /* Sketchy border radius values */
  --sketchy-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
  --sketchy-radius-alt: 15px 225px 15px 255px/255px 15px 225px 15px;
  --sketchy-radius-button: 100px 15px 100px 15px/15px 100px 15px 100px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-sand);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background-color: var(--bg-sand);
  /* Saturated halftone paper dot grid */
  background-image: 
    radial-gradient(rgba(26, 26, 26, 0.12) 1.5px, transparent 1.5px),
    radial-gradient(rgba(19, 37, 140, 0.05) 1.5px, transparent 1.5px);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
  color: var(--ink-black);
  font-family: var(--font-body);
  letter-spacing: -0.01em;
}

button,
select {
  font: inherit;
}

#matrix {
  position: fixed;
  inset: 0;
  z-index: -2;
  width: 100vw;
  height: 100vh;
  background: transparent;
  pointer-events: none;
}

.scanline {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(26, 26, 26, 0.02) 0,
    rgba(26, 26, 26, 0.02) 1.5px,
    transparent 1.5px,
    transparent 5px
  );
  opacity: 0.7;
}

/* Header Topbar - Rich Navy with neon green outline stripe */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 14px clamp(16px, 4vw, 44px);
  border-bottom: var(--border-thick);
  background: var(--primary-blue);
  color: #ffffff;
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 100%;
  height: 5px;
  background: var(--neon-lime);
  border-bottom: var(--border-thick);
  z-index: 6;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

/* Image logo styled professionally and kept compact */
.brand-logo-img {
  height: 38px;
  width: auto;
  display: block;
  filter: drop-shadow(2px 2px 0px var(--ink-black));
}

.brand-text-container {
  display: flex;
  flex-direction: column;
}

.brand strong {
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 2px 2px 0px var(--ink-black);
}

.brand small {
  margin-top: 1px;
  color: var(--neon-lime);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

/* Target Status Capsule - Lime tag with double shadow */
.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: var(--border-thick);
  border-radius: var(--sketchy-radius-button);
  color: var(--ink-black);
  background: var(--neon-lime);
  box-shadow: 3px 3px 0px var(--ink-black);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
}

.pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink-black);
  box-shadow: 0 0 6px var(--ink-black);
  animation: pulse 1.6s linear infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* Layout - Notebook card stacks */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 28px;
  width: min(1600px, calc(100% - 64px));
  margin: 0 auto;
  padding: clamp(24px, 5vw, 48px) 0 48px;
}

/* Panel - Sketchy borders & dual-layer neobrutalist shadows */
.panel {
  position: relative;
  border: var(--border-thick);
  border-radius: var(--sketchy-radius);
  background: var(--bg-panel);
  box-shadow: var(--shadow-double);
  padding: 28px;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
}

/* Rotate side panels slightly for handwritten notebook feel */
.side-stack > .panel:nth-child(odd) {
  transform: rotate(-0.5deg);
  border-radius: var(--sketchy-radius-alt);
}
.side-stack > .panel:nth-child(even) {
  transform: rotate(0.4deg);
}

.panel:hover {
  transform: translate(-3px, -3px) rotate(0deg) !important;
  box-shadow: 6px 6px 0px 0px var(--neon-lime), 11px 11px 0px 0px var(--ink-black);
}

.install-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 640px;
  padding: clamp(20px, 4vw, 32px);
}

.side-stack {
  display: grid;
  gap: 28px;
  align-content: start;
}

.panel-head {
  display: grid;
  gap: 8px;
}

.panel-head.compact {
  gap: 4px;
}

.kicker {
  margin: 0;
  color: var(--orange-accent);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-shadow: 1px 1px 0px rgba(26, 26, 26, 0.1);
}

h1,
h2 {
  margin: 0;
  color: var(--primary-blue);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  text-shadow: 2px 2px 0px var(--bg-panel), 4px 4px 0px var(--ink-black);
  margin-bottom: 8px;
}

h2 {
  font-size: 1.35rem;
  border-bottom: var(--border-thick);
  padding-bottom: 10px;
  margin-bottom: 18px;
  text-shadow: 1.5px 1.5px 0px var(--bg-panel), 3px 3px 0px var(--ink-black);
}

/* Inputs & Form selects with sketchy bounds */
.version-control {
  display: grid;
  gap: 8px;
}

.version-control label,
.label {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.version-control select {
  width: 100%;
  min-height: 52px;
  border: var(--border-thick);
  border-radius: var(--sketchy-radius-button);
  padding: 0 16px;
  background: var(--bg-panel);
  color: var(--ink-black);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  outline: none;
  cursor: pointer;
  box-shadow: 4px 4px 0px 0px var(--ink-black);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='%231a1a1a' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

.version-control select:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0px 0px var(--ink-black);
}

.version-control select:focus-visible {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 4px 4px 0px 0px var(--neon-lime), 6px 6px 0px 0px var(--ink-black);
}

/* Info grid tiles with sketchy style */
.active-release,
.health-grid {
  display: grid;
  gap: 16px;
}

.active-release {
  grid-template-columns: 1.4fr 0.7fr 0.7fr;
}

.health-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.active-release > div,
.health-grid > div {
  min-width: 0;
  min-height: 82px;
  padding: 14px;
  border: var(--border-thin);
  border-radius: var(--sketchy-radius-alt);
  background: var(--bg-sand);
  box-shadow: 3px 3px 0px 0px var(--ink-black);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.active-release > div:hover,
.health-grid > div:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0px 0px var(--ink-black);
}

.active-release strong,
.health-grid strong {
  display: block;
  margin-top: 6px;
  color: var(--primary-blue);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
  text-shadow: none;
}

.health-grid strong.ready,
.health-grid strong.secure {
  color: var(--primary-blue);
}

.health-grid strong.warn,
.health-grid strong.blocked {
  color: var(--orange-accent);
}

.health-grid strong.fail,
.health-grid strong.unsupported {
  color: var(--red);
}

.installer-mount {
  display: grid;
  min-height: 80px;
  align-items: center;
}

esp-web-install-button {
  --esp-tools-button-color: var(--primary-blue);
  --esp-tools-button-text-color: #ffffff;
  --esp-tools-dialog-color: var(--bg-panel);
  --esp-tools-dialog-text-color: var(--ink-black);
  --esp-tools-error-color: var(--red);
  --esp-tools-progress-color: var(--primary-blue);
  --esp-tools-bar-color: var(--bg-sand);
}

/* Primary Flash Button - High neobrutalist style */
.flash-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 440px;
  min-height: 58px;
  border: var(--border-thick);
  border-radius: var(--sketchy-radius-button);
  background: var(--primary-blue);
  color: #ffffff;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  text-transform: uppercase;
  box-shadow: 4px 4px 0px 0px var(--neon-lime), 8px 8px 0px 0px var(--ink-black);
  transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.flash-button:hover {
  background: var(--neon-lime);
  color: var(--ink-black);
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px 0px var(--ink-black);
}

.flash-button:active {
  transform: translate(5px, 5px);
  box-shadow: 0px 0px 0px var(--ink-black);
}

.flash-button .icon {
  font-weight: 700;
}

/* Flash Dialog */
.flash-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: min(720px, calc(100vh - 28px));
  padding: 0;
  border: var(--border-thick);
  border-radius: var(--sketchy-radius);
  background: var(--bg-sand);
  color: var(--ink-black);
  box-shadow: 10px 10px 0px 0px var(--ink-black);
  overflow: hidden;
}

.flash-dialog::backdrop {
  background: rgba(26, 26, 26, 0.6);
  backdrop-filter: blur(5px);
}

.dialog-shell {
  position: relative;
  display: grid;
  gap: 0;
  background: var(--bg-sand);
}

.dialog-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: var(--primary-blue);
  border-bottom: var(--border-thick);
  color: #ffffff;
}

.dialog-top p {
  margin: 0;
  flex: 1;
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dialog-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--neon-lime);
  box-shadow: 0 0 8px var(--neon-lime);
}

.dialog-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: var(--border-thin);
  border-radius: var(--sketchy-radius-button);
  background: var(--bg-panel);
  color: var(--ink-black);
  font-weight: 700;
  cursor: pointer;
  outline: none;
  box-shadow: 2px 2px 0px var(--ink-black);
}

.dialog-icon-btn:hover {
  background: var(--red);
  color: #ffffff;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--ink-black);
}

.dialog-body {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 20px;
  padding: 22px;
}

.dialog-title {
  display: grid;
  gap: 6px;
}

.dialog-title span {
  color: var(--orange-accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.dialog-title strong {
  color: var(--ink-black);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.6rem;
}

.dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dialog-grid > div {
  min-width: 0;
  min-height: 72px;
  padding: 12px;
  border: var(--border-thin);
  border-radius: var(--sketchy-radius-alt);
  background: var(--bg-panel);
  box-shadow: 3px 3px 0px 0px var(--ink-black);
}

.dialog-grid span {
  display: block;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.dialog-grid strong {
  display: block;
  margin-top: 6px;
  color: var(--primary-blue);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.dialog-log {
  min-height: 120px;
  margin: 0;
  padding: 14px;
  border: var(--border-thin);
  border-radius: var(--sketchy-radius-alt);
  background: var(--ink-black);
  color: var(--neon-lime);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  overflow: auto;
  white-space: pre-wrap;
}

.dialog-actions {
  justify-content: flex-end;
  display: flex;
  gap: 14px;
  padding: 18px 22px;
  background: var(--bg-panel);
  border-top: var(--border-thick);
}

.dialog-btn {
  min-width: 125px;
  min-height: 44px;
  border-radius: var(--sketchy-radius-button);
  border: var(--border-thick);
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  outline: none;
}

.dialog-btn.secondary {
  background: var(--bg-panel);
  color: var(--ink-black);
  box-shadow: 3px 3px 0px var(--ink-black);
}

.dialog-btn.secondary:hover {
  background: var(--bg-sand);
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0px var(--ink-black);
}

.dialog-btn.primary {
  background: var(--primary-blue);
  color: #ffffff;
  box-shadow: 3px 3px 0px var(--neon-lime), 3px 3px 0px 2px var(--ink-black);
}

.dialog-btn.primary:hover {
  background: var(--neon-lime);
  color: var(--ink-black);
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0px var(--ink-black);
}

/* Slot warnings & custom text */
.slot-message {
  margin: 0;
  max-width: 620px;
  color: var(--orange-accent);
  line-height: 1.55;
  font-family: var(--font-mono);
  font-weight: 700;
}

/* Text Terminal / Log Box */
.boot-log {
  min-height: 190px;
  margin: 0;
  padding: 18px;
  border: var(--border-thick);
  border-radius: var(--sketchy-radius-alt);
  background: var(--ink-black);
  color: var(--neon-lime);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.65;
  overflow: auto;
  white-space: pre-wrap;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.85);
}

/* Bullet list components with comic markers */
.feature-list,
.ops-list {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
  padding-left: 20px;
  color: var(--ink-black);
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.55;
}

.feature-list li::marker {
  color: var(--primary-blue);
  font-weight: 700;
  font-size: 1.1rem;
}

.ops-list li::marker {
  color: var(--orange-accent);
  font-weight: 700;
  font-family: var(--font-mono);
}

/* Metadata detailing */
.meta-list {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
}

.meta-list div {
  min-width: 0;
  padding: 12px 0;
  border-top: var(--border-thin);
}

.meta-list div:first-child {
  border-top: none;
  padding-top: 0;
}

.meta-list dt {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.meta-list dd {
  margin: 6px 0 0;
  color: var(--primary-blue);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
  text-shadow: none;
}

/* Responsive adjustments */
@media (max-width: 860px) {
  .topbar {
    position: relative; /* Scroll with content on mobile */
    top: auto;
    min-height: auto;
    padding: 16px 20px;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .topbar::after {
    bottom: -5px;
    height: 3px;
  }

  .layout {
    grid-template-columns: 1fr;
    width: min(100% - 24px, 680px);
    gap: 20px;
    padding: 24px 0 32px;
  }

  .install-panel {
    min-height: 0;
    padding: 20px;
  }

  .active-release {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
  }

  .health-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
  }

  /* Disable notebook tilt on mobile stacks to prevent clipping and overflow */
  .side-stack > .panel:nth-child(odd),
  .side-stack > .panel:nth-child(even) {
    transform: none !important;
  }

  .panel {
    padding: 20px;
  }

  h1 {
    font-size: clamp(1.8rem, 8vw, 2.4rem);
    text-shadow: 1.5px 1.5px 0px var(--bg-panel), 3px 3px 0px var(--ink-black);
  }
  
  h2 {
    font-size: 1.2rem;
    margin-bottom: 14px;
    text-shadow: 1px 1px 0px var(--bg-panel), 2px 2px 0px var(--ink-black);
  }
}

@media (max-width: 480px) {
  .active-release,
  .health-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .brand strong,
  .brand small {
    white-space: normal;
  }

  .flash-button {
    font-size: 1rem;
  }

  .dialog-grid {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .dialog-btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulse {
    animation: none;
  }
}

/* Board Selector Visual Container styling */
.board-selector-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.board-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  width: 100%;
}

.board-card-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  border: var(--border-thick);
  border-radius: var(--sketchy-radius-alt);
  background: var(--bg-sand);
  padding: 14px 18px;
  cursor: pointer;
  box-shadow: 4px 4px 0px 0px var(--ink-black);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  text-align: left;
  outline: none;
  font-family: inherit;
  width: 100%;
}

.board-card-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px 0px var(--ink-black);
}

.board-card-btn.active {
  background: var(--bg-panel);
  border-color: var(--primary-blue);
  box-shadow: 4px 4px 0px 0px var(--neon-lime), 8px 8px 0px 0px var(--ink-black);
  transform: translate(-3px, -3px);
}

.board-card-btn.active::before {
  content: 'SELECTED';
  position: absolute;
  top: -8px;
  right: 12px;
  background: var(--neon-lime);
  color: var(--ink-black);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 8px;
  border: 2px solid var(--ink-black);
  border-radius: var(--sketchy-radius-button);
  box-shadow: 1px 1px 0px var(--ink-black);
  z-index: 2;
}

.board-card-img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: var(--border-thin);
  border-radius: var(--sketchy-radius);
  width: 60px;
  height: 60px;
  min-width: 60px;
  padding: 4px;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.board-card-btn:hover .board-card-img-wrap {
  transform: scale(1.06);
}

.board-card-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.board-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.board-card-info strong {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-black);
  text-transform: uppercase;
  line-height: 1.1;
}

.board-card-info small {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.board-card-btn.active .board-card-info small {
  color: var(--primary-blue);
}

@media (max-width: 640px) {
  .board-selector-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}
