:root {
  --background: hsl(220, 15%, 8%);
  --background-secondary: hsl(220, 15%, 12%);
  --background-tertiary: hsl(220, 12%, 16%);
  --foreground: hsl(210, 40%, 98%);
  --sidebar-w: 400px;
  /* Glass Effects */
  --card: hsl(220, 15%, 12%, 0.8);
  --card-foreground: hsl(210, 40%, 95%);
  --card-border: hsl(220, 20%, 25%, 0.4);
  --popover: hsl(220, 15%, 10%, 0.95);
  --popover-foreground: hsl(210, 40%, 95%);
  /* Primary Colors */
  --primary: hsl(210, 85%, 55%);
  --primary-glow: hsl(210, 90%, 65%);
  --primary-dark: hsl(210, 80%, 45%);
  --primary-foreground: hsl(210, 40%, 98%);
  /* Secondary Colors */
  --secondary: hsl(220, 15%, 20%);
  --secondary-foreground: hsl(210, 40%, 95%);
  --secondary-hover: hsl(220, 15%, 25%);
  --accent: hsl(280, 70%, 55%);
  --accent-glow: hsl(280, 80%, 65%);
  --accent-foreground: hsl(210, 40%, 98%);
  /* Neutral Colors */
  --muted: hsl(220, 15%, 18%);
  --muted-foreground: hsl(220, 10%, 65%);
  --muted-hover: hsl(220, 15%, 22%);
  /* Borders */
  --border: hsl(220, 20%, 25%, 0.6);
  --border-hover: hsl(220, 25%, 35%, 0.8);
  --input: hsl(220, 15%, 16%);
  --input-border: hsl(220, 20%, 30%);
  --ring: hsl(210, 85%, 55%, 0.3);
  /* Glass & Blur */
  --glass-bg: hsl(220, 15%, 10%, 0.7);
  --glass-border: hsl(220, 30%, 40%, 0.3);
  --blur-strong: blur(20px) saturate(150%);
  --blur-medium: blur(12px) saturate(120%);
  --blur-light: blur(8px) saturate(110%);
  /* Gradients */
  --gradient-primary: linear-gradient(
    135deg,
    hsl(210, 85%, 55%),
    hsl(280, 70%, 55%)
  );
  --gradient-background: radial-gradient(
    ellipse at top,
    hsl(220, 15%, 12%),
    hsl(220, 15%, 8%)
  );
  --gradient-glass: linear-gradient(
    145deg,
    hsl(220, 15%, 15%, 0.8),
    hsl(220, 15%, 10%, 0.6)
  );
  --gradient-canvas: radial-gradient(
    circle at 50% 50%,
    hsl(210, 31%, 15%),
    hsl(210, 23%, 9%) 80%
  );
  --tabs-height: 52px;
  --mobile-panel-height: 45vh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Shadows */
  --shadow-soft: 0 4px 16px hsl(220, 15%, 5%, 0.3);
  --shadow-medium: 0 8px 32px hsl(220, 15%, 5%, 0.4);
  --shadow-strong: 0 8px 32px hsl(220, 15%, 5%, 0.5);
  --shadow-glow: 0 0 20px hsl(210, 85%, 55%, 0.3);
  --shadow-accent-glow: 0 0 15px hsl(280, 70%, 55%, 0.4);
  /* Transitions */
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  /* Layout */
  --action-bar-h: 64px;
  --header-h: 64px;
}
/* =========================
   BASE RESET
========================= */
html,
body {
  width: 100%;
  max-width: 100vw;
  height: 100%;
  min-height: 100%;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  background: var(--gradient-background);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  color: var(--foreground);
  font-size: 14px;
  line-height: 1.5;
}
* {
  box-sizing: border-box;
}
/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}
/* =========================
   GLOBAL HEADER - 0 STYLE
========================= */
.global-header {
  position: fixed;
  top: 0;
  left: var(--sidebar-w); /* pomeri ga desno koliko je sidebar */
  width: calc(100% - var(--sidebar-w)); /* skrati ga za sidebar širinu */

  display: flex;
  align-items: center;
  justify-content: space-between;
height: calc(64px + env(safe-area-inset-top));
padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--background-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}
.header-left,
.header-center,
.header-right {
  flex: 1;
  display: flex;
  align-items: center;
}
.header-left {
  justify-content: flex-start;
}
.tooltip {
  position: absolute;
  top: 100%;
  left: 0;
  transform: translateY(4px);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
/* kad se doda show-tooltip klasa */
.header-left.show-tooltip .tooltip {
  opacity: 1;
}
/* kad klikneš na strelicu (dodaš .clicked) tooltip nestaje */
.header-left.clicked .tooltip {
  opacity: 0;
}
.header-center {
  justify-content: center;
}
.header-right {
  justify-content: flex-end;
}
/* Logo */
.logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}
/* Export dugme */
.export-btn {
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.export-btn:hover {
  background: var(--primary-glow);
  transform: translateY(-2px);
}
.global-header .boat-name {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  padding-left: 16px;
  font-weight: bold;
  color: var(--foreground);
  letter-spacing: 0.5px;
}
.boat-name-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--background-secondary);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
.dropdown-toggle {
  background: none;
  border: none;
  color: var(--foreground);
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.dropdown-toggle:hover {
  transform: rotate(180deg);
}
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--background-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  padding: 6px 0;
  z-index: 1000;
}
.dropdown-menu.hidden {
  display: none;
}
.dropdown-menu button {
  background: none;
  border: none;
  color: var(--foreground);
  text-align: left;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.dropdown-menu button:hover {
  background: var(--background-secondary);
}
.saved-configs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0;
  max-height: 220px;
  overflow-y: auto;
}
.saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between; /* razdvoji ih */
  width: 100%;                    /* da flex ima prostor */
  background: none;
  border: none;
  color: var(--foreground);
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.saved-item .cfg-name {
  flex-grow: 1;                   /* zauzmi sav prostor levo */
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.saved-item .del-btn {
  flex-shrink:1;                 /* X ostaje na kraju */
  background: none;
  border: none;
  color: var(--foreground);
  cursor: pointer;
}
.saved-item:hover {
  background: var(--background-secondary);
}
.saved-item-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--background-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--foreground);
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition-fast);
}
.saved-item-btn:hover {
  border-color: var(--primary);
  background: rgba(85, 214, 255, 0.08);
}
.saved-item-btn .del-btn {
  background: var(--muted);
  color: var(--foreground);
  border-radius: 8px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.saved-item-btn .del-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.25s ease;
}
.modal.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-content {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 24px 28px;
  text-align: center;
  min-width: 280px;
  backdrop-filter: var(--blur-medium);
  -webkit-backdrop-filter: var(--blur-medium);
}
.modal-content h3 {
  margin: 0 0 12px 0;
  color: var(--foreground);
  font-size: 16px;
  font-weight: 600;
}
.modal-content input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--background-tertiary);
  color: var(--foreground);
  font-size: 13px;
  margin-bottom: 14px;
  outline: none;
}
.modal-content input:focus {
  border-color: var(--primary);
}
.modal-buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.modal-buttons button {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: var(--transition-fast);
}
#cancelSave {
  background: var(--muted);
  color: var(--muted-foreground);
}
#confirmSave {
  background: var(--primary);
  color: var(--foreground);
}
#confirmSave:hover {
  background: var(--primary-glow);
}
/* =========================
   CANVAS - 0 STYLE
========================= */
canvas,
#glCanvas {
  display: block;
  position: absolute;
  top: var(--header-h);
  left: var(--sidebar-w);
  right: 0;
  background: var(--gradient-canvas);
  transition: var(--transition-smooth);
  bottom: calc(var(--action-bar-h) + env(safe-area-inset-bottom));
  width: calc(100% - var(--sidebar-w));
  height: calc(100% - var(--header-h) - var(--action-bar-h) - env(safe-area-inset-bottom));
}
#glCanvas {
  position: fixed;
  max-height: 100dvh;
  transform-origin: center center;
  will-change: transform;
  transition: none !important; /* <- sprečava "scale flicker" */
}
/* =========================
   CAMERA CONTROLS - 0 STYLE
========================= */
#camera-controls {
  position: fixed;
  top: 6rem;
  left: 30rem;
  z-index: 50;
  max-width: 240px;
  background: var(--background-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#camera-controls.expanded .controls-content {
  max-height: 600px;
  opacity: 1;
}
  /* ---------- INNER CONTENT ---------- */
  .controls-inner {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  .controls-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  .controls-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
/* ---------- BUTTON GRID ---------- */
.button-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
/* ---------- CONTENT WRAPPER ---------- */
.controls-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
}
#camera-controls .separator {
  width: 90%;
  height: 1px;
  background: rgba(0, 0, 0, 0.5);
  margin: 5px 0;
}
/* ---------- BUTTONS ---------- */
#camera-controls button {
  height: 3rem;
  padding: 0.5rem 1rem;
  background: var(--secondary);
  border: 1px solid var(--border);
  color: var(--secondary-foreground);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
