/* ============================================================
   Gopher Diorama Builder — Stylesheet
   Torrington Gopher Hole Museum Interactive Experience
   ============================================================
   Color Palette
     Parchment (bg):    #F5E6D3
     Golden Wheat:      #8B6914
     Prairie Green:     #4A7C59
     Barn Red:          #C73E1D
     Rich Earth Brown:  #3D2B1F
     Linen (light txt): #FAF0E6
     Canvas BG:         #E8DCC8
   ============================================================ */

/* ----- Custom Properties ----- */
:root {
  --color-parchment: #F5E6D3;
  --color-wheat: #8B6914;
  --color-wheat-light: #A8841A;
  --color-wheat-dark: #6E5410;
  --color-prairie: #4A7C59;
  --color-prairie-light: #5E9A70;
  --color-prairie-dark: #3A6347;
  --color-barn-red: #C73E1D;
  --color-barn-red-light: #D95A3A;
  --color-barn-red-dark: #A03218;
  --color-earth: #3D2B1F;
  --color-earth-light: #554030;
  --color-linen: #FAF0E6;
  --color-canvas-bg: #E8DCC8;

  --font-heading: "Fredoka", "Nunito", "Rounded Mplus 1c", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --panel-left-width: 240px;
  --panel-right-width: 260px;
  --toolbar-height: 52px;
  --bottombar-height: 56px;

  --shadow-sm: 0 1px 3px rgba(61, 43, 31, 0.15);
  --shadow-md: 0 4px 12px rgba(61, 43, 31, 0.18);
  --shadow-lg: 0 8px 28px rgba(61, 43, 31, 0.22);
  --shadow-inset-frame: inset 0 4px 16px rgba(61, 43, 31, 0.35),
    inset 0 1px 4px rgba(61, 43, 31, 0.2);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;
}

/* ----- Reset & Base ----- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-earth);
  background-color: var(--color-parchment);
  overflow: hidden; /* Prevent body scroll; panels scroll internally */
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3, h4, h5, h6,
.heading {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-earth);
}

a {
  color: var(--color-wheat);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-wheat-light);
}

img {
  max-width: 100%;
  height: auto;
}

/* ----- Selection ----- */
::selection {
  background-color: var(--color-wheat);
  color: var(--color-linen);
}

/* ----- Scrollbar (Webkit) ----- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background-color: rgba(139, 105, 20, 0.35);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(139, 105, 20, 0.55);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 105, 20, 0.35) transparent;
}

/* ============================================================
   APP SHELL / LAYOUT
   ============================================================ */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app-body {
  display: flex;
  flex: 1 1 0%;
  min-height: 0;
  overflow: hidden;
}

/* ============================================================
   TOOLBAR
   ============================================================ */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--toolbar-height);
  padding: 0 12px;
  background:
    /* Subtle wood-grain texture via repeating gradients */
    repeating-linear-gradient(
      87deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.018) 3px,
      rgba(255, 255, 255, 0.018) 5px
    ),
    repeating-linear-gradient(
      93deg,
      transparent,
      transparent 7px,
      rgba(0, 0, 0, 0.03) 7px,
      rgba(0, 0, 0, 0.03) 9px
    ),
    linear-gradient(180deg, #4a382a 0%, var(--color-earth) 40%, #352117 100%);
  border-bottom: 3px solid var(--color-wheat);
  flex-shrink: 0;
}

.toolbar .brand {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-linen);
  white-space: nowrap;
  margin-right: 12px;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.toolbar .brand .brand-icon {
  margin-right: 4px;
}

/* Toolbar button group */
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
}

.toolbar-group + .toolbar-group {
  border-left: 1px solid rgba(250, 240, 230, 0.15);
  margin-left: 4px;
  padding-left: 8px;
}

.toolbar-spacer {
  flex: 1 1 auto;
}

/* Toolbar buttons */
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-linen);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
  line-height: 1;
}

.toolbar-btn i,
.toolbar-btn svg {
  font-size: 1rem;
  width: 16px;
  height: 16px;
}

.toolbar-btn:hover {
  background: rgba(139, 105, 20, 0.3);
  border-color: var(--color-wheat);
  color: #fff;
}

.toolbar-btn:active {
  transform: scale(0.95);
  background: rgba(139, 105, 20, 0.5);
}

.toolbar-btn.active {
  background: var(--color-wheat);
  color: var(--color-earth);
  border-color: var(--color-wheat-light);
}

.toolbar-btn:disabled,
.toolbar-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Toolbar label (e.g. zoom %) */
.toolbar-label {
  font-size: 0.75rem;
  color: rgba(250, 240, 230, 0.7);
  padding: 0 4px;
  white-space: nowrap;
  user-select: none;
}

/* ============================================================
   ASSET PANEL (left sidebar)
   ============================================================ */

.asset-panel {
  width: var(--panel-left-width);
  min-width: var(--panel-left-width);
  display: flex;
  flex-direction: column;
  background-color: var(--color-parchment);
  border-right: 1px solid rgba(61, 43, 31, 0.12);
  overflow: hidden;
  flex-shrink: 0;
  transition: width var(--transition-base), min-width var(--transition-base);
}

