/* Block Builder Code - style.css */

@font-face {
  font-family: 'Rubik';
  src: url('../assets/fonts/rubik-latin-wght-normal.woff2') format('woff2');
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../assets/fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Layout idea: a sunny header, code on the left, the building grid on the right,
     tools floating over the grid like pieces on a play mat. */
  --ink: #1B2340;          /* text and strong shapes */
  --ink-soft: #5A6585;     /* quieter text */
  --sun: #FFC21A;          /* the header and every highlight */
  --sun-deep: #E0A300;
  --paper: #FFFFFF;        /* panels and buttons */
  --mist: #EEF3F9;         /* page background and quiet fills */
  --line: #D3DCE9;         /* hairlines */
  --go: #17B169;           /* Run */
  --go-deep: #0E8A50;
  --halt: #F0464C;         /* Stop and Destroy */
  --halt-deep: #C22D33;
  --blue: #2F7BFF;         /* links and selection */
  --axis-x: #FF5A5F;       /* the three axes wear the same colors everywhere */
  --axis-y: #19B36B;
  --axis-z: #2F7BFF;
  --sky-top: #BCE3FF;
  --sky-bottom: #F4FAFF;
  --font-ui: 'Rubik', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-code: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(27, 35, 64, 0.12);
  --press: 0 3px 0 rgba(27, 35, 64, 0.92);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--ink);
  background: var(--mist);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.icon { width: 20px; height: 20px; flex: none; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- frame ---------- */
#app { height: 100%; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  height: 54px; padding: 0 14px;
  background: var(--sun);
  border-bottom: 3px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-code {
  font-family: var(--font-code); font-weight: 700; font-size: 14px;
  background: var(--ink); color: var(--sun);
  padding: 3px 8px 4px; border-radius: 7px; margin-left: 3px; letter-spacing: 0.02em;
}
.project-name { flex: 0 1 220px; min-width: 90px; display: flex; }
.project-name input {
  width: 100%; height: 34px; padding: 0 10px;
  border: 2px solid transparent; border-radius: 9px;
  background: rgba(255, 255, 255, 0.55); font-weight: 600;
}
.project-name input:hover { background: rgba(255, 255, 255, 0.8); }
.project-name input:focus { background: #fff; border-color: var(--ink); outline: none; }
.save-status { flex: none; display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 500; color: rgba(27, 35, 64, 0.78); white-space: nowrap; }
.save-status .icon { width: 15px; height: 15px; }
.save-status.is-warn { color: #8A1F24; font-weight: 600; }
.topbar .spacer { flex: 1 1 0; min-width: 0; }
.menu { display: flex; align-items: center; gap: 2px; flex: none; }
.menu button {
  display: flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 10px;
  border: 0; border-radius: 9px; background: transparent;
  font-weight: 600; font-size: 14px; white-space: nowrap;
}
.menu button:hover { background: rgba(255, 255, 255, 0.5); }
.menu button:active { background: rgba(255, 255, 255, 0.75); }
.menu .icon-only { padding: 0 8px; }

.work { flex: 1 1 0; min-height: 0; display: flex; }
.code-panel { flex: 0 0 var(--split, 46%); min-width: 0; display: flex; flex-direction: column; background: var(--paper); }
.stage-panel { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; container-type: inline-size; }
@container (max-width: 600px) {
  .stage-head .segmented .label, .stage-head .chip-button .label { display: none; }
  .stage-head .chip-button { padding: 0 7px; }
  .stage-head { gap: 5px; padding: 5px 7px; }
  .stage-head .segmented button { min-width: 29px; padding: 0 4px; }
  .big-button { padding: 0 9px 0 7px; gap: 5px; }
  .toolbar { gap: 5px; left: 8px; right: 8px; top: 8px; }
  .tool-group { padding: 3px; gap: 2px; }
  .toolbar .tool { width: 32px; height: 32px; }
  .toolbar .tool.small { width: 25px; }
  .size-readout { min-width: 22px; }
  .swatch-button { width: 38px; height: 32px; }
  .swatch-button img { width: 24px; height: 24px; }
  .camera-pad { grid-template-columns: repeat(3, 30px); }
  .camera-pad .tool { width: 30px; height: 30px; }
}
.splitter {
  flex: none; width: 10px; cursor: col-resize; background: var(--mist);
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; touch-action: none;
}
.splitter::before { content: ''; width: 4px; height: 44px; border-radius: 2px; background: #B4C0D2; }
.splitter:hover::before, .splitter.is-dragging::before { background: var(--ink); }
#app.layout-build .code-panel, #app.layout-build .splitter { display: none; }

/* ---------- code panel ---------- */
.panel-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--paper);
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.panel-head .spacer { flex: 1; }
.chip-button {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px;
  border: 1.5px solid var(--line); border-radius: 9px; background: var(--paper); font-weight: 600; font-size: 13.5px; white-space: nowrap;
}
.chip-button:hover { border-color: var(--ink); }
.chip-button:disabled { color: #9BA8BD; border-color: var(--line); cursor: default; }
.chip-button[aria-pressed='true'] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-button .icon { width: 17px; height: 17px; }
.chip-button.is-go { background: var(--go); border-color: var(--go-deep); color: #fff; }
.only-narrow { display: none; }
.code-body { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
#blockly { flex: 1 1 0; min-height: 0; position: relative; }
#blockly.is-locked { pointer-events: none; }
#blockly.is-locked::after {
  content: 'Running…'; position: absolute; right: 12px; top: 10px; z-index: 30;
  background: var(--go); color: #fff; font-weight: 700; font-size: 13px; padding: 5px 11px; border-radius: 999px;
}
.text-code { flex: 0 0 34%; min-height: 90px; display: flex; flex-direction: column; border-top: 3px solid var(--ink); background: #16203B; color: #E8EEFA; }
.text-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 12.5px; font-weight: 600; color: #AEBBDA; }
.text-head .spacer { flex: 1; }
.text-head button { border: 0; background: transparent; color: #AEBBDA; font-weight: 600; font-size: 12.5px; display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px; border-radius: 6px; }
.text-head button:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.text-lines { position: relative; flex: 1 1 0; min-height: 0; overflow: auto; margin: 0; padding: 0 0 10px; font-family: var(--font-code); font-size: 13px; line-height: 1.65; counter-reset: line; }
.text-line { display: block; padding: 0 14px 0 0; white-space: pre; }
.text-line::before { counter-increment: line; content: counter(line); display: inline-block; width: 38px; padding-right: 12px; text-align: right; color: #5E6E96; }
.text-line.is-current { background: rgba(255, 194, 26, 0.22); }
.tk-key { color: #FF9FC3; }
.tk-fn { color: #8FD0FF; }
.tk-num { color: #FFD479; }
.tk-str { color: #A6E9B4; }
.tk-com { color: #7F8FB5; font-style: italic; }

/* Blockly, restyled */
.blocklyToolbox { background: var(--paper) !important; border-right: 1px solid var(--line); padding: 6px 0; width: 86px; scrollbar-width: none; }
.blocklyToolbox::-webkit-scrollbar { display: none; }
.blocklyToolboxCategoryContainer { padding: 0 !important; }
.blocklyToolboxCategory.bb-cat {
  height: auto !important; line-height: 1.2 !important; padding: 7px 2px 6px !important; margin: 2px 6px !important;
  border: 0 !important; border-radius: 11px; cursor: pointer;
}
.bb-cat .blocklyTreeRowContentContainer { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bb-cat .blocklyToolboxCategoryIcon { display: block !important; visibility: visible !important; width: 24px; height: 24px; border-radius: 50%; background: var(--cat, #999); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18); }
.bb-cat .blocklyToolboxCategoryLabel { font-family: var(--font-ui); font-size: 11.5px; font-weight: 600; color: var(--ink) !important; white-space: normal; text-align: center; }
.bb-cat:hover { background: var(--mist) !important; }
.bb-cat.blocklyToolboxSelected { background: var(--ink) !important; }
.bb-cat.blocklyToolboxSelected .blocklyToolboxCategoryLabel { color: #fff !important; }
.bb-cat-builder { --cat: #3D7BFF; } .bb-cat-shapes { --cat: #0E9488; } .bb-cat-material { --cat: #8E5BFF; } .bb-cat-control { --cat: #E67A00; }
.bb-cat-sensing { --cat: #1B94C9; } .bb-cat-math { --cat: #2FA84F; } .bb-cat-variables { --cat: #E8552D; } .bb-cat-myblocks { --cat: #E83E8C; }
.blocklyFlyoutLabelText { font-family: var(--font-ui) !important; font-weight: 600; fill: var(--ink) !important; }
.blocklyFlyoutButton { fill: var(--ink) !important; }
.blocklyFlyoutButton:hover { fill: #2C3760 !important; }
.blocklyMainBackground { stroke: none !important; }
.blocklyDropDownDiv { border-radius: 12px !important; box-shadow: 0 8px 28px rgba(27, 35, 64, 0.28) !important; }
.blocklyDropDownDiv:focus, .blocklyDropDownDiv:focus-visible { outline: none; }
/* plain cursors, so Blockly never asks for its cursor image files */
.blocklyDragging.blocklyDraggingDelete, .blocklyDragging.blocklyDraggingDelete .blocklyField,
.blocklyToolboxDelete, .blocklyToolboxDelete .blocklyToolboxCategoryLabel { cursor: grabbing !important; }
.blocklyTooltipDiv { font-family: var(--font-ui) !important; font-size: 13px !important; background: var(--ink) !important; color: #fff !important; border: 0 !important; border-radius: 8px !important; padding: 6px 9px !important; max-width: 260px; opacity: 1 !important; box-shadow: var(--shadow) !important; }
.blocklyMenu { font-family: var(--font-ui) !important; }
.blocklyHtmlInput { font-family: var(--font-ui) !important; }
/* the block that is running right now wears a bright ring */
.blocklyHighlighted > .blocklyPath { filter: drop-shadow(0 0 5px rgba(255, 194, 26, 0.95)) !important; stroke: #FFC21A !important; stroke-width: 4.5px !important; }

/* ---------- stage ---------- */
.stage-head {
  flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  min-height: 46px; padding: 5px 10px; border-bottom: 1px solid var(--line); background: var(--paper);
}
.stage-head .spacer { flex: 1 1 0; }
.big-button {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px 0 11px;
  border: 2px solid var(--ink); border-radius: 10px; font-weight: 700; font-size: 14.5px; color: #fff;
  box-shadow: var(--press); transform: translateY(-1px); white-space: nowrap;
}
.big-button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 rgba(27, 35, 64, 0.92); }
.big-button .icon { width: 17px; height: 17px; fill: currentColor; }
.big-button.run { background: var(--go); }
.big-button.run:hover { background: #1EC477; }
.big-button.stop { background: var(--halt); }
.big-button:disabled { background: #C9D2E0; border-color: #9BA8BD; box-shadow: 0 3px 0 #9BA8BD; color: #fff; cursor: default; }
.big-button.run.is-running { background: var(--go-deep); }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--mist); border-radius: 10px; }
.segmented button {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 34px; height: 30px; padding: 0 7px;
  border: 0; border-radius: 8px; background: transparent; font-weight: 600; font-size: 13px; color: var(--ink-soft);
}
.segmented button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.7); }
.segmented button[aria-checked='true'] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(27, 35, 64, 0.22); }
.segmented .icon { width: 18px; height: 18px; }
.segmented .label { white-space: nowrap; }

.stage { flex: 1 1 0; min-height: 0; position: relative; overflow: hidden; background: linear-gradient(var(--sky-top), var(--sky-bottom) 72%); }
.stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; cursor: crosshair; }
.toolbar, .coords, .camera-pad, .say { z-index: 2; }
.stage-canvas.is-dragging { cursor: grabbing; }
.stage-canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--blue); }
.stage-fail { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 30px; text-align: center; font-weight: 600; }

.toolbar { position: absolute; left: 10px; top: 10px; right: 10px; display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; }
.tool-group { display: flex; align-items: center; gap: 3px; padding: 4px; background: var(--paper); border-radius: 13px; box-shadow: var(--shadow); pointer-events: auto; }
.tool {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink);
}
.tool:hover { background: var(--mist); }
.tool[aria-pressed='true'], .tool[aria-checked='true'] { background: var(--ink); color: var(--sun); }
.tool.is-destroy[aria-checked='true'] { background: var(--halt); color: #fff; }
.tool:disabled { color: #B4C0D2; cursor: default; background: transparent; }
.tool.small { width: 30px; }
.size-readout { min-width: 26px; text-align: center; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.swatch-button { position: relative; width: 44px; height: 38px; padding: 0; border: 0; border-radius: 10px; background: transparent; display: inline-flex; align-items: center; justify-content: center; }
.swatch-button:hover { background: var(--mist); }
.swatch-button img { width: 30px; height: 30px; border-radius: 7px; image-rendering: pixelated; box-shadow: 0 0 0 2px var(--ink); background: repeating-conic-gradient(#D5DEEA 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.swatch-button .icon { position: absolute; right: 1px; bottom: 0; width: 15px; height: 15px; background: var(--paper); border-radius: 50%; padding: 1px; }

.coords {
  position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 4px;
  padding: 5px 6px; background: var(--paper); border-radius: 12px; box-shadow: var(--shadow);
  font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; pointer-events: none;
}
.coords .axis { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 4px; border-radius: 8px; background: var(--mist); }
.coords .axis b { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 6px; color: #fff; font-size: 12px; }
.coords .axis-x b { background: var(--axis-x); } .coords .axis-y b { background: var(--axis-y); } .coords .axis-z b { background: var(--axis-z); }
.coords .axis span { min-width: 17px; text-align: right; }
.coords .what { font-weight: 500; font-size: 13px; color: var(--ink-soft); padding: 0 6px 0 4px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.camera-pad { position: absolute; right: 10px; bottom: 10px; display: grid; grid-template-columns: repeat(3, 34px); gap: 3px; padding: 4px; background: var(--paper); border-radius: 13px; box-shadow: var(--shadow); }
.camera-pad .tool { width: 34px; height: 34px; }
.camera-pad .icon { width: 18px; height: 18px; }

.say {
  position: absolute; left: 0; top: 0; max-width: 240px; padding: 8px 12px; background: var(--paper); border: 2px solid var(--ink); border-radius: 14px;
  font-weight: 600; font-size: 14.5px; line-height: 1.3; box-shadow: var(--press); pointer-events: none; transform: translate(-50%, -100%); overflow-wrap: anywhere;
}
.say::after { content: ''; position: absolute; left: 50%; bottom: -9px; width: 14px; height: 14px; margin-left: -7px; background: var(--paper); border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg); }

.toasts { position: absolute; left: 10px; right: 136px; bottom: 58px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 5; }
.toast {
  display: flex; align-items: flex-start; gap: 8px; padding: 9px 13px; border-radius: 12px; background: var(--ink); color: #fff;
  font-weight: 500; font-size: 14px; line-height: 1.35; box-shadow: var(--shadow); pointer-events: auto; animation: toast-in 0.18s ease-out; max-width: 520px;
}
.toast .icon { width: 18px; height: 18px; margin-top: 1px; }
.toast.is-ok .icon { color: #6FE3A7; } .toast.is-warn .icon { color: var(--sun); } .toast.is-error { background: #7E1B20; } .toast.is-hint .icon { color: #8FD0FF; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- dialogs ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 200000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(27, 35, 64, 0.5); animation: fade-in 0.12s ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  display: flex; flex-direction: column; width: min(100%, 560px); max-height: 100%;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 8px 0 rgba(27, 35, 64, 0.9); overflow: hidden;
}
.modal.is-wide { width: min(100%, 860px); }
.modal.is-small { width: min(100%, 420px); }
.modal-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 18px; background: var(--sun); border-bottom: 3px solid var(--ink); }
.modal-head h2 { margin: 0; flex: 1; font-size: 19px; font-weight: 800; text-wrap: balance; }
.modal-close { width: 36px; height: 36px; border: 2px solid var(--ink); border-radius: 10px; background: var(--paper); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.modal-close:hover { background: var(--ink); color: #fff; }
.modal-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 16px 18px; }
.modal-body p { margin: 0 0 10px; line-height: 1.45; }
.modal-foot { flex: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 12px 18px 16px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 16px;
  border: 2px solid var(--ink); border-radius: 11px; background: var(--paper); font-weight: 700; font-size: 15px; box-shadow: var(--press); transform: translateY(-1px);
}
.button:hover { background: var(--mist); }
.button:active { transform: translateY(2px); box-shadow: none; }
.button.is-primary { background: var(--sun); }
.button.is-primary:hover { background: #FFCE45; }
.button.is-go { background: var(--go); color: #fff; }
.button.is-danger { background: var(--halt); color: #fff; }
.button:disabled { opacity: 0.5; cursor: default; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin: 0 0 6px; }
.text-input { width: 100%; height: 42px; padding: 0 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px; }
.text-input:focus { border-color: var(--ink); outline: none; }
.note { font-size: 13.5px; color: var(--ink-soft); }

/* home */
.home-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.home-hero svg { width: 76px; height: 76px; flex: none; }
.home-hero h3 { margin: 0 0 4px; font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.home-hero p { margin: 0; color: var(--ink-soft); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; text-align: left;
  border: 2px solid var(--ink); border-radius: 14px; background: var(--paper); box-shadow: var(--press); transform: translateY(-1px);
}
.card:hover { background: #FFF7DB; }
.card:active { transform: translateY(2px); box-shadow: none; }
.card .icon { width: 26px; height: 26px; }
.card strong { font-size: 16px; }
.card span { font-size: 13.5px; color: var(--ink-soft); line-height: 1.35; }
.card.is-primary { background: var(--sun); }
.card.is-primary:hover { background: #FFCE45; }
.card.is-primary span { color: rgba(27, 35, 64, 0.8); }
.card.is-selected { background: var(--ink); color: #fff; }
.card.is-selected span { color: #C9D3EA; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--mist); font-size: 12px; font-weight: 600; color: var(--ink); }

/* material picker */
.mat-panel { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mat-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.mat-tab { height: 32px; padding: 0 11px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--paper); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.mat-tab:hover { border-color: var(--ink); }
.mat-tab[aria-selected='true'] { background: var(--ink); border-color: var(--ink); color: #fff; }
.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; align-content: start; min-height: 150px; }
.mat-cell { position: relative; aspect-ratio: 1; padding: 0; border: 2px solid var(--line); border-radius: 11px; background: repeating-conic-gradient(#D5DEEA 0 25%, #fff 0 50%) 0 0 / 14px 14px; overflow: hidden; }
.mat-cell img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.mat-cell:hover { border-color: var(--ink); }
.mat-cell[aria-pressed='true'] { border-color: var(--ink); box-shadow: 0 0 0 3px var(--sun); }
.mat-cell.is-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: var(--mist); font-size: 11.5px; font-weight: 600; border-style: dashed; border-color: #9BA8BD; }
.mat-caption { display: flex; align-items: center; gap: 8px; min-height: 26px; font-weight: 600; }
.mat-caption .note { font-weight: 400; }
.mat-sub { font-size: 13px; font-weight: 600; color: var(--ink-soft); margin: 4px 0 -2px; }
.mat-edit { position: absolute; right: 3px; top: 3px; display: flex; gap: 3px; }
.mat-edit span { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; background: var(--paper); box-shadow: 0 0 0 1.5px var(--ink); }
.mat-edit .icon { width: 13px; height: 13px; }
.color-mix { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 5px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--paper); font-weight: 600; font-size: 13.5px; cursor: pointer; }
.color-mix:hover { border-color: var(--ink); }
.color-mix input { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.mat-panel.is-compact { width: 318px; padding: 6px; gap: 8px; }
.mat-panel.is-compact .mat-tabs { gap: 4px; }
.mat-panel.is-compact .mat-grid { grid-template-columns: repeat(7, 1fr); gap: 5px; max-height: 216px; overflow-y: auto; min-height: 0; padding: 3px; }
.mat-panel.is-compact .mat-tab { height: 26px; padding: 0 7px; font-size: 12px; border-width: 1px; }
.mat-panel.is-compact .mat-cell { border-radius: 8px; }

/* pattern maker */
.maker { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.maker-canvas-wrap { flex: none; padding: 6px; border: 2px solid var(--ink); border-radius: 12px; background: repeating-conic-gradient(#D5DEEA 0 25%, #fff 0 50%) 0 0 / 20px 20px; touch-action: none; }
.maker-canvas { display: block; width: 320px; height: 320px; image-rendering: pixelated; cursor: crosshair; touch-action: none; }
.maker-side { flex: 1 1 250px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.maker-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.maker-palette { display: grid; grid-template-columns: repeat(9, 26px); gap: 4px; }
.maker-color { width: 26px; height: 26px; padding: 0; border: 2px solid rgba(27, 35, 64, 0.25); border-radius: 7px; }
.maker-color[aria-pressed='true'] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--sun); }
.maker-preview { display: flex; align-items: center; gap: 14px; }
.maker-preview canvas { flex: none; padding: 8px; border-radius: 12px; background: linear-gradient(var(--sky-top), var(--sky-bottom)); }
.home-grid { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }

/* help */
.help-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.help-list { display: grid; gap: 9px; margin: 0 0 14px; padding: 0; list-style: none; }
.help-list li { display: flex; align-items: flex-start; gap: 11px; line-height: 1.4; }
.help-list .badge { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: var(--ink); color: var(--sun); font-weight: 700; }
.help-list .badge.is-key { width: auto; min-width: 34px; padding: 0 8px; background: var(--mist); color: var(--ink); font-size: 12.5px; box-shadow: inset 0 -2px 0 var(--line); white-space: nowrap; }
.help h3 { margin: 4px 0 9px; font-size: 16px; }
.axis-key { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.axis-key span { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 6px; border-radius: 10px; background: var(--mist); font-weight: 500; }
.axis-key b { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 7px; color: #fff; }

/* picture */
.picture-preview { display: block; max-width: 100%; max-height: 46vh; margin: 0 auto 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff; }
.check-row { display: flex; align-items: center; gap: 9px; margin: 6px 0; font-weight: 500; }
.check-row input { width: 20px; height: 20px; accent-color: var(--ink); }
.copy-box { width: 100%; height: 150px; font-family: var(--font-code); font-size: 12px; border: 2px solid var(--line); border-radius: 10px; padding: 8px; resize: vertical; }

.drop-hint { position: fixed; inset: 0; z-index: 200001; display: flex; align-items: center; justify-content: center; background: rgba(255, 194, 26, 0.9); font-size: 26px; font-weight: 800; pointer-events: none; }

/* ---------- small screens ---------- */
@media (max-width: 1180px) {
  .menu button .label { display: none; }
  .menu button { padding: 0 9px; }
  .save-status span { display: none; }
}
@media (max-width: 760px) {
  .brand-name { font-size: 16px; }
  .project-name { display: none; }
  .only-narrow { display: inline-flex; }
  #code-hint, #layout [data-layout='both'] { display: none; }
  .menu { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; justify-content: flex-end; }
  .menu::-webkit-scrollbar { display: none; }
  .topbar .spacer { display: none; }
  #app.layout-code .stage-panel, #app.layout-code .splitter { display: none; }
  #app.layout-code .code-panel, #app.layout-both .code-panel { flex-basis: 100%; }
  #app.layout-both .stage-panel, #app.layout-both .splitter { display: none; }
  .segmented .label { display: none; }
  .maker-canvas { width: 256px; height: 256px; }
}
@media (max-width: 460px) {
  .brand-name .brand-words, .save-status { display: none; }
  .topbar { gap: 6px; padding: 0 8px; }
  .menu { justify-content: flex-start; }
  .menu button { padding: 0 6px; }
  .panel-head { gap: 6px; padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
