/* ==========================================================================
   Design System Variables & Theme Setup
   ========================================================================== */
:root {
  /* ------------------------------------------------------------------
     Brand color tokens — the ONLY colors set directly. Everything else
     below (tints, shades, status colors, borders, muted text) is derived
     from these four via color-mix() so the whole widget always reduces
     to white + primary + secondary + accent. These four are overridden
     from the WordPress admin settings page; the values here are just the
     out-of-the-box defaults.
     ------------------------------------------------------------------ */
  --primary: #0077c8;
  --secondary: #06295e;
  --accent: #d41a32;
  --bg-app: #f1f1f1;
  --bg-card: #ffffff;

  /* Derived tints / shades - do not set these directly, only the tokens above */
  --primary-light: color-mix(in srgb, var(--primary) 8%, white);
  --primary-medium: var(--primary);
  --primary-dark: color-mix(in srgb, var(--primary) 85%, black);

  --secondary-light: color-mix(in srgb, var(--secondary) 6%, white);

  --border-color: color-mix(in srgb, var(--secondary) 12%, white);
  --border-focus: var(--primary);

  /* Text Colors */
  --text-main: var(--secondary);
  --text-muted: color-mix(in srgb, var(--secondary) 62%, white);
  --text-light: color-mix(in srgb, var(--secondary) 40%, white);
  --text-inverse: #ffffff;

  /* Status Colors - mapped onto the brand palette (no green/orange) */
  --status-safe: var(--primary);
  --status-safe-light: color-mix(in srgb, var(--primary) 12%, white);
  --status-warning: var(--secondary);
  --status-warning-light: color-mix(in srgb, var(--secondary) 12%, white);
  --status-danger: var(--accent);
  --status-danger-light: color-mix(in srgb, var(--accent) 12%, white);

  /* Shadows (neutral, not part of the brand color set) */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 24px -4px rgba(18, 30, 45, 0.08), 0 4px 12px -2px rgba(18, 30, 45, 0.03);

  /* Typography Scale */
  --font-heading: 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  /* Border Radii */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Base Styles & Reset - Scoped to WordPress widget container
   ========================================================================== */
.spacefinder-widget-container,
.spacefinder-widget-container *,
.spacefinder-widget-container *::before,
.spacefinder-widget-container *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.spacefinder-widget-container {
  --tab-hover-bg: var(--primary-light);
  --tab-hover-text: var(--primary);
  --gauge-gradient-start: var(--primary);
  --gauge-gradient-end: var(--secondary);
  --sticky-top: 100px;

  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

/* App Wrapper for layout consistency */
.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header Styles */
.app-header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--primary);
}

