/* ── OLED Code Generator — Simple Wokwi-style UI ─── */
/* Google Fonts loaded via <link> in HTML for better performance (no @import blocking) */

:root {
  --bg:     #f0f2f5;
  --card:   #ffffff;
  --border: #dde1e7;
  --panel:  #f8f9fb;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --text:   #1e293b;
  --muted:  #64748b;
  --oled-bg:#000;
  --oled-px:#00efff;
  --pcb:    #1a4fa0;
  --pcb-dk: #0f3070;
  --radius: 10px;
  --danger: #ef4444;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); }

body { display: flex; flex-direction: column; min-height: 100dvh; }

/* ─── Header ─────────────────────────────────────────────────────────────── */
#header {
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; align-content: center;
  gap: 8px 10px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  min-height: 54px; height: auto; flex-shrink: 0; z-index: 200;
  position: relative;
}
.header-brand {
  display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0;
}
#logo {
  font-size: 15px; font-weight: 700; color: var(--accent);
  display: flex; align-items: center; gap: 7px; text-decoration: none;
  min-width: 0;
}
#logo svg { width: 26px; height: 26px; flex-shrink: 0; }
.site-title { font-size: 15px; font-weight: 700; margin: 0; white-space: nowrap; }
.site-title--short { display: none; }
.site-tagline {
  font-size: 11px; font-weight: 500; color: var(--muted); margin: 0;
  white-space: nowrap; display: none;
}
@media (min-width: 1100px) {
  .site-tagline { display: block; }
}
.header-site-nav {
  display: none;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
@media (min-width: 900px) {
  .header-site-nav { display: flex; }
}
.header-site-nav a {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
}
.header-site-nav a:hover {
  color: var(--accent);
  background: #eff6ff;
}
.header-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  flex: 1 1 auto; justify-content: flex-end;
}
.header-serial {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; font-size: 11px; color: var(--muted); font-weight: 500;
}
.header-serial__dot {
  width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; flex-shrink: 0;
}
.header-serial__label { white-space: nowrap; }
.btn-connect-serial {
  background: var(--accent); color: #fff; border: none; font-weight: 600;
  font-size: 12px; font-family: inherit; padding: 6px 12px; height: 32px;
  border-radius: 7px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  touch-action: manipulation;
}
.btn-connect-serial:hover { background: #1d4ed8; }
.btn-connect-wifi {
  background: #0d9488; color: #fff; border: none; font-weight: 600;
  font-size: 12px; font-family: inherit; padding: 6px 12px; height: 32px;
  border-radius: 7px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  touch-action: manipulation;
}
.btn-connect-wifi:hover { background: #0f766e; }
.header-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  flex: 1 1 auto; justify-content: flex-end; min-width: 0;
}
.header-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
}
.header-menu-btn__bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}
.header-menu-btn.is-active .header-menu-btn__bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.header-menu-btn.is-active .header-menu-btn__bar:nth-child(2) { opacity: 0; }
.header-menu-btn.is-active .header-menu-btn__bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}
.header-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 180;
}
.header-menu-backdrop.is-visible { display: block; }
.header-mobile-menu {
  display: none;
}
.header-mobile-menu__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 10px;
}
.header-menu-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.header-menu-field > span {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.header-menu-field .hsel { width: 100%; max-width: none; }
.header-menu-field--lang .lang-pill {
  width: 100%;
  justify-content: center;
  padding: 8px 12px;
}
@media (min-width: 769px) {
  .header-mobile-menu {
    display: contents;
  }
  .header-mobile-menu__title { display: none; }
  .header-menu-field {
    display: contents;
  }
  .header-menu-field > span { display: none; }
  .header-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    justify-content: flex-end;
  }
}
@media (max-width: 768px) {
  .header-menu-btn { display: flex; }
  .header-controls {
    flex: 1 1 auto;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    width: auto;
    flex-wrap: nowrap;
  }
  .header-mobile-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: -1px;
    padding: 14px 12px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
    z-index: 190;
    max-height: min(70dvh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .header-mobile-menu.is-open { display: block; }
  .header-mobile-menu .header-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    width: 100%;
    overflow: visible;
    flex-wrap: wrap;
  }
  .header-mobile-menu .hsel--addr,
  .header-mobile-menu .hsel--lib { display: block; }
}
.h-sep { flex: 1; display: none; }

.skip-link {
  position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  position: fixed; left: 16px; top: 12px; z-index: 9999; width: auto; height: auto;
  padding: 10px 16px; background: var(--accent); color: #fff; border-radius: 8px;
  font-size: 13px; font-weight: 600; text-decoration: none;
}

.hsel {
  background: var(--panel); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; font-family: 'Inter', sans-serif;
  padding: 6px 10px; border-radius: 7px; cursor: pointer; outline: none;
  transition: border-color .2s;
}
.hsel:focus { border-color: var(--accent); }

.lang-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 10px; font-size: 12px;
}
.lang-pill span { font-weight: 500; color: var(--muted); transition: color .2s; }
.lang-pill span.on { color: var(--accent); font-weight: 600; }

.sw { position: relative; width: 36px; height: 20px; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw .knob {
  position: absolute; inset: 0; border-radius: 20px;
  background: #cbd5e1; cursor: pointer; transition: background .25s;
}
.sw .knob::before {
  content: ''; position: absolute;
  width: 14px; height: 14px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .25s;
}
.sw input:checked + .knob { background: var(--accent); }
.sw input:checked + .knob::before { transform: translateX(16px); }

/* ─── Main Layout ────────────────────────────────────────────────────────── */
#main {
  flex: none;
  height: calc(100dvh - 54px);
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0;
  overflow: hidden;
}