/* Drag handle: hidden on desktop, shown on mobile via media query */
.asset-panel .drag-handle {
  display: none;
}

/* Panel heading */
.asset-panel .panel-heading {
  padding: 10px 14px 6px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-earth);
  border-bottom: 1px solid rgba(61, 43, 31, 0.08);
  flex-shrink: 0;
}

/* ----- Pill Tabs ----- */
.asset-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 10px 6px;
  flex-shrink: 0;
}

.asset-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-earth);
  background: rgba(61, 43, 31, 0.06);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  line-height: 1.3;
}

.asset-tab i,
.asset-tab svg {
  font-size: 0.85rem;
}

.asset-tab:hover {
  background: rgba(74, 124, 89, 0.15);
  color: var(--color-prairie-dark);
}

.asset-tab.active {
  background: var(--color-prairie);
  color: #fff;
  border-color: var(--color-prairie-dark);
}

/* Search within panel */
.asset-search {
  padding: 4px 10px 8px;
  flex-shrink: 0;
}

.asset-search input {
  width: 100%;
  padding: 6px 10px 6px 32px;
  font-size: 0.8rem;
  border: 1px solid rgba(61, 43, 31, 0.15);
  border-radius: var(--radius-pill);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%233D2B1F' opacity='0.4' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.414-1.414l-3.85-3.85zm-5.242.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E")
    10px center / 14px no-repeat,
    #fff;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.asset-search input:focus {
  border-color: var(--color-prairie);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.18);
}

/* ----- Asset Grid ----- */
.asset-grid {
  flex: 1 1 0%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 10px 14px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  align-content: start;
}

.asset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border: 1px solid rgba(61, 43, 31, 0.1);
  border-radius: var(--radius-md);
  padding: 6px;
  cursor: grab;
  user-select: none;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    border-color var(--transition-fast);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.asset-card:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
  border-color: var(--color-wheat);
  z-index: 2;
}

.asset-card:active {
  cursor: grabbing;
  transform: scale(1.02);
}

.asset-card .asset-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--color-canvas-bg);
  pointer-events: none;
}

.asset-card .asset-name {
  margin-top: 4px;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--color-earth);
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Drag ghost styling */
.asset-card.dragging {
  opacity: 0.5;
}

/* Category badge on asset card */
.asset-card .asset-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  background: var(--color-prairie);
  color: #fff;
  font-weight: 600;
  line-height: 1.4;
}

/* ============================================================
   CANVAS AREA
   ============================================================ */

.canvas-area {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--color-canvas-bg);
  min-width: 0;
  position: relative;
  overflow: hidden;
}

#canvas-container {
  position: relative;
  box-shadow: var(--shadow-inset-frame);
  border: 6px solid var(--color-earth);
  border-image:
    /* Decorative wood-look frame */
    linear-gradient(
      135deg,
      #5c432f 0%,
      #7a5c3f 20%,
      #3D2B1F 40%,
      #5c432f 60%,
      #7a5c3f 80%,
      #3D2B1F 100%
    ) 1;
  background: #fff;
  overflow: hidden;
}

/* Additional decorative frame overlay */
#canvas-container::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  box-shadow:
    inset 0 0 30px rgba(61, 43, 31, 0.15),
    inset 0 0 6px rgba(61, 43, 31, 0.1);
}

/* Konva stage sits inside */
#canvas-container .konvajs-content {
  display: block !important;
}

/* Grid overlay (toggled by JS) */
.canvas-grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background-image:
    linear-gradient(rgba(61, 43, 31, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(61, 43, 31, 0.06) 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.canvas-grid-overlay.visible {
  opacity: 1;
}

/* Drop zone indicator */
.canvas-area.drag-over::after {
  content: "Drop to add";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--color-wheat);
  background: rgba(245, 230, 211, 0.7);
  border: 3px dashed var(--color-wheat);
  border-radius: var(--radius-md);
  z-index: 20;
  pointer-events: none;
}

/* Canvas info bar (coordinates / zoom) */
.canvas-info {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: rgba(61, 43, 31, 0.5);
  background: rgba(255, 255, 255, 0.7);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  backdrop-filter: blur(4px);
  z-index: 15;
  pointer-events: none;
  user-select: none;
}

/* ============================================================
   PROPERTIES PANEL (right sidebar)
   ============================================================ */

.properties-panel {
  width: var(--panel-right-width);
  min-width: var(--panel-right-width);
  display: flex;
  flex-direction: column;
  background-color: var(--color-parchment);
  border-left: 1px solid rgba(61, 43, 31, 0.12);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  transition: width var(--transition-base), min-width var(--transition-base),
    opacity var(--transition-base);
}

/* Mobile close button in properties header */
.prop-panel-close-btn {
  display: none; /* hidden on desktop */
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--color-earth);
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.prop-panel-close-btn:hover {
  opacity: 1;
}

.panel-heading.properties-header-mobile {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Hidden state when nothing is selected */
.properties-panel.empty {
  opacity: 0.4;
  pointer-events: none;
}

.properties-panel .panel-heading {
  padding: 12px 14px 8px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-earth);
  border-bottom: 1px solid rgba(61, 43, 31, 0.08);
  flex-shrink: 0;
}

.empty-state,
.properties-panel .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: rgba(61, 43, 31, 0.4);
  font-size: 0.85rem;
}