.logo-text {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.03em;
  color: var(--text-main);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-text h1 {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.header-text p {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 600px;
}

/* Main Container Grid */
.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  min-width: 0;
}

.calculator-container {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 2rem;
  align-items: start;
}

/* ==========================================================================
   Left Panel: Selection Area
   ========================================================================== */
.selection-panel {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 600px;
  /* Grid items default to min-width: auto, which refuses to shrink below the
     content's intrinsic width and forces the whole grid wider than the
     viewport on phones/tablets. min-width: 0 lets it respect its 1fr track. */
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Horizontal scrollable category tabs */
/* Wraps the scrollable tab strip together with its two scroll-arrow
   buttons, so mouse/trackpad users on desktop and laptop have an obvious,
   clickable way to reach categories that don't fit (touch users can still
   just swipe the strip itself). */
.tabs-scroll-wrapper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.tabs-scroll-btn {
  display: none; /* JS reveals this only when the strip actually overflows */
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: var(--primary-light);
  color: var(--primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tabs-scroll-btn.visible {
  display: flex;
}

.tabs-scroll-btn:hover,
.tabs-scroll-btn:active {
  background-color: var(--primary);
  color: var(--text-inverse);
}

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

.tabs-nav {
  display: flex;
  flex: 1;
  gap: 0.25rem;
  background-color: var(--secondary-light);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  scrollbar-width: none; /* Hide standard Firefox scrollbar */
  /* Without this, a flex item defaults to min-width: auto and refuses to
     shrink below the combined width of all 6 category tabs, forcing the
     whole panel (and page) wider instead of letting this row's own
     overflow-x: auto handle it. */
  min-width: 0;
  /* "Scroll shadow" affordance: hints there are more tabs off-screen
     whenever all 6 categories don't fit. The two "local"-attached
     gradients matching the bar's own background fade the edge tab out as
     it scrolls under; the two "scroll"-attached gradients paint a soft
     shadow that only shows through once something is actually scrolled
     off that side - it disappears on its own at each scroll end. */
  background-image:
    linear-gradient(to right, var(--secondary-light) 40%, transparent),
    linear-gradient(to left, var(--secondary-light) 40%, transparent),
    linear-gradient(to right, color-mix(in srgb, var(--secondary) 18%, transparent), transparent),
    linear-gradient(to left, color-mix(in srgb, var(--secondary) 18%, transparent), transparent);
  background-repeat: no-repeat;
  background-size: 28px 100%, 28px 100%, 10px 100%, 10px 100%;
  background-position: left center, right center, left center, right center;
  background-attachment: local, local, scroll, scroll;
}

.tabs-nav::-webkit-scrollbar {
  display: none; /* Hide Chrome scrollbar */
}

.tab-btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-muted);
  border: none;
  background: transparent;
  padding: 0.5rem 1rem;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

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

.tab-btn.active {
  background-color: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Clear Button */
.btn-clear {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  background: transparent;
  color: var(--text-light);
  cursor: not-allowed;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-clear:not(:disabled) {
  color: var(--status-danger);
  cursor: pointer;
}

.btn-clear:not(:disabled):hover {
  background-color: var(--status-danger-light);
}

.icon-clear {
  width: 16px;
  height: 16px;
}

/* Search Bar */
.search-bar-container {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  width: 18px;
  height: 18px;
  color: var(--text-light);
  pointer-events: none;
}

#search-items {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--secondary-light);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-main);
  transition: all var(--transition-fast);
}

#search-items:focus {
  outline: none;
  border-color: var(--border-focus);
  background-color: var(--bg-card);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, white);
}

/* Items Viewport & Grid list */
.items-viewport {
  padding-right: 0.25rem;
}

/* Custom Scrollbar for list */
.items-viewport::-webkit-scrollbar {
  width: 6px;
}

.items-viewport::-webkit-scrollbar-track {
  background: transparent;
}

.items-viewport::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: var(--radius-pill);
}

.items-viewport::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-light);
}

.items-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Item Selection Row Item */
.item-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.item-row:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.item-row.selected {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.item-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-right: 1rem;
}

.item-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.item-volume {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.item-quantity-text-bubble {
  font-size: 0.8rem;
  font-weight: 700;
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
  margin-right: 1rem;
  opacity: 0;
  transform: scale(0.8);
  transition: all var(--transition-fast);
}

.item-row.selected .item-quantity-text-bubble {
  opacity: 1;
  transform: scale(1);
}

/* Quantity Control Widgets */
.qty-controls {
  display: flex;
  align-items: center;
  background-color: var(--secondary-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 0.15rem;
  gap: 0.15rem;
}

.item-row.selected .qty-controls {
  border-color: var(--primary-light);
  background-color: var(--bg-card);
}

.btn-qty {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background-color: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-qty:hover {
  background-color: var(--border-color);
  color: var(--text-main);
}

.item-row.selected .btn-qty:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

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

.qty-input {
  width: 28px;
  border: none;
  background: transparent;
  text-align: center;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-main);
  padding: 0;
}

.qty-input:focus {
  outline: none;
}

/* Hide spin buttons in input */
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.qty-input[type=number] {
  -moz-appearance: textfield;
}

/* No Search Results */
.no-results {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.no-results-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 0.75rem;
  color: var(--text-light);
}

/* ==========================================================================
   Right Panel: Recommended Card
   ========================================================================== */
.result-panel {
  /* position is static by default on mobile, sticky on desktop/tablet */
  /* See .selection-panel comment: prevents this grid item from blowing out
     the layout width on phones/tablets. */
  min-width: 0;
}

.result-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-slow);
}

/* Empty recommendation visual */
.result-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
  animation: fadeIn var(--transition-normal);
}

.empty-icon-wrapper {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: var(--secondary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  color: var(--text-light);
}

.empty-icon-wrapper svg {
  width: 36px;
  height: 36px;
}

.result-empty h3 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.result-empty p {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 280px;
  margin-bottom: 2rem;
}

.preview-unit-frame.disabled {
  opacity: 0.15;
  filter: grayscale(1);
}

.preview-unit-frame {
  width: 100%;
  max-width: 240px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-app);
  border-radius: var(--radius-md);
  padding: 1rem;
  overflow: hidden;
  position: relative;
}