/* ─── Left Panel ─────────────────────────────────────────────────────────── */
#left {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg); overflow: hidden;
}

/* Mode bar */
#modeBar {
  display: flex; gap: 0;
  background: #fff; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mode-btn {
  flex: 1; padding: 11px 8px; text-align: center;
  background: none; border: none; border-bottom: 2px solid transparent;
  font-size: 13px; font-weight: 500; color: var(--muted);
  cursor: pointer; transition: all .18s;
}
.mode-btn:hover { color: var(--text); background: var(--panel); }
.mode-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ─── Gallery ────────────────────────────────────────────────────────────── */
#galleryView { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
#gallerySearchBox { padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--border); }
#tplSearch { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; font-size: 13px; outline: none; background: var(--panel); transition: all .2s; }
#tplSearch:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

#catTabs {
  display: flex; gap: 0; overflow-x: auto; flex-shrink: 0;
  background: #fff; padding: 0 16px; border-bottom: 1px solid var(--border);
}
#catTabs::-webkit-scrollbar { display: none; }
.cat-tab {
  padding: 9px 14px; font-size: 12px; font-weight: 500;
  color: var(--muted); border: none; background: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  transition: all .18s; white-space: nowrap; flex-shrink: 0;
}
.cat-tab:hover { color: var(--text); }
.cat-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

#iconGrid {
  overflow-y: auto; padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: flex-start;
  will-change: scroll-position;
  contain: layout style;
}
.icon-card {
  background: var(--card); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 8px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: pointer; transition: all .18s; touch-action: manipulation;
  width: 110px; flex-shrink: 0;
}
.icon-card canvas { display: block; image-rendering: pixelated; background: #000; border-radius: 3px; width: 100px !important; }
.icon-card span { font-size: 10px; color: var(--muted); text-align: center; font-weight: 500; line-height: 1.3; }
.icon-card:hover { border-color: var(--accent); background: var(--accent-light); }
.icon-card.selected { border-color: var(--accent); background: var(--accent-light); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.icon-card.selected span { color: var(--accent); }

/* ─── Draw View ──────────────────────────────────────────────────────────── */
#drawView { flex: 1; overflow: hidden; display: none; flex-direction: column; }
#drawView.show { display: flex; }

#toolStrip {
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px; flex-shrink: 0; overflow-x: auto;
}
#toolStrip::-webkit-scrollbar { display: none; }
.t-sep { width: 1px; height: 26px; background: var(--border); margin: 0 2px; flex-shrink: 0; }
.tool-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 7px; cursor: pointer; color: var(--muted);
  font-size: 15px; display: flex; align-items: center; justify-content: center;
  transition: all .15s; touch-action: manipulation;
}
.tool-btn:hover { color: var(--text); border-color: #94a3b8; }
.tool-btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.tool-btn.red:hover { border-color: var(--danger); color: var(--danger); }

#textRow {
  display: none; align-items: center; gap: 8px;
  padding: 7px 12px; background: #eff6ff; border-bottom: 1px solid #bfdbfe;
  flex-shrink: 0; flex-wrap: wrap;
}
#textRow.show { display: flex; }
#textRow input {
  flex: 1; min-width: 120px;
  border: 1px solid var(--border); background: #fff;
  color: var(--text); font-family: 'JetBrains Mono', monospace;
  font-size: 13px; padding: 5px 9px; border-radius: 7px; outline: none;
}
#textRow input:focus { border-color: var(--accent); }
#textRow select { border: 1px solid var(--border); background: #fff; padding: 5px 8px; border-radius: 7px; font-size: 12px; }
.place-btn { background: var(--accent); color: #fff; border: none; font-size: 12px; font-weight: 600; padding: 6px 14px; border-radius: 7px; cursor: pointer; }

#canvasScroll { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 20px; background: #e8ecf0; position: relative; }
#canvasWrap { line-height: 0; box-shadow: 0 2px 12px rgba(0,0,0,.15); border-radius: 3px; overflow: hidden; }
#mainCanvas { display: block; cursor: crosshair; image-rendering: pixelated; touch-action: none; }
#mainCanvas.tool-move { cursor: grab; }
#mainCanvas.tool-move.is-dragging { cursor: grabbing; }

/* Animate tab inside draw */
#animBar {
  background: #fff; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  flex-shrink: 0; flex-wrap: wrap;
}
.a-btn { background: var(--panel); border: 1px solid var(--border); color: var(--text); font-size: 11px; padding: 5px 10px; border-radius: 6px; cursor: pointer; transition: all .15s; }
.a-btn:hover { border-color: var(--accent); color: var(--accent); }
.a-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.fps-grp { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); margin-left: auto; }
.fps-grp input[type=range] { width: 70px; accent-color: var(--accent); }
.fps-grp b { font-family: 'JetBrains Mono', monospace; color: var(--accent); }