.empty-state i,
.empty-state svg,
.properties-panel .empty-state i,
.properties-panel .empty-state svg {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.3;
}

/* Property groups */
.prop-group {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(61, 43, 31, 0.06);
}

.prop-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(61, 43, 31, 0.5);
  margin-bottom: 8px;
}

.prop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.prop-row:last-child {
  margin-bottom: 0;
}

.prop-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-earth);
  white-space: nowrap;
  min-width: 60px;
}

/* Themed form controls */
.prop-input {
  flex: 1;
  padding: 5px 8px;
  font-size: 0.8rem;
  border: 1px solid rgba(61, 43, 31, 0.18);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-earth);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.prop-input:focus {
  border-color: var(--color-wheat);
  box-shadow: 0 0 0 3px rgba(139, 105, 20, 0.15);
}

/* Range / slider */
.prop-range {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(61, 43, 31, 0.12);
  outline: none;
  transition: background var(--transition-fast);
}

.prop-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-wheat);
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.prop-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: var(--shadow-md);
}

.prop-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-wheat);
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

/* Range value indicator */
.prop-range-value {
  font-size: 0.72rem;
  color: rgba(61, 43, 31, 0.6);
  min-width: 32px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Checkbox — themed toggle */
.prop-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.prop-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.prop-toggle .toggle-track {
  position: absolute;
  inset: 0;
  background: rgba(61, 43, 31, 0.15);
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.prop-toggle .toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.prop-toggle input:checked + .toggle-track {
  background: var(--color-prairie);
}

.prop-toggle input:checked + .toggle-track::after {
  transform: translateX(16px);
}

.prop-toggle input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.25);
}

/* Color picker swatch */
.prop-color {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(61, 43, 31, 0.15);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}

.prop-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.prop-color::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

/* Prop action buttons */
.prop-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(61, 43, 31, 0.15);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-earth);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast);
}

.prop-btn:hover {
  background: rgba(139, 105, 20, 0.08);
  border-color: var(--color-wheat);
}

.prop-btn.active {
  background: var(--color-wheat);
  color: #fff;
  border-color: var(--color-wheat);
}

/* ============================================================
   BOTTOM BAR
   ============================================================ */

.bottom-bar {
  position: sticky;
  bottom: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background:
    repeating-linear-gradient(
      87deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.015) 3px,
      rgba(255, 255, 255, 0.015) 5px
    ),
    linear-gradient(0deg, #352117 0%, var(--color-earth) 60%, #4a382a 100%);
  border-top: 2px solid var(--color-wheat);
  flex-shrink: 0;
  min-height: var(--bottombar-height);
}

.bottom-bar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bottom-bar-group + .bottom-bar-group {
  margin-left: 6px;
  padding-left: 10px;
  border-left: 1px solid rgba(250, 240, 230, 0.15);
}

/* Bottom bar "more" toggle: hidden on desktop */
.bottom-bar-more-toggle {
  display: none;
}

/* Bottom bar buttons inherit from utility classes below */

/* ============================================================
   GALLERY VIEW
   ============================================================ */

.gallery-view {
  padding: 24px;
  overflow-y: auto;
}

.gallery-heading {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  text-align: center;
  color: var(--color-earth);
  margin-bottom: 24px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* Polaroid-style card */
.gallery-card {
  background: #fff;
  border: 1px solid rgba(61, 43, 31, 0.08);
  border-radius: 2px;
  padding: 12px 12px 8px;
  box-shadow: var(--shadow-md);
  transition:
    transform var(--transition-base),
    box-shadow var(--transition-base);
  cursor: pointer;
}

.gallery-card:hover {
  transform: translateY(-4px) rotate(-1deg);
  box-shadow: var(--shadow-lg);
}

/* Alternating hover rotations */
.gallery-card:nth-child(2n):hover {
  transform: translateY(-4px) rotate(1deg);
}

.gallery-card:nth-child(3n):hover {
  transform: translateY(-5px) rotate(-1.5deg);
}

.gallery-card:nth-child(5n):hover {
  transform: translateY(-3px) rotate(2deg);
}

.gallery-card .gallery-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--color-canvas-bg);
  display: block;
}

.gallery-card .gallery-caption {
  padding: 10px 4px 4px;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--color-earth);
  text-align: center;
}

.gallery-card .gallery-author {
  font-size: 0.72rem;
  color: rgba(61, 43, 31, 0.5);
  text-align: center;
}

.gallery-card .gallery-likes {
  font-size: 0.72rem;
  color: var(--color-barn-red);
  text-align: center;
  margin-top: 4px;
}