.unit-image-preview {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  transition: transform var(--transition-slow);
  cursor: zoom-in;
}

.preview-unit-frame:hover .unit-image-preview {
  transform: scale(1.2);
}

/* Hover-to-play preview video (admin-configured per unit size) */
.unit-video-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  display: none;
}

.preview-unit-frame.has-video .unit-image-preview {
  cursor: pointer;
}

.preview-unit-frame.video-playing .unit-video-preview {
  display: block;
}

.preview-unit-frame.video-playing .unit-image-preview {
  display: none;
}

/* Active Suggestion Style */
.result-active {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: slideUp var(--transition-normal);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.result-header h2 {
  font-family: var(--font-heading);
  font-size: clamp(1rem, 3vw, 1.25rem);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.unit-badge {
  font-family: var(--font-heading);
  /* Scales down on narrow screens and for longer multi-unit labels
     (e.g. "2x 10x20x10"); wraps to its own line via .result-header's
     flex-wrap if it still doesn't fit next to the heading. */
  font-size: clamp(1.25rem, 5vw, 2.2rem);
  font-weight: 800;
  color: var(--primary);
  line-height: 1.15;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  max-width: 100%;
}

/* Progress bar gauge */
.capacity-gauge-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background-color: var(--bg-app);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.gauge-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  font-weight: 600;
  font-size: 0.85rem;
}

.gauge-label {
  color: var(--text-main);
}

.gauge-value {
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 700;
}

/* Colors depending on capacity level (mapped to the brand palette) */
.gauge-value.safe {
  background-color: var(--status-safe-light);
  color: var(--status-safe);
}

.gauge-value.warning {
  background-color: var(--status-warning-light);
  color: var(--status-warning);
}

.gauge-value.danger {
  background-color: var(--status-danger-light);
  color: var(--status-danger);
}

.gauge-track {
  height: 10px;
  background-color: var(--border-color);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  transition: width var(--transition-slow), background-color var(--transition-fast);
  background: linear-gradient(90deg, var(--gauge-gradient-start) 0%, var(--gauge-gradient-end) 100%) !important;
}

.gauge-info {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.15rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.gauge-info span {
  color: var(--text-main);
}

.gauge-info .muted {
  color: var(--text-muted);
}

/* Photo unit alignment */
.result-active .preview-unit-frame {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
}

.unit-description {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-muted);
  border-left: 3px solid var(--primary);
  padding-left: 1rem;
}

/* Unit 2D Layout visualizer */
.dimensions-visualizer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.visualizer-header {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dimension-specs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.spec-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

.spec-num {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--primary);
}

.spec-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Floor Grid */
.grid-2d-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 0;
}

.grid-2d {
  display: grid;
  gap: 2px;
  /* grid-template-columns set dynamically by JS */
  background-color: var(--border-color);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  /* Do NOT set width: 100% — let the fixed cell size drive the width */
}

.grid-cell {
  background-color: var(--bg-card);
  width: 8px;
  height: 8px;
  border-radius: 1px;
  flex-shrink: 0;
}

/* Sticky left panel (applied via JS when admin enables it). Only turns on
   once the 2-column layout is active (901px+) - the layout is a single
   stacked column below that (see the max-width: 900px block), where sticky
   positioning has nothing meaningful to pin against and only causes glitches. */
@media (min-width: 901px) {
  .selection-panel-sticky {
    position: sticky;
    top: var(--sticky-top, 100px);
    align-self: start;
  }
}
@media (min-width: 901px) {
  .result-panel {
    position: sticky;
    top: var(--sticky-top, 100px);
  }
}

.grid-cell.filled {
  background-color: var(--primary);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Item selection breakdown */
.summary-breakdown {
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
}

.breakdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.breakdown-header h3 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.count-badge {
  background-color: var(--secondary-light);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
}

.breakdown-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 160px;
  overflow-y: auto;
  padding-right: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--secondary-light);
}

.breakdown-list::-webkit-scrollbar {
  width: 6px;
}

.breakdown-list::-webkit-scrollbar-track {
  background-color: var(--secondary-light);
  border-radius: var(--radius-pill);
}

.breakdown-list::-webkit-scrollbar-thumb {
  background-color: var(--primary);
  border-radius: var(--radius-pill);
}

.breakdown-list::-webkit-scrollbar-thumb:hover {
  background-color: var(--primary-dark);
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.1rem 0.75rem;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  background-color: var(--secondary-light);
  border-radius: var(--radius-sm);
}

.breakdown-item-name {
  color: var(--text-main);
  font-weight: 500;
}

