/* ───────────────────────────────────────────────────────────────
   Pixel Art & Sprite Studio (owned by pixel.js)
   ─────────────────────────────────────────────────────────────── */
#pixel-art-view, .px-modal {
  --px-surface: rgba(255, 255, 255, 0.03);
  --px-btn: rgba(255, 255, 255, 0.05);
  --px-hover: rgba(255, 255, 255, 0.1);
  --px-overlay: rgba(10, 14, 28, 0.62);
  --px-solid: #161a2c;
  --px-stage-bg: #0b0f1d;
  width: 100%;
}
[data-theme="light"] #pixel-art-view, [data-theme="light"] .px-modal {
  --px-surface: rgba(15, 23, 42, 0.025);
  --px-btn: #ffffff;
  --px-hover: rgba(99, 102, 241, 0.08);
  --px-solid: #ffffff;
  --px-stage-bg: #e4e7f1;
}

.px-studio {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 28px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; min-width: 0; box-sizing: border-box;
}
#px-root { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.px-studio button, .px-modal button { font-family: var(--font-display); -webkit-tap-highlight-color: transparent; }
.px-studio button:focus-visible, .px-modal button:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }
.px-emo { line-height: 1; }
.px-studio [hidden], .px-modal [hidden] { display: none !important; }
.px-faint { color: var(--text-faint); font-size: 0.74rem; }