/* ---------- FULL WIDTH BUTTON ---------- */
#camera-controls button.full-width {
  width: 100%;
}
#camera-controls button:hover {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  transform: translateY(-2px);
}
@media (hover: none) and (pointer: coarse) {
  #camera-controls button:hover,
  #camera-controls button:focus,
  #camera-controls button:active {
    background: var(--secondary);
    color: var(--secondary-foreground);
    border-color: var(--border);
    transform: none;
  }
}
#camera-controls .weather-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.25rem;
  border-radius: 0.75rem;
}
#camera-controls .switch-track {
  --thumb-size: 44px;
  --thumb-shift: 72px;
  position: relative;
  height: 52px;
  width: 100%;
  background:
    linear-gradient(90deg, hsla(210, 85%, 55%, 1.0) 0%, hsla(25, 85%, 60%, 1.0) 100%),
    var(--secondary);
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
#camera-controls .switch-track .track-icon {
  position: absolute;
  top: 50%;
  width: 28px;
  height: 28px;
  transform: translateY(-50%);

  transition: opacity 180ms ease;
  pointer-events: none;
}
#camera-controls .switch-track .icon-day { left: 10px; }
#camera-controls .switch-track .icon-sunset { right: 10px; }
#camera-controls .weather-switch[data-weather="day"] .switch-track .icon-day { opacity: 1.0; }
#camera-controls .weather-switch[data-weather="sunset"] .switch-track .icon-sunset { opacity: 1.0; }
#camera-controls .switch-thumb {
  position: absolute;
  top: calc((100% - var(--thumb-size)) / 2);
  left: 4px;
  width: var(--thumb-size);
  height: var(--thumb-size);
  border-radius: 50%;
  background: var(--secondary);
  border: 1px solid hsla(210, 20%, 80%, 1.0);
  box-shadow:
    0 6px 18px rgba(0,0,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.35);
  transition: transform 240ms ease, background 240ms ease;
  display: grid;
  place-items: center;
}
#camera-controls .switch-thumb .thumb-icon {
  position: absolute;
  width: 28px;
  height: 28px;
  object-fit: contain;
  opacity: 0;
  transition: opacity 180ms ease;
}
#camera-controls .weather-switch[data-weather="day"] .switch-thumb .thumb-day { opacity: 1; }
#camera-controls .weather-switch[data-weather="sunset"] .switch-thumb .thumb-sunset { opacity: 1; }
#camera-controls .weather-switch[data-weather="sunset"] .switch-thumb {
  transform: translateX(var(--thumb-shift));
}
#camera-controls .weather-switch.disabled {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(0.8);
}
#camera-controls .weather-switch.disabled .switch-track {
  pointer-events: none;
}
#camera-controls .weather-switch.disabled .weather-label {
  color: var(--muted);
}
#toggleDims {
  grid-area: right;
}
/* =========================
   DIMENSION LABELS
========================= */
#lengthLabel,
#labels .label {
  position: absolute;
  color: var(--foreground);
  font-size: 14px;
  font-weight: bold;
  pointer-events: none;
  transform: translate(-50%, -100%) scale(0.96);
  background: var(--glass-bg);
  backdrop-filter: var(--blur-medium);
  -webkit-backdrop-filter: var(--blur-medium);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--glass-border);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