.breakdown-item-qty {
  font-weight: 700;
  color: var(--primary);
}

/* ==========================================================================
   Additional Storage Options (Vehicle / Boat / RV / Container reference list)
   ========================================================================== */
.additional-storage {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.additional-storage-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.additional-storage-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.additional-storage-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.additional-storage-item {
  padding: 0.75rem 1rem;
  background-color: var(--secondary-light);
  border-radius: var(--radius-md);
}

.additional-storage-item .aso-name {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary);
  margin-bottom: 0.15rem;
}

.additional-storage-item .aso-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .additional-storage-list {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Utility Classes & Footer
   ========================================================================== */
.hidden {
  display: none !important;
}

.app-footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-card);
  margin-top: auto;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes popIn {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   Responsive Media Queries
   ========================================================================== */
/* Small laptop / tablet landscape - keep the 2-column layout but tighten it up */
@media (min-width: 901px) and (max-width: 1100px) {
  .calculator-container {
    gap: 1rem;
    grid-template-columns: 1.3fr 1fr;
  }
  .spacefinder-widget-container {
    padding: 1rem;
  }
  .selection-panel {
    padding: 1.25rem;
  }
  .result-active {
    padding: 1.25rem;
  }
}

/* Tablet portrait and phones - most tablets in portrait (roughly 768-900px)
   are too narrow for a comfortable 2-column layout, so this stacks to a
   single column the same way phones do. */
@media (max-width: 900px) {
  .calculator-container {
    grid-template-columns: 1fr;
  }
  .result-panel {
    position: static;
  }
  .spacefinder-widget-container {
    padding: 1rem;
    padding-bottom: 5.5rem; /* Space for mobile sticky footer bar */
  }
  .result-active .preview-unit-frame {
    max-width: 320px;
    margin: 0 auto;
  }
  .additional-storage-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 1.25rem 1rem;
  }
  .app-main {
    padding: 1rem;
  }
  .selection-panel {
    padding: 1.25rem;
  }
  .panel-header {
    flex-direction: column;
    align-items: stretch;
    /* The base rule sets flex-wrap: wrap for desktop; combined with
       flex-direction: column that stops align-items: stretch from working
       (tabs-nav rendered at its full unwrapped content width instead of
       being stretched to the panel's width). A simple 2-item vertical
       stack never needs to wrap. */
    flex-wrap: nowrap;
  }
  .btn-clear {
    justify-content: center;
  }
  .item-row {
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
  }
  .item-quantity-text-bubble {
    display: none; /* Hide bubbles to save horizontal space */
  }
}

/* ==========================================================================
   Mobile Sticky Summary Bar
   ========================================================================== */
.mobile-sticky-bar {
  display: none;
}

@media (max-width: 768px) {
  .mobile-sticky-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    padding: 0.75rem 1rem;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    animation: slideUp 0.3s ease;
  }
  
  .mobile-sticky-bar.hidden {
    display: none !important;
  }
  
  .mobile-sticky-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .mobile-sticky-info {
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
  }
  
  .mobile-sticky-label {
    color: var(--text-muted);
  }
  
  .mobile-sticky-value {
    color: var(--primary);
    font-weight: 700;
  }
  
  .mobile-sticky-percentage {
    color: var(--text-main);
  }
  
  .mobile-sticky-gauge {
    height: 6px;
    background-color: var(--border-color);
    border-radius: var(--radius-pill);
    overflow: hidden;
    width: 100%;
  }
  
  .mobile-sticky-gauge-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gauge-gradient-start, var(--primary)) 0%, var(--gauge-gradient-end, var(--secondary)) 100%);
    border-radius: var(--radius-pill);
    width: 0%;
    transition: width var(--transition-slow);
  }
  
  .mobile-sticky-btn {
    background-color: var(--primary);
    color: var(--text-inverse);
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--transition-fast);
  }
  
  .mobile-sticky-btn:hover {
    filter: brightness(0.95);
  }
  
  .arrow-down-icon {
    width: 12px;
    height: 12px;
  }
}

/* Fix Elementor & other page builder container overflows breaking position sticky */
.elementor-widget:has(.spacefinder-widget-container),
.elementor-widget-container:has(.spacefinder-widget-container),
.elementor-column:has(.spacefinder-widget-container),
.elementor-column-wrap:has(.spacefinder-widget-container),
.elementor-widget-wrap:has(.spacefinder-widget-container) {
  overflow: visible !important;
}