/* Featured badge */
.gallery-card.featured {
  border: 2px solid var(--color-wheat);
  position: relative;
}

.gallery-card.featured::after {
  content: "\2605 Featured";
  position: absolute;
  top: -10px;
  right: 12px;
  background: var(--color-wheat);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  letter-spacing: 0.03em;
}

/* ============================================================
   WELCOME OVERLAY / ONBOARDING
   ============================================================ */

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(61, 43, 31, 0.85);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.4s ease;
}

.welcome-overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.welcome-card {
  background: var(--color-parchment);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 520px;
  width: 90%;
  padding: 32px;
  position: relative;
  text-align: center;
  animation: slideUp 0.45s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(32px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcome-card .welcome-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  color: var(--color-earth);
  margin-bottom: 8px;
}

.welcome-card .welcome-subtitle {
  font-size: 0.9rem;
  color: rgba(61, 43, 31, 0.65);
  margin-bottom: 20px;
}

.welcome-card .welcome-illustration {
  max-width: 200px;
  margin: 0 auto 20px;
}

.welcome-card .welcome-step {
  font-size: 0.88rem;
  color: var(--color-earth);
  margin-bottom: 18px;
  line-height: 1.6;
}

/* Step dots */
.welcome-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.welcome-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(61, 43, 31, 0.15);
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.welcome-dot.active {
  background: var(--color-wheat);
  transform: scale(1.3);
}

/* Skip button */
.welcome-skip {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(61, 43, 31, 0.45);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.welcome-skip:hover {
  color: var(--color-earth);
  background: rgba(61, 43, 31, 0.06);
}

/* Nav buttons */
.welcome-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* ============================================================
   MODALS — Bootstrap Overrides
   ============================================================ */

.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  background: linear-gradient(135deg, var(--color-wheat) 0%, var(--color-prairie) 100%);
  color: #fff;
  border-bottom: none;
  padding: 16px 20px;
}

.modal-header .modal-title {
  font-family: var(--font-heading);
  font-weight: 700;
}

.modal-header .btn-close {
  filter: brightness(0) invert(1);
  opacity: 0.8;
}

.modal-header .btn-close:hover {
  opacity: 1;
}

.modal-body {
  padding: 20px;
  background: var(--color-parchment);
}

.modal-footer {
  background: var(--color-parchment);
  border-top: 1px solid rgba(61, 43, 31, 0.08);
  padding: 12px 20px;
}

/* Share-specific */
.share-modal .share-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid rgba(61, 43, 31, 0.12);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.share-modal .share-link input {
  flex: 1;
  border: none;
  font-size: 0.85rem;
  background: transparent;
  outline: none;
}

.share-modal .share-social {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.share-modal .share-social-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.2rem;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.share-modal .share-social-btn:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

/* Print preview */
.print-modal .print-preview {
  background: #fff;
  border: 1px solid rgba(61, 43, 31, 0.1);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
}

.print-modal .print-preview img {
  max-width: 100%;
  border: 1px solid rgba(61, 43, 31, 0.08);
}

.print-modal .print-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.print-modal .print-option {
  padding: 14px;
  border: 2px solid rgba(61, 43, 31, 0.1);
  border-radius: var(--radius-md);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.print-modal .print-option:hover {
  border-color: var(--color-wheat);
  background: rgba(139, 105, 20, 0.04);
}

.print-modal .print-option.selected {
  border-color: var(--color-wheat);
  background: rgba(139, 105, 20, 0.08);
}

.print-modal .print-option .price {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-wheat);
}

/* My Dioramas modal */
.diorama-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.diorama-list-item {
  background: #fff;
  border: 1px solid rgba(61, 43, 31, 0.1);
  border-radius: var(--radius-md);
  padding: 8px;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.diorama-list-item:hover {
  border-color: var(--color-wheat);
  box-shadow: var(--shadow-md);
}

.diorama-list-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.diorama-list-item .diorama-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-earth);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   UTILITY BUTTON CLASSES
   ============================================================ */

/* Prairie (golden wheat) button */
.btn-prairie {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-wheat);
  border: 1px solid var(--color-wheat-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  text-decoration: none;
  line-height: 1.4;
}

.btn-prairie:hover {
  background: var(--color-wheat-light);
  box-shadow: var(--shadow-sm);
  color: #fff;
}

.btn-prairie:active {
  transform: scale(0.97);
  background: var(--color-wheat-dark);
}

/* Barn Red button */
.btn-barn-red {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-barn-red);
  border: 1px solid var(--color-barn-red-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  text-decoration: none;
  line-height: 1.4;
}

.btn-barn-red:hover {
  background: var(--color-barn-red-light);
  box-shadow: var(--shadow-sm);
  color: #fff;
}

.btn-barn-red:active {
  transform: scale(0.97);
  background: var(--color-barn-red-dark);
}

/* Prairie Green button */
.btn-prairie-green {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-prairie);
  border: 1px solid var(--color-prairie-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  text-decoration: none;
  line-height: 1.4;
}

.btn-prairie-green:hover {
  background: var(--color-prairie-light);
  box-shadow: var(--shadow-sm);
  color: #fff;
}

.btn-prairie-green:active {
  transform: scale(0.97);
  background: var(--color-prairie-dark);
}

/* Outline Prairie button */
.btn-outline-prairie {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-wheat);
  background: transparent;
  border: 1.5px solid var(--color-wheat);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
  text-decoration: none;
  line-height: 1.4;
}

.btn-outline-prairie:hover {
  background: var(--color-wheat);
  color: #fff;
}

.btn-outline-prairie:active {
  transform: scale(0.97);
}

/* Button sizes */
.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 10px 24px;
  font-size: 0.95rem;
}

