/* ============================================================
   MC Studio — Minecraft Texture & Model Studio
   Global Stylesheet
   ============================================================ */

:root {
  /* Dark developer-tool palette */
  --bg-base: #1a1d21;
  --bg-elevated: #22262b;
  --bg-surface: #2a2f35;
  --bg-inset: #141619;
  --bg-hover: #32383f;
  --bg-active: #3a4149;

  /* Borders */
  --border: #3a3f46;
  --border-strong: #4a5159;
  --border-subtle: #2d3137;

  /* Text */
  --text-primary: #e6e8eb;
  --text-secondary: #9ba1a9;
  --text-tertiary: #6b7280;
  --text-muted: #5a616b;

  /* Accents — Minecraft-inspired */
  --accent-green: #5cb85c;
  --accent-green-hover: #6cc26c;
  --accent-green-active: #4ca84c;
  --accent-amber: #f0a020;
  --accent-red: #e05050;
  --accent-blue: #4a90d9;
  --accent-purple: #a060d0;

  /* Minecraft palette */
  --mc-grass: #67c248;
  --mc-dirt: #8b5a2b;
  --mc-stone: #8a8a8a;
  --mc-diamond: #5de7e7;

  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;
  --font-ui: 'Noto Sans TC', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body, #root {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

@media (max-width: 768px) {
  body { font-size: 12px; }
}

@media (max-width: 480px) {
  body { font-size: 11px; }
}

body {
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ============================================================
   App Shell Layout
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-rows: 32px 1fr 24px;
  grid-template-columns: 48px 1fr;
  grid-template-areas:
    "menubar menubar"
    "toolbar  content"
    "statusbar statusbar";
  height: 100vh;
  width: 100vw;
  min-width: 320px;
  min-height: 320px;
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 44px 1fr;
    grid-template-rows: auto 1fr 22px;
  }
}

@media (max-width: 480px) {
  .app-shell {
    grid-template-columns: 40px 1fr;
    grid-template-rows: auto 1fr 20px;
  }
}

.view-content {
  grid-area: content;
  position: relative;
  display: flex;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.view-main {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.view-right {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

@media (max-width: 1024px) {
  .view-right { width: 240px; }
}

@media (max-width: 768px) {
  .view-right { width: 200px; }
}

@media (max-width: 560px) {
  .view-right { width: 100%; position: absolute; bottom: 0; left: 0; right: 0; height: 45%; border-left: none; border-top: 1px solid var(--border); z-index: 20; }
}

/* ============================================================
   Menu Bar
   ============================================================ */

.menu-bar {
  grid-area: menubar;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-height: 32px;
  height: auto;
  padding: 4px 8px;
  gap: 4px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  z-index: 100;
}

@media (max-width: 640px) {
  .menu-bar { font-size: 11px; padding: 2px 6px; }
}

.menu-bar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 16px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--accent-green);
}

.menu-bar__brand-icon {
  width: 16px;
  height: 16px;
  background: var(--accent-green);
  position: relative;
}

.menu-bar__menu-items {
  display: flex;
  height: 100%;
}

.menu-item {
  padding: 4px 10px;
  min-height: 28px;
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
}

@media (max-width: 640px) {
  .menu-item { padding: 3px 6px; font-size: 11px; }
}

.menu-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.menu-item.active {
  color: var(--text-primary);
  background: var(--bg-active);
}

.menu-dropdown {
  position: absolute;
  top: 32px;
  left: 0;
  min-width: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top: none;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  padding: 4px 0;
}

.menu-dropdown__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
}

.menu-dropdown__item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.menu-dropdown__item.disabled {
  color: var(--text-muted);
  cursor: default;
}
.menu-dropdown__item.disabled:hover { background: none; }

.menu-dropdown__shortcut {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 20px;
}