#tlScroll {
  overflow-x: auto; background: var(--panel); padding: 8px 12px;
  display: flex; gap: 8px; min-height: 68px; align-items: flex-start;
  scroll-padding-left: 12px;
}
.frame-th { flex-shrink: 0; background: #fff; border: 2px solid var(--border); border-radius: 7px; padding: 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: all .15s; }
.frame-th canvas { display: block; image-rendering: pixelated; border-radius: 2px; background: #000; }
.frame-th span { font-size: 9px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.frame-th.active { border-color: var(--accent); }
.icon-card { position: relative; }
.card-del-btn {
  position: absolute; top: 4px; right: 4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(239, 68, 68, 0.9); color: #fff;
  border: none; font-size: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
  z-index: 10;
}
.icon-card:hover .card-del-btn { opacity: 1; }
.card-del-btn:hover { background: #dc2626; transform: scale(1.1); }

/* ─── Right Panel ────────────────────────────────────────────────────────── */
#right {
  display: flex; flex-direction: column;
  background: var(--card); overflow-y: auto;
  min-width: 280px;
}

/* OLED board mockup */
.oled-preview-container {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  width: 100%;
  margin: 20px auto 12px;
}
.oled-board-unit {
  background: linear-gradient(145deg, #1e5cb3, #0f3878);
  border-radius: 12px;
  padding: 14px 20px 20px;
  box-shadow: 0 6px 28px rgba(0,0,0,.3), 0 1px 0 rgba(255,255,255,.08) inset;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: fit-content; max-width: calc(100% - 32px);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
  scroll-margin-top: calc(var(--header-h, 54px) + 12px);
}
.oled-board-unit.oled-focus-pulse {
  box-shadow: 0 0 0 3px var(--accent), 0 6px 28px rgba(37, 99, 235, 0.45);
  transform: scale(1.02);
}
#drawView.is-playing #canvasWrap {
  box-shadow: 0 0 0 2px var(--accent), 0 0 16px rgba(37, 99, 235, 0.25);
  border-radius: 8px;
}
.pcb-top {
  display: flex; justify-content: space-between; width: 100%;
  padding-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.pcb-label { font-size: 7px; color: rgba(255,255,255,.5); font-family: 'JetBrains Mono', monospace; letter-spacing: .05em; }
.oled-screen {
  background: #000; border-radius: 4px;
  padding: 4px; position: relative;
  box-shadow: inset 0 0 10px rgba(0,0,0,.9), 0 0 0 1px rgba(255,255,255,.07);
}
#previewCanvas, #previewCanvas2 { display: block; image-rendering: pixelated; border-radius: 2px; }
.pcb-pins {
  display: flex; gap: 10px; margin-top: 4px;
}
.pcb-pin { width: 6px; height: 12px; background: #c8a84b; border-radius: 1px; box-shadow: 0 0 3px rgba(200,168,75,.4); }

/* Config section */
#configArea { padding: 0 16px; }
.cfg-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--border);
  gap: 10px;
}
.cfg-row:last-child { border-bottom: none; }
.cfg-row label { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.cfg-sel {
  background: var(--panel); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; padding: 5px 8px;
  border-radius: 7px; outline: none; cursor: pointer; max-width: 170px;
}
.cfg-sel:focus { border-color: var(--accent); }

/* Get code button */
#getCodeBtn {
  margin: 14px 16px 10px; width: calc(100% - 32px);
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 700; font-family: 'Inter', sans-serif;
  padding: 12px; border: none; border-radius: var(--radius);
  cursor: pointer; transition: all .2s; letter-spacing: .02em;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
#getCodeBtn:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(37,99,235,.35); }

/* ─── Code Modal ─────────────────────────────────────────────────────────── */
#codeModal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  animation: fadeIn 0.3s ease;
}
#codeModal.open { display: flex; }
body.code-modal-open { overflow: hidden; }

#modalContent {
  background: #fff; width: 100%; max-width: 900px; max-height: min(90vh, calc(100dvh - 40px));
  border-radius: 20px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255,255,255,0.1);
}

#modalHeader {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: #fff; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#modalHeader h3 { font-size: 16px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: var(--panel); color: var(--muted);
  font-size: 18px; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--danger); color: #fff; transform: rotate(90deg); }

.code-acts { display: flex; gap: 8px; }
.code-act {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 8px;
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 6px;
}
.code-act:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.code-act#btnCopy { background: var(--accent); color: #fff; border-color: var(--accent); }
.code-act#btnCopy:hover { background: #1d4ed8; }

.code-style-toggle {
  display: inline-flex; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 2px; gap: 2px;
}
.code-style-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 6px;
  cursor: pointer; transition: all 0.15s;
}
.code-style-btn:hover { color: var(--accent); }
.code-style-btn.active { background: var(--accent); color: #fff; }

/* ── Icon Library Modal ─────────────────────────────────────────────────── */
.iconlib-modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px); display: none; align-items: center;
  justify-content: center; z-index: 2100; padding: 20px;
}
.iconlib-modal.open { display: flex; }
.iconlib-content {
  background: var(--card, #fff); width: 100%; max-width: 760px; max-height: 86vh;
  border-radius: 18px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; overflow: hidden;
}
.iconlib-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.iconlib-header h3 { font-size: 16px; font-weight: 700; color: var(--text); }
.iconlib-toolbar { padding: 16px 22px 4px; display: flex; gap: 10px; align-items: center; }
.iconlib-search {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; color: var(--text); background: var(--panel);
}
.iconlib-search:focus { outline: none; border-color: var(--accent); }
.iconlib-hint { padding: 4px 22px 0; font-size: 12px; color: var(--muted); margin: 0; }
.iconlib-status { padding: 8px 22px 0; font-size: 12px; color: var(--muted); min-height: 18px; }
.iconlib-grid {
  padding: 14px 22px 22px; overflow-y: auto; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px;
}
.iconlib-cell {
  aspect-ratio: 1; border: 1px solid var(--border); border-radius: 10px;
  background: #0a0a0a; cursor: pointer; display: flex; align-items: center;
  justify-content: center; padding: 8px; transition: all 0.15s;
}
.iconlib-cell:hover { border-color: var(--accent); transform: translateY(-2px); }
.iconlib-cell img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }

/* Category browse view (shown when the search box is empty) */
.iconlib-grid--cats {
  display: block; /* stack category sections vertically */
}
.iconlib-cat { margin-bottom: 22px; }
.iconlib-cat:last-child { margin-bottom: 0; }
.iconlib-cat__head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 10px;
}
.iconlib-cat__head h4 {
  font-size: 13px; font-weight: 700; color: var(--text); margin: 0;
  text-transform: uppercase; letter-spacing: .04em;
}
.iconlib-cat__grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 10px; min-height: 64px;
}
.iconlib-more {
  margin-top: 10px; padding: 7px 16px; font-size: 12px; font-weight: 600;
  color: var(--accent); background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; transition: all 0.15s;
}
.iconlib-more:hover:not(:disabled) { border-color: var(--accent); background: var(--card); }
.iconlib-more:disabled { color: var(--muted); cursor: default; opacity: 0.7; }
.iconlib-skeleton {
  grid-column: 1 / -1; display: flex; align-items: center;
  min-height: 64px; font-size: 12px; color: var(--muted);
}

@media (max-width: 768px) {
  .iconlib-grid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
  .iconlib-cat__grid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
}

#codeOut { flex: 1; overflow-y: auto; background: #0f172a; padding: 10px; }
pre#codeText {
  font-family: 'JetBrains Mono', monospace; font-size: 13px; line-height: 1.6;
  padding: 20px; background: transparent !important; color: #e2e8f0;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px) scale(0.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* Highlight overrides (for dark mode code) */