/* Disabled state for all custom buttons */
.btn-prairie:disabled,
.btn-barn-red:disabled,
.btn-prairie-green:disabled,
.btn-outline-prairie:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

/* Text colors */
.text-wheat {
  color: var(--color-wheat) !important;
}

.text-prairie {
  color: var(--color-prairie) !important;
}

.text-barn-red {
  color: var(--color-barn-red) !important;
}

.text-earth {
  color: var(--color-earth) !important;
}

.text-linen {
  color: var(--color-linen) !important;
}

/* Background */
.bg-parchment {
  background-color: var(--color-parchment) !important;
}

.bg-earth {
  background-color: var(--color-earth) !important;
}

.bg-canvas {
  background-color: var(--color-canvas-bg) !important;
}

/* Frame shadow (diorama / shadow-box effect) */
.frame-shadow {
  box-shadow: var(--shadow-inset-frame);
}

/* Wood grain background texture */
.wood-grain {
  background:
    repeating-linear-gradient(
      87deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.02) 3px,
      rgba(255, 255, 255, 0.02) 5px
    ),
    repeating-linear-gradient(
      93deg,
      transparent,
      transparent 7px,
      rgba(0, 0, 0, 0.035) 7px,
      rgba(0, 0, 0, 0.035) 9px
    ),
    linear-gradient(180deg, #4a382a 0%, var(--color-earth) 40%, #352117 100%) !important;
}

/* ============================================================
   TOAST / NOTIFICATIONS
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: calc(var(--bottombar-height) + 16px);
  right: 16px;
  z-index: 9000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast-message {
  pointer-events: auto;
  background: var(--color-earth);
  color: var(--color-linen);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastSlide 0.35s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-message.success {
  border-left: 4px solid var(--color-prairie);
}

.toast-message.error {
  border-left: 4px solid var(--color-barn-red);
}

.toast-message.info {
  border-left: 4px solid var(--color-wheat);
}

@keyframes toastSlide {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================================
   LOADING / SPINNER
   ============================================================ */

.loading-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(139, 105, 20, 0.2);
  border-top-color: var(--color-wheat);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 230, 211, 0.75);
  z-index: 100;
  backdrop-filter: blur(2px);
}

/* ============================================================
   TOOLTIP OVERRIDES (Bootstrap)
   ============================================================ */

