/* ==========================================================================
   TinkySpeak Board Builder — Stylesheet
   --------------------------------------------------------------------------
   EXTRACTED from builder.html on 2026-05-01 as Phase 0a step 1 of the
   3681-line monolith split. No declarations changed — this is a pure
   lift of the inline <style> block at the top of the page. The HTML now
   loads it via <link rel="stylesheet" href="/css/builder.css">.

   LABEL: PRODUCTION-READY (lift-and-shift; zero behavior change).
   ========================================================================== */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root{
  --bg:#FBF7F0;--bg-warm:#F5EDE0;--bg-cool:#F0EBE3;
  --ink:#1A1A2E;--ink-soft:#4A4A5A;--ink-muted:#8A8A9A;
  --amber:#E8A838;--amber-light:#F5C563;--amber-dark:#C48A20;
  --nav-bg:#1A1A2E;--nav-text:#F5EDE0;
  --surface:#FFFFFF;--surface-hover:#FAFAF5;--surface-active:#F5F0E8;
  --border:#E5DDD0;--border-light:#EDE8E0;
  --shadow-sm:0 1px 3px rgba(26,26,46,0.06);
  --shadow-md:0 4px 12px rgba(26,26,46,0.08);
  --shadow-lg:0 8px 30px rgba(26,26,46,0.12);
  --shadow-xl:0 16px 50px rgba(26,26,46,0.16);
  --radius-sm:8px;--radius-md:12px;--radius-lg:18px;--radius-xl:24px;
  /* Fitzgerald Key */
  --fk-verb:#FF8C00;--fk-noun:#FFD700;--fk-adj:#4169E1;
  --fk-social:#FF69B4;--fk-question:#32CD32;--fk-misc:#FFFFFF;--fk-neg:#DC143C;
  --fk-verb-bg:#FFF3E0;--fk-noun-bg:#FFFDE7;--fk-adj-bg:#E3F2FD;
  --fk-social-bg:#FCE4EC;--fk-question-bg:#E8F5E9;--fk-misc-bg:#FAFAFA;--fk-neg-bg:#FFEBEE;
  --sidebar-w:280px;--topbar-h:60px;--props-w:320px;--ai-rail-w:320px;
  --transition:0.2s cubic-bezier(0.4,0,0.2,1);
}
html{font-size:16px;-webkit-font-smoothing:antialiased}
body{font-family:'DM Sans',sans-serif;background:var(--bg);color:var(--ink);overflow:hidden;height:100vh}
h1,h2,h3,h4{font-family:'Bricolage Grotesque',sans-serif;font-weight:700}
button{font-family:inherit;cursor:pointer;border:none;background:none;font-size:inherit}
input,select,textarea{font-family:inherit;font-size:inherit}

/* ═══════════ LOGIN SCREEN ═══════════ */
#loginScreen{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;
  background:var(--bg);transition:opacity 0.4s,transform 0.4s}
#loginScreen.hidden{opacity:0;pointer-events:none;transform:scale(1.02)}
.login-card{width:440px;max-width:90vw;text-align:center}
.login-logo{font-family:'Bricolage Grotesque',sans-serif;font-size:1.8rem;font-weight:800;color:var(--ink);margin-bottom:0.25rem}
.login-logo span{color:var(--amber)}
.login-sub{color:var(--ink-muted);font-size:0.95rem;margin-bottom:2.5rem}
.login-card label{display:block;text-align:left;font-weight:600;font-size:0.8rem;
  text-transform:uppercase;letter-spacing:0.05em;color:var(--ink-soft);margin-bottom:0.4rem}
.login-card input[type="text"],.login-card input[type="email"],.login-card input[type="password"]{
  width:100%;padding:0.75rem 1rem;border:2px solid var(--border);border-radius:var(--radius-md);
  font-size:1rem;background:var(--surface);transition:border-color var(--transition);margin-bottom:1.25rem;outline:none}