.hljs { background: transparent !important; color: #e2e8f0 !important; }
.hljs-keyword { color: #60a5fa !important; }
.hljs-string  { color: #34d399 !important; }
.hljs-number  { color: #fb923c !important; }
.hljs-comment { color: #64748b !important; font-style: italic; }
.hljs-title   { color: #a78bfa !important; }
.hljs-built_in{ color: #22d3ee !important; }
.hljs-type    { color: #2dd4bf !important; }

/* ─── Scrollbars ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ─── Icons8 gallery (Wokwi-style library) ───────────────────────────────── */
.icons8-bar {
  display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.icons8-bar__link { color: var(--accent); text-decoration: none; font-weight: 500; }
.icons8-bar__link:hover { text-decoration: underline; }
.icons8-load-overlay {
  position: absolute; inset: 0; z-index: 30;
  display: none; align-items: center; justify-content: center;
  background: rgba(232, 236, 240, 0.92);
}
.icons8-load-overlay.is-active { display: flex; }
.icons8-load-overlay__box {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 20px 28px; background: #fff; border-radius: 12px;
  border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}
.icons8-load-overlay__spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: icons8Spin 0.7s linear infinite;
}
.icons8-load-overlay__text {
  font-size: 13px; font-weight: 600; color: var(--text); margin: 0;
}
@keyframes icons8Spin { to { transform: rotate(360deg); } }
.icons8-card { min-height: 120px; }
.icons8-lottie-thumb {
  width: 100px; height: 100px; display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
}
.icons8-lottie-thumb svg {
  width: 88% !important; height: 88% !important;
}
.icons8-card:hover .icons8-lottie-thumb {
  border-color: var(--accent);
  background: var(--accent-light);
}
.icons8-lottie-thumb.is-loading::after {
  content: '…'; color: #64748b; font-size: 18px;
}
.icons8-lottie-thumb.is-error {
  background: var(--panel); font-size: 10px; color: var(--muted); text-align: center; padding: 4px;
}

/* ─── What's New modal ───────────────────────────────────────────────────── */
.whatsnew-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(14px);
}
.whatsnew-modal.is-open { display: flex; }

.whatsnew-content {
  background: #fff;
  width: 100%;
  max-width: 620px;
  max-height: min(90vh, 720px);
  border-radius: 24px;
  box-shadow: 0 32px 64px -12px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.whatsnew-header {
  position: relative;
  padding: 28px 28px 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #fff;
  flex-shrink: 0;
}

.whatsnew-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.whatsnew-title {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  line-height: 1.2;
  padding-right: 36px;
}

.whatsnew-subtitle {
  font-size: 13px;
  color: rgba(148, 163, 184, 1);
  margin: 0;
  line-height: 1.5;
}

.whatsnew-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}
.whatsnew-close:hover { background: rgba(255,255,255,0.2); transform: rotate(90deg); }

.whatsnew-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.whatsnew-features {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.whatsnew-feature {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.whatsnew-feature:last-child { border-bottom: none; }
.whatsnew-feature:hover { background: var(--panel); }

.whatsnew-feature--highlight {
  background: linear-gradient(135deg, #eff6ff, #fff);
  border-left: 3px solid var(--accent);
}
.whatsnew-feature--highlight:hover { background: linear-gradient(135deg, #dbeafe, #eff6ff); }
.whatsnew-feature--wifi.whatsnew-feature--highlight {
  background: linear-gradient(135deg, #ecfdf5, #f0fdfa);
  border-bottom-color: #99f6e4;
}
.whatsnew-feature--wifi.whatsnew-feature--highlight:hover {
  background: linear-gradient(135deg, #d1fae5, #ecfdf5);
}
.whatsnew-wifi-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: #0d9488;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.whatsnew-wifi-btn:hover {
  background: #0f766e;
  transform: translateY(-1px);
}

.whatsnew-feature__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fee2e2;
  color: #dc2626;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  margin-bottom: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.whatsnew-feature__top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.whatsnew-feature__icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.whatsnew-feature__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 5px;
}

.whatsnew-feature__desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

.whatsnew-feature__desc code {
  background: #f1f5f9;
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.whatsnew-howto {
  margin-top: 14px;
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 10px;
  padding: 12px 14px;
}

.whatsnew-howto__label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.whatsnew-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.whatsnew-steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  min-width: 20px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
}

.whatsnew-footer {
  flex-shrink: 0;
  padding: 16px 24px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.whatsnew-footer__btn {
  width: 100%;
  max-width: 280px;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: #fff;
  border: none;
  padding: 13px 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.35);
  transition: all 0.2s;
  touch-action: manipulation;
}
.whatsnew-footer__btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45); }

@media (max-width: 768px) {
  .whatsnew-content {
    max-height: min(92dvh, calc(100dvh - 24px));
    max-width: 100%;
    border-radius: 16px;
    margin: auto;
  }
  .whatsnew-header { padding: 20px 16px 16px; }
  .whatsnew-title { font-size: 17px; }
  .whatsnew-feature { padding: 14px 16px; }
  .whatsnew-footer { padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .whatsnew-footer__btn { max-width: none; font-size: 14px; }
  .whatsnew-steps li { font-size: 12px; }
}

/* ─── Welcome modal ──────────────────────────────────────────────────────── */
.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
}
.welcome-modal.is-open { display: flex; }
.welcome-content {
  background: #fff;
  width: 100%;
  max-width: 850px;
  max-height: min(90vh, 720px);
  border-radius: 24px;
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.welcome-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.welcome-hero {
  padding: 32px 24px;
  text-align: center;
  background: linear-gradient(135deg, var(--accent-light), #fff);
  border-bottom: 1px solid var(--border);
}
.welcome-hero__icon {
  width: 64px;
  height: 64px;
  background: var(--accent);
  color: #fff;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.3);
}
.welcome-hero__title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 10px;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.welcome-hero__text {
  font-size: 15px;
  color: var(--muted);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.55;
}
.welcome-features {
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  background: #fff;
}
.welcome-feature {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.welcome-feature__icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}
.welcome-feature h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}
.welcome-feature p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}
.welcome-footer {
  flex-shrink: 0;
  padding: 16px 20px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}
.welcome-footer__btn {
  width: 100%;
  max-width: 320px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
  touch-action: manipulation;
}
.welcome-footer__btn:hover { background: #1d4ed8; }

/* ─── SEO footer (crawlable content) ─────────────────────────────────────── */
.seo-footer {
  background: var(--bg); border-top: 1px solid var(--border);
  padding: 48px 20px 32px;
}
.seo-footer__inner { max-width: 1100px; margin: 0 auto; }
.seo-footer__hero { margin-bottom: 36px; text-align: center; }
.seo-footer__hero h1 {
  font-size: clamp(1.35rem, 3vw, 1.75rem); font-weight: 800; color: var(--text);
  line-height: 1.25; margin-bottom: 12px; letter-spacing: -0.02em;
}
.seo-footer__lead {
  font-size: 15px; color: var(--muted); line-height: 1.65; max-width: 720px; margin: 0 auto;
}
.seo-footer__grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 32px; margin-bottom: 40px;
}
.seo-footer__grid h2 {
  font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 12px;
}
.seo-footer__grid p,
.seo-footer__grid li {
  font-size: 13px; color: var(--muted); line-height: 1.65;
}
.seo-footer__grid ul,
.seo-footer__grid ol { padding-left: 18px; }
.seo-footer__grid li { margin-bottom: 6px; }
.seo-footer__faq { margin-bottom: 28px; }
.seo-footer__faq h2 {
  font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 14px;
}
.seo-footer__faq details {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px;
  margin-bottom: 8px; background: var(--card);
}
.seo-footer__faq summary {
  font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer;
}
.seo-footer__faq p {
  font-size: 13px; color: var(--muted); line-height: 1.6; margin-top: 10px;
}
.seo-footer__keywords {
  font-size: 12px; color: var(--muted); line-height: 1.8; text-align: center; margin-bottom: 20px;
}
.seo-footer__keywords span { color: var(--text); opacity: 0.85; }
.seo-footer__guides { margin-bottom: 40px; }
.seo-footer__guides > p {
  font-size: 14px; color: var(--muted); line-height: 1.65; margin-bottom: 20px; max-width: 720px;
}
.site-guide-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.site-guide-card {
  display: block;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.site-guide-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.08);
}
.site-guide-card h3 {
  font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 8px; line-height: 1.35;
}
.site-guide-card p {
  font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0;
}
.site-guide-card__more {
  display: inline-block; margin-top: 10px; font-size: 12px; font-weight: 600; color: var(--accent);
}
.seo-footer__usecases { margin-bottom: 36px; }
.seo-footer__usecases p,
.seo-footer__usecases li {
  font-size: 14px; color: var(--muted); line-height: 1.7;
}
.seo-footer__usecases ul { padding-left: 18px; margin-top: 10px; }
.seo-footer__usecases li { margin-bottom: 8px; }
.seo-footer__legal {
  font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 12px;
}
.seo-footer__legal a { color: var(--accent); font-weight: 500; text-decoration: none; }
.seo-footer__legal a:hover { text-decoration: underline; }
.seo-footer__copy {
  font-size: 12px; color: var(--muted); text-align: center;
  padding-top: 20px; border-top: 1px solid var(--border);
}

/* ─── Tablet ─────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  #main {
    height: auto;
    min-height: calc(100dvh - var(--header-h, 54px));
    grid-template-columns: 1fr;
    overflow: visible;
  }
  #left {
    border-right: none;
    border-bottom: 1px solid var(--border);
    min-height: 45vh;
    max-height: none;
  }
  #right {
    min-width: 0;
    width: 100%;
    overflow-y: visible;
  }
  #header .hsel--addr { display: none; }
}

/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body { overflow-x: hidden; }

  .site-title--full { display: none; }
  .site-title--short { display: inline; }

  #header { padding: 8px 10px; gap: 8px; }
  .header-site-nav { display: none; }
  .header-brand { flex: 1 1 auto; min-width: 0; }
  .header-controls {
    flex: 1 1 100%;
    justify-content: space-between;
    flex-wrap: nowrap;
  }
  .header-mobile-menu .hsel {
    font-size: 13px;
    padding: 10px 12px;
    max-width: none;
  }
  .lang-pill--menu,
  .header-mobile-menu .lang-pill {
    font-size: 12px;
    padding: 8px 12px;
  }

  #main {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - var(--header-h, 100px));
  }
  #right { order: -1; flex-shrink: 0; }
  #left {
    flex: 1 1 auto;
    min-height: 50vh;
    display: flex;
    flex-direction: column;
  }
  /* Keep SEO footer visible for crawlers and AdSense content review */

  #modeBar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #modeBar::-webkit-scrollbar { display: none; }
  .mode-btn {
    font-size: 11px;
    padding: 10px 6px;
    min-width: 72px;
    flex: 1 0 auto;
  }

  #gallerySearchBox { padding: 8px 10px; }
  #catTabs { padding: 0 10px; }
  #iconGrid {
    padding: 10px;
    gap: 8px;
    justify-content: center;
  }
  .icon-card {
    width: calc(50% - 6px);
    max-width: 160px;
    min-width: 0;
  }
  .icon-card canvas { width: 100% !important; height: auto !important; max-width: 100px; }
  .icons8-lottie-thumb { width: 100%; max-width: 100px; height: auto; aspect-ratio: 1; }
  .icon-card:hover .card-del-btn,
  .card-del-btn { opacity: 1; }

  #drawView { min-height: 280px; }
  #toolStrip { padding: 6px 8px; gap: 3px; }
  .tool-btn { width: 40px; height: 40px; font-size: 16px; }

  #canvasScroll {
    padding: 10px;
    min-height: 220px;
    -webkit-overflow-scrolling: touch;
  }
  #canvasWrap { max-width: 100%; }
  #mainCanvas { max-width: 100%; height: auto !important; }

  #animBar {
    padding: 6px 8px;
    gap: 4px;
    justify-content: flex-start;
  }
  #animBar .fps-grp {
    margin-left: 0;
    flex: 1 1 100%;
    justify-content: center;
    margin-top: 2px;
  }
  #animBar #saveGalleryBtn { font-size: 10px; padding: 5px 6px; }
  .a-btn { font-size: 10px; padding: 5px 8px; }

  #tlScroll {
    min-height: 64px;
    padding: 6px 8px;
    -webkit-overflow-scrolling: touch;
  }

  .oled-board-unit {
    margin: 10px auto 6px;
    padding: 10px 14px 14px;
    transform: scale(0.92);
    transform-origin: center top;
  }
  .oled-preview-container {
    margin: 10px auto 6px;
    gap: 8px;
  }
  #templateEditorBox { margin: 0 10px 10px !important; padding: 10px !important; }
  #configArea { padding: 0 12px; }
  #getCodeBtn {
    margin: 10px 12px;
    width: calc(100% - 24px);
    padding: 14px;
    font-size: 15px;
    margin-bottom: max(10px, env(safe-area-inset-bottom));
  }

  #codeModal {
    align-items: center;
    justify-content: center;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  #modalContent {
    max-height: min(82dvh, calc(100dvh - 32px));
    max-width: 100%;
    border-radius: 16px;
    margin: auto;
  }
  #codeOut { max-height: none; flex: 1 1 auto; min-height: 0; }
  #modalHeader {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }
  #modalHeader h3 { font-size: 14px; }
  .code-acts {
    flex-wrap: wrap;
    width: 100%;
    gap: 6px;
  }
  .code-act {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
    font-size: 11px;
    padding: 8px 6px;
  }
  pre#codeText { font-size: 11px; padding: 12px; }

  .welcome-modal {
    align-items: center;
    justify-content: center;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .welcome-content {
    max-height: min(88dvh, calc(100dvh - 24px));
    max-width: 100%;
    border-radius: 16px;
    margin: auto;
  }
  .welcome-hero { padding: 18px 14px; }
  .welcome-hero__icon {
    width: 48px;
    height: 48px;
    font-size: 22px;
    margin-bottom: 10px;
  }
  .welcome-hero__title { font-size: 17px; margin-bottom: 6px; }
  .welcome-hero__text { font-size: 12px; line-height: 1.45; }
  .welcome-features {
    padding: 12px 14px 16px;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .welcome-feature { gap: 8px; }
  .welcome-feature__icon { font-size: 18px; }
  .welcome-feature h4 { font-size: 12px; margin-bottom: 2px; }
  .welcome-feature p { font-size: 11px; line-height: 1.4; }
  .welcome-footer {
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .welcome-footer__btn {
    max-width: none;
    font-size: 14px;
    padding: 12px 16px;
  }

  #hwModal {
    align-items: center;
    justify-content: center;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  #hwContent {
    max-height: min(88dvh, calc(100dvh - 24px));
    border-radius: 16px;
    margin: auto;
  }

  .seo-footer { padding: 32px 16px 24px; }
  .seo-footer__grid { gap: 24px; }
}

@media (max-width: 380px) {
  .icon-card { width: calc(50% - 4px); }
  .btn-connect-serial,
  .btn-connect-wifi { padding: 6px 10px; font-size: 11px; }
  #header .hsel--addr,
  #header .hsel--lib { display: none; }
}

/* ─── Wiring Connection Diagram ──────────────────────────────────────────── */
#wiringCard {
  margin: 0 16px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wiring-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.wiring-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.wiring-badge {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.wiring-tabs {
  display: flex;
  background: var(--panel);
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.wiring-tab {
  flex: 1;
  border: none;
  background: none;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 4px;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.wiring-tab:hover {
  color: var(--text);
}

.wiring-tab.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.wiring-viewport {
  position: relative;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  height: 240px;
  overflow: hidden;
}

.wiring-svg-container {
  width: 100%;
  height: 100%;
}

#wiringSvg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Wiring paths animation */
.wire-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: wireDraw 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  transition: stroke-width 0.2s ease, filter 0.2s ease;
  cursor: pointer;
}

.wire-path:hover {
  stroke-width: 4px !important;
  filter: drop-shadow(0 0 4px currentColor);
  z-index: 100;
}

@keyframes wireDraw {
  to { stroke-dashoffset: 0; }
}

/* Dynamic pulsing pin dots */
.pin-glow {
  animation: pinPulse 2s infinite ease-in-out;
  transform-origin: center;
}

@keyframes pinPulse {
  0% { r: 3.5px; opacity: 1; }
  50% { r: 6.5px; opacity: 0.4; }
  100% { r: 3.5px; opacity: 1; }
}

/* Wires colors matching industry standards */
.wire-gnd { stroke: #475569; } /* Charcoal / Black */
.wire-vcc { stroke: #ef4444; } /* Red */
.wire-scl { stroke: #f59e0b; } /* Amber / Yellow */
.wire-sda { stroke: #06b6d4; } /* Cyan / Blue */

/* Pin table styles */
.wiring-table-container {
  padding: 4px;
  width: 100%;
  display: none;
}

.wiring-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.wiring-table th {
  text-align: left;
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
  padding: 6px 10px;
  border-bottom: 2px solid var(--border);
}

.wiring-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.wiring-table tr:last-child td {
  border-bottom: none;
}

.pin-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.pin-badge.gnd { background: #cbd5e1; color: #334155; }
.pin-badge.vcc { background: #fecaca; color: #991b1b; }
.pin-badge.scl { background: #fef3c7; color: #92400e; }
.pin-badge.sda { background: #cffafe; color: #0891b2; }

/* Wiring Instructions Panel */
.wiring-notes {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11px;
  line-height: 1.5;
  color: #1e40af;
}

.wiring-notes p {
  margin-bottom: 4px;
}

.wiring-notes strong {
  color: #1d4ed8;
}

.wiring-notes code {
  font-family: 'JetBrains Mono', monospace;
  font-weight: bold;
  background: rgba(30, 64, 175, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 10.5px;
}

/* Float controls & rotation button styles */
.wiring-controls {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 10;
}

.wiring-ctrl-grp {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.btn-wiring-float {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 10px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-wiring-float:hover {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}

.btn-wiring-float:active {
  transform: translateY(0);
}

.btn-wiring-icon {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-wiring-icon:hover {
  color: var(--accent);
  background: var(--accent-light);
  transform: scale(1.08);
}

/* Glassmorphic fullscreen modal */
.wiring-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
  padding: 20px;
}

.wiring-modal.is-open {
  display: flex;
  opacity: 1;
}

.wiring-modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 850px;
  height: 90vh;
  max-height: 600px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.25), 0 10px 10px -5px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wiring-modal.is-open .wiring-modal-content {
  transform: scale(1);
}

.wiring-modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wiring-modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.btn-wiring-close {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  transition: all 0.2s ease;
}

.btn-wiring-close:hover {
  background: #f1f5f9;
  color: var(--text);
  transform: rotate(90deg);
}

.wiring-modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  min-height: 0;
}

.wiring-modal-viewport {
  position: relative;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#wiringSvgBoard, #wiringSvgOled, #wiringModalSvgBoard, #wiringModalSvgOled {
  cursor: grab;
  pointer-events: auto;
}
#wiringSvgBoard:active, #wiringSvgOled:active, #wiringModalSvgBoard:active, #wiringModalSvgOled:active {
  cursor: grabbing;
}

.wiring-drag-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 9999px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  pointer-events: none;
  user-select: none;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.02em;
  animation: bounceSlow 3s infinite ease-in-out;
}

@keyframes bounceSlow {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -4px); }
}

/* ─── Import view ────────────────────────────────────────────────────────── */
#importView {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 24px 32px;
  gap: 16px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}
#importView.is-visible {
  display: flex;
}
#importView .import-drop-zone {
  width: 100%;
  max-width: 480px;
  flex-shrink: 0;
  border: 2.5px dashed var(--border);
  border-radius: 16px;
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--card);
}
#importView .import-panel {
  width: 100%;
  max-width: 480px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
#importView .import-panel--progress {
  text-align: center;
}
#importView .import-panel--result {
  display: none;
  flex-direction: column;
  align-items: center;
  background: #eff6ff;
  border: 2px solid var(--accent);
  text-align: center;
}
#importView .import-panel--result.is-visible {
  display: flex;
}

/* Import — live resolution + OLED preview */
.import-resolution {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--panel);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}
.import-res-src { color: var(--text); font-family: 'JetBrains Mono', monospace; }
.import-res-arrow { color: var(--muted); font-size: 14px; }
.import-res-oled { color: var(--accent); font-family: 'JetBrains Mono', monospace; }
.import-live-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
#importPreviewCanvas {
  display: block;
  width: min(256px, 100%);
  height: auto;
  image-rendering: pixelated;
  background: #000;
  border-radius: 6px;
  border: 2px solid var(--border);
  box-shadow: inset 0 0 12px rgba(0, 239, 255, 0.08);
}
.import-live-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.import-options-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 12px;
}
.import-option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.import-option-row--last { margin-bottom: 0; }
.import-option-label {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  width: 80px;
  flex-shrink: 0;
}
.import-option-range {
  flex: 1;
  min-width: 120px;
  accent-color: var(--accent);
}
.import-option-value {
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: bold;
  color: var(--accent);
  width: 28px;
  flex-shrink: 0;
}
.import-option-number {
  width: 72px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text);
  background: var(--panel);
  accent-color: var(--accent);
}
.import-option-number:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.import-option-check {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.import-option-hint {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  min-width: 140px;
}
#importOptions.import-options--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.import-tune-panel {
  width: 100%;
  max-width: 480px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.import-tune-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.import-tune-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 14px;
}
.import-tune-hint strong { color: var(--text); font-weight: 600; }