.tooltip-inner {
  background: var(--color-earth);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.tooltip .tooltip-arrow::before {
  border-top-color: var(--color-earth);
}

/* ============================================================
   CONTEXT MENU (right-click on canvas objects)
   ============================================================ */

.context-menu {
  position: fixed;
  z-index: 8000;
  background: #fff;
  border: 1px solid rgba(61, 43, 31, 0.12);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  min-width: 160px;
  animation: fadeIn 0.15s ease;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 0.82rem;
  color: var(--color-earth);
  cursor: pointer;
  transition: background var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.context-menu-item:hover {
  background: rgba(139, 105, 20, 0.08);
}

.context-menu-item.danger {
  color: var(--color-barn-red);
}

.context-menu-item.danger:hover {
  background: rgba(199, 62, 29, 0.08);
}

.context-menu-divider {
  height: 1px;
  background: rgba(61, 43, 31, 0.08);
  margin: 4px 0;
}

/* ============================================================
   RESPONSIVE — Tablet (768px – 1024px)
   ============================================================ */

@media (max-width: 1024px) and (min-width: 768px) {
  .asset-panel {
    width: 60px;
    min-width: 60px;
  }

  .asset-panel .panel-heading,
  .asset-panel .asset-search,
  .asset-panel .asset-name {
    display: none;
  }

  .asset-tabs {
    flex-direction: column;
    padding: 8px 4px;
    gap: 6px;
  }

  .asset-tab {
    padding: 8px;
    justify-content: center;
    font-size: 0;
    border-radius: var(--radius-md);
  }

  .asset-tab i,
  .asset-tab svg {
    font-size: 1.1rem;
    margin: 0;
  }

  .asset-grid {
    grid-template-columns: 1fr;
    padding: 4px;
    gap: 4px;
  }

  .asset-card {
    padding: 4px;
  }

  .asset-card .asset-thumb {
    border-radius: var(--radius-sm);
  }

  /* Properties as floating popover */
  .properties-panel {
    position: fixed;
    top: var(--toolbar-height);
    right: 0;
    bottom: var(--bottombar-height);
    width: var(--panel-right-width);
    min-width: var(--panel-right-width);
    z-index: 1020;
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform var(--transition-base);
  }

  .properties-panel.open {
    transform: translateX(0);
  }

  /* Scrim behind popover */
  .properties-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: 1019;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
  }

  .properties-scrim.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .toolbar .brand {
    font-size: 0.95rem;
  }
}

/* ============================================================
   RESPONSIVE — Mobile (<768px)
   ============================================================ */

@media (max-width: 767.98px) {
  :root {
    --toolbar-height: 48px;
    --bottombar-height: auto;
  }

  .app-body {
    flex-direction: column;
    position: relative;
  }

  /* Canvas fills width */
  .canvas-area {
    flex: 1 1 0%;
    width: 100%;
    min-height: 0;
  }

  #canvas-container {
    border-width: 4px;
  }

  /* ----- Toolbar becomes compact ----- */
  .toolbar {
    padding: 0 8px;
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .toolbar .brand {
    font-size: 0.85rem;
    margin-right: 6px;
  }

  .toolbar .brand-text-full {
    display: none;
  }

  .toolbar-btn {
    padding: 6px 8px;
    font-size: 0;
  }

  .toolbar-btn i,
  .toolbar-btn svg {
    font-size: 1.1rem;
    width: 18px;
    height: 18px;
  }

  .toolbar-label {
    display: none;
  }

  .toolbar-group + .toolbar-group {
    border-left: none;
    margin-left: 2px;
    padding-left: 2px;
  }

  /* ----- Asset panel as bottom sheet drawer ----- */
  .asset-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-width: 100%;
    height: 60vh;
    max-height: 75vh;
    z-index: 1040;
    border-right: none;
    border-top: 1px solid rgba(61, 43, 31, 0.12);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -4px 20px rgba(61, 43, 31, 0.2);
    transform: translateY(calc(100% - 90px));
    transition: transform var(--transition-base);
  }

  .asset-panel.open {
    transform: translateY(0);
  }

  /* Drag handle */
  .asset-panel .drag-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 10px 4px;
    cursor: pointer;
    touch-action: none;
    min-height: 44px;
    background: rgba(74, 124, 89, 0.06);
    border-bottom: 1px solid rgba(61, 43, 31, 0.06);
  }

  .asset-panel .drag-handle .drag-handle-bar {
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: rgba(61, 43, 31, 0.25);
    margin-bottom: 2px;
  }

  .asset-panel .drag-handle .drag-handle-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(61, 43, 31, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .asset-panel .drag-handle:active {
    background: rgba(74, 124, 89, 0.12);
  }

  .asset-panel .drag-handle:active .drag-handle-bar {
    background: rgba(61, 43, 31, 0.4);
  }

  .asset-tabs {
    padding: 4px 10px 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .asset-tab {
    flex-shrink: 0;
  }

  .asset-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 6px 12px 80px; /* extra bottom padding for bottom bar */
  }

  /* ----- Properties panel as bottom sheet ----- */
  .properties-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-width: 100%;
    height: auto;
    max-height: 50vh;
    z-index: 1045;
    border-left: none;
    border-top: 1px solid rgba(61, 43, 31, 0.12);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -4px 20px rgba(61, 43, 31, 0.2);
    transform: translateY(100%);
    transition: transform var(--transition-base);
  }

  .properties-panel.open {
    transform: translateY(0);
  }

  .properties-panel .prop-group {
    padding: 8px 14px;
  }

  /* ----- Bottom bar wraps ----- */
  .bottom-bar {
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 4px;
    justify-content: center;
  }

  .bottom-bar-group {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }

  .bottom-bar-group + .bottom-bar-group {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    padding-top: 4px;
    border-top: 1px solid rgba(250, 240, 230, 0.1);
    width: 100%;
    justify-content: center;
  }

  .btn-prairie,
  .btn-barn-red,
  .btn-prairie-green,
  .btn-outline-prairie {
    padding: 6px 12px;
    font-size: 0.76rem;
  }

  /* ----- Gallery becomes vertical feed ----- */
  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    max-width: 400px;
  }

  .gallery-card:hover {
    transform: none;
  }

  /* ----- Welcome overlay tighter ----- */
  .welcome-card {
    padding: 24px 20px;
    max-width: 95%;
  }

  .welcome-card .welcome-title {
    font-size: 1.3rem;
  }

  /* FAB cluster (floating action buttons) — toggled by JS */
  .toolbar-fabs {
    position: fixed;
    bottom: 80px; /* fixed value since --bottombar-height is auto on mobile */
    right: 16px;
    z-index: 1025;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
  }

  .toolbar-fab {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition:
      transform var(--transition-fast),
      box-shadow var(--transition-fast);
  }

  .toolbar-fab:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
  }

  .toolbar-fab.primary {
    background: var(--color-wheat);
  }

  .toolbar-fab.secondary {
    background: var(--color-prairie);
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  /* Toast positioning on mobile */
  .toast-container {
    bottom: 80px;
    right: 12px;
    left: 12px;
  }

  /* ----- Mobile close button in properties panel ----- */
  .prop-panel-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }

  /* ----- Bottom bar: hide text labels, show icons only ----- */
  .bottom-bar .bottom-bar-label {
    display: none;
  }

  .bottom-bar-more-toggle {
    display: inline-flex;
    margin-left: auto;
    min-height: 44px;
  }

  .bottom-bar .bottom-bar-secondary {
    width: 100%;
    justify-content: center;
    padding-top: 4px;
    border-top: 1px solid rgba(250, 240, 230, 0.1);
  }

  /* ----- Touch target enlargements ----- */
  .prop-range::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
  }

  .prop-range::-moz-range-thumb {
    width: 28px;
    height: 28px;
  }

  .prop-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
  }

  .toolbar-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .bottom-bar .btn-sm {
    min-height: 44px;
    padding: 8px 14px;
  }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */

@media print {
  .toolbar,
  .bottom-bar,
  .asset-panel,
  .properties-panel,
  .welcome-overlay,
  .toast-container,
  .toolbar-fabs,
  .context-menu {
    display: none !important;
  }

  body {
    overflow: visible;
    background: #fff;
  }

  .app-shell {
    height: auto;
  }

  .canvas-area {
    background: #fff;
    box-shadow: none;
  }

  #canvas-container {
    border: 1px solid #ccc;
    box-shadow: none;
  }
}

/* ============================================================
   ACCESSIBILITY — Focus Visible
   ============================================================ */

:focus-visible {
  outline: 2px solid var(--color-wheat);
  outline-offset: 2px;
}

.toolbar-btn:focus-visible,
.btn-prairie:focus-visible,
.btn-barn-red:focus-visible,
.btn-prairie-green:focus-visible,
.btn-outline-prairie:focus-visible {
  outline: 2px solid var(--color-linen);
  outline-offset: 2px;
}

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 99999;
  padding: 8px 16px;
  background: var(--color-wheat);
  color: #fff;
  font-weight: 600;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   DARK MODE HINT (optional, driven by data-theme="dark")
   ============================================================ */

[data-theme="dark"] {
  --color-parchment: #2a2018;
  --color-canvas-bg: #352a1e;
  --color-earth: #FAF0E6;
  --color-linen: #3D2B1F;
}

[data-theme="dark"] body {
  color: #e8dcc8;
}

[data-theme="dark"] .asset-panel,
[data-theme="dark"] .properties-panel {
  background-color: var(--color-parchment);
  border-color: rgba(250, 240, 230, 0.08);
}

[data-theme="dark"] .asset-card,
[data-theme="dark"] .prop-input,
[data-theme="dark"] .prop-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(250, 240, 230, 0.1);
  color: #e8dcc8;
}

[data-theme="dark"] .modal-body,
[data-theme="dark"] .modal-footer {
  background: var(--color-parchment);
}

[data-theme="dark"] .gallery-card {
  background: #352a1e;
  border-color: rgba(250, 240, 230, 0.08);
}

[data-theme="dark"] .welcome-card {
  background: #352a1e;
}

[data-theme="dark"] .context-menu {
  background: #352a1e;
  border-color: rgba(250, 240, 230, 0.1);
}

[data-theme="dark"] .context-menu-item {
  color: #e8dcc8;
}

[data-theme="dark"] .context-menu-item:hover {
  background: rgba(139, 105, 20, 0.15);
}

/* ============================================================
   DRAG-AND-DROP HELPERS (Alpine/JS driven)
   ============================================================ */

[x-cloak] {
  display: none !important;
}

/* Visible only when asset is being dragged over canvas */
.drop-indicator {
  position: absolute;
  pointer-events: none;
  border: 2px dashed var(--color-wheat);
  border-radius: var(--radius-md);
  background: rgba(139, 105, 20, 0.08);
  z-index: 25;
  transition:
    left var(--transition-fast),
    top var(--transition-fast),
    width var(--transition-fast),
    height var(--transition-fast);
}

/* Transformer handles match theme */
.konvajs-content .konvajs-transformer .anchor {
  fill: var(--color-wheat) !important;
  stroke: #fff !important;
}

/* ============================================================
   LAYER PANEL (optional, future feature placeholder)
   ============================================================ */

.layer-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 0.78rem;
  border-bottom: 1px solid rgba(61, 43, 31, 0.06);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.layer-item:hover {
  background: rgba(139, 105, 20, 0.06);
}

.layer-item.active {
  background: rgba(139, 105, 20, 0.12);
  font-weight: 600;
}

.layer-item .layer-thumb {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--color-canvas-bg);
  flex-shrink: 0;
}