/* ── Chips & small buttons ───────────────────────────────────── */
.px-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 7px 12px;
  border-radius: 12px; border: 1px solid var(--border-color);
  background: var(--px-btn); color: var(--text-main);
  font-weight: 600; font-size: 0.9rem; cursor: pointer; white-space: nowrap;
  transition: background 0.2s, transform 0.15s, color 0.2s, border-color 0.2s;
}
.px-chip .px-emo { font-size: 1.1rem; }
.px-chip:hover:not(:disabled) { background: var(--px-hover); border-color: var(--primary); }
.px-chip:active:not(:disabled) { transform: scale(0.95); }
.px-chip.active { background: var(--primary); color: #fff; border-color: transparent; }
.px-chip:disabled { opacity: 0.38; cursor: not-allowed; }
.px-chip.px-icon { min-width: 42px; padding: 7px 8px; }
.px-group .px-chip { background: transparent; border-color: transparent; }
.px-group .px-chip:hover:not(:disabled) { background: var(--px-hover); border-color: transparent; }
.px-group .px-chip.active { background: var(--primary); color: #fff; }
.px-danger { color: var(--danger) !important; }
.px-chip.px-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.12); border-color: var(--danger); }
.px-go { color: var(--success); border-color: rgba(16, 185, 129, 0.35); }
.px-chip.px-big { min-height: 48px; font-size: 1rem; padding: 8px 18px; background: var(--grad-main); color: #fff; border: none; box-shadow: 0 6px 16px var(--primary-glow); }

.px-mini-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 34px; padding: 5px 10px; border-radius: 10px;
  border: 1px solid var(--border-color); background: var(--px-btn); color: var(--text-main);
  font-weight: 600; font-size: 0.78rem; cursor: pointer; white-space: nowrap;
  transition: border-color 0.2s, transform 0.15s, background 0.2s;
}
.px-mini-btn:hover:not(:disabled) { border-color: var(--primary); }
.px-mini-btn:active:not(:disabled) { transform: scale(0.95); }
.px-mini-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.px-mini-btn.active { background: var(--primary); color: #fff; border-color: transparent; }
.px-mini-label { font-family: var(--font-display); font-weight: 700; font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }

/* ── Top bar ─────────────────────────────────────────────────── */
.px-topbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.px-group {
  display: flex; align-items: center; gap: 3px; flex-wrap: wrap;
  background: var(--px-surface); border: 1px solid var(--border-color);
  border-radius: 16px; padding: 4px;
}
.px-group-label { font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; color: var(--text-muted); padding: 0 6px; white-space: nowrap; }


/* ── Main layout ─────────────────────────────────────────────── */
.px-main {
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr) 262px;
  gap: 12px;
  align-items: start;
}
.px-tools, .px-side {
  background: var(--px-surface); border: 1px solid var(--border-color);
  border-radius: 20px; padding: 12px;
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.px-panel-title { font-family: var(--font-display); font-weight: 700; font-size: 0.88rem; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.px-title-row { justify-content: space-between; flex-wrap: wrap; }
.px-head-btns { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.px-head-btns .px-mini-btn { min-width: 32px; padding: 4px 6px; font-size: 0.85rem; }
.px-section { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.px-side .px-section + .px-section { border-top: 1px dashed var(--border-color); padding-top: 10px; }
.px-sub { font-family: var(--font-display); font-weight: 700; font-size: 0.76rem; color: var(--text-faint); }

.px-tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.px-tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 54px; padding: 5px 2px; min-width: 0;
  border-radius: 14px; border: 1px solid var(--border-color);
  background: var(--px-btn); color: var(--text-main);
  font-weight: 600; font-size: 0.7rem; line-height: 1.1; text-align: center; cursor: pointer;
  transition: transform 0.15s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.px-tool .px-emo { font-size: 1.35rem; }
.px-tool:hover { transform: translateY(-1px); border-color: var(--primary); }
.px-tool:active { transform: scale(0.94); }
.px-tool.active { background: var(--grad-main); color: #fff; border-color: transparent; box-shadow: 0 6px 16px var(--primary-glow); }
.px-tool-options { border-top: 1px dashed var(--border-color); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.px-opt { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.px-opt[data-opt="size"] { display: grid; grid-template-columns: repeat(3, 1fr); }
.px-opt[data-opt="size"] .px-mini-label { grid-column: 1 / -1; }
.px-opt[data-opt="fill"] { display: grid; grid-template-columns: 1fr 1fr; }
.px-opt .px-mini-btn { padding: 5px 6px; }
.px-sel-actions { display: grid; grid-template-columns: 1fr 1fr; }
.px-tip { font-size: 0.8rem; line-height: 1.35; color: var(--text-muted); font-weight: 500; margin: 0; }

/* ── Stage ───────────────────────────────────────────────────── */
.px-stage-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.px-stage {
  position: relative; width: 100%; height: clamp(320px, 62vh, 640px);
  border-radius: 20px; overflow: hidden;
  border: 2px solid var(--border-color);
  background: var(--px-stage-bg);
  background-image: radial-gradient(rgba(139, 92, 246, 0.12) 1px, transparent 1px);
  background-size: 18px 18px;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.15);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#pixel-art-view #pixel-art-canvas {
  position: absolute !important; inset: 0 !important;
  width: 100% !important; height: 100% !important; max-width: none !important;
  border: none !important; border-radius: 0 !important; box-shadow: none !important;
  background: transparent !important; display: block;
  image-rendering: pixelated; cursor: crosshair; touch-action: none !important;
}
.px-studio[data-tool="hand"] #pixel-art-canvas, .px-stage.px-space #pixel-art-canvas { cursor: grab !important; }
.px-stage.px-panning #pixel-art-canvas { cursor: grabbing !important; }
.px-studio[data-tool="picker"] #pixel-art-canvas { cursor: copy !important; }
.px-studio[data-tool="bucket"] #pixel-art-canvas, .px-studio[data-tool="replace"] #pixel-art-canvas { cursor: cell !important; }
.px-studio[data-tool="select"] #pixel-art-canvas { cursor: crosshair !important; }
.px-is-playing #pixel-art-canvas { cursor: pointer !important; }
.px-badge {
  position: absolute; top: 10px; left: 10px; z-index: 3; pointer-events: none;
  background: var(--px-overlay); color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 5px 12px; border-radius: 999px;
  font-family: var(--font-display); font-weight: 600; font-size: 0.78rem;
  max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.px-is-playing .px-badge { background: rgba(16, 185, 129, 0.85); }
.px-stage.px-drop { border-color: var(--success); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.35); }
.px-stage.px-drop::after {
  content: '📥 Drop a picture to make it pixel art!'; position: absolute; inset: 0; z-index: 6; pointer-events: none;
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px;
  background: rgba(16, 185, 129, 0.2); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 1.2rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.px-zoombar {
  position: absolute; right: 10px; bottom: 10px; z-index: 3;
  display: flex; gap: 3px; padding: 4px; border-radius: 14px;
  background: var(--px-overlay); border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.px-zoom-btn { min-width: 38px; height: 36px; border-radius: 10px; border: none; background: transparent; color: #fff; font-size: 0.9rem; cursor: pointer; font-weight: 700; }
.px-zoom-btn:hover { background: rgba(255, 255, 255, 0.16); }
.px-zoom-label { min-width: 58px; font-size: 0.8rem; }

/* ── Timeline ────────────────────────────────────────────────── */
.px-timeline {
  background: var(--px-surface); border: 1px solid var(--border-color);
  border-radius: 20px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.px-timeline-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.px-play { min-width: 96px; }
.px-play.active { background: var(--success); color: #fff; border-color: transparent; }
.px-fps { display: inline-flex; align-items: center; gap: 6px; flex: 1 1 160px; min-width: 0; font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; color: var(--text-muted); }
.px-fps input[type="range"], .px-opacity input[type="range"] { flex: 1 1 60px; width: 0; min-width: 60px; accent-color: var(--primary); cursor: pointer; height: 24px; }
.px-studio output { font-family: var(--font-display); font-weight: 700; font-size: 0.9rem; color: var(--primary); min-width: 2.4ch; text-align: center; }
.px-filmstrip {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; min-width: 0;
  scrollbar-width: thin;
}
.px-frame {
  position: relative; flex: 0 0 auto; width: 76px; height: 76px; padding: 4px;
  border-radius: 14px; border: 2px solid var(--border-color); cursor: pointer;
  background-color: #fff;
  background-image: linear-gradient(45deg, #e3e5ee 25%, transparent 25%, transparent 75%, #e3e5ee 75%), linear-gradient(45deg, #e3e5ee 25%, transparent 25%, transparent 75%, #e3e5ee 75%);
  background-size: 12px 12px; background-position: 0 0, 6px 6px;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
}
.px-frame canvas { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; display: block; }
.px-frame:hover { transform: translateY(-2px); border-color: var(--primary); }
.px-frame.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.px-frame-num {
  position: absolute; left: 4px; bottom: 4px; min-width: 20px; padding: 1px 5px; border-radius: 8px;
  background: rgba(15, 17, 26, 0.75); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 0.7rem;
}
.px-frame.active .px-frame-num { background: var(--primary); }
.px-frame-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Colors ──────────────────────────────────────────────────── */
.px-color-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.px-cur {
  position: relative; width: 46px; height: 46px; border-radius: 14px; cursor: pointer;
  border: 3px solid var(--text-main); background: var(--c, #ff4757); padding: 0;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}
.px-cur-2 { width: 36px; height: 36px; border-width: 2px; border-color: var(--text-muted); }
.px-cur-tag {
  position: absolute; right: -6px; bottom: -6px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 0.66rem; font-weight: 700; line-height: 18px; text-align: center;
}
.px-cur-2 .px-cur-tag { background: var(--text-faint); }
.px-mix { position: relative; overflow: hidden; }
.px-mix input[type="color"] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: none; padding: 0; }
.px-select {
  width: 100%; min-height: 38px; padding: 6px 10px; border-radius: 12px;
  border: 1px solid var(--border-color); background: var(--px-btn); color: var(--text-main);
  font-family: var(--font-display); font-weight: 600; font-size: 0.88rem; cursor: pointer;
}
.px-select option { background: var(--px-solid); color: var(--text-main); }
.px-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.px-swatch {
  position: relative; aspect-ratio: 1; width: 100%; min-height: 28px; border-radius: 9px; padding: 0; cursor: pointer;
  background: var(--c); border: 2px solid rgba(0, 0, 0, 0.25);
  transition: transform 0.12s;
}
.px-swatch:hover { transform: scale(1.1); z-index: 1; }
.px-swatch.active { box-shadow: 0 0 0 2px var(--bg-app, #0f111a), 0 0 0 4px var(--primary); transform: scale(1.06); z-index: 1; }
.px-swatch.px-is-2::after {
  content: '2'; position: absolute; right: -4px; bottom: -4px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-faint); color: #fff; font-size: 0.55rem; font-weight: 700; line-height: 14px; text-align: center;
}
.px-recent { min-height: 28px; }
.px-recent .px-faint { grid-column: 1 / -1; align-self: center; }
#pixel-art-view #pixel-custom-color-palette { gap: 6px !important; padding: 2px 0 4px !important; }
#pixel-art-view #pixel-custom-color-palette .color-swatch { width: 30px !important; height: 30px !important; flex: 0 0 auto; }

/* ── Layers ──────────────────────────────────────────────────── */
.px-layer-list { display: flex; flex-direction: column; gap: 5px; }
.px-layer {
  display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 4px 8px 4px 4px;
  border-radius: 12px; border: 1px solid var(--border-color); background: var(--px-btn);
  cursor: pointer; font-family: var(--font-display); font-weight: 600; font-size: 0.85rem; color: var(--text-main);
}
.px-layer:hover { border-color: var(--primary); }
.px-layer.active { border-color: var(--primary); background: rgba(139, 92, 246, 0.16); box-shadow: inset 3px 0 0 var(--primary); }
.px-layer.px-hidden-layer .px-layer-name { opacity: 0.5; text-decoration: line-through; }
.px-eye { width: 34px; height: 34px; border-radius: 10px; border: none; background: transparent; font-size: 1rem; cursor: pointer; flex: 0 0 auto; }
.px-eye:hover { background: var(--px-hover); }
.px-layer-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.px-layer-op { font-size: 0.72rem; color: var(--text-faint); }
.px-opacity { display: flex; align-items: center; gap: 6px; font-family: var(--font-display); font-weight: 700; font-size: 0.8rem; color: var(--text-muted); }

/* ── Flip & Move / Preview ───────────────────────────────────── */
.px-btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.px-btn-grid .px-chip { min-height: 40px; padding: 6px 8px; font-size: 0.82rem; }
.px-nudge { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.px-nudge .px-mini-btn { min-width: 38px; }
.px-preview-wrap {
  align-self: center; width: 128px; height: 128px; border-radius: 14px; overflow: hidden; border: 2px solid var(--border-color);
  background-color: #fff;
  background-image: linear-gradient(45deg, #e3e5ee 25%, transparent 25%, transparent 75%, #e3e5ee 75%), linear-gradient(45deg, #e3e5ee 25%, transparent 25%, transparent 75%, #e3e5ee 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
#px-preview { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; display: block; }

/* ── Submit bar ──────────────────────────────────────────────── */
.px-studio .px-submit-bar {
  display: flex; gap: 8px; flex-wrap: wrap; width: 100%;
  border-top: 1px dashed var(--border-color); padding-top: 14px; margin-top: 2px;
}
.px-studio .px-submit-bar button {
  flex: 1 1 160px; margin: 0; height: 46px; padding: 10px 16px; width: auto;
  border-radius: 14px; font-size: 1rem; font-weight: 700; cursor: pointer;
}
.px-studio .px-submit-bar .btn-gate { background: var(--grad-main); border: none; color: #fff; }

/* ── Modals ──────────────────────────────────────────────────── */
.px-modal {
  position: fixed; inset: 0; z-index: 1600;
  background: rgba(5, 8, 18, 0.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: px-fade 0.18s ease-out;
}
@keyframes px-fade { from { opacity: 0; } to { opacity: 1; } }
.px-modal-card {
  width: min(540px, 100%); max-height: min(88vh, 760px); overflow-y: auto; box-sizing: border-box;
  background: var(--bg-app, #0f111a); color: var(--text-main);
  border: 1px solid var(--border-hover); border-radius: 24px; box-shadow: var(--shadow-lg);
  padding: 18px; display: flex; flex-direction: column; gap: 12px;
  animation: px-pop 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.2);
}
@keyframes px-pop { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }
.px-modal-wide { width: min(780px, 100%); }
.px-modal-small { width: min(420px, 100%); }
.px-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.px-modal-head h3 { font-family: var(--font-display); font-size: 1.3rem; margin: 0; }
.px-modal-x { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border-color); background: transparent; color: var(--text-main); cursor: pointer; font-size: 0.95rem; flex: 0 0 auto; }
.px-modal-body { display: flex; flex-direction: column; gap: 12px; }
.px-modal-text { color: var(--text-muted); font-size: 0.95rem; line-height: 1.45; margin: 0; }
.px-modal-note { color: var(--text-faint); font-size: 0.8rem; line-height: 1.4; margin: 0; }
.px-empty { text-align: center; padding: 18px 0; }
.px-modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.px-modal .px-chip, .px-modal .px-mini-btn { background: rgba(127, 127, 127, 0.08); }
.px-modal .px-chip.px-big { background: var(--grad-main); }
.px-modal .px-mini-btn.active { background: var(--primary); }
.px-check { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; color: var(--text-main); cursor: pointer; }
.px-check input { width: 20px; height: 20px; accent-color: var(--primary); }

.px-size-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.px-size-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; border-radius: 16px;
  border: 1px solid var(--border-color); background: rgba(127, 127, 127, 0.08); color: var(--text-main); cursor: pointer;
}
.px-size-btn b { font-size: 1.05rem; }
.px-size-btn span { font-size: 0.75rem; color: var(--text-muted); }
.px-size-btn:hover { border-color: var(--primary); }
.px-size-btn.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; }
.px-custom-size { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.px-custom-size input, .px-save-row input {
  min-height: 40px; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--border-color);
  background: rgba(127, 127, 127, 0.08); color: var(--text-main); font-family: var(--font-display); font-size: 1rem; box-sizing: border-box;
}
.px-custom-size input { width: 76px; }
.px-save-row { display: flex; gap: 8px; }
.px-save-row input { flex: 1 1 auto; min-width: 0; }

.px-starter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.px-starter {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; border-radius: 18px;
  border: 1px solid var(--border-color); background: rgba(127, 127, 127, 0.06);
}
.px-starter-pic {
  width: 84px; height: 84px; display: flex; align-items: center; justify-content: center; border-radius: 12px;
  background-color: #fff;
  background-image: linear-gradient(45deg, #e3e5ee 25%, transparent 25%, transparent 75%, #e3e5ee 75%), linear-gradient(45deg, #e3e5ee 25%, transparent 25%, transparent 75%, #e3e5ee 75%);
  background-size: 12px 12px; background-position: 0 0, 6px 6px;
}
.px-starter-pic img { width: 72px; height: 72px; object-fit: contain; image-rendering: pixelated; }
.px-starter-emo { font-size: 2.6rem; }
.px-starter-name { font-family: var(--font-display); font-weight: 700; font-size: 0.88rem; text-align: center; }
.px-starter-btns { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }

.px-proj-list { display: flex; flex-direction: column; gap: 6px; }
.px-proj { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 14px; border: 1px solid var(--border-color); }
.px-proj-thumb { width: 48px; height: 48px; border-radius: 10px; image-rendering: pixelated; background: #fff; flex: 0 0 auto; }
.px-proj-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.px-proj-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.px-proj-info span { font-size: 0.78rem; color: var(--text-muted); }

.px-scale-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.px-scale-row .px-mini-btn { min-width: 48px; min-height: 40px; font-size: 0.95rem; }
.px-export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.px-export {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 14px 10px; border-radius: 18px; border: 1px solid var(--border-color);
  background: rgba(127, 127, 127, 0.07); color: var(--text-main); cursor: pointer;
  transition: transform 0.15s, border-color 0.2s;
}
.px-export .px-emo { font-size: 1.8rem; }
.px-export b { font-size: 0.95rem; }
.px-export span:not(.px-emo) { font-size: 0.76rem; color: var(--text-muted); font-family: var(--font-body, sans-serif); }
.px-export:hover { border-color: var(--primary); transform: translateY(-2px); }
.px-keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; font-size: 0.88rem; }
.px-keys kbd {
  font-family: var(--font-display); font-weight: 700; font-size: 0.78rem; padding: 3px 8px; border-radius: 8px;
  border: 1px solid var(--border-color); background: rgba(127, 127, 127, 0.12); white-space: nowrap; justify-self: start;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .px-main { grid-template-columns: 172px minmax(0, 1fr); }
  .px-side {
    grid-column: 1 / -1;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 18px;
  }
  .px-side .px-section + .px-section { border-top: none; padding-top: 0; }

}
@media (hover: none) { .px-hide-touch { display: none !important; } }

@media (max-width: 820px) {
  .px-studio { padding: 12px; gap: 10px; border-radius: 22px; }
  /* Flatten so the order becomes: top bar, canvas, tools, frames, side panels */
  .px-main, .px-stage-col { display: contents; }
  .px-stage { order: 1; height: auto; aspect-ratio: 1 / 1; max-height: 72vh; }
  .px-tools { order: 2; }
  .px-timeline { order: 3; }
  .px-side { order: 4; }
  #px-root { gap: 10px; }
  .px-tool-grid { grid-template-columns: repeat(6, 1fr); }
  .px-topbar .px-group { flex: 1 1 auto; justify-content: center; }
  .px-sel-actions { grid-template-columns: repeat(3, 1fr); }
  .px-swatches { grid-template-columns: repeat(9, 1fr); }
}

@media (max-width: 520px) {
  .px-studio { padding: 8px; border-radius: 18px; }
  .px-topbar { gap: 6px; }
  .px-group { padding: 3px; gap: 2px; }
  .px-chip { padding: 6px 8px; font-size: 0.8rem; min-height: 40px; }
  .px-chip.px-icon { min-width: 38px; }
  .px-hide-sm { display: none; }
  .px-topbar { display: grid; grid-template-columns: 1fr 1fr; }
  .px-topbar .px-group { flex-wrap: nowrap; min-width: 0; }
  .px-topbar .px-mirror { grid-column: 1 / -1; order: 3; }
  .px-topbar .px-menu { grid-column: 1 / -1; order: 4; }
  .px-mirror .px-chip { flex: 1 1 0; }
  .px-menu .px-chip { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; padding: 4px 2px; font-size: 0.66rem; min-height: 46px; }
  .px-menu .px-chip .px-emo { font-size: 1.1rem; }
  .px-tool-grid { grid-template-columns: repeat(4, 1fr); }
  .px-tool { min-height: 52px; font-size: 0.68rem; }
  .px-tool .px-emo { font-size: 1.25rem; }
  .px-stage { border-radius: 14px; max-height: none; }
  .px-badge { font-size: 0.68rem; padding: 3px 9px; top: 6px; left: 6px; }
  .px-zoombar { right: 6px; bottom: 6px; }
  .px-zoom-btn { min-width: 36px; }
  .px-swatches { grid-template-columns: repeat(7, 1fr); }
  .px-frame { width: 64px; height: 64px; }
  .px-frame-actions .px-chip { flex: 1 1 auto; }
  .px-studio .px-submit-bar button { flex-basis: 100%; }
  .px-export-grid, .px-size-grid { grid-template-columns: 1fr 1fr; }
  .px-starter-grid { grid-template-columns: 1fr 1fr; }
  .px-modal-card { padding: 14px; border-radius: 20px; }
  .px-side { grid-template-columns: 1fr; }
}