/* ─── Video Crop ─────────────────────────────────────────────────────────── */
.import-crop-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.import-crop-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--accent);
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.import-crop-btn:hover {
  background: var(--accent);
  color: #fff;
}
.import-crop-clear {
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.import-crop-clear:hover { color: var(--text); }
.import-crop-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
}

.crop-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2200;
  padding: 20px;
}
.crop-modal.is-open { display: flex; }
.crop-modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  width: min(560px, 100%);
  max-height: 92vh;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.crop-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.crop-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.crop-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.crop-modal-close:hover { color: var(--text); }
.crop-modal-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 14px;
}
.crop-modal-hint strong { color: var(--accent); font-family: 'JetBrains Mono', monospace; }
.crop-stage {
  position: relative;
  display: inline-block;
  width: 100%;
  text-align: center;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.crop-canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: auto;
}
.crop-dim { display: none; }
.crop-box {
  position: absolute;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  cursor: move;
  box-sizing: border-box;
}
.crop-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.crop-handle--nw { top: -9px; left: -9px; cursor: nwse-resize; }
.crop-handle--ne { top: -9px; right: -9px; cursor: nesw-resize; }
.crop-handle--sw { bottom: -9px; left: -9px; cursor: nesw-resize; }
.crop-handle--se { bottom: -9px; right: -9px; cursor: nwse-resize; }
.crop-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.crop-lock {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.crop-lock input { accent-color: var(--accent); width: 16px; height: 16px; }
.crop-modal-buttons { display: flex; gap: 10px; }
.crop-btn {
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
}
.crop-btn--ghost {
  background: var(--panel);
  color: var(--text);
}
.crop-btn--ghost:hover { border-color: var(--accent); }
.crop-btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.crop-btn--primary:hover { filter: brightness(1.08); }

/* ─── Instagram Follow Button & Modal ────────────────────────────────────── */
.btn-ig-follow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(45deg, #f9ce34, #ee2a7b, #6228d7);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  text-decoration: none;
  border: none;
  padding: 6px 12px;
  height: 32px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(238, 42, 123, 0.2);
  touch-action: manipulation;
}
.btn-ig-follow:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(238, 42, 123, 0.45);
}
.btn-ig-follow svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}
.btn-ig-follow span {
  display: inline;
}