#lengthLabel.visible,
#labels .label.visible {
  opacity: 1;
  transform: translate(-50%, -110%) scale(1);
  display: block;
}
.ruler-anchor {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.ruler-anchor.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
/* =========================
   LOADING SCREEN - 0 STYLE
========================= */
#loading-screen {
  position: fixed;
  inset: 0;
  background: #0d111a;
  color: var(--foreground);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: var(--transition-slow);
}
#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}
.hidden {
  display: none;
  pointer-events: none;
}
#loading-screen .sheet {
  background: var(--card);
  backdrop-filter: var(--blur-strong);
  -webkit-backdrop-filter: var(--blur-strong);
  border: 1px solid var(--card-border);
  border-radius: 32px;
  padding: 28px 32px;
  text-align: center;
  min-width: 320px;
  animation: scale-in 0.5s var(--spring);
  box-shadow: var(--shadow-strong);
}
@keyframes scale-in {
  0% {
    transform: scale(0.95);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
#loading-screen .sheet > div:first-child {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--foreground);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.progress {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: 6px;
  background: var(--muted);
  overflow: hidden;
  margin: 0 auto 20px;
}
.progress::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: var(--gradient-primary);
  border-radius: inherit;
  animation: slide-progress 1.4s ease-in-out infinite;
}
#loading-screen.hidden .progress::before {
  animation: none !important;
}
@keyframes slide-progress {
  0% {
    left: -40%;
  }
  50% {
    left: 30%;
  }
  100% {
    left: 100%;
  }
}
#loading-screen .sheet > div:last-child {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  text-align: right;
  width: 100%;
  min-height: 16px;
}
#loading-screen .progress {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
  margin: 8px 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
#loading-screen .progress::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--progress-fill, 12%);
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  box-shadow: var(--shadow-accent-glow);
  transition: width 0.25s ease;
  animation: none;
}
.progress-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  width: 100%;
  text-align: right;
  min-height: 16px;
}
/* =========================
   SIDEBAR - 0 STYLE
========================= */
.tree {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  height: auto;
  padding-top: 0;
  padding-bottom: 0;
  background: var(--card);
  border-right: 1px solid var(--card-border);
  overflow: hidden;            /* sprečava da total iseče ivicu */
  z-index: 500;
}
/* =========================
   VARIANT GROUPS - 0 STYLE
========================= */
.variant-group {
  overflow: hidden;
}
.variant-sidebar {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;               /* bitno za iOS */
  background: var(--background-secondary);
  padding-bottom: var(--safe-bottom);
}
.variant-group h3 {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 18px;
  padding: 16px 20px;
  margin: 0;
  background: var(--gradient-glass);
  color: var(--foreground);
  font-weight: 600;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}