.login-card input:focus{border-color:var(--amber)}
.login-card input.input-error{border-color:#DC143C}
.login-error{color:#DC143C;font-size:0.85rem;font-weight:600;margin-bottom:1rem;min-height:1.2em}
.login-submit{width:100%;padding:0.9rem;background:var(--amber);color:#fff;font-weight:700;
  font-size:1rem;border-radius:var(--radius-md);transition:all var(--transition);letter-spacing:0.02em}
.login-submit:hover{background:var(--amber-dark);transform:translateY(-1px);box-shadow:var(--shadow-md)}
.login-submit:disabled{opacity:0.6;cursor:not-allowed;transform:none}
.login-divider{display:flex;align-items:center;gap:1rem;margin:1.5rem 0;color:var(--ink-muted);font-size:0.8rem}
.login-divider::before,.login-divider::after{content:'';flex:1;height:1px;background:var(--border)}
.login-quick{width:100%;padding:0.75rem;background:var(--surface);color:var(--ink-soft);font-weight:600;
  font-size:0.9rem;border:2px solid var(--border);border-radius:var(--radius-md);transition:all var(--transition)}
.login-quick:hover{border-color:var(--amber-light);color:var(--ink)}
.login-note{margin-top:1.5rem;font-size:0.8rem;color:var(--ink-muted)}
.login-note a{color:var(--amber);text-decoration:underline}
.login-bg-tiles{position:absolute;inset:0;overflow:hidden;pointer-events:none;opacity:0.04}
.login-bg-tiles .bg-tile{position:absolute;width:80px;height:80px;border-radius:var(--radius-lg);
  display:flex;align-items:center;justify-content:center;font-size:2.2rem}

/* ═══════════ TOP BAR ═══════════ */
.topbar{height:var(--topbar-h);background:var(--nav-bg);display:flex;align-items:center;
  padding:0 1.25rem;gap:1rem;position:relative;z-index:100}
.topbar-brand{display:flex;align-items:center;gap:0.6rem;text-decoration:none;color:var(--nav-text);flex-shrink:0}
.topbar-brand-name{font-family:'Bricolage Grotesque',sans-serif;font-weight:800;font-size:1.1rem}
.topbar-brand-name span{color:var(--amber)}
.topbar-brand-tag{font-size:0.7rem;opacity:0.5;font-weight:500}
.topbar-divider{width:1px;height:28px;background:rgba(255,255,255,0.12);flex-shrink:0}
.board-name-input{background:rgba(255,255,255,0.08);border:1px solid transparent;border-radius:var(--radius-sm);
  color:var(--nav-text);padding:0.4rem 0.75rem;font-size:0.95rem;font-weight:600;
  min-width:200px;transition:all var(--transition);outline:none}
.board-name-input:hover{background:rgba(255,255,255,0.12)}
.board-name-input:focus{background:rgba(255,255,255,0.15);border-color:var(--amber)}
.board-name-input::placeholder{color:rgba(245,237,224,0.35)}
.topbar-spacer{flex:1}
.topbar-actions{display:flex;align-items:center;gap:0.5rem}
.topbar-btn{padding:0.45rem 1rem;border-radius:var(--radius-sm);font-size:0.8rem;font-weight:600;
  transition:all var(--transition);display:flex;align-items:center;gap:0.4rem}
.topbar-btn-ghost{color:rgba(245,237,224,0.7)}
.topbar-btn-ghost:hover{color:var(--nav-text);background:rgba(255,255,255,0.08)}
.topbar-btn-outline{color:var(--nav-text);border:1px solid rgba(255,255,255,0.2)}
.topbar-btn-outline:hover{border-color:var(--amber);color:var(--amber)}
.topbar-btn-primary{background:var(--amber);color:#fff}
.topbar-btn-primary:hover{background:var(--amber-dark);transform:translateY(-1px);box-shadow:0 4px 15px rgba(232,168,56,0.4)}
.topbar-nav{display:flex;align-items:center;gap:0.25rem;margin-right:0.5rem}
.topbar-nav-link{padding:0.4rem 0.7rem;border-radius:var(--radius-md);color:rgba(245,237,224,0.6);
  font-size:0.8rem;font-weight:600;text-decoration:none;transition:all var(--transition);white-space:nowrap}
.topbar-nav-link:hover{background:rgba(255,255,255,0.1);color:var(--nav-text)}
.topbar-nav-link.active{background:rgba(255,255,255,0.12);color:var(--nav-text)}
.topbar-user{display:flex;align-items:center;gap:0.5rem;color:rgba(245,237,224,0.6);
  font-size:0.8rem;margin-left:0.5rem;cursor:pointer;padding:0.3rem 0.6rem;border-radius:var(--radius-sm);
  transition:all var(--transition)}
.topbar-user:hover{background:rgba(255,255,255,0.08);color:var(--nav-text)}
.topbar-user-avatar{width:28px;height:28px;border-radius:50%;background:var(--amber);
  display:flex;align-items:center;justify-content:center;font-size:0.75rem;color:#fff;font-weight:700}

/* ═══════════ MAIN LAYOUT ═══════════ */
.app-layout{display:flex;height:calc(100vh - var(--topbar-h))}

/* ═══════════ SIDEBAR ═══════════ */
.sidebar{width:var(--sidebar-w);background:var(--surface);border-right:1px solid var(--border-light);
  display:flex;flex-direction:column;overflow:hidden;flex-shrink:0;transition:width 0.3s}
.sidebar-section{padding:1rem 1rem 0.5rem}
.sidebar-section-title{font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;
  color:var(--ink-muted);margin-bottom:0.6rem;display:flex;align-items:center;justify-content:space-between}
.sidebar-list{list-style:none;padding:0 0.5rem;overflow-y:auto;flex:1}
.sidebar-item{padding:0.6rem 0.75rem;border-radius:var(--radius-sm);cursor:pointer;
  display:flex;align-items:center;gap:0.6rem;transition:all var(--transition);
  font-size:0.85rem;color:var(--ink-soft);margin-bottom:2px}
.sidebar-item:hover{background:var(--surface-active);color:var(--ink)}
.sidebar-item.active{background:var(--fk-noun-bg);color:var(--amber-dark);font-weight:600}
.sidebar-item-icon{font-size:1.2rem;width:24px;text-align:center;flex-shrink:0}
.sidebar-item-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}
.sidebar-item-count{font-size:0.7rem;color:var(--ink-muted);background:var(--bg);
  padding:0.1rem 0.45rem;border-radius:10px;flex-shrink:0}
.sidebar-new-btn{margin:0.75rem;padding:0.65rem;border-radius:var(--radius-md);
  border:2px dashed var(--border);color:var(--ink-muted);font-weight:600;font-size:0.85rem;
  transition:all var(--transition);display:flex;align-items:center;justify-content:center;gap:0.4rem}
.sidebar-new-btn:hover{border-color:var(--amber);color:var(--amber);background:var(--fk-noun-bg)}
.sidebar-divider{height:1px;background:var(--border-light);margin:0.5rem 1rem}
.sidebar-templates{padding:0 0.5rem}
.sidebar-dash-links{padding:0 0.5rem}
.sidebar-dash-link{display:block;padding:0.55rem 0.75rem;border-radius:var(--radius-sm);
  font-size:0.8rem;font-weight:600;color:var(--ink-muted);text-decoration:none;
  transition:all var(--transition);margin-bottom:2px}
.sidebar-dash-link:hover{background:var(--surface-active);color:var(--amber-dark)}
.template-item{padding:0.5rem 0.75rem;border-radius:var(--radius-sm);cursor:pointer;
  display:flex;align-items:center;gap:0.5rem;transition:all var(--transition);
  font-size:0.8rem;color:var(--ink-muted);margin-bottom:2px}
.template-item:hover{background:var(--surface-active);color:var(--ink)}
.template-item-icon{font-size:1.1rem}
.template-item-meta{font-size:0.65rem;color:var(--ink-muted);margin-left:auto}
/* Category filter chip row above the templates list. Compact, wraps,
   horizontal-scrollable on narrow sidebars. The active chip uses the
   amber accent so the user can see at a glance which filter is on. */
.template-cat-bar{display:flex;flex-wrap:wrap;gap:0.25rem;padding:0 0.5rem 0.4rem}
.template-cat-chip{padding:0.25rem 0.55rem;border-radius:999px;
  background:var(--surface-active);color:var(--ink-muted);
  font-size:0.7rem;font-weight:600;cursor:pointer;border:1px solid transparent;
  white-space:nowrap;transition:all var(--transition)}
.template-cat-chip:hover{color:var(--ink);border-color:var(--ink-muted)}
.template-cat-chip.active{background:var(--amber);color:#fff;border-color:var(--amber)}
.template-cat-chip-count{opacity:0.7;margin-left:0.2rem;font-weight:400}
.template-search{display:block;width:calc(100% - 1rem);margin:0 0.5rem 0.5rem;
  padding:0.4rem 0.6rem;border-radius:var(--radius-sm);
  background:var(--surface);border:1px solid var(--surface-active);
  color:var(--ink);font-size:0.75rem;outline:none}
.template-search:focus{border-color:var(--amber)}
.template-empty{padding:0.75rem;text-align:center;font-size:0.7rem;
  color:var(--ink-muted);font-style:italic}

/* ═══════════ EDITOR AREA ═══════════ */
.editor-area{flex:1;display:flex;flex-direction:column;align-items:center;
  padding:1.5rem;overflow-y:auto;background:var(--bg);
  background-image:radial-gradient(circle at 1px 1px, rgba(26,26,46,0.03) 1px, transparent 0);
  background-size:24px 24px}

.editor-toolbar{display:flex;align-items:center;gap:0.5rem;margin-bottom:1.25rem;width:100%;max-width:680px}
.editor-toolbar-group{display:flex;align-items:center;gap:0.25rem;background:var(--surface);
  border-radius:var(--radius-sm);padding:0.2rem;box-shadow:var(--shadow-sm);border:1px solid var(--border-light)}
.toolbar-btn{padding:0.45rem 0.65rem;border-radius:6px;font-size:0.8rem;font-weight:500;
  color:var(--ink-soft);transition:all var(--transition);display:flex;align-items:center;gap:0.35rem}
.toolbar-btn:hover{background:var(--surface-active);color:var(--ink)}
.toolbar-btn.active{background:var(--amber);color:#fff}
.toolbar-sep{width:1px;height:20px;background:var(--border-light)}
.editor-toolbar-spacer{flex:1}
.toolbar-label{font-size:0.75rem;color:var(--ink-muted);font-weight:500;margin-right:0.25rem}

/* Tablet Frame */
.tablet-frame{background:var(--ink);border-radius:28px;padding:18px;box-shadow:var(--shadow-xl);
  width:100%;max-width:680px;position:relative}
.tablet-frame::before{content:'';position:absolute;top:8px;left:50%;transform:translateX(-50%);
  width:60px;height:4px;border-radius:4px;background:rgba(255,255,255,0.08)}
.tablet-screen{background:#FAFAFA;border-radius:14px;overflow:hidden;min-height:400px;position:relative}
/* Board canvas header — bumped 2026-05-01: was 0.85rem (~13.6px) which made
   the board name nearly invisible at the top of the canvas. Parents and
   teachers couldn't tell which board they were editing. Now ~24px so the
   title actually reads as a title. */
.board-header{padding:0.85rem 1.1rem;background:#fff;border-bottom:1px solid #eee;
  display:flex;align-items:baseline;gap:0.6rem}
.board-header-title{font-family:'Bricolage Grotesque',sans-serif;font-weight:800;font-size:1.5rem;color:var(--ink);letter-spacing:-0.01em;line-height:1.1}
.board-header-meta{font-size:0.75rem;color:var(--ink-muted);margin-left:auto;font-weight:500}

/* Image picker cache-hit banner — shown when the result came from
   localStorage rather than the worker. Reassures the user that nothing
   is being re-fetched. Added 2026-05-01 with image cache. */
.image-picker-cache-hint{padding:6px 10px;margin:0 0 8px;border-radius:6px;
  background:rgba(232,168,56,0.12);color:var(--amber-dark);font-size:0.75rem;
  font-weight:600;display:inline-block}

/* Tile Grid */
.tile-grid{display:grid;gap:8px;padding:12px;min-height:350px;transition:all 0.3s}
/* cols-1 through cols-6 (Task #70). Settings dropdown exposes the
   full 1–6 range; quick toolbar still only has 2/3/4 for one-click
   common cases. 1-col is for visual neglect / single-switch scanning;
   5/6-col is for tablet-mounted users with high cognition + small
   hand-target needs. */
.tile-grid.cols-1{grid-template-columns:repeat(1,1fr)}
.tile-grid.cols-2{grid-template-columns:repeat(2,1fr)}
.tile-grid.cols-3{grid-template-columns:repeat(3,1fr)}
.tile-grid.cols-4{grid-template-columns:repeat(4,1fr)}
.tile-grid.cols-5{grid-template-columns:repeat(5,1fr)}
.tile-grid.cols-6{grid-template-columns:repeat(6,1fr)}

/* Tiles — matches Android TinkySpeak app rendering */
.tile{border-radius:var(--radius-md);text-align:center;cursor:grab;
  display:flex;flex-direction:column;align-items:stretch;justify-content:stretch;
  border:2px solid transparent;transition:all var(--transition);position:relative;
  min-height:100px;user-select:none;-webkit-user-select:none;overflow:hidden}
.tile:hover{transform:translateY(-2px);box-shadow:var(--shadow-md);border-color:rgba(0,0,0,0.08)}
.tile.selected{border-color:var(--amber);box-shadow:0 0 0 3px rgba(232,168,56,0.2)}
.tile.dragging{opacity:0.5;transform:scale(0.95)}
.tile-emoji-area{flex:1;display:flex;align-items:center;justify-content:center;padding:0.5rem;min-height:60px;position:relative}
.tile-emoji{font-size:2.2rem;line-height:1}
.tile-image{width:100%;height:100%;object-fit:cover;position:absolute;inset:0}
.tile-image-badge{position:absolute;bottom:2px;right:2px;width:20px;height:20px;border-radius:50%;
  background:rgba(0,0,0,0.45);color:#fff;font-size:10px;display:flex;align-items:center;
  justify-content:center;cursor:pointer;opacity:0;transition:opacity 0.15s;z-index:2}
.tile:hover .tile-image-badge{opacity:1}
.tile-image-badge:hover{background:rgba(0,0,0,0.7)}
.tile-label-bar{padding:0.35rem 0.4rem;text-align:center;
  background:rgba(0,0,0,0.25);backdrop-filter:blur(2px)}
.tile-label{font-size:0.7rem;font-weight:800;color:#fff;line-height:1.15;word-break:break-word;
  text-transform:uppercase;letter-spacing:0.03em;text-shadow:0 1px 2px rgba(0,0,0,0.3)}
.tile-delete{position:absolute;top:4px;right:4px;width:20px;height:20px;border-radius:50%;
  background:rgba(0,0,0,0.3);color:#fff;font-size:0.65rem;display:flex;align-items:center;
  justify-content:center;opacity:0;transition:opacity var(--transition);z-index:2}
.tile:hover .tile-delete{opacity:1}
.tile-delete:hover{background:var(--fk-neg)}

/* Fitzgerald colors on tiles — vivid backgrounds like Android app */
.tile-verb{background:var(--fk-verb)}
.tile-noun{background:var(--fk-noun)}
.tile-adj{background:var(--fk-adj)}
.tile-social{background:var(--fk-social)}
.tile-question{background:var(--fk-question)}
.tile-misc{background:#B8A9C9}
.tile-neg{background:var(--fk-neg)}

/* Drop zone indicator */
.tile-drop-zone{border:2px dashed var(--amber);border-radius:var(--radius-md);
  min-height:90px;display:flex;align-items:center;justify-content:center;
  color:var(--amber);font-size:0.75rem;font-weight:600;opacity:0;transition:opacity 0.2s}
.tile-drop-zone.visible{opacity:1}

/* Add Tile Button */
.add-tile-btn{border:2px dashed var(--border);border-radius:var(--radius-md);min-height:90px;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.3rem;
  color:var(--ink-muted);transition:all var(--transition);cursor:pointer;font-size:0.75rem;font-weight:600}
.add-tile-btn:hover{border-color:var(--amber);color:var(--amber);background:rgba(232,168,56,0.04)}
.add-tile-btn .plus{font-size:1.5rem;line-height:1}

/* ═══════════ PROPERTIES PANEL ═══════════ */
.props-panel{width:0;overflow:hidden;background:var(--surface);border-left:1px solid var(--border-light);
  transition:width 0.3s;flex-shrink:0}
.props-panel.open{width:var(--props-w)}
.props-inner{width:var(--props-w);padding:1.25rem;overflow-y:auto;height:100%}
.props-title{font-family:'Bricolage Grotesque',sans-serif;font-weight:700;font-size:1rem;
  margin-bottom:1.25rem;display:flex;align-items:center;justify-content:space-between}
.props-close{width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;
  color:var(--ink-muted);transition:all var(--transition);font-size:0.8rem}
.props-close:hover{background:var(--surface-active);color:var(--ink)}
.props-group{margin-bottom:1.25rem}
.props-label{font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.06em;
  color:var(--ink-muted);margin-bottom:0.4rem;display:block}
.props-input{width:100%;padding:0.6rem 0.75rem;border:1.5px solid var(--border);border-radius:var(--radius-sm);
  font-size:0.9rem;background:var(--bg);transition:border-color var(--transition);outline:none}
.props-input:focus{border-color:var(--amber)}

/* Tile Image Section */
.props-image-section{margin-top:0.25rem}
.props-image-mode{display:flex;gap:0;border-radius:var(--radius-sm);overflow:hidden;border:1.5px solid var(--border);margin-bottom:0.5rem}
.props-img-tab{flex:1;padding:0.4rem 0.5rem;background:var(--bg);border:none;font-size:0.75rem;font-weight:700;
  color:var(--ink-muted);cursor:pointer;transition:all 0.15s;text-transform:uppercase;letter-spacing:0.04em}
.props-img-tab.active{background:var(--amber);color:#fff}
.props-img-tab:hover:not(.active){background:var(--surface-active)}
.props-image-preview{width:100%;height:80px;border-radius:var(--radius-sm);border:1.5px dashed var(--border);
  display:flex;align-items:center;justify-content:center;overflow:hidden;margin-bottom:0.5rem;background:var(--bg)}
.props-image-preview img{width:100%;height:100%;object-fit:contain}
.props-image-placeholder{font-size:0.65rem;color:var(--ink-muted);text-align:center;padding:0.5rem}
.props-image-btns{display:flex;gap:0.35rem;flex-wrap:wrap}
.props-upload-btn{padding:0.35rem 0.6rem;border-radius:var(--radius-sm);background:var(--surface-active);
  border:1px solid var(--border);font-size:0.65rem;font-weight:600;color:var(--ink-muted);cursor:pointer;
  transition:all 0.15s;text-align:center}
.props-upload-btn:hover{border-color:var(--amber);color:var(--amber)}
.props-search-btn{background:var(--ink);color:#fff;border-color:var(--ink)}
.props-search-btn:hover{background:var(--amber);border-color:var(--amber);color:#fff}
.props-remove-img-btn{background:transparent;color:var(--fk-neg);border-color:var(--fk-neg)}
.props-remove-img-btn:hover{background:var(--fk-neg);color:#fff}
.props-image-results{display:grid;grid-template-columns:repeat(3,1fr);gap:4px;margin-top:0.5rem;
  max-height:200px;overflow-y:auto;padding:2px;border-radius:var(--radius-sm);background:var(--bg)}
.props-image-results img{width:100%;aspect-ratio:1;object-fit:cover;border-radius:4px;cursor:pointer;
  border:2px solid transparent;transition:all 0.15s}
.props-image-results img:hover{border-color:var(--amber);transform:scale(1.05)}
.props-image-results .img-loading{grid-column:1/-1;text-align:center;padding:1rem;color:var(--ink-muted);font-size:0.7rem}

/* Image Picker Panel (overlay) */
.image-picker-overlay{position:fixed;inset:0;background:rgba(26,26,46,0.5);z-index:500;
  opacity:0;pointer-events:none;transition:opacity 0.25s;backdrop-filter:blur(2px)}
.image-picker-overlay.open{opacity:1;pointer-events:auto}
.image-picker{position:fixed;top:0;right:0;bottom:0;width:420px;background:var(--surface);z-index:501;
  transform:translateX(100%);transition:transform 0.3s cubic-bezier(0.4,0,0.2,1);
  display:flex;flex-direction:column;box-shadow:-4px 0 30px rgba(0,0,0,0.2)}
.image-picker.open{transform:translateX(0)}
.image-picker-header{padding:1rem 1.25rem;background:var(--ink);color:#fff;display:flex;align-items:center;gap:0.75rem}
.image-picker-header h3{font-size:0.95rem;font-weight:700;margin:0;flex:1}
.image-picker-close{background:none;border:none;color:#aaa;font-size:1.2rem;cursor:pointer;padding:4px 8px;border-radius:4px}
.image-picker-close:hover{color:#fff;background:rgba(255,255,255,0.1)}
.image-picker-search{padding:0.75rem 1.25rem;border-bottom:1px solid var(--border-light);display:flex;gap:0.5rem}
.image-picker-search input{flex:1;padding:0.5rem 0.75rem;border:1.5px solid var(--border);border-radius:var(--radius-sm);
  font-size:0.85rem;outline:none;background:var(--bg)}
.image-picker-search input:focus{border-color:var(--amber)}
.image-picker-search button{padding:0.5rem 1rem;background:var(--amber);color:#fff;border:none;border-radius:var(--radius-sm);
  font-weight:700;font-size:0.8rem;cursor:pointer;white-space:nowrap}
.image-picker-search button:hover{background:#c48a20}
.image-picker-body{flex:1;overflow-y:auto;padding:0.75rem}
.image-picker-section{margin-bottom:1rem}
.image-picker-section-title{font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.06em;
  color:var(--ink-muted);margin-bottom:0.5rem;display:flex;align-items:center;gap:0.5rem}
.image-picker-section-title::after{content:'';flex:1;height:1px;background:var(--border-light)}
.image-picker-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}
.image-picker-item{position:relative;border-radius:var(--radius-sm);overflow:hidden;cursor:pointer;
  border:2px solid transparent;transition:all 0.15s;background:var(--bg);aspect-ratio:1}
.image-picker-item:hover{border-color:var(--amber);transform:scale(1.03);box-shadow:var(--shadow-sm)}
.image-picker-item img{width:100%;height:100%;object-fit:cover;display:block}
.image-picker-item .img-source{position:absolute;bottom:0;left:0;right:0;padding:2px 4px;
  background:rgba(0,0,0,0.6);color:#fff;font-size:0.55rem;text-align:center;text-transform:uppercase;letter-spacing:0.04em}
.image-picker-loading{text-align:center;padding:2rem;color:var(--ink-muted);font-size:0.8rem}
.image-picker-loading .spinner{display:inline-block;width:24px;height:24px;border:3px solid var(--border);
  border-top-color:var(--amber);border-radius:50%;animation:spin 0.6s linear infinite;margin-bottom:0.5rem}
@keyframes spin{to{transform:rotate(360deg)}}
@media(max-width:600px){.image-picker{width:100%}}
.props-textarea{resize:vertical;min-height:60px}
.props-emoji-preview{font-size:3rem;text-align:center;padding:1rem;background:var(--bg);
  border-radius:var(--radius-md);margin-bottom:0.75rem;cursor:pointer;transition:all var(--transition);
  border:1.5px solid var(--border)}
.props-emoji-preview:hover{border-color:var(--amber);transform:scale(1.05)}

/* Color Picker */
.fk-colors{display:grid;grid-template-columns:repeat(4,1fr);gap:0.4rem}
.fk-color-btn{padding:0.5rem;border-radius:var(--radius-sm);border:2px solid transparent;
  text-align:center;font-size:0.65rem;font-weight:600;transition:all var(--transition);cursor:pointer}
.fk-color-btn:hover{transform:translateY(-1px)}
.fk-color-btn.active{border-color:var(--ink);box-shadow:var(--shadow-sm)}
.fk-color-btn .fk-dot{width:18px;height:18px;border-radius:50%;margin:0 auto 0.25rem;
  border:2px solid rgba(0,0,0,0.1)}

/* Emoji Picker */
.emoji-picker{position:absolute;background:var(--surface);border-radius:var(--radius-lg);
  box-shadow:var(--shadow-xl);border:1px solid var(--border);width:300px;z-index:500;
  display:none;overflow:hidden}
.emoji-picker.open{display:block}
.emoji-picker-search{width:100%;padding:0.65rem 1rem;border:none;border-bottom:1px solid var(--border-light);
  font-size:0.9rem;outline:none;background:var(--bg)}
.emoji-picker-grid{display:grid;grid-template-columns:repeat(8,1fr);padding:0.5rem;
  max-height:200px;overflow-y:auto;gap:2px}
.emoji-pick{padding:0.35rem;text-align:center;font-size:1.4rem;border-radius:6px;
  cursor:pointer;transition:background 0.15s}
.emoji-pick:hover{background:var(--surface-active)}

/* ═══════════ EMPTY STATE ═══════════ */
.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;
  height:100%;text-align:center;padding:2rem;color:var(--ink-muted)}
.empty-state-icon{font-size:4rem;margin-bottom:1rem;opacity:0.3}
.empty-state h3{font-family:'Bricolage Grotesque',sans-serif;font-size:1.3rem;color:var(--ink-soft);margin-bottom:0.5rem}
.empty-state p{font-size:0.9rem;max-width:320px;line-height:1.5;margin-bottom:1.5rem}
.empty-state-btn{padding:0.75rem 1.5rem;background:var(--amber);color:#fff;font-weight:700;
  border-radius:var(--radius-md);font-size:0.95rem;transition:all var(--transition)}
.empty-state-btn:hover{background:var(--amber-dark);transform:translateY(-2px);box-shadow:var(--shadow-md)}

/* ═══════════ MODAL ═══════════ */
.modal-overlay{position:fixed;inset:0;background:rgba(26,26,46,0.5);z-index:900;
  display:flex;align-items:center;justify-content:center;opacity:0;pointer-events:none;
  transition:opacity 0.25s;backdrop-filter:blur(4px)}
.modal-overlay.open{opacity:1;pointer-events:auto}
.modal{background:var(--surface);border-radius:var(--radius-xl);padding:2rem;
  max-width:500px;width:90%;box-shadow:var(--shadow-xl);transform:translateY(10px);
  transition:transform 0.3s}
.modal-overlay.open .modal{transform:translateY(0)}
.modal-title{font-family:'Bricolage Grotesque',sans-serif;font-size:1.3rem;font-weight:700;margin-bottom:0.5rem}
.modal-sub{color:var(--ink-muted);font-size:0.9rem;margin-bottom:1.5rem}
.modal-actions{display:flex;gap:0.5rem;justify-content:flex-end;margin-top:1.5rem}
.modal-btn{padding:0.6rem 1.25rem;border-radius:var(--radius-sm);font-weight:600;font-size:0.85rem;
  transition:all var(--transition)}
.modal-btn-cancel{color:var(--ink-muted)}
.modal-btn-cancel:hover{background:var(--surface-active);color:var(--ink)}
.modal-btn-primary{background:var(--amber);color:#fff}
.modal-btn-primary:hover{background:var(--amber-dark)}

/* Push Modal specifics */
.push-options{display:flex;flex-direction:column;gap:0.75rem}
.push-option{padding:1rem;border:1.5px solid var(--border);border-radius:var(--radius-md);
  cursor:pointer;transition:all var(--transition);display:flex;align-items:center;gap:0.75rem}
.push-option:hover{border-color:var(--amber);background:var(--fk-noun-bg)}
.push-option-icon{font-size:1.5rem;width:40px;text-align:center;flex-shrink:0}
.push-option-text h4{font-size:0.9rem;font-weight:700;margin-bottom:0.15rem}
.push-option-text p{font-size:0.75rem;color:var(--ink-muted)}
.qr-display{text-align:center;padding:1.5rem}
.qr-display canvas{border-radius:var(--radius-md);box-shadow:var(--shadow-md)}
.qr-display p{margin-top:0.75rem;font-size:0.8rem;color:var(--ink-muted)}

/* Push Modal Tabs */
.push-tab-bar{display:flex;gap:0;border-bottom:2px solid var(--border-light);margin-bottom:1.25rem}
.push-tab{padding:0.6rem 1rem;font-size:0.82rem;font-weight:600;color:var(--ink-muted);
  border-bottom:2px solid transparent;margin-bottom:-2px;transition:all var(--transition);cursor:pointer;
  background:none;border-top:none;border-left:none;border-right:none}
.push-tab:hover{color:var(--ink)}
.push-tab.active{color:var(--amber-dark);border-bottom-color:var(--amber)}
.push-tab-content{display:none}
.push-tab-content.active{display:block}

/* Device List */
.device-list{max-height:240px;overflow-y:auto}
.device-item{display:flex;align-items:center;padding:0.75rem;border:1.5px solid var(--border);
  border-radius:var(--radius-md);margin-bottom:0.5rem;transition:all var(--transition)}
.device-item:hover{border-color:var(--amber-light);background:var(--fk-noun-bg)}
.device-item-icon{font-size:1.3rem;margin-right:0.75rem}
.device-item-info{flex:1}
.device-item-info h4{font-size:0.85rem;font-weight:700;margin:0}
.device-item-info p{font-size:0.7rem;color:var(--ink-muted);margin:0}
.device-item-push{padding:0.4rem 0.8rem;background:var(--amber);color:#fff;border-radius:var(--radius-sm);
  font-size:0.75rem;font-weight:700;transition:all var(--transition);cursor:pointer;border:none}
.device-item-push:hover{background:var(--amber-dark)}
.device-item-push:disabled{opacity:0.5;cursor:not-allowed}

/* Serial Input */
.serial-input-row{display:flex;gap:0.5rem;margin-bottom:1rem}
.serial-input{flex:1;padding:0.6rem 0.75rem;border:1.5px solid var(--border);border-radius:var(--radius-sm);
  font-size:0.9rem;outline:none;background:var(--bg)}
.serial-input:focus{border-color:var(--amber)}

/* Scan Button */
.scan-btn{width:100%;padding:0.7rem;border-radius:var(--radius-md);background:var(--ink);
  color:#fff;font-weight:700;font-size:0.85rem;transition:all var(--transition);cursor:pointer;border:none;
  display:flex;align-items:center;justify-content:center;gap:0.5rem;margin-bottom:1rem}
.scan-btn:hover{background:var(--amber-dark)}
.scan-btn:disabled{opacity:0.5;cursor:not-allowed}
.scan-btn .spinner{display:inline-block;width:14px;height:14px;border:2px solid rgba(255,255,255,0.3);
  border-top-color:#fff;border-radius:50%;animation:spin 0.8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* Push Status */
.push-status{padding:0.6rem 0.85rem;border-radius:var(--radius-sm);font-size:0.8rem;font-weight:600;
  margin-top:0.75rem;display:none}
.push-status.success{display:block;background:#E8F5E9;color:#2E7D32}
.push-status.error{display:block;background:#FFEBEE;color:#C62828}
.push-status.info{display:block;background:#E3F2FD;color:#1565C0}

/* ═══════════ TOAST ═══════════ */
.toast{position:fixed;bottom:1.5rem;left:50%;transform:translateX(-50%) translateY(100px);
  background:var(--ink);color:#fff;padding:0.75rem 1.5rem;border-radius:var(--radius-lg);
  font-size:0.85rem;font-weight:600;z-index:2000;box-shadow:var(--shadow-lg);
  transition:transform 0.4s cubic-bezier(0.34,1.56,0.64,1);display:flex;align-items:center;gap:0.5rem}
.toast.show{transform:translateX(-50%) translateY(0)}
.toast-icon{font-size:1.1rem}

/* ═══════════ BOARD SETTINGS MODAL ═══════════ */
.settings-grid{display:grid;grid-template-columns:1fr 1fr;gap:0.75rem}
.settings-grid .full{grid-column:1/-1}
.settings-select{width:100%;padding:0.6rem 0.75rem;border:1.5px solid var(--border);
  border-radius:var(--radius-sm);background:var(--bg);font-size:0.9rem;outline:none;cursor:pointer}
.settings-select:focus{border-color:var(--amber)}

/* ═══════════ AI HELPER ═══════════ */
.ai-helper{width:100%;max-width:680px;margin-top:1.25rem;border-radius:var(--radius-lg);
  overflow:hidden;background:var(--surface);box-shadow:var(--shadow-md);border:1px solid var(--border-light)}
.ai-helper-toggle{width:100%;padding:0.7rem 1rem;display:flex;align-items:center;gap:0.6rem;
  background:linear-gradient(135deg,#1A1A2E 0%,#2A2A4E 100%);color:#fff;font-weight:600;
  font-size:0.85rem;transition:all var(--transition);border:none;cursor:pointer;text-align:left}
.ai-helper-toggle:hover{background:linear-gradient(135deg,#2A2A4E 0%,#3A3A5E 100%)}
.ai-helper-toggle .ai-spark{font-size:1.1rem}
.ai-helper-toggle .ai-tag{margin-left:auto;font-size:0.65rem;opacity:0.5;font-weight:400}
.ai-helper-toggle .ai-chevron{transition:transform 0.3s;font-size:0.7rem}
.ai-helper.open .ai-chevron{transform:rotate(180deg)}
.ai-helper-body{display:none;border-top:1px solid var(--border-light)}
.ai-helper.open .ai-helper-body{display:block}

.ai-chat{max-height:320px;overflow-y:auto;padding:0.75rem}
.ai-msg{margin-bottom:0.75rem;display:flex;gap:0.6rem;animation:fadeIn 0.3s}
.ai-msg-avatar{width:28px;height:28px;border-radius:50%;display:flex;align-items:center;
  justify-content:center;font-size:0.85rem;flex-shrink:0;margin-top:2px}
.ai-msg-avatar.ai{background:linear-gradient(135deg,#E8A838,#FF8C00);color:#fff}
.ai-msg-avatar.user{background:var(--bg);border:1.5px solid var(--border)}
.ai-msg-bubble{flex:1}
.ai-msg-text{font-size:0.85rem;line-height:1.55;color:var(--ink-soft)}
.ai-msg-text strong{color:var(--ink);font-weight:600}
.ai-msg-text .ai-reason{display:block;margin-top:0.4rem;padding:0.4rem 0.6rem;
  background:var(--bg);border-radius:var(--radius-sm);font-size:0.78rem;color:var(--ink-muted);
  border-left:3px solid var(--amber)}
.ai-msg-actions{display:flex;gap:0.4rem;margin-top:0.5rem;flex-wrap:wrap}
.ai-action-btn{padding:0.3rem 0.7rem;border-radius:20px;font-size:0.75rem;font-weight:600;
  border:1.5px solid var(--border);color:var(--ink-soft);transition:all var(--transition);cursor:pointer;background:var(--surface)}
.ai-action-btn:hover{border-color:var(--amber);color:var(--amber);background:var(--fk-noun-bg)}
.ai-action-btn.primary{background:var(--amber);color:#fff;border-color:var(--amber)}
.ai-action-btn.primary:hover{background:var(--amber-dark)}

.ai-input-row{display:flex;gap:0.5rem;padding:0.75rem;border-top:1px solid var(--border-light);background:var(--bg)}
.ai-input{flex:1;padding:0.6rem 0.85rem;border:1.5px solid var(--border);border-radius:var(--radius-lg);
  font-size:0.85rem;outline:none;background:var(--surface);transition:border-color var(--transition)}
.ai-input:focus{border-color:var(--amber)}
.ai-input::placeholder{color:var(--ink-muted)}
.ai-send-btn{padding:0.6rem 1rem;border-radius:var(--radius-lg);background:var(--amber);
  color:#fff;font-weight:700;font-size:0.8rem;transition:all var(--transition);border:none;cursor:pointer;white-space:nowrap}
.ai-send-btn:hover{background:var(--amber-dark)}
.ai-send-btn:disabled{opacity:0.5;cursor:not-allowed}
/* "↺ Start over" hint — shown by ai-rail.js once a board has been
   generated so the user can abandon the current iteration thread.
   Subtle by design — should look like a link, not a CTA. (Task #50 v2) */
.ai-reset-hint{margin:0 0.75rem 0.5rem;background:transparent;border:none;color:var(--ink-muted);
  font-size:0.75rem;cursor:pointer;padding:0.25rem 0.4rem;border-radius:var(--radius-sm);
  align-self:flex-start;font-family:inherit;transition:color var(--transition)}
.ai-reset-hint:hover{color:var(--amber-dark);text-decoration:underline}
.ai-typing{display:flex;align-items:center;gap:0.3rem;padding:0.2rem 0}
.ai-typing span{width:6px;height:6px;border-radius:50%;background:var(--ink-muted);
  animation:aiDot 1.2s infinite}
.ai-typing span:nth-child(2){animation-delay:0.2s}
.ai-typing span:nth-child(3){animation-delay:0.4s}
@keyframes aiDot{0%,80%,100%{opacity:0.3;transform:scale(0.8)}40%{opacity:1;transform:scale(1)}}

.ai-suggestions{display:flex;flex-wrap:wrap;gap:0.35rem;padding:0.5rem 0.75rem;border-top:1px solid var(--border-light)}
.ai-suggest-chip{padding:0.35rem 0.7rem;border-radius:20px;font-size:0.75rem;
  background:var(--bg);border:1px solid var(--border);color:var(--ink-soft);
  cursor:pointer;transition:all var(--transition);white-space:nowrap}
.ai-suggest-chip:hover{border-color:var(--amber);color:var(--amber);background:var(--fk-noun-bg)}

/* ═══════════ ANIMATIONS ═══════════ */
@keyframes tileAppear{from{opacity:0;transform:scale(0.8)}to{opacity:1;transform:scale(1)}}
.tile-appear{animation:tileAppear 0.3s cubic-bezier(0.34,1.56,0.64,1)}
@keyframes slideInRight{from{opacity:0;transform:translateX(20px)}to{opacity:1;transform:translateX(0)}}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}

/* ═══════════ SCROLLBAR ═══════════ */
::-webkit-scrollbar{width:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}
::-webkit-scrollbar-thumb:hover{background:var(--ink-muted)}

/* ═══════════ V2 LAYOUT — RAIL OVERRIDES ═══════════
   Activated 2026-05-01. Restructures the page into:
      [ AI rail (left) | Canvas (center) | Sidebar rail (right) | Props panel (far right, slides) ]
   Pre-v2 the AI was a 680px card below the canvas (scrolled away while
   editing tiles) and the sidebar/My-Boards lived on the left. v2 swaps
   sidebar to right and promotes the AI to a persistent left rail.
   These rules ONLY apply when the AI helper carries the .ai-rail class
   (set in HTML), so the underlying inline-card styles still work if a
   future page reuses the .ai-helper component.
*/

/* AI helper as full-height left rail */
.ai-helper.ai-rail{
  width:var(--ai-rail-w);
  max-width:none;
  margin:0;
  border-radius:0;
  border:none;
  border-right:1px solid var(--border-light);
  height:calc(100vh - var(--topbar-h));
  flex-shrink:0;
  display:flex;
  flex-direction:column;
  background:var(--surface);
  box-shadow:none;
  overflow:hidden;
}
.ai-helper.ai-rail .ai-helper-toggle{
  border-radius:0;
  cursor:default; /* rail header is informational, not a collapse trigger */
  flex-shrink:0;
}
.ai-helper.ai-rail .ai-helper-body{
  display:flex;
  flex:1 1 auto;
  flex-direction:column;
  min-height:0;
}
/* Always-on body even when .open is removed — the rail isn't collapsible */
.ai-helper.ai-rail:not(.open) .ai-helper-body{display:flex}
.ai-helper.ai-rail .ai-chat{
  flex:1 1 0;       /* basis 0 so chat doesn't claim natural height */
  min-height:80px;  /* keep at least one message visible */
  max-height:none;
  overflow-y:auto;
}
/* Suggestions cap to ~2 chip rows on the narrow 320px rail. Without this,
   6 wrapping chips can claim 4+ rows and push the input/Build button off
   the bottom of the viewport. Internal scroll keeps all chips reachable. */
.ai-helper.ai-rail .ai-suggestions{
  flex:0 0 auto;
  max-height:88px;
  overflow-y:auto;
  padding:0.5rem 0.6rem;
}
/* Input row (Build button) is sticky-bottom: even if a sibling overflows,
   the user can always reach Build. flex-shrink:0 + position:sticky belt
   AND suspenders so this never clips again. */
.ai-helper.ai-rail .ai-input-row{
  flex:0 0 auto;
  position:sticky;
  bottom:0;
  background:var(--bg);
  z-index:2;
}

/* Sidebar moved to right rail — flip the divider border */
.sidebar.sidebar-right{
  border-right:none;
  border-left:1px solid var(--border-light);
}

/* ═══════════ SIDEBAR v2.1 — ACCORDION + INDEPENDENT SCROLL ═══════════
   The right rail is height-bounded by .app-layout (calc(100vh - topbar)).
   Inside it, .sidebar-scroll is the only scroll context — so My Boards
   and Templates each cap their own height instead of pushing one another
   off-screen. Native <details> = no JS, free keyboard support, free a11y.
*/
.sidebar.sidebar-right .sidebar-scroll{
  flex:1 1 auto;
  overflow-y:auto;
  overflow-x:hidden;
  display:flex;
  flex-direction:column;
  gap:0.25rem;
  padding:0.5rem 0;
  min-height:0; /* lets flex children shrink + scroll inside flex parent */
}

.sidebar-acc{
  border-bottom:1px solid var(--border-light);
  background:transparent;
}
.sidebar-acc[open]{
  /* slight tint when open so the open section is obvious at a glance */
  background:var(--surface);
}
.sidebar-acc-summary{
  list-style:none;
  cursor:pointer;
  padding:0.7rem 1rem;
  font-size:0.72rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.08em;
  color:var(--ink-muted);
  display:flex;
  align-items:center;
  justify-content:space-between;
  user-select:none;
  transition:background var(--transition);
}
.sidebar-acc-summary::-webkit-details-marker{display:none}
.sidebar-acc-summary:hover{background:var(--surface-active);color:var(--ink)}
.sidebar-acc-summary:focus-visible{
  outline:2px solid var(--amber);
  outline-offset:-2px;
}
.sidebar-acc-chev{
  font-size:0.85rem;
  color:var(--ink-muted);
  transition:transform 0.18s ease;
  transform:rotate(-90deg);
}
.sidebar-acc[open] > .sidebar-acc-summary .sidebar-acc-chev{
  transform:rotate(0deg);
}
.sidebar-acc-body{
  padding:0.25rem 0 0.6rem;
  /* Bound the inner list so a long boards list doesn't push templates
     off the screen. The .sidebar-scroll above still scrolls the whole
     rail if accordion totals exceed viewport. */
  display:flex;
  flex-direction:column;
}
.sidebar-acc-body .sidebar-list{
  max-height:38vh;
}
.sidebar-acc-body .sidebar-templates{
  max-height:48vh;
  overflow-y:auto;
}

/* ═══════════ DEPLOY QR (Push-to-Devices accordion) ═══════════
   Persistent QR in the right rail so a parent can scan and start using
   the board on their phone with no account, no install. v2.2 2026-05-01. */
.sidebar-deploy{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:0.4rem;
  padding:0.4rem 0.75rem 0.6rem;
}
.sidebar-deploy-qr{
  width:148px;
  height:148px;
  background:#fff;
  border-radius:12px;
  padding:8px;
  box-shadow:var(--shadow-sm);
  display:flex;
  align-items:center;
  justify-content:center;
  /* QRCode library injects a <canvas> or <img> child; size them to fit */
}
.sidebar-deploy-qr canvas,
.sidebar-deploy-qr img,
.sidebar-deploy-qr svg{
  width:100%!important;
  height:100%!important;
  display:block;
}
.sidebar-deploy-qr.empty{
  background:var(--bg);
  color:var(--ink-muted);
  font-size:0.75rem;
  text-align:center;
  padding:14px;
}
.sidebar-deploy-caption{
  font-size:0.72rem;
  color:var(--ink-soft);
  text-align:center;
  line-height:1.35;
}
.sidebar-deploy-url{
  font-size:0.65rem;
  color:var(--ink-muted);
  font-family:ui-monospace,Menlo,Consolas,monospace;
  word-break:break-all;
  text-align:center;
  max-width:100%;
}
.sidebar-deploy-copy{
  margin-top:0.15rem;
  padding:0.4rem 0.85rem;
  border-radius:var(--radius-sm);
  background:var(--amber);
  color:#fff;
  font-size:0.72rem;
  font-weight:700;
  border:none;
  cursor:pointer;
  transition:background var(--transition);
}
.sidebar-deploy-copy:hover{background:var(--amber-dark)}
.sidebar-deploy-copy.copied{background:#2a7a3a}

/* ═══════════ A11Y SKIP LINK ═══════════
   Visible only when keyboard-focused. Was leaking visible at top-left
   on every page load (Luke screenshot 2026-05-01). The :not(:focus)
   guarantees screen readers still get it but sighted users don't see
   the leak. */
.a11y-skip{
  position:absolute;
  left:-9999px;
  top:auto;
  width:1px;
  height:1px;
  overflow:hidden;
  z-index:10000;
}
.a11y-skip:focus{
  left:0.5rem;
  top:0.5rem;
  width:auto;
  height:auto;
  padding:0.6rem 1rem;
  background:var(--ink);
  color:#fff;
  border-radius:var(--radius-sm);
  text-decoration:none;
  font-weight:600;
  outline:2px solid var(--amber);
}

/* ═══════════ RESPONSIVE ═══════════ */
@media(max-width:1280px){
  .ai-helper.ai-rail{width:280px}
}
@media(max-width:1024px){
  .sidebar{width:220px}
  .ai-helper.ai-rail{width:240px}
  .props-panel.open{width:280px}
  .props-inner{width:280px}
}
@media(max-width:768px){
  .sidebar{display:none}
  .ai-helper.ai-rail{display:none} /* TODO: bottom-sheet on mobile */
  .topbar{padding:0 0.75rem}
  .board-name-input{min-width:120px}
  .editor-area{padding:1rem 0.75rem}
  .tablet-frame{border-radius:20px;padding:12px}
}
/* Language Picker */
.lang-picker { position: relative; margin-left: 0.5rem; }
.lang-picker-btn { background: none; border: 1px solid rgba(255,255,255,0.2); color: #fff; padding: 0.35rem 0.7rem; border-radius: 8px; font-size: 0.75rem; cursor: pointer; font-family: var(--f-sans); display: flex; align-items: center; gap: 0.35rem; transition: all 0.3s; white-space: nowrap; }
.lang-picker-btn:hover { border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.05); }
.lang-picker-dropdown { position: absolute; top: calc(100% + 0.5rem); right: 0; background: var(--surface-dark, #13111a); border: 1px solid rgba(255,255,255,0.12); border-radius: 14px; padding: 0.6rem; display: none; grid-template-columns: repeat(3, 1fr); gap: 0.25rem; box-shadow: 0 16px 48px rgba(0,0,0,0.6); z-index: 1001; min-width: 320px; max-height: 70vh; overflow-y: auto; }
.lang-picker-dropdown.open { display: grid; }
.lang-option { padding: 0.45rem 0.55rem; border-radius: 8px; font-size: 0.73rem; color: rgba(255,255,255,0.65); cursor: pointer; text-align: center; transition: all 0.2s; white-space: nowrap; }
.lang-option:hover { background: rgba(255,255,255,0.08); color: #fff; }
.lang-option.active { background: var(--amber, #e8a33d); color: var(--ink, #0d0b0e); font-weight: 700; }
@media (max-width: 768px) {
  .lang-picker { position: fixed; top: 0.8rem; right: 3.5rem; z-index: 1001; }
  .lang-picker-dropdown { min-width: 280px; right: -1rem; }
}

/* ═══════════ PROPS DELETE BUTTON ═══════════
   Lives at the bottom of the props panel. Visually quarantined with a
   top border + extra margin so a parent's eye doesn't drift onto it
   while editing label/spoken/image fields. Color = same as Fitzgerald
   "neg" (red), matching the per-tile ✕ button on the grid.            */
.props-danger-group { border-top:1px solid var(--border-light); padding-top:1rem; margin-top:1.5rem }
.props-delete-btn{ width:100%;padding:0.7rem;border-radius:var(--radius-sm);
  background:var(--surface);border:1.5px solid var(--fk-neg);color:var(--fk-neg);
  font-weight:700;font-size:0.85rem;cursor:pointer;transition:all var(--transition) }
.props-delete-btn:hover{ background:var(--fk-neg);color:#fff }
.props-delete-btn:active{ transform:scale(0.98) }

/* Hamburger lives in the topbar but is hidden on desktop. */
.topbar-hamburger{display:none;width:36px;height:36px;border-radius:var(--radius-sm);
  align-items:center;justify-content:center;font-size:1.2rem;color:var(--nav-text);
  background:rgba(255,255,255,0.06);transition:background var(--transition);flex-shrink:0}
.topbar-hamburger:hover{background:rgba(255,255,255,0.14)}

/* Backdrop layer that sits between the slid-out sidebar and the rest of
   the page. Tap to dismiss. Inert on desktop. */
.sidebar-backdrop{display:none;position:fixed;inset:var(--topbar-h) 0 0 0;z-index:45;
  background:rgba(0,0,0,0.35);opacity:0;transition:opacity 0.2s}
.sidebar-backdrop.show{display:block;opacity:1}

/* ═══════════ MOBILE / TABLET RESPONSIVE ═══════════
   The builder was designed desktop-first (sidebar + canvas + props
   panel = 3 columns) and broke completely on phones — toolbar overflowed,
   sidebar squeezed the canvas to nothing, props panel slid OVER the
   tablet frame instead of beside it.

   Strategy below 1024px:
     • Sidebar collapses to a slide-in drawer (off-screen by default,
       toggled via existing left-side hamburger pattern). Until a
       hamburger is wired (next pass), the sidebar is hidden in mobile;
       templates remain reachable from the empty-state CTA.
     • Props panel becomes a bottom sheet that slides up from below
       when .open — full-width, max 70vh tall, scrolls inside.
     • Topbar tightens: brand-tag hidden, button labels truncated.
     • Tablet frame loses its chrome (the rounded-bezel "tablet" look)
       so tiles use the full screen.
   Phone-specific (≤640px) tightens further.

   This is the FIRST mobile-friendly pass. It does not yet ship a
   hamburger — that's a follow-up. But the builder no longer crashes
   visually on a phone, which is the bug Luke flagged. */

@media (max-width: 1024px) {
  /* Topbar: drop the tagline and tighten gaps so buttons don't wrap. */
  .topbar { padding:0 0.75rem; gap:0.4rem }
  .topbar-hamburger { display:flex }
  .topbar-brand-tag { display:none }
  .topbar-divider { display:none }
  .topbar-nav { gap:0.1rem; margin-right:0.25rem }
  .topbar-nav-link { padding:0.35rem 0.5rem; font-size:0.75rem }
  .topbar-actions { gap:0.3rem; flex-wrap:nowrap }
  .topbar-btn { padding:0.4rem 0.6rem; font-size:0.72rem }
  /* Sidebar collapses out of the layout flow — drawer pattern.
     `display:flex` here OVERRIDES the legacy ≤768px `display:none` rule
     (line ~760) so the sidebar can slide in/out as a drawer instead of
     vanishing entirely. */
  .sidebar {
    display:flex !important;
    position:fixed; top:var(--topbar-h); bottom:0; left:0; z-index:50;
    width:280px; max-width:80vw; transform:translateX(-100%);
    transition:transform 0.25s ease-out; box-shadow:var(--shadow-xl);
  }
  .sidebar.open { transform:translateX(0) }
  .app-layout { position:relative }
  .editor-area { padding:1rem 0.75rem 0.5rem; flex:1 1 auto; min-width:0 }
  /* Tablet "frame" loses its chunky bezel on small screens — wasted px. */
  .tablet-frame { padding:6px; border-radius:14px; max-width:100% }
  .tablet-frame::before { display:none }
  .tablet-screen { border-radius:10px }
  /* Props panel becomes a bottom sheet. */
  .props-panel {
    position:fixed; left:0; right:0; bottom:0; top:auto; width:100% !important;
    max-height:75vh; transform:translateY(100%);
    transition:transform 0.25s ease-out; z-index:60;
    border-left:none; border-top:1px solid var(--border-light);
    border-top-left-radius:16px; border-top-right-radius:16px;
    box-shadow:var(--shadow-xl);
  }
  .props-panel.open { transform:translateY(0) }
  .props-inner { width:100%; padding:1rem 1.25rem 1.5rem; max-height:75vh }
  /* Mobile UX hardening. Universal input font-size floor (≥16px,
     iOS-zoom defense) now lives in mobile-tokens.css and applies
     automatically — Phase 1a 2026-05-02 deduped the per-class rules
     that used to live here. Surviving rules are layout-specific:
     (1) textarea min-height — gives the spoken-text field room to
         breathe on a phone where 60px feels cramped.
     (2) Close ✕ bumped to 44×44 (Apple HIG / WCAG 2.5.5 tap target).
     (3) Image-mode tabs sized up — tab labels become readable. */
  .props-textarea { min-height:80px }
  .props-close { width:44px; height:44px; font-size:1rem }
  .props-img-tab { font-size:0.85rem; padding:0.6rem 0.5rem }
}

@media (max-width: 640px) {
  /* Phone: trim topbar nav links — they're a wash on a 360px viewport. */
  .topbar-brand-name { font-size:0.95rem }
  .topbar-nav { display:none }
  .editor-toolbar { flex-wrap:wrap; gap:0.3rem; margin-bottom:0.75rem }
  .editor-toolbar-group { padding:0.2rem }
  .toolbar-btn { padding:0.35rem 0.55rem; font-size:0.75rem }
  /* Tile grid: tiles already auto-size from .cols-N — let them breathe. */
  .tile-grid { gap:0.35rem; padding:0.5rem }
  /* Props image button row: stack into single column on the narrowest
     screens so 4 buttons (Upload/Camera/Search/Remove) don't crush each
     other into 1-letter widths. */
  .props-image-btns { flex-direction:column }
  .props-upload-btn { width:100% }
  /* Push modal: make it usable on a phone — full bleed, scrollable,
     bigger tap targets on the tab bar. The default 500px max-width
     gets squeezed to 90% viewport which clips the WiFi/Serial/More
     tab labels. */
  .modal { padding:1.25rem; max-height:88vh; overflow-y:auto; width:96% }
  .push-tab { padding:0.55rem 0.5rem; font-size:0.72rem }
  .push-tab-bar { gap:0.1rem }
  /* Topbar action buttons collapse labels → emoji-only on the
     narrowest viewport so all five fit without wrapping. */
  .topbar-btn { padding:0.4rem 0.55rem; font-size:0.78rem }
}

/* ── Students panel (Task #78 — per-student CSV export) ─────────
   Therapist roster + per-student tap log + IEP-data CSV export.
   Modal overlay; locks scroll while open. PILOT badge in header
   reminds therapist this is local-only until Stage 2 ships. */
.students-overlay{position:fixed;inset:0;background:rgba(20,20,20,0.55);
  z-index:9000;display:flex;align-items:center;justify-content:center;
  padding:1rem;overflow:auto}
.students-card{background:#fff;border-radius:14px;box-shadow:0 18px 60px rgba(0,0,0,0.3);
  width:100%;max-width:780px;max-height:92vh;display:flex;flex-direction:column;
  overflow:hidden}
.students-header{display:flex;align-items:center;justify-content:space-between;
  padding:1rem 1.25rem;border-bottom:1px solid #ECECEC;background:#FAF7F1}
.students-title{font-size:1.05rem;font-weight:700;color:#23211D}
.students-pilot-badge{display:inline-block;margin-left:0.4rem;padding:0.1rem 0.5rem;
  border-radius:999px;background:#FEEEC8;color:#7A4A00;font-size:0.65rem;
  font-weight:700;letter-spacing:0.04em;vertical-align:middle}
.students-close{background:transparent;border:0;font-size:1.6rem;line-height:1;
  cursor:pointer;color:#666;padding:0.2rem 0.6rem}
.students-close:hover{color:#000}
.students-active-bar{display:flex;align-items:center;gap:0.6rem;padding:0.7rem 1.25rem;
  border-bottom:1px solid #F1ECE2;background:#FFFCF5;flex-wrap:wrap}
.students-active-label{font-size:0.85rem;font-weight:600;color:#444}
.students-active-select{flex:1;min-width:180px;padding:0.45rem 0.6rem;
  border-radius:8px;border:1px solid #DCD3C0;background:#fff;font-size:0.9rem}
.students-body{display:flex;gap:0;flex:1;overflow:hidden;min-height:340px}
.students-roster{flex:0 0 240px;border-right:1px solid #ECECEC;display:flex;
  flex-direction:column;overflow:hidden}
.students-roster-head{padding:0.7rem 0.9rem;font-size:0.78rem;font-weight:700;
  color:#666;text-transform:uppercase;letter-spacing:0.06em;
  border-bottom:1px solid #F2EFE6}
.students-list{flex:1;overflow-y:auto;padding:0.3rem 0}
.students-list-row{padding:0.55rem 0.9rem;cursor:pointer;border-left:3px solid transparent}
.students-list-row:hover{background:#FAF7F1}
.students-list-row.active{background:#FFF4DC;border-left-color:var(--amber,#E8A838)}
.students-list-name{font-size:0.92rem;font-weight:600;color:#23211D}
.students-list-meta{font-size:0.72rem;color:#888;margin-top:0.1rem}
.students-add-btn{margin:0.6rem 0.7rem;padding:0.55rem 0.7rem;border:1px dashed #C8B98A;
  background:#FFFCF5;border-radius:8px;color:#7A4A00;font-weight:600;cursor:pointer;
  font-size:0.85rem}
.students-add-btn:hover{background:#FFF4DC}
.students-detail{flex:1;padding:1rem 1.25rem;overflow-y:auto;display:flex;
  flex-direction:column;gap:0.7rem}
.students-detail-name{font-size:1.2rem;font-weight:700;color:#23211D}
.students-detail-sub{font-size:0.78rem;color:#888}
.students-detail-privacy{padding:0.55rem 0.7rem;border-radius:8px;background:#F4F2EC;
  border:1px solid #E8E2D2;font-size:0.82rem;color:#444}
.students-detail-notes{padding:0.55rem 0.7rem;border-radius:8px;background:#FCFAF4;
  border:1px solid #F0EBDC;font-size:0.84rem;color:#333;white-space:pre-wrap}
.students-detail-actions{display:flex;flex-wrap:wrap;gap:0.45rem;margin-top:0.4rem}
.students-action-btn{padding:0.5rem 0.75rem;border-radius:8px;border:1px solid #DCD3C0;
  background:#fff;color:#23211D;font-weight:600;font-size:0.82rem;cursor:pointer}
.students-action-btn:hover{background:#FAF7F1}
.students-action-btn.primary{background:var(--amber,#E8A838);border-color:var(--amber,#E8A838);
  color:#fff}
.students-action-btn.primary:hover{background:var(--amber-dark,#C68A22)}
.students-action-btn.danger{color:#A22A2A;border-color:#E8C5C5}
.students-action-btn.danger:hover{background:#FAEDED}
.students-empty{padding:1rem;color:#888;font-size:0.86rem;font-style:italic}

/* QR overlay (per-student) */
.students-qr-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:9100;
  display:flex;align-items:center;justify-content:center;padding:1rem}
.students-qr-card{background:#fff;border-radius:14px;padding:1.3rem 1.4rem;
  width:100%;max-width:380px;box-shadow:0 18px 60px rgba(0,0,0,0.35);text-align:center}
.students-qr-title{font-size:1.05rem;font-weight:700;margin-bottom:0.3rem}
.students-qr-sub{font-size:0.78rem;color:#555;margin-bottom:0.7rem;line-height:1.4}
.students-qr-box{display:flex;justify-content:center;align-items:center;
  min-height:230px;background:#FAF7F1;border-radius:10px;padding:0.5rem;margin:0.3rem 0}
.students-qr-url{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:0.7rem;
  color:#444;background:#F4F2EC;padding:0.45rem 0.5rem;border-radius:6px;
  word-break:break-all;margin:0.5rem 0 0.7rem}
.students-qr-actions{display:flex;gap:0.4rem;justify-content:center}

@media (max-width: 640px){
  .students-body{flex-direction:column;min-height:0}
  .students-roster{flex:0 0 auto;max-height:200px;border-right:0;
    border-bottom:1px solid #ECECEC}
  .students-detail{padding:0.8rem 0.9rem}
}