.layer-item .layer-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-item .layer-visibility {
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.layer-item .layer-visibility:hover {
  opacity: 1;
}

.layer-item .layer-visibility.hidden {
  opacity: 0.2;
}

/* ============================================================
   WORKSPACE LAYOUT (three-column flex layout)
   ============================================================ */

.workspace {
  display: flex;
  flex: 1 1 0%;
  min-height: 0;
  overflow: hidden;
}

/* ============================================================
   TOOLBAR EXTENSIONS (groups, dividers, name input)
   ============================================================ */

.toolbar-groups {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: rgba(250, 240, 230, 0.2);
  margin: 0 4px;
  flex-shrink: 0;
}

.toolbar-name {
  flex-shrink: 0;
  margin-left: auto;
}

.diorama-name-input {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(250, 240, 230, 0.2);
  border-radius: var(--radius-sm);
  color: var(--color-linen);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 4px 10px;
  width: 200px;
  outline: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.diorama-name-input::placeholder {
  color: rgba(250, 240, 230, 0.4);
}

.diorama-name-input:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--color-wheat);
}

/* ============================================================
   PROPERTIES PANEL — HTML class names (property-group, etc.)
   ============================================================ */

.properties-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid rgba(61, 43, 31, 0.08);
  flex-shrink: 0;
}

.properties-header h5 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-earth);
}

.property-group {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(61, 43, 31, 0.06);
}

.property-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-earth);
  white-space: nowrap;
  margin-bottom: 4px;
  display: block;
}

.property-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.property-value {
  font-size: 0.82rem;
  color: rgba(61, 43, 31, 0.7);
}

.property-value-small {
  font-size: 0.72rem;
  color: rgba(61, 43, 31, 0.6);
  min-width: 32px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Badge overrides for prairie theme */
.badge.bg-prairie {
  background-color: var(--color-prairie) !important;
  color: #fff;
}

/* ============================================================
   CANVAS VIEW SWITCHING
   ============================================================ */

.canvas-view-builder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-view-gallery {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 0;
}

.canvas-view-my-dioramas {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 0;
}

/* ============================================================
   GALLERY HEADER (back button + title)
   ============================================================ */

.gallery-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(61, 43, 31, 0.08);
  background: var(--color-parchment);
  flex-shrink: 0;
}

.gallery-header h4 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-earth);
}

/* ============================================================
   GALLERY CARD EXTENSIONS (from gallery.js rendering)
   ============================================================ */

.gallery-card-image {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.gallery-card-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--color-canvas-bg);
}

.gallery-card-placeholder {
  width: 100%;
  background: var(--color-canvas-bg);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-card-placeholder svg {
  width: 100%;
  height: auto;
}

.gallery-card-body {
  padding: 4px 0;
}

.gallery-card-body h5 {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--color-earth);
  margin: 0 0 2px;
}

.gallery-card-body p {
  margin: 0 0 6px;
}

.gallery-card-featured {
  border: 2px solid var(--color-wheat) !important;
}

.gallery-featured-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

.gallery-remix-btn,
.gallery-view-btn {
  cursor: pointer;
}

/* ============================================================
   SAVED DIORAMAS GRID (My Dioramas view)
   ============================================================ */

.saved-dioramas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  padding: 20px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.saved-dioramas-grid .empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: rgba(61, 43, 31, 0.4);
  font-size: 0.9rem;
}

.saved-dioramas-grid .empty-state i {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.3;
}

/* ============================================================
   CUSTOM MODAL OVERLAY (non-Bootstrap modals used in HTML)
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(61, 43, 31, 0.6);
  backdrop-filter: blur(4px);
}

.modal-card {
  background: var(--color-parchment);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 90%;
  overflow: hidden;
}

.modal-card-lg {
  max-width: 680px;
}

.modal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--color-wheat) 0%, var(--color-prairie) 100%);
  color: #fff;
}

.modal-card-header h4 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
}

.modal-card-header .btn-close {
  filter: brightness(0) invert(1);
  opacity: 0.8;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 24px;
  height: 24px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
}

.modal-card-header .btn-close:hover {
  opacity: 1;
}

.modal-card-body {
  padding: 20px;
}

/* ============================================================
   SHARE SOCIAL BUTTONS
   ============================================================ */

.share-social {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}

/* ============================================================
   WELCOME DOTS (HTML uses .dot class)
   ============================================================ */

.welcome-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(61, 43, 31, 0.15);
  display: inline-block;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.welcome-dots .dot.active {
  background: var(--color-wheat);
  transform: scale(1.3);
}

/* ============================================================
   ASSET CARD — HTML class aliases (asset-card-img, asset-card-name)
   ============================================================ */

.asset-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--color-canvas-bg);
  pointer-events: none;
}

.asset-card-name {
  margin-top: 4px;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--color-earth);
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   GALLERY MODAL PLACEHOLDER
   ============================================================ */

.gallery-modal-placeholder {
  background: var(--color-canvas-bg);
  border-radius: var(--radius-md);
}

/* ============================================================
   RESPONSIVE — WORKSPACE on mobile
   ============================================================ */

@media (max-width: 767.98px) {
  .workspace {
    flex-direction: column;
    position: relative;
  }

  .toolbar-name {
    display: none;
  }

  .diorama-name-input {
    width: 120px;
    font-size: 0.75rem;
  }
}