.variant-group h3::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: var(--transition-smooth);
}
.variant-group h3:hover {
  color: var(--foreground);
}
.variant-group h3:hover::before {
  opacity: 0.1;
}
.variant-group h3::after {
  content: "›";
  font-size: 20px;
  transition: transform 0.3s var(--spring);
  z-index: 1;
  position: relative;
}
.variant-group.open h3::after {
  transform: rotate(90deg);
}
.variant-group.filter-only {
  background: transparent;
  border: none;
}
.variant-group.filter-only h3,
.variant-group.filter-only .variant-group-controls {
  display: none;
}
.variant-group-controls {
  display: none;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 4px 16px;
}
.variant-group.open .variant-group-controls {
  display: flex;
}
.reset-group-btn {
  background: var(--muted);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition-fast);
}
.reset-group-btn.disabled,
.reset-group-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.reset-group-btn:hover {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
/* =========================
   VARIANT ITEMS - CLEAN
========================= */
.variant-intro {
  padding: 16px 20px;
  color: var(--muted-foreground);
}
.variant-filter-bar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 0 12px;
}
.variant-filter-buttons {
  display: inline-flex;
  gap: 6px;
}
.filter-btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--background-tertiary);
  color: var(--foreground);
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}
.filter-btn.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
.filter-btn.disabled,
.filter-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.variant-intro h2 {
  margin: 0 0 6px 0;
  font-size: 16px;
  color: var(--foreground);
  font-weight: 600;
}
.variant-intro p {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}
/* =========================
   VARIANT CARD - HORIZONTAL + INLINE DESCRIPTION
========================= */
.variant-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transform: translateY(-8px);
  max-height: 0;
  overflow: hidden;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    max-height 0.3s ease,
    padding 0.3s ease;
}
.variant-group.open .variant-items {
  opacity: 1;
  transform: translateY(0);
  max-height: 2000px;
  padding: 12px;
}
.variant-part {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.variant-card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.variant-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: var(--background-tertiary);
  border: 1px solid var(--border);
  border-radius: 18px;
  cursor: pointer;
  transition: var(--transition-smooth);
  overflow: hidden;
  position: relative;
  max-width: 100%;
  isolation: isolate;
}
.variant-item.compact {
  min-height: 120px;
}
.variant-item::after {
  display: none;
}
.variant-item:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}
.variant-item.active {
  border-color: var(--primary);
}
.variant-item {
  animation: none;
}
.variant-item.card-entering {
  animation: cardIn 0.35s ease forwards;
}
@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.variant-item::before {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
  transition: var(--transition-fast);
  z-index: 3;
  pointer-events: none;
}
.variant-item.active::before {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2), 0 0 10px var(--primary-glow);
}
.variant-item .thumb-wrapper {
  position: relative;
  width: 384px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 10; /* enforce 16:10 while keeping 384px width */
  overflow: hidden;
  border: none;
}
.variant-item .thumb-wrapper::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.3) 65%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
}
.variant-item:not(.compact).open .thumb-wrapper {
  height: auto;
}
.variant-item.compact .thumb-wrapper {
  height: 90px;
}
.variant-item.compact .thumb-wrapper img.thumb {
  height: 100%;
  width: auto;
  object-fit: contain;
  margin: 0;
  display: block;
}
.thumb-wrapper img.thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: var(--transition-smooth);
  transform: scale(1.02);
}
.variant-item:hover .thumb-wrapper img.thumb {
  transform: scale(1.03);
}
@media (hover: none) and (pointer: coarse) {
  .variant-item:hover {
    transform: none;
    border-color: var(--border);
  }
  .variant-item:hover .thumb-wrapper img.thumb {
    transform: scale(1.02);
  }
}
.variant-body {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.75) 60%, rgba(0,0,0,0.9) 100%);
  color: var(--foreground);
}
.variant-item.compact .variant-body {
  position: relative;
  padding: 10px 14px 12px;
  gap: 6px;
  background: var(--background-tertiary);
}
.variant-body .title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--primary-foreground);
  text-shadow: 0 12px 28px rgba(0, 0, 0, 0.65);
}
.variant-item.compact .variant-body .title {
  font-size: 15px;
}
.variant-item .colors {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  background-size: cover;
  background-position: center;
  transition: transform 0.2s ease, filter 0.2s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
}
.color-swatch:hover { filter: brightness(1.15); }
.color-swatch.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}
.color-swatch::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  transition: var(--transition-fast);
}
.color-swatch.selected::after {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2), 0 0 10px var(--primary-glow);
}
.color-swatch.texture {
  background-size: 1000% 1000%;
  background-position: center;
}
.color-swatch .swatch-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  color: var(--primary-foreground);
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  pointer-events: none;
}
.variant-footer {
  position: relative;
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  text-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
}
.variant-description.inline {
  display: block;
  margin-top: 4px;
  color: var(--muted-foreground);
  font-size: 13px;
  line-height: 1.4;
}
.color-panel {
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
}
.color-panel.hidden { display: none; }
.color-panel.visible { display: block; }
.color-panel-header {
  font-weight: 700;
  font-size: 18px;
  margin: 12px 0 8px;
}
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, 150px);
  justify-content: center;
  gap: 12px;
}
.color-grid .color-swatch {
  width: 150px;
  height: 150px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  background-size: cover;
  background-position: center;
  transition: transform 0.2s ease, filter 0.2s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
}
.details-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--background-tertiary);
  display: none;
}
.details-panel.visible { display: block; }
.details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
}
.details-body {
  display: none;
  padding: 8px 12px 12px;
  min-height: 8px;
}
.details-panel.open .details-body {
  display: block;
}
/* ----------- OPIS ---------- */

/* kada je kartica "open" */
.variant-item.open .variant-description {
  display: block;
  padding: 8px 16px 12px;
}
/* dugme */
.desc-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-foreground);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  z-index: 2;
  backdrop-filter: blur(4px);
}
.desc-toggle:hover {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
/* Hide everything while app is still loading to avoid flicker */
body.app-loading #glCanvas,
body.app-loading #labels,
body.app-loading .variant-hotspot,
body.app-loading #info-panel,
body.app-loading #sidebar,
body.app-loading .global-header,
body.app-loading #variantSidebar,
body.app-loading #camera-controls {
  visibility: hidden !important;
}
/* =========================
   SIDEBAR TOTAL - 0 STYLE
========================= */
.sidebar-total {
  flex-shrink: 0;
  background: var(--background-secondary);
  border-top: 1px solid var(--card-border);
  padding:14px;

  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--foreground);
  min-height: var(--action-bar-h);
}
.sidebar-total .price {
  font-weight: bold;
  font-size: 20px;
  color: var(--primary);
  text-shadow: var(--shadow-glow);
}
/* =========================
   INFO PANEL - 0 STYLE
========================= */
#info-panel {
    position: fixed;
    left: var(--sidebar-w);
    right: 0;
    width: calc(100% - var(--sidebar-w));
    bottom: calc(var(--action-bar-h) + env(safe-area-inset-bottom));
    background: transparent;
    border: none;
    z-index: 140;
    padding: 0 16px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
  }