@media (max-width: 500px) {
  .btn-ig-follow span {
    display: none;
  }
  .btn-ig-follow {
    padding: 6px 8px;
    width: 32px;
    justify-content: center;
  }
}

.ig-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.3s ease;
}
.ig-modal.is-open {
  display: flex;
}
.ig-content {
  background: #fff;
  width: 100%;
  max-width: 420px;
  border-radius: 24px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}
.ig-modal-body {
  padding: 40px 24px 32px;
  text-align: center;
  background: linear-gradient(135deg, #fdf2f8, #f5f3ff);
}
.ig-icon-container {
  width: 68px;
  height: 68px;
  background: linear-gradient(45deg, #f9ce34, #ee2a7b, #6228d7);
  color: #fff;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(238, 42, 123, 0.35);
  animation: igBounce 3s infinite ease-in-out;
}
.ig-icon-container svg {
  width: 34px;
  height: 34px;
  stroke: currentColor;
}
.ig-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 10px;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.ig-text {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 auto 24px;
  max-width: 320px;
}
.ig-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 280px;
  background: linear-gradient(45deg, #f9ce34, #ee2a7b, #6228d7);
  color: #fff;
  border: none;
  padding: 13px 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(238, 42, 123, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  touch-action: manipulation;
}
.ig-cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(238, 42, 123, 0.55);
}
.ig-cta-btn:active {
  transform: translateY(0);
}
.ig-secondary-btn {
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
  cursor: pointer;
  transition: color 0.2s;
  font-family: inherit;
}
.ig-secondary-btn:hover {
  color: var(--muted);
}

/* ─── "Don't show today" checkbox (shared by IG + What's New modals) ────── */
.donot-show-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  transition: color 0.2s;
  user-select: none;
}
.donot-show-label:hover { color: var(--muted); }

.donot-show-cb {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 3px;
}

/* What's New footer layout: stack checkbox above button */
.whatsnew-footer {
  flex-shrink: 0;
  padding: 14px 24px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.ig-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.05);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.ig-close-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  transform: rotate(90deg);
}

@keyframes igBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.target-btn.active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.target-btn:hover:not(.active) {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}



/* ─── Auth & Share Modals ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fadeIn 0.2s ease;
}
.modal-box {
  background: var(--card); border-radius: 16px;
  padding: 28px; width: 90%; position: relative;
  box-shadow: 0 25px 50px rgba(0,0,0,0.4);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-box .modal-close {
  position: absolute; top: 12px; right: 14px;
  background: var(--panel); border: none; color: var(--muted);
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 16px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}
.modal-box .modal-close:hover { background: var(--danger); color: #fff; }
.share-soc-btn {
  color: #fff; border: none; padding: 8px 16px;
  border-radius: 8px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s;
}
.share-soc-btn:hover { opacity: 0.85; }
#userMenu {
  display: none; position: fixed; top: 8px; right: 12px;
  z-index: 1000; align-items: center; gap: 8px;
}
#userMenu.is-visible { display: flex; }