.menu-dropdown__separator {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

/* ============================================================
   Tool Bar (Left)
   ============================================================ */

.tool-bar {
  grid-area: toolbar;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 2px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.tool-bar::-webkit-scrollbar { width: 4px; }
.tool-bar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.tool-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background 0.1s, color 0.1s;
  position: relative;
  touch-action: manipulation;
}

@media (hover: none) and (pointer: coarse) {
  .tool-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  .tool-btn svg { width: 20px; height: 20px; }
}

.tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tool-btn.active {
  background: var(--accent-green);
  color: #fff;
}

.tool-btn svg {
  width: 18px;
  height: 18px;
}

.tool-separator {
  width: 28px;
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

.tool-tooltip {
  position: absolute;
  left: 44px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  white-space: nowrap;
  color: var(--text-primary);
  pointer-events: none;
  opacity: 0;
  z-index: 500;
  box-shadow: var(--shadow-md);
}

.tool-btn:hover .tool-tooltip {
  opacity: 1;
}

/* ============================================================
   Main Canvas Area
   ============================================================ */

.main-area {
  position: relative;
  background: var(--bg-base);
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.canvas-container {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image:
    linear-gradient(45deg, #2a2a2a 25%, transparent 25%),
    linear-gradient(-45deg, #2a2a2a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a2a2a 75%),
    linear-gradient(-45deg, transparent 75%, #2a2a2a 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-color: #1e1e1e;
}

.canvas-wrapper {
  position: relative;
  display: inline-block;
  cursor: crosshair;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.canvas-wrapper canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.canvas-grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  image-rendering: pixelated;
}

/* ============================================================
   Right Panel
   ============================================================ */

.right-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 1024px) {
  .right-panel { width: 240px; }
}

@media (max-width: 768px) {
  .right-panel { width: 200px; }
}

@media (max-width: 560px) {
  .right-panel { width: 100%; border-left: none; }
}

.panel-section {
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.panel-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel-section__header:hover {
  color: var(--text-primary);
}

.panel-section__header-toggle {
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-section__body {
  padding: 8px 10px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   Layers Panel
   ============================================================ */

.layers-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
}

.layer-item:hover {
  background: var(--bg-hover);
}

.layer-item.active {
  background: var(--bg-active);
  border-color: var(--accent-green);
}

.layer-item__thumb {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 2px;
  flex-shrink: 0;
  background-image:
    linear-gradient(45deg, #444 25%, transparent 25%),
    linear-gradient(-45deg, #444 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #444 75%),
    linear-gradient(-45deg, transparent 75%, #444 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
  overflow: hidden;
  position: relative;
}

.layer-item__thumb canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  display: block;
}

.layer-item__name {
  flex: 1;
  font-size: 12px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-item__icons {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.layer-icon-btn {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  color: var(--text-tertiary);
}

.layer-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.layer-icon-btn.active {
  color: var(--accent-green);
}

.layer-icon-btn svg {
  width: 12px;
  height: 12px;
}

.layer-toolbar {
  display: flex;
  gap: 4px;
  padding: 4px 0;
  margin-bottom: 4px;
}

.layer-tool-btn {
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 11px;
}

.layer-tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.layer-tool-btn svg {
  width: 14px;
  height: 14px;
}

/* ============================================================
   Color Picker
   ============================================================ */

.color-picker-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-swatch-large {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-strong);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.color-swatch-large input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.color-values {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.color-hex-input {
  width: 100%;
  padding: 3px 6px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 1px;
}

.palette-color {
  aspect-ratio: 1;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  border-radius: 1px;
}

.palette-color:hover {
  border-color: var(--text-primary);
  transform: scale(1.15);
  z-index: 1;
}

.color-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.color-tab {
  flex: 1;
  padding: 4px;
  font-size: 10px;
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

.color-tab.active {
  background: var(--bg-active);
  border-color: var(--accent-green);
  color: var(--text-primary);
}

/* ============================================================
   Status Bar
   ============================================================ */

.status-bar {
  grid-area: statusbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  height: auto;
  padding: 0 10px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  flex-wrap: wrap;
  gap: 4px;
}

@media (max-width: 640px) {
  .status-bar { font-size: 10px; padding: 2px 6px; gap: 4px; }
  .status-bar__left, .status-bar__right { gap: 8px; flex-wrap: wrap; }
}

.status-bar__left,
.status-bar__right {
  display: flex;
  gap: 16px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-item__label {
  color: var(--text-muted);
}

/* ============================================================
   Home View
   ============================================================ */

.home-view {
  grid-column: 1 / -1;
  grid-row: menubar-end / statusbar-start;
  display: grid;
  grid-template-columns: 1fr 280px;
  background: var(--bg-base);
  overflow: hidden;
}

.home-view--no-sidebar {
  grid-template-columns: 1fr;
}

@media (max-width: 1024px) {
  .home-view { grid-template-columns: 1fr 240px; }
  .home-view--no-sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .home-view { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow-y: auto; }
  .home-view__sidebar { order: 2; border-left: none; border-top: 1px solid var(--border); }
  .home-view__main { order: 1; }
}

@media (max-width: 480px) {
  .home-view__main { padding: 20px; }
  .home-view__sidebar { padding: 20px; }
}

.home-view__main {
  padding: 40px 60px;
  overflow-y: auto;
  min-height: 0;
}

.home-view__sidebar {
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
  min-height: 0;
}

.cloud-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
  line-height: 1.5;
}

.home-hero {
  margin-bottom: 36px;
}

.home-hero__title {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.home-hero__title span {
  color: var(--accent-green);
}

.home-hero__subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.home-section {
  margin-bottom: 32px;
}

.home-section__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-section__title::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--accent-green);
  border-radius: 1px;
}

.new-project-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 1024px) {
  .new-project-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .new-project-grid { grid-template-columns: 1fr; }
}

.project-type-card {
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.project-type-card:hover {
  border-color: var(--accent-green);
  background: var(--bg-surface);
}

.project-type-card:active {
  transform: scale(0.98);
}

.project-type-card__icon {
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  color: var(--accent-green);
}

.project-type-card__icon svg {
  width: 24px;
  height: 24px;
}

.project-type-card__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.project-type-card__desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.recent-projects-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recent-project-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
}

.recent-project-item:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}

.recent-project-item__icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border-radius: 2px;
  color: var(--accent-green);
  flex-shrink: 0;
}

.recent-project-item__icon svg {
  width: 16px;
  height: 16px;
}

.recent-project-item__info {
  flex: 1;
  min-width: 0;
}

.recent-project-item__name {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-project-item__meta {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ============================================================
   New Project Modal
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  width: 560px;
  max-height: 80vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.modal__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal__close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
}

.modal__close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal__body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  padding: 6px 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-green);
}

.form-select {
  padding: 6px 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.size-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.size-preset {
  padding: 4px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  cursor: pointer;
}

.size-preset:hover {
  border-color: var(--accent-green);
  color: var(--text-primary);
}

.size-preset.active {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #fff;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  white-space: nowrap;
  touch-action: manipulation;
  min-height: 28px;
}

.btn--primary {
  background: var(--accent-green);
  border: 1px solid var(--accent-green);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-green-hover);
  border-color: var(--accent-green-hover);
}

.btn--primary:active {
  background: var(--accent-green-active);
}

.btn--secondary {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn--secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn--danger {
  background: transparent;
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
}

.btn--danger:hover {
  background: rgba(224, 80, 80, 0.1);
}

.btn--sm {
  padding: 3px 8px;
  font-size: 11px;
}

.btn--icon {
  padding: 4px;
  width: 26px;
  height: 26px;
}

.btn--icon svg {
  width: 14px;
  height: 14px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================================
   Block View — 3D + 2D split
   ============================================================ */

.block-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.block-view > * { flex-shrink: 0; }
.block-view > :first-child { flex: 1; min-height: 0; }

.block-view__viewport {
  position: relative;
  background: var(--bg-base);
  overflow: hidden;
}

.block-view__canvas-area {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#three-canvas {
  display: block;
  image-rendering: pixelated;
}

.viewport-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.viewport-toolbar-right {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.view-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 10px;
  cursor: pointer;
  touch-action: manipulation;
}

@media (hover: none) and (pointer: coarse) {
  .view-btn { width: 40px; height: 40px; font-size: 11px; }
}

.view-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.view-btn.active {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #fff;
}

.face-selector {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  z-index: 10;
}

.face-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 50px;
}

.face-btn:hover {
  border-color: var(--accent-green);
}

.face-btn.active {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #fff;
}

.face-btn__label {
  font-size: 10px;
  font-weight: 500;
}

.face-btn__preview {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  overflow: hidden;
  image-rendering: pixelated;
}

.face-btn__preview canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

/* Pixel Editor Drawer (bottom of block view) */
.block-drawer {
  height: 280px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 768px) {
  .block-drawer { height: 220px; }
}

@media (max-width: 480px) {
  .block-drawer { height: 180px; }
}

.block-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.block-drawer__body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.block-drawer__canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image:
    linear-gradient(45deg, #2a2a2a 25%, transparent 25%),
    linear-gradient(-45deg, #2a2a2a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a2a2a 75%),
    linear-gradient(-45deg, transparent 75%, #2a2a2a 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-color: #1e1e1e;
  overflow: auto;
  padding: 20px;
}

.block-drawer__options {
  width: 200px;
  padding: 10px;
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

/* ============================================================
   Texture Links Panel
   ============================================================ */

.texture-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.texture-link-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
}

.texture-link-item:hover {
  border-color: var(--accent-green);
}

.texture-link-item.active {
  border-color: var(--accent-green);
  background: var(--bg-active);
}

.texture-link-item__faces {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-green);
}

.texture-link-item__name {
  flex: 1;
  color: var(--text-primary);
}

/* ============================================================
   Creature View
   ============================================================ */

.creature-view {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr auto;
}

.creature-viewport {
  position: relative;
  overflow: hidden;
}

.creature-timeline {
  height: 160px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 768px) {
  .creature-timeline { height: 140px; }
}

.timeline-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
}

.timeline-ruler {
  height: 22px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.timeline-tracks {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
}

.timeline-track {
  display: flex;
  align-items: center;
  height: 28px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.timeline-track__name {
  width: 120px;
  flex-shrink: 0;
  padding: 0 8px;
  font-size: 11px;
  color: var(--text-secondary);
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  height: 100%;
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-track__keyframes {
  flex: 1;
  position: relative;
  height: 100%;
}

.keyframe-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: var(--accent-amber);
  border: 1px solid #fff;
  cursor: pointer;
}

.keyframe-dot.selected {
  background: var(--accent-red);
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-red);
  z-index: 5;
  pointer-events: none;
}

.anim-select {
  padding: 3px 8px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 11px;
}

/* ============================================================
   Hierarchy Panel
   ============================================================ */

.hierarchy-tree {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 12px;
}

.hierarchy-node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.hierarchy-node:hover {
  background: var(--bg-hover);
}

.hierarchy-node.selected {
  background: var(--bg-active);
  color: var(--accent-green);
}

.hierarchy-node__toggle {
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 9px;
  flex-shrink: 0;
}

.hierarchy-node__icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hierarchy-node__icon svg {
  width: 12px;
  height: 12px;
}

.hierarchy-node__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hierarchy-children {
  margin-left: 14px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-left: 1px solid var(--border-subtle);
  padding-left: 2px;
}

/* ============================================================
   Properties Panel
   ============================================================ */

.props-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.props-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.props-group__title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.prop-row {
  display: grid;
  grid-template-columns: 50px 1fr 1fr 1fr;
  gap: 4px;
  align-items: center;
}

.prop-row--wide {
  grid-template-columns: 50px 1fr;
}

.prop-label {
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.prop-input {
  padding: 3px 5px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 11px;
  font-family: var(--font-mono);
  text-align: right;
  outline: none;
  width: 100%;
}

.prop-input:focus {
  border-color: var(--accent-green);
}

.prop-axis {
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: center;
}

/* ============================================================
   Explorer (Resource Pack)
   ============================================================ */

.explorer-panel {
  position: absolute;
  left: 48px;
  top: 0;
  bottom: 0;
  width: 200px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  z-index: 5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.explorer-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.explorer-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.file-tree {
  font-size: 12px;
}

.file-tree__item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  cursor: pointer;
}

.file-tree__item:hover {
  background: var(--bg-hover);
}

.file-tree__item.active {
  background: var(--bg-active);
}

.file-tree__item--folder {
  color: var(--text-primary);
  font-weight: 500;
}

.file-tree__item--file {
  color: var(--text-secondary);
}

.file-tree__indent {
  width: 14px;
  flex-shrink: 0;
}

.file-tree__icon {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.file-tree__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-tree__children {
  overflow: hidden;
}

/* ============================================================
   Toggle & Switch
   ============================================================ */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.toggle-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.toggle-switch {
  position: relative;
  width: 32px;
  height: 16px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  background: var(--text-tertiary);
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}

.toggle-switch.on {
  background: var(--accent-green);
  border-color: var(--accent-green);
}

.toggle-switch.on::after {
  transform: translateX(16px);
  background: #fff;
}

/* ============================================================
   Zoom Controls
   ============================================================ */

.zoom-controls {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  z-index: 10;
}

.zoom-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
}

.zoom-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.zoom-level {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  min-width: 50px;
  text-align: center;
}

/* ============================================================
   Tab Bar (View modes)
   ============================================================ */

.view-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
  height: 28px;
  align-items: flex-end;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.view-tab {
  padding: 5px 14px;
  font-size: 11px;
  color: var(--text-tertiary);
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin-right: 2px;
  position: relative;
  top: 1px;
}

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

.view-tab.active {
  background: var(--bg-base);
  border-color: var(--border);
  color: var(--text-primary);
  font-weight: 500;
}

/* ============================================================
   Symmetry / Outline / Noise toolbar
   ============================================================ */

.mc-helpers {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mc-helpers__group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.mc-helpers__title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mc-helpers__row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.mc-helper-btn {
  padding: 3px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  flex: 1;
}

.mc-helper-btn:hover {
  border-color: var(--accent-green);
  color: var(--text-primary);
}

.mc-helper-btn.active {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #fff;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.slider-row input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  background: var(--bg-inset);
  border-radius: 2px;
  outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--accent-green);
  border-radius: 50%;
  cursor: pointer;
}

.slider-value {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  min-width: 28px;
  text-align: right;
}

/* ============================================================
   Touch / Pointer Event Helpers
   ============================================================ */

.no-touch-scroll {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.touch-manipulation {
  touch-action: manipulation;
}

/* Prevent browser zoom on double-tap for interactive elements */
button, .btn, .tool-btn, .view-btn, .layer-icon-btn, .mc-helper-btn,
.color-tab, .size-preset, .toggle-switch, .face-btn, .hierarchy-node {
  touch-action: manipulation;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #5a6169;
}

/* ============================================================
   Toast
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 12px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease-out;
}

.toast--success { border-color: var(--accent-green); }
.toast--error { border-color: var(--accent-red); }
.toast--warning { border-color: var(--accent-amber); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Misc
   ============================================================ */

.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.w-full { width: 100%; }
.text-mono { font-family: var(--font-mono); }
.text-xs { font-size: 10px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

/* ============================================================
   Workspace Switcher (in menu bar)
   ============================================================ */

.workspace-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 8px;
  padding: 2px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

@media (max-width: 640px) {
  .workspace-switcher { margin: 2px 4px; font-size: 10px; }
  .workspace-switcher__btn { padding: 3px 6px; font-size: 10px; }
}

.workspace-switcher__btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-tertiary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.workspace-switcher__btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.workspace-switcher__btn.active {
  color: var(--text-primary);
  background: var(--bg-surface);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* ============================================================
   Mode Switch (Beginner/Advanced)
   ============================================================ */

.mode-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: 12px;
  padding: 2px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

@media (max-width: 640px) {
  .mode-switch { margin-right: 6px; }
  .mode-switch__label { font-size: 9px; padding: 2px 6px; }
}

.mode-switch__label {
  padding: 2px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
}

.mode-switch__label:hover {
  color: var(--text-secondary);
}

.mode-switch__label.active {
  background: var(--accent-blue);
  color: white;
}

/* ============================================================
   Responsive & Mobile / Tablet Layout
   ============================================================ */

/* Panel toggle buttons */
.panel-toggle-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  z-index: 5;
}

.panel-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Left panel collapse toggle */
.left-panel-toggle {
  position: absolute;
  left: 0;
  top: 12px;
  z-index: 20;
  transform: translateX(100%);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Right panel collapse toggle */
.right-panel-toggle {
  position: absolute;
  right: 0;
  top: 12px;
  z-index: 20;
  transform: translateX(-100%);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

/* Collapsed states */
.tool-bar.collapsed {
  display: none;
}

.right-panel.collapsed {
  display: none;
}

/* Mobile bottom toolbar (for touch devices) */
.mobile-toolbar {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 4px 8px;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  z-index: 15;
  -webkit-overflow-scrolling: touch;
}

.mobile-toolbar .tool-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  flex-shrink: 0;
}

.mobile-toolbar .tool-btn svg {
  width: 22px;
  height: 22px;
}

/* Touch-optimized mode */
.touch-mode .tool-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

.touch-mode .tool-btn svg {
  width: 20px;
  height: 20px;
}

.touch-mode .btn {
  min-height: 36px;
  padding: 8px 16px;
}

.touch-mode .view-btn {
  width: 40px;
  height: 40px;
}

.touch-mode .mc-helper-btn {
  padding: 8px 10px;
  font-size: 11px;
}

.touch-mode .layer-icon-btn {
  width: 24px;
  height: 24px;
}

.touch-mode .layer-icon-btn svg {
  width: 16px;
  height: 16px;
}

.touch-mode .layer-tool-btn {
  height: 32px;
}

.touch-mode .zoom-btn {
  width: 32px;
  height: 32px;
  font-size: 16px;
}

.touch-mode .toggle-switch {
  width: 40px;
  height: 22px;
  border-radius: 11px;
}

.touch-mode .toggle-switch::after {
  width: 18px;
  height: 18px;
}

.touch-mode .toggle-switch.on::after {
  transform: translateX(18px);
}

/* Reset layout button */
.reset-layout-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 10px;
  color: var(--text-tertiary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
}

.reset-layout-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Mobile: status bar wraps better */
@media (max-width: 640px) {
  .status-bar__right .status-item:nth-child(n+2) {
    display: none;
  }
  .menu-bar__brand span:last-child {
    display: none;
  }
  .menu-bar__menu-items {
    order: 3;
    width: 100%;
  }
  .workspace-switcher {
    order: 2;
  }
  .mode-switch {
    order: 3;
  }
}

/* Tablet portrait — left toolbar becomes horizontal at top or stays narrow */
@media (max-width: 768px) {
  .new-project-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .home-view {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow-y: auto;
  }
  .home-view__sidebar {
    order: 2;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .home-view__main { order: 1; }
}

/* Mobile phone — bottom toolbar appears */
@media (hover: none) and (pointer: coarse) {
  .mobile-toolbar {
    display: flex;
  }
  .main-area {
    padding-bottom: 56px;
  }
  .tool-bar {
    display: none;
  }
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "menubar"
      "content"
      "statusbar";
  }
}

/* Touch mode button larger */
.touch-mode .size-preset {
  min-height: 32px;
  padding: 6px 12px;
}

.touch-mode .form-input,
.touch-mode .form-select {
  min-height: 36px;
}

.touch-mode .color-tab {
  min-height: 28px;
}

.touch-mode .panel-section__header {
  padding: 10px 12px;
  font-size: 12px;
}

.touch-mode .panel-section__body {
  padding: 10px 12px;
}

/* Pressure indicator */
.pressure-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

.pressure-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-inset);
  border-radius: 2px;
  overflow: hidden;
}

.pressure-bar__fill {
  height: 100%;
  background: var(--accent-amber);
  border-radius: 2px;
  transition: width 0.05s linear;
}

/* Image to pixel converter panel */
.pixel-convert-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pixel-convert-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pixel-convert-preview__box {
  aspect-ratio: 1;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.pixel-convert-preview__label {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pixel-convert-preview__box canvas {
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
}

.pixel-convert-settings {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pixel-convert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pixel-convert-row label {
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.pixel-convert-row input[type="range"] {
  flex: 1;
}

.auth-error {
  color: var(--accent-red);
  font-size: 12px;
  margin-top: 4px;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-right: 8px;
}

.btn--ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 11px;
}

.gui-lib-hint {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 8px;
}

.gui-lib-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.gui-lib-card {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: grab;
  text-align: center;
}

.gui-lib-card:hover,
.gui-lib-card.active {
  border-color: var(--accent-green);
}

.gui-lib-card__preview {
  width: 100%;
  height: 20px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  margin: 0 auto 4px;
  background: repeating-conic-gradient(var(--bg-surface) 0% 25%, var(--bg-inset) 0% 50%) 0 0 / 8px 8px;
}

.gui-lib-card__name {
  font-size: 11px;
  color: var(--text-primary);
}

.gui-lib-card__desc {
  font-size: 9px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.gui-props {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.gui-prop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-secondary);
  margin: 4px 0;
}

.gui-mono {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-size: 10px;
}

.gui-color {
  width: 28px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
}

.gui-layer-list {
  margin-top: 10px;
}

.gui-layer-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 6px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.gui-layer-item:hover,
.gui-layer-item.active {
  background: var(--bg-hover);
}

.gui-mode-toggle {
  display: flex;
  gap: 6px;
}

.gui-mode-toggle .mc-helper-btn {
  flex: 1;
}

.gui-widget-overlay {
  position: absolute;
  inset: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.gui-hud {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  background: rgba(20, 22, 25, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  pointer-events: none;
  z-index: 4;
}

.canvas-wrapper {
  position: relative;
}