#info-panel table {
  table-layout: fixed;
  width: 100%;
}
#info-panel th,
#info-panel td {
  width: 33.33%; /* prilagodi po broju kolona */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.canvas-actions {
  position: fixed;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  height: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: var(--action-bar-h);
  background: var(--background-secondary);
  border-top: 1px solid var(--card-border);
  border-left: 1px solid var(--card-border);
  border-radius: 0;
  padding: 8px 16px;

  box-shadow: 0 -4px 18px hsl(220, 15%, 5%, 0.3);
  z-index: 140;
}
  .info-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
  width: 100%;
}
.action-button {
  background: var(--secondary);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-fast);
  height: 36px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.action-button.mini {
  margin-bottom: 14px;
  padding: 6px 10px;
  font-size: 12px;
  height: 30px;
}
.action-button.load-toggle {
  /* neutral by default */
  box-shadow: none;
}
.action-button.load-toggle.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(10, 170, 255, 0.18);
}
.action-button.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(10, 170, 255, 0.18);
}
.action-button:hover {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  transform: translateY(-1px);
}
.action-button.has-chevron {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.action-button .chevron {
  width: 10px;
  height: 10px;
  display: inline-block;
  transform: rotate(0deg);
  transition: transform 0.3s var(--spring);
}
.action-button .chevron::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid currentColor;
}
.action-button.text-label .chevron,
.info-toggle.text-label .chevron {
  display: none;
}
.action-button.active .chevron {
  transform: rotate(180deg);
}
.saved-configs-card {
  background: var(--background-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.saved-configs-card .saved-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.35px;
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.saved-configs {
  display: flex;
  flex-direction: column;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  max-height: 160px;
  overflow-y: auto;
  gap: 6px;
}
.info-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.45s var(--spring), opacity 0.3s var(--spring);
  background: var(--background-secondary);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 16px 16px;
  opacity: 0;
}
#info-panel.info-open .info-body {
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  opacity: 1;
}
.load-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.45s var(--spring), opacity 0.3s var(--spring);
  background: var(--card);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 16px 16px;
  opacity: 0;
  width: 100%;
  max-width: 420px;
  min-width: 280px;
  align-self: flex-start;
  box-shadow: var(--shadow-soft);
}
#info-panel.load-open .load-body {
  max-height: 40vh;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  opacity: 1;
}
#info-panel.mobile-local {
  position: relative;
  left: 0;
  right: 0;
  width: 100%;
  bottom: auto;
}
/* Desktop enforce alignment with canvas */
@media (min-width: 1201px) {
  #info-panel {
    position: fixed;
    left: var(--sidebar-w);
    right: 0;
    width: calc(100% - var(--sidebar-w));
  }
}
#info-content {
  padding: 8px 4px 16px 4px;
  z-index: 1;
  position: relative;
}
#info-content h3 {
  font-size: 18px;
  font-weight: bold;
  color: var(--foreground);
  margin-bottom: 12px;
}
#boat-info {
  padding: 0 4px 16px 4px;
}
/* =========================
   TABLES - 0 STYLE
========================= */
#partsTable,
#boat-info table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 12px;
  background: var(--muted);
  border-radius: 8px;
  overflow: hidden;
}
#partsTable th,
#partsTable td,
#boat-info table th,
#boat-info table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
#partsTable th,
#boat-info table th {
  background: var(--gradient-glass);
  color: var(--foreground);
  font-weight: 600;
  font-size: 13px;
}
#partsTable td,
#boat-info table td {
  color: var(--muted-foreground);
  transition: var(--transition-fast);
}
#partsTable tr:hover td,
#boat-info table tr:hover td {
  background: var(--muted-hover);
  color: var(--foreground);
}
#partsTable tr:last-child td,
#boat-info table tr:last-child td {
  border-bottom: none;
}
/* =========================
   FPS METER - 0 STYLE
========================= */
#fps-meter {
  position: fixed;
  top: 80px;
  right:400px;
  background: var(--glass-bg);
  backdrop-filter: var(--blur-medium);
  -webkit-backdrop-filter: var(--blur-medium);
  color: var(--primary);
  padding: 6px 14px;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 14px;
  font-weight: bold;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  z-index: 9999;
  pointer-events: none;
}
#drawcall-meter {
  position: fixed;
  top: 120px;
  right: 400px;
  background: var(--glass-bg);
  backdrop-filter: var(--blur-medium);
  -webkit-backdrop-filter: var(--blur-medium);
  color: var(--primary);
  padding: 6px 14px;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 14px;
  font-weight: bold;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
}
#res-meter {
  position: fixed;
  top: 80px;
  right: 500px;
  background: var(--glass-bg);
  backdrop-filter: var(--blur-medium);
  -webkit-backdrop-filter: var(--blur-medium);
  color: var(--primary);
  padding: 6px 14px;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 14px;
  font-weight: bold;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  z-index: 9999;
  pointer-events: none;
}
/* =========================
   RESPONSIVE DESIGN
========================= */
@media (max-width: 1200px) {
  :root {
    --sidebar-w: 320px;
    --action-bar-h: 64px;
    --header-h: 64px;
  }
  .tree {
    width: var(--sidebar-w);
  }
  canvas,
  #glCanvas {
    left: var(--sidebar-w);
    right: 0;
    width: calc(100vw - var(--sidebar-w));
    top: var(--header-h);
    bottom: var(--action-bar-h);
    height: calc(100% - var(--header-h) - var(--action-bar-h));
  }
  #camera-controls {
    left: 350px;
  }
  #info-panel {
    width: calc(100% - var(--sidebar-w));
    left: var(--sidebar-w);
  }
}
/* =========================
   ANIMATIONS
========================= */
.animate-glow-pulse {
  animation: glow-pulse 2s ease-in-out infinite;
}
/* Focus states for accessibility */
button:focus-visible,
.color-swatch:focus-visible,
.variant-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.hamburger-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--foreground);
  cursor: pointer;
  padding: 8px 12px;
  transition: opacity 0.2s ease;
}
.hamburger-btn:hover { opacity: 0.7; }
/* Sidebar panel */
.sidebar-menu {
  overflow-y: auto;             /* omogućava skrol */
  overscroll-behavior: contain; /* sprečava bubble na body */
  position: fixed;
  top: 0;
  right: 0;
  width: 350px;
  height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
  background: var(--background-secondary);
  color: var(--foreground);
  transform: translateX(100%);
  transition: transform 0.35s ease;
  z-index: 9999;
  display: flex;
  flex-direction: column;
}
.sidebar-menu.open {
  transform: translateX(0);
}
.sidebar-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--background-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-title {
  font-weight: 600;
  font-size: 16px;
}
#closeSidebar {
  position: relative;
  z-index: 10000;        /* iznad svega u sidebaru */
  pointer-events: auto;  /* osigurava da prima klik */
  background: none;
  border: none;
  color: var(--foreground);
  font-size: 24px;
  cursor: pointer;
}
.sidebar-menu ul {
  list-style: none;
  margin: 0;
  padding: 20px;
}
.sidebar-menu li {
  margin: 0;
  padding: 20px;
  border: none;
  background: var(--glass-bg);
  backdrop-filter: var(--blur-medium);
  -webkit-backdrop-filter: var(--blur-medium);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  margin-bottom: 4px;
  overflow: hidden;
}
.sidebar-menu a {
  color: var(--foreground);
  text-decoration: none;
  font-size: 15px;
  transition: color 0.2s;
}
.sidebar-menu a:hover {
  color: var(--primary);
}
#sidebarList li {
  position: relative;
  cursor: pointer;
  transition: background 0.3s ease;
}
#sidebarList li:hover {
  background: var(--background-tertiary);
}
.item-desc {
  margin-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 13px;
  line-height: 1.4;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 14px;
}
.contact-form label {
  font-weight: 600;
  color: var(--foreground);
  font-size: 13px;
}
.contact-form input,
.contact-form textarea {
  background: var(--background-tertiary);
  border: 1px solid var(--border);
  color: var(--foreground);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
}
.contact-form input:focus,
.contact-form textarea:focus {
  outline: 1px solid var(--primary);
  border-color: var(--primary);
}
.contact-form button {
  margin-top: 8px;
  background: var(--primary);
  border: none;
  color: var(--foreground);
  padding: 10px;
  font-weight: 600;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
}
.contact-form button:hover {
  background: var(--primary-glow);
}
.thumb[data-thumb-kind="placeholder"] {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: none;
}
body.studio-mode .btn-weather {
    opacity: 0.3;
    pointer-events: none;
}
.variant-hotspot-layer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 20;
}
.variant-hotspot {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--glass-bg);
  color: var(--foreground);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: none;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  backdrop-filter: var(--blur-medium);
  -webkit-backdrop-filter: var(--blur-medium);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
  overflow: visible;
  animation: hotspot-glow 1.8s ease-in-out infinite;
}
.variant-hotspot::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 10px;
  border: 1px solid rgba(255, 184, 86, 0.9);
  opacity: 0.6;
  animation: label-pulse 1.6s ease-in-out infinite;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(255, 184, 86, 0.4);
}
.variant-hotspot:hover {
  transform: translate(-50%, -120%) scale(1.05);
}
.variant-hotspot.hidden {
  opacity: 0;
  pointer-events: none;
}
.variant-hotspot.offscreen {
  opacity: 0;
  pointer-events: none;
}
@keyframes hotspot-glow {
  0% {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25),
      0 0 0 0 rgba(255, 184, 86, 0.22);
  }
  50% {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25),
      0 0 14px 10px rgba(255, 184, 86, 0.36);
  }
  100% {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25),
      0 0 0 0 rgba(255, 184, 86, 0.22);
  }
}
.center-box {
  position: fixed;
  right: 24px;
  bottom: 100px;
  transform: none;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
  z-index: 999;
}
.center-box .control-title {
  font-weight: 700;
  color: var(--foreground);
  margin: 0 0 4px 0;
}
.center-box ul {
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--foreground);
  list-style: disc;
}
.center-box li {
  margin: 2px 0;
  font-size: 13px;
}
.center-box strong {
  color: var(--primary);
}
/* Variant tabs (no collapsible groups) */
.variant-tabs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.variant-tabs-buttons {
  margin: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.variant-tab {
  padding: 18px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--background-tertiary);
  color: var(--foreground);
  cursor: pointer;
  transition: var(--transition-fast);
}
.variant-tab:hover {
  border-color: var(--primary);
  color: var(--primary-foreground);
}
.variant-tab.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}
.variant-tabs-content .variant-group {
  display: none;
}
.variant-tabs-content .variant-group.active {
  display: block;
}
.variant-tabs-wrapper {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0;
}
.variant-scroll-area {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 4px;
}
.variant-placeholder {
  margin: 12px 0;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 13px;
}
.variant-placeholder.hidden {
  display: none;
}
.variant-active-title {
  margin: 12px;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-foreground);
}
.variant-active-title.hidden {
  display: none;
}

/* =========================
   TABLET PORTRAIT MODE - CLEAN VERSION
========================= */
  @media (max-width: 1024px) and (orientation: portrait) {
  :root {
    --sidebar-w: 100%;
    --header-h: 72px;
    --action-bar-h: 72px;
    --mobile-panel-height: 50vh;
  }

    #camera-controls {
      position: fixed;
      top: calc(var(--header-h) + 8px);
      left: 8px;
      right: auto;
      width: auto;
      max-width: 520px;
      height: auto; /* pusti sadrzaj da odredi visinu */
      z-index: 60; /* ispod info-panela u portret modu */
      padding: 6px 8px;
    }

  /* Controls content uvek vidljiv */
  .controls-content {
    max-height: none !important;
    opacity: 1 !important;
    overflow: visible;
    height: auto;
  }

  /* Grid: 4 grupe u jednom redu (Viewports / Dimensions / Lighting / Weather) */
  .controls-inner {
    padding: 6px 8px;
    display: grid;
    grid-template-columns: repeat(4, auto);
    grid-template-rows: auto auto;
    column-gap: 6px;
    row-gap: 4px;
    align-items: start;
    justify-content: flex-start;
    height: auto;
    width: auto;
  }

    /* Naslov iznad, centriran u koloni */
    .section-label {
      font-size: 10px;
      font-weight: 600;
      color: var(--muted-foreground);
      text-transform: uppercase;
      margin: 0;
      text-align: center;
      width: 100%;
    }
    /* Fiksne kolone po vrsti sekcije – da ne zavisi od nth-of-type redosleda */
    .section-label-viewports  { grid-column: 1; grid-row: 1; }
    .section-label-dimensions { grid-column: 2; grid-row: 1; }
    .section-label-lighting   { grid-column: 3; grid-row: 1; }
    .section-label-weather    { grid-column: 4; grid-row: 1; }

  /* Grupa elemenata puni kolonu */
  .controls-inner > div {
    width: 100%;
  }

  /* Viewports dugmad ispod svog naslova */
  .button-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
    justify-items: center;
    grid-column: 1;
    grid-row: 2;
  }

  /* Buttons */
  #camera-controls button {
    width: 44px;
    height: 28px;
    padding: 0;
    font-size: 10px;
    border-radius: 4px;
  }

  /* Full width buttons, ali kompaktne širine */
  #camera-controls button.full-width {
    width: 88px;
    height: 28px;
    grid-row: 2;
    justify-self: center;
  }

  /* Weather switch ispod svog naslova */
  #camera-controls .weather-switch {
    width: 88px;
    padding: 0;
    grid-column: 4;
    grid-row: 2;
    justify-self: center;
  }

  #camera-controls .switch-track {
    width: 88px;
    height: 28px;
    --thumb-size: 24px;
    --thumb-shift: 57px;
  }

  /* Pozicioniraj pojedinačne dugmiće u svoje kolone */
  #toggleDims { grid-column: 2; grid-row: 2; justify-self: center; }
  #toggleWater { grid-column: 3; grid-row: 2; justify-self: center; }

  #camera-controls .switch-track .track-icon,
  #camera-controls .switch-thumb .thumb-icon {
    width: 16px;
    height: 16px;
  }

  /* Sakrij close dugme */
  #closeOptions {
    display: none;
  }

  /* Variant tabs buttons - fleksibilno */
  .variant-tabs-buttons {
    margin: 8px;
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
  }

  .variant-tab {
    flex: 1; /* Svaki tab zauzima jednako mesta */
    min-width: 0; /* Dozvoli smanjivanje */
    padding: 12px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--background-tertiary);
    color: var(--foreground);
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: center;
    font-size: 13px;
    white-space: nowrap;
  }

  .variant-tab:hover {
    border-color: var(--primary);
    color: var(--primary-foreground);
  }

  .variant-tab.active {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
  }

  /* Header full width */
  .global-header {
    left: 0;
    width: 100%;
    position: fixed;
    top: 0;
    z-index: 1001;
  }

  .hamburger-btn {
    display: block;
  }

  /* Canvas full width */
  canvas, #glCanvas {
    left: 0 !important;
    width: 100vw !important;
    top: var(--header-h);
    height: calc(100vh - var(--header-h)) !important; /* Uklonio mobile-panel-height */
    position: fixed;
    z-index: 1;
  }

  /* Sidebar becomes bottom panel - NO TABS */
  .tree {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: var(--mobile-panel-height);
    border-right: none;
    border-top: 1px solid var(--card-border);
    border-radius: 20px 20px 0 0;
    overflow: hidden;
    z-index: 100; /* Preko canvasa */
  }

  /* Keep mobile tabs HIDDEN */
  #mobileTabs {
    display: none !important;
  }

  /* Variant sidebar full height */
  .variant-sidebar {
    height: calc(var(--mobile-panel-height) - 64px);
    overflow-y: auto;
    padding-right: 6px;
  }

  /* Variant items - 3 kolone */
  .variant-card-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 0 4px;
  }

  .variant-item {
    border-radius: 12px;
    min-height: auto;
  }

  .variant-item .thumb-wrapper {
    aspect-ratio: 4/3;
    height: auto;
  }

  .variant-item .thumb-wrapper img.thumb {
    object-fit: cover;
  }

  /* Kompaktniji tekst */
  .variant-body {
    padding: 8px 12px;
  }

  .variant-body .title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
  }

  .variant-footer {
    font-size: 12px;
  }

  .variant-description.inline {
    font-size: 11px;
    line-height: 1.3;
    margin-top: 2px;
  }

  /* Compact mode adjustments */
  .variant-item.compact .thumb-wrapper {
    height: 80px;
  }

  .variant-item.compact .variant-body {
    padding: 8px 10px;
    gap: 4px;
  }

  .variant-item.compact .variant-body .title {
    font-size: 13px;
  }

  /* Color grid takođe 2 kolone */
  .color-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .color-grid .color-swatch {
    width: 100%;
    height: 100px;
  }

  /* Variant groups - manje padding */
  .variant-group.open .variant-items {
    padding: 8px;
    gap: 6px;
  }

  .variant-group h3 {
    font-size: 15px;
    padding: 10px 12px;
  }


  /* Info panel above bottom panel */
  #info-panel {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
    bottom: var(--mobile-panel-height);
    background: transparent;
    padding: 0 16px 8px;
    z-index: 120; /* Preko sidebar-a */
    display: flex;
    flex-direction: column;
  }

  .canvas-actions {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    /* kompaktan chip bar, centriran u info-panelu */
    width: auto;
    max-width: 100%;
    align-self: center;
    background: var(--glass-bg);
    backdrop-filter: var(--blur-medium);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    padding: 8px 10px;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    order: 2;
  }

  .info-actions {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .load-body,
  .info-body {
    order: 1;
  }

  /* Control box repositioned */
  .center-box {
    right: 16px;
    bottom: calc(var(--mobile-panel-height) + 16px);
    max-width: 240px;
  }

  /* Sidebar total at bottom */
  .sidebar-total {
    position: sticky;
    bottom: 0;
    background: var(--background-secondary);
    border-top: 1px solid var(--border);
    padding: 16px;
    font-size: 18px;
    min-height: 64px;
  }
}

/* Landscape: sakrij Options/Close dugmad da ne smeta */
@media (orientation: landscape) {
  #toggleOptions,
  #closeOptions {
    display: none;
  }
}

/* Responsive za manje tablete */
@media (max-width: 820px) and (orientation: portrait) {
  .variant-card-list {
    gap: 6px;
    padding: 0 2px;
  }
  
  .variant-item .thumb-wrapper {
    aspect-ratio: 3/2;
  }
  
  .variant-body .title {
    font-size: 13px;
  }
}



/* Tablet portrait override: 40% canvas / 60% controls (final) */
@media (orientation: portrait) and (min-width: 700px) and (max-width: 1199px) {
  :root {
    --header-h: calc(64px + env(safe-area-inset-top));
    --action-bar-h: 64px;
  }

  .global-header {
    left: 0;
    width: 100%;
    top: 0;
  }

  body {
    overflow: hidden;
  }

  .canvas-wrapper {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    width: 100%;
    height: calc((100vh - var(--header-h) - var(--safe-bottom)) * 0.5);
    background: var(--gradient-canvas);
    overflow: hidden;
    z-index: 50;
  }

  .canvas-wrapper canvas,
  .canvas-wrapper #glCanvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    max-height: none !important;
    z-index: 2;
    pointer-events: auto;
  }

  #sidebar {
    position: fixed;
    top: calc(var(--header-h) + ((100vh - var(--header-h) - var(--safe-bottom)) * 0.5));
    left: 0;
    right: 0;
    width: 100%;
    height: calc((100vh - var(--header-h) - var(--safe-bottom)) * 0.5);
    border-right: none;
    border-top: 1px solid var(--card-border);
    background: var(--background-secondary);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 60;
    overflow: hidden;
  }

  .variant-sidebar {
    flex: 1;
    overflow-y: auto;
  }

  .sidebar-total {
    position: sticky;
    bottom: 0;
    border-top: 1px solid var(--card-border);
    background: var(--background-secondary);
  }

  #info-panel {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--header-h);
    bottom: calc((100vh - var(--header-h) - var(--safe-bottom)) * 0.5 + var(--safe-bottom));
    width: 100%;
    padding: 0 12px 8px;
    box-sizing: border-box;
    background: transparent;
    border: none;
    box-shadow: none;
    z-index: 70;
    pointer-events: none; /* ne blokira drag po canvasu */
  }

    .canvas-actions {
      position: absolute;
      bottom: 8px;
      /* kompaktan chip bar, centriran ispod canvasa */
      left: 50%;
      transform: translateX(-50%);
      width: auto;
      max-width: calc(100% - 24px);
      border-left: none;
      border-radius: 12px;
      padding: 10px 12px;
      box-shadow: none;
      background: var(--background-secondary);
      border: 1px solid var(--card-border);
      pointer-events: auto; /* ostavi dugmad klikabilna */
      justify-content: center;
    }

  #info-panel.info-open .info-body,
  #info-panel.load-open .load-body {
    max-height: calc(((100vh - var(--header-h) - var(--safe-bottom)) * 0.5) - var(--action-bar-h) - 24px);
    pointer-events: auto; /* dozvoli skrol u panelu kad je otvoren */
  }

  /* Load config panel sedi tik iznad dugmeta (ne lepi se za vrh) */
  .load-body {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(var(--action-bar-h) + 12px);
    max-width: none;
    width: auto;
    pointer-events: auto;
  }

  #fps-meter,
  #drawcall-meter,
  #res-meter {
    right: 16px;
  }
}


