:root{
  /* Dark Mode Palette - Enhanced for Sleek/High-Tech Look */
  --bg: #ffffff;
  --fg: #1f2937;
  --muted: #6b7280;
  --card-bg: #ffffff;
  --accent: #0ea5a4; /* teal-ish accent for light theme */
  --border-color: #e6e6e6;
  --input-bg: #fbfbfb;
  --hover-bg: #f3f4f6;
  --shadow-color: rgba(16,24,40,0.06);
  --neon-glow: 0 0 5px rgba(0, 192, 255, 0.5), 0 0 10px rgba(0, 192, 255, 0.2);
}

html,body{height:100%}
body{
  margin:0;
  font-family:"Noto Sans",system-ui,-apple-system,Segoe UI,Roboto,"Helvetica Neue",Arial,sans-serif;
  background:var(--bg);
  color:var(--fg);
  display:flex;
  align-items:flex-start; /* Changed from center to ensure content starts visible at the top */
  justify-content:center;
  padding:0; /* Bootstrap container handles padding now */
  min-height: 100vh;
}

main.container{ /* Target the main container specifically */
  max-width:960px; /* Use max-width instead of fixed width */
  text-align:left;
  background: var(--bg);
  padding:0; /* Cards handle padding */
  border-radius:16px;
  /* Remove overall main shadow, cards will have their own */
  transition:transform .18s ease;
}

/* Card Style */
.card {
  /* Using Bootstrap .card, override defaults */
  background: var(--card-bg);
  padding: 30px; 
  border-radius: 14px;
  /* Bootstrap uses mb-* for margin-bottom */
  box-shadow: 0 10px 30px var(--shadow-color), inset 0 0 0 1px var(--border-color); /* Deeper shadow, subtle border */
  border: none;
  transition: box-shadow 0.3s ease;
}
.card:hover {
    box-shadow: 0 12px 40px var(--shadow-color), inset 0 0 0 1px var(--accent); /* Subtle hover glow */
}
.card h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}


/* Input Card Layout */
.separator {
  margin: 0 10px; /* Adjusted margin for Bootstrap grid column */
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  align-self: stretch;
  display: flex; /* Keep flex for inner content */
  align-items: center;
  min-width: 40px; /* Ensure space for OSE text */
}
.separator::before, .separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
  margin: 0 5px; /* Reduced margin */
}

@media (max-width: 768px) { /* Bootstrap default medium breakpoint */
  /* Re-enable vertical separator display only if it wraps */
  .separator {
    width: 100%;
    margin: 10px 0;
  }
  .separator::before, .separator::after {
    margin: 0 20px;
  }
}

@media (max-width: 720px) {
  /* Overrides for smaller screens */
  body { align-items: flex-start; padding:18px 12px; }
  main.container{ padding:0; border-radius:10px; }
  h1{ font-size:24px; margin-top: 5px; }
  
  /* Mobile Input Layout */
  .card{ padding: 20px; margin-bottom: 15px; border-radius: 10px; }
  .input-card h3 { font-size: 18px; margin-bottom: 10px; }
  
  /* The form within col-md-6 is now handled by d-flex in HTML, adjust input width if needed */
  .country-input-group input#country{ font-size:16px; padding:12px; }
  
  .upload-control-group { flex-direction: column; align-items: stretch; gap: 8px; }
  
  .controls{ flex-direction:column; gap:10px; }
  /* control-actions now uses row/col, adjust mobile behavior */
  .control-actions{ 
    gap: 10px;
    padding-top: 10px;
  }
  
  /* Make controls full width on mobile */
  .control-actions button, 
  .segmented-control,
  .custom-dropdown-wrapper {
      margin-left: 0 !important;
  }
  
  /* Segmented control layout for mobile */
  .segmented-control {
      display: flex;
      flex-wrap: wrap; /* Allow label and buttons to wrap */
      justify-content: space-between;
      align-items: center;
      gap: 5px;
      padding: 0;
      border-top: none;
  }
  .segmented-control label {
      text-align: left;
      margin-bottom: 0;
      font-size: 14px;
  }
  .segmented-control button {
      padding: 8px 10px;
      font-size: 14px;
      flex-grow: 1;
  }

  .custom-dropdown-trigger {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    border-radius: 8px;
  }
  .custom-dropdown-options {
      min-width: auto;
      left: 0;
      right: 0;
      border-radius: 8px;
  }
  
  /* Mobile controls stack adjustments */
  .control-stack {
    gap: 0;
    margin-bottom: 15px;
  }
  .control-row { 
    padding: 10px 0; 
  }
  .control-stack .control-row:first-child {
      padding-top: 0;
  }

  .canvas-wrap{ min-height:220px; padding:6px; }
  canvas{ width:100%; height:auto; max-height:60vh; image-rendering: pixelated; }
  
  /* Targeting BS buttons */
  .btn, button { 
    padding:10px 12px; font-size:16px; border-radius:8px; 
    width: 100%; 
  }
  
  /* Icon buttons on mobile should also be full width, but center the icon */
  .btn.icon-btn {
      /* Override fixed width/height for stacked layout */
      width: 100%;
      height: auto;
      padding: 12px; /* Ensure vertical space when full width */
  }
  
  .fs-overlay-btn { top: 10px; right: 10px; padding: 8px; width: 36px; height: 36px; }
  
  /* Share Row adjustments */
  .share-row {
      flex-direction: column !important; 
      align-items: stretch !important;
      gap: 8px !important; 
  }
  .share-row h3 {
      padding-bottom: 10px;
      border-bottom: 1px solid var(--border-color);
      margin-bottom: 10px !important;
  }
  .share-row label {
      min-width: 0;
      margin-bottom: -5px; 
  }
  
  .share-row button {
      flex-shrink: 0;
  }
  
  /* Checkbox on mobile */
  .checkbox-control {
      display: flex; 
      align-items: center;
      width: 100%; 
      padding: 10px 0;
      border-top: 1px solid var(--border-color);
      border-bottom: 1px solid var(--border-color);
  }
  
  .checkbox-control input[type="checkbox"] {
      width: 24px;
      height: 24px;
  }
  
  .checkbox-control label {
      font-size: 18px;
  }
}

/* Add a small helper for button text spans so we can hide them on mobile */
.btn-text { display: inline; }

/* Use inline <img> icons from icons8; hide text on small screens but keep img visible */
.btn .icon-img, .custom-dropdown-trigger .icon-img, .fs-overlay-btn .icon-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  margin-right: 8px;
}

/* On mobile, hide textual spans and let the <img> display at its natural icon size */
@media (max-width: 720px) {
  button[data-icon-src] .btn-text { display: none !important; }
  .custom-dropdown-trigger .label,
  .custom-dropdown-trigger #currentWaveStyleName,
  .custom-dropdown-trigger #currentDisplayStyleName { display: none !important; }
  
  /* Make icon images show at the icon's natural size (no cropping), but cap to comfortable size */
  .btn .icon-img, .icon-btn .icon-img, .custom-dropdown-trigger .icon-img, .fs-overlay-btn .icon-img {
      width: auto;
      height: 40px;
      margin-right: 0;
      display: block;
  }
  /* For icon-only buttons make them size to their content */
  .btn.icon-btn { width: auto; height: auto; padding: 8px; }
}

/* Base Styles */
h1{ 
  margin:10px 0 12px; 
  font-size:38px; /* Larger */
  letter-spacing:1px; 
  font-weight:800; /* Bolder */
  color:var(--accent); /* Use accent color for H1 */
  text-shadow: var(--neon-glow); 
  transition: text-shadow 0.3s ease;
}
.welcome{ margin:8px 0 30px; color:var(--muted); font-size:16px; }


/* Buttons */
/* Overriding Bootstrap .btn defaults */
.btn, button{ /* Target both custom buttons and Bootstrap .btn */
  padding:12px 20px;
  border-radius:10px;
  border:none;
  background:var(--accent);
  color:var(--bg); /* Dark text on bright background */
  font-weight:700;
  cursor:pointer;
  transition:background .2s ease, transform .05s ease, box-shadow .2s ease;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 192, 255, 0.3);
  width: 5em;
}

/* Style for icon-only buttons (Desktop/Row layout) */
.btn.icon-btn {
    padding: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
}
.btn.icon-btn img.icon-img { width:20px; height:20px; }

.btn:hover, button:hover{ 
  background: color-mix(in srgb, var(--accent), #fff 20%);
  box-shadow: 0 4px 15px rgba(0, 192, 255, 0.5);
  color: var(--bg); /* Ensure text stays dark */
}
.btn:active, button:active {
  transform: translateY(1px);
}

.btn.muted, button.muted{
  background:var(--input-bg);
  color:var(--fg);
  border:1px solid var(--border-color);
  box-shadow: none;
}
.btn.muted:hover, button.muted:hover{
  background:var(--hover-bg);
  border-color: var(--accent);
  color: var(--fg); /* Ensure text stays light */
}
.btn[disabled], button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
    pointer-events: none; /* Prevent interaction */
}

/* Input Fields */
input[type="text"], input[type="search"], .share-row input, .form-control{
  flex:1;
  padding:14px 16px;
  border:1px solid var(--border-color);
  border-radius:10px;
  font-size:17px;
  background:var(--input-bg);
  color:var(--fg);
  min-width: 0;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input:focus, .form-control:focus {
    border-color: var(--accent);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6), 0 0 5px rgba(0, 192, 255, 0.5);
    outline: none;
    background:var(--input-bg); /* Keep background consistent */
    color:var(--fg);
}
input::placeholder { color: #888; opacity:1; }

/* Form Layout */
form{
  margin-bottom:0;
}
.autocomplete-wrapper { flex: 1; }

/* Autocomplete related styles START */
.country-input-group {
  flex: 1; 
  position: relative;
  display: flex;
  flex-direction: column;
}

.country-input-group label {
  margin-bottom: 6px; 
  color: var(--muted);
  font-size: 14px;
}

.suggestions-list {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 10px 10px;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 8px 25px var(--shadow-color);
  display: none;
  list-style: none;
  padding: 0;
  margin: 0;
}

.suggestions-list.visible {
  display: block;
}

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

.suggestions-list li {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 16px;
  color: var(--fg);
}

.suggestions-list li:hover,
.suggestions-list li.selected {
  background: var(--hover-bg);
  color: var(--accent);
}

.suggestions-list li b {
  font-weight: 700;
  color: var(--accent);
}
/* Autocomplete related styles END */

/* Upload Control Styling */
.upload-control-group {
    /* Uses d-flex align-items-center gap-2 */
}
.upload-section h3 { margin-top: 0; }
.filename-display {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 5px;
    font-size: 15px;
    color: var(--muted);
    min-width: 50px; /* Ensure space for filename */
}
.upload-section label {
  display: none; /* Label for the whole section is now H3 */
}

/* Controls */
.controls{
  /* Restyled responsive controls panel */
  display: block; /* Change from grid to block, let groups manage layout */
  gap: 18px;
  align-items: start;
  background: var(--card-bg);
  padding: 22px;
  border-radius: 12px;
  margin-bottom: 25px;
  box-shadow: 0 8px 24px var(--shadow-color);
}

/* New container for grouping sections, enabling multi-column on desktop */
.control-groups-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Default 3 columns for desktop -> Changed to 2 */
    gap: 20px;
    margin-bottom: 15px;
}

.control-group h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 17px;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.control-group:nth-child(2) h4 {
    border-color: transparent; /* Remove border for visual settings group */
    padding-bottom: 0;
    margin-bottom: 10px;
}


.control-stack{ /* Replacing control-grid with vertical stack of enhanced inputs */
  display:flex;
  flex-direction:column;
  gap:12px;
  min-width:0;
}
.control-row{
  display:flex;
  gap:12px;
  align-items:center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}
.control-row label{
  min-width: 160px;
  flex-shrink:0;
  font-size:15px;
  font-weight:600;
  color:var(--muted);
}
.control-row .form-range, .control-row input[type="range"]{
  flex:1;
  margin:0;
}
/* Compact numeric/value display */
.control-row .value-badge {
  min-width:48px;
  font-size:14px;
}
.control-stack .control-row:first-child {
    padding-top: 0;
}
.control-stack .control-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Special treatment for checkbox and intensity rows in Visual Settings */
.control-group .control-row.checkbox-row,
.control-group .control-row.intensity-row {
    border-bottom: none; 
    padding: 0;
    margin-bottom: 10px;
    display: block; /* Ensure full width for these elements */
}

/* Ensure shadow intensity label/input lay out nicely */
.control-group .control-row.intensity-row label {
    display: block;
    margin-bottom: 6px;
}


.control-actions{ 
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:0;
  border-top:none;
  align-items:stretch;
}

/* Dropdown/Segmented Action group layout */
.control-actions.action-dropdowns {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Space between dropdowns/segmented control */
    align-items: stretch;
}


/* Action row inside the right column (buttons + extras) */
.control-actions .actions-row {
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:flex-start;
  flex-wrap:wrap;
}
.control-actions .actions-row .btn {
  flex: 0 0 auto;
  width: auto;
  padding:10px 14px;
  border-radius:8px;
}
/* Move segmented control & dropdowns into vertical stack on narrower widths */
.control-actions .controls-block {
  display:flex;
  gap:10px;
  flex-direction:column;
  width:100%;
}
.control-actions .controls-block .segmented-control, 
.control-actions .controls-block .custom-dropdown-wrapper {
  flex: 1;
  min-width: 0;
}

/* Custom Range Input Styling for high-tech look (Overriding BS .form-range) */
.form-range{ 
    accent-color: var(--accent); 
    width: 100%; 
    height: 6px; 
    background: var(--input-bg);
    border-radius: 3px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
    -webkit-appearance: none;
    appearance: none;
    transition: box-shadow 0.2s;
    /* Reset BS default background image for custom track */
    background-image: none; 
}

.form-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--input-bg);
    border-radius: 3px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 192, 255, 0.8), 0 0 1px #000;
    margin-top: -6px; 
    transition: box-shadow 0.2s, background 0.2s;
}

.form-range:focus {
    outline: none;
}

.form-range:active::-webkit-slider-thumb {
    background: color-mix(in srgb, var(--accent), #fff 20%);
    box-shadow: 0 0 12px rgba(0, 192, 255, 1);
}

.form-range::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--input-bg);
    border-radius: 3px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}

.form-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 192, 255, 0.8);
}


/* Segmented Control for Direction */
.segmented-control {
    display: inline-flex;
    gap:8px;
    align-items:center;
    background: transparent;
    padding:6px;
    border-radius:8px;
}
.segmented-control button.btn { /* Target buttons inside segmented control */
    padding:8px 10px;
    border-radius:8px;
    min-width: 86px;
    text-align:center;
}
.segmented-control label {
    font-size: 15px;
    color: var(--muted);
    font-weight: 400;
}
.segmented-control button.selected {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    box-shadow: var(--neon-glow);
}
.segmented-control button.btn:hover:not(.selected) {
    background: var(--hover-bg);
    border-color: var(--fg);
}

/* Custom Dropdown Styling */
.custom-dropdown-wrapper {
    position: relative;
    flex-shrink: 0;
    z-index: 5;
}
.custom-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: auto;
    min-width: 180px;
    padding: 12px 16px; 
    border-radius: 10px; 
    border: 1px solid var(--border-color); 
    background: var(--input-bg); 
    color: var(--fg); 
    cursor: pointer;
    font-size: 17px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.custom-dropdown-trigger:hover, .custom-dropdown-trigger.active {
    border-color: var(--accent);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6), 0 0 5px rgba(0, 192, 255, 0.5);
    background: var(--hover-bg);
}
.custom-dropdown-trigger .label {
    color: var(--muted);
    font-weight: 400;
    margin-right: 8px;
}
#currentWaveStyleName, #currentDisplayStyleName {
    font-weight: 700;
    flex-grow: 1;
    text-align: left;
}
.dropdown-arrow {
    margin-left: 10px;
    transition: transform 0.2s ease;
    color: var(--muted);
}
.custom-dropdown-trigger.active .dropdown-arrow {
    transform: rotate(180deg);
    color: var(--accent);
}

/* Dropdown Options List */
.custom-dropdown-options {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    z-index: 2000; /* Ensure this is above other elements */
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    min-width: 250px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 8px 20px var(--shadow-color);
    padding: 10px 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.custom-dropdown-options.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.custom-dropdown-option-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.1s ease;
    border: none;
    background: transparent;
    color: var(--fg);
    font-size: 15px;
}
.custom-dropdown-option-item:hover {
    background: var(--hover-bg);
}
.custom-dropdown-option-item.selected {
    background: color-mix(in srgb, var(--accent), var(--card-bg) 70%);
    color: var(--fg);
    font-weight: 700;
}
.custom-dropdown-option-item .description {
    display: block;
    font-size: 12px;
    color: var(--muted);
    font-weight: 400;
    margin-top: 2px;
}

/* Checkbox Control */
/* Use custom styles + BS form-check-input */
.checkbox-control {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    flex-shrink: 0;
}

.checkbox-control input[type="checkbox"], .form-check-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    /* Overriding BS default checkbox look for dark theme */
    border: 1px solid var(--border-color); 
    background-color: var(--input-bg);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
/* Ensure checked state uses accent color */
.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 5px rgba(0, 192, 255, 0.5);
}

.checkbox-control input[type="checkbox"]:hover, .form-check-input:hover {
    box-shadow: 0 0 8px rgba(0, 192, 255, 0.5);
}

.checkbox-control label, .form-check-label {
    font-size: 16px;
    color: var(--fg);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}
/* Targeting custom checkbox style */
.checkbox-control input[type="checkbox"]:checked + label {
    color: var(--accent);
}

.checkbox-control label:hover {
    color: var(--accent);
}

/* Canvas Output */
.canvas-output {
  margin-bottom: 25px;
}

/* Base Canvas Wrap (Modern Flat Default) */
.canvas-wrap{
  width:100%;
  overflow:hidden;
  border-radius:12px;
  margin-top:10px;
  background:#000;
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:300px;
  position:relative;
  /* Default Modern Flat Look - enhanced */
  border:1px solid var(--border-color);
  box-shadow: 0 0 60px rgba(0,0,0,0.8), inset 0 0 15px rgba(0,0,0,0.3); 
  transition: all 0.3s ease, padding 0.3s ease, background 0.3s ease;
  padding: 0; 
}

/* Make canvas responsive and keep pixel crisp */
canvas{
  display:block;
  width:100%;
  height:auto;
  image-rendering: pixelated;
  background:#000;
  border-radius:0; /* Let canvas-wrap handle radius */
  box-shadow: none; 
  transform-origin:center top;
  transition:filter .3s ease, transform .3s ease, opacity .3s ease, box-shadow .3s ease;
  border: none;
  filter: none;
  transform: none;
  opacity: 1;
}

/* --- Display Styles --- */

/* Deep Shadow */
.canvas-wrap.deep-shadow {
    border: none; 
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.9), inset 0 0 20px rgba(0, 0, 0, 0.9);
}
.canvas-wrap.deep-shadow canvas {
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1); 
    filter: brightness(1.05); 
}

/* Worn Vintage */
.canvas-wrap.vintage-worn {
    border: 5px solid #776e66;
    background: #38342f; 
    border-radius: 4px;
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.4);
}
.canvas-wrap.vintage-worn canvas {
    filter: sepia(0.7) contrast(1.1) brightness(1.05);
    transform: rotateZ(-0.5deg) scale(0.99); 
    opacity: 0.95;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    border: 1px solid #000; /* Add a subtle inner border */
}

/* Metal Frame */
.canvas-wrap.metal-frame {
    padding: 20px; 
    background: #6c757d; 
    border-radius: 15px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.7);
    border: 3px solid transparent; 
    border-image: linear-gradient(to bottom right, #555 0%, #aaa 50%, #555 100%) 1;
}
.canvas-wrap.metal-frame canvas {
    border: 2px solid #222; 
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5) inset;
    filter: brightness(1.1);
}
/* Ensure the fullscreen button position is correct regardless of padding changes */
.canvas-wrap.metal-frame .fs-overlay-btn {
    top: 30px; 
    right: 30px;
}
.canvas-wrap:not(.metal-frame) .fs-overlay-btn {
    top: 18px; 
    right: 18px;
}

/* Digital Mosaic Style */
.canvas-wrap.digital-mosaic {
    background: #000; /* Ensure solid black background for gaps */
    border: 3px solid #00fff2; /* Neon Cyan border */
    box-shadow: 0 0 15px rgba(0, 255, 242, 0.5), 0 0 50px rgba(0, 0, 0, 0.8) inset;
    border-radius: 4px;
    padding: 2px; /* Small inner padding */
}
.canvas-wrap.digital-mosaic canvas {
    /* Subtle digital artifacts look */
    filter: contrast(1.1) brightness(1.05);
    box-shadow: 0 0 5px rgba(0, 255, 242, 0.1) inset;
    opacity: 0.98;
}

/* NEW: Glass Effect Style */
.canvas-wrap.glass-effect {
    background: #1f2533; /* Dark slate background for contrast in gaps/bezel */
    border: 2px solid rgba(255, 255, 255, 0.4); 
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 5px; 
    /* Add a slight 'glossy' top highlight on the frame */
    position: relative;
    overflow: hidden; /* Important for clean look */
}

.canvas-wrap.glass-effect canvas {
    /* Apply filters for a glassy, high contrast, slightly refracted look */
    filter: saturate(1.3) contrast(1.1); 
    border-radius: 8px;
    /* Simulate depth on each pixel block using inner shadow */
    box-shadow: 
        inset 0 0 0 1px rgba(255, 255, 255, 0.1), /* Subtle light refraction edge */
        inset 0 0 10px rgba(0, 0, 0, 0.5); /* Inner deep shadow for convexity */
    
    /* Ensure block rendering logic applies the gaps */
    opacity: 1;
}

/* --- ENHANCED WINDOW SHADOW STYLE --- */
/* This combines the dynamic movement and the multi-pane shadow definition,
   using the existing window-shadow-active class for the checkbox toggle. */
.canvas-wrap.window-shadow-active {
    /* Keep container neutral; remove ambient outer shadow so shadow only shows in the overlay (::after) */
    background: #111111;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: visible; /* allow overlay to sit visually above the flag without extra outer shadow */
}
.canvas-wrap.window-shadow-active::after {
    content: '';
    position: absolute;
    top: 0;                   /* anchor overlay to the top of the canvas-wrap */
    left: 0;
    width: 100%;
    height: 45%;              /* larger top-only overlay so shadow sits above the flag */
    pointer-events: none;
    z-index: 50;              /* ensure overlay renders above canvas and controls inside the wrap */
 
    /* dynamic variables (JS will update --sun-angle, --shadow-pos-x, --shadow-pos-y, --shadow-intensity) */
    --mullion-width: 3.5%; /* relative width of mullions */
    --pane-softness: 3.0px; /* Increased blur for softness */
    --shadow-veil: rgba(0,0,0,0.12);
     
    /* Build multi-pane window shadow limited to the overlay area:
       Use non-repeating gradients and position them relative to the overlay. */
    background-image:
        /* Vertical mullions (non-repeating, subtle) */
        linear-gradient(
            0deg, 
            rgba(0,0,0,0) 0%,
            rgba(0,0,0,0) calc(20% - var(--mullion-width) / 2),
            rgba(0,0,0, calc(var(--shadow-intensity) * 0.65)) calc(20% - var(--mullion-width) / 2),
            rgba(0,0,0, calc(var(--shadow-intensity) * 1.0)) calc(20%),
            rgba(0,0,0,0) calc(20% + var(--mullion-width) / 2)
        ),
        /* Horizontal mullions (non-repeating) */
        linear-gradient(
            90deg, 
            rgba(0,0,0,0) 0%,
            rgba(0,0,0,0) calc(25% - var(--mullion-width) / 2),
            rgba(0,0,0, calc(var(--shadow-intensity) * 0.65)) calc(25% - var(--mullion-width) / 2),
            rgba(0,0,0, calc(var(--shadow-intensity) * 1.0)) calc(25%),
            rgba(0,0,0,0) calc(25% + var(--mullion-width) / 2)
        ),
        /* Large soft oval/circle (simulating sunlight position) */
        radial-gradient(
            circle 60% at var(--shadow-pos-x) var(--shadow-pos-y),
            rgba(0,0,0, calc(var(--shadow-intensity) * 0.06)) 0%,
            rgba(0,0,0, calc(var(--shadow-intensity) * 0.65)) 30%,
            rgba(0,0,0, 0) 70%
        ),
        /* soft ambient veil for subtle darkening restricted to top */
        linear-gradient(180deg, var(--shadow-veil), transparent 60%);
     
    background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
     
    /* Positioning: align decorations within the top overlay */
    background-position: 
        left top,    /* vertical mullions */
        left top,    /* horizontal mullions */
        var(--shadow-pos-x) var(--shadow-pos-y), 
        0 0;
         
    /* Sizes tuned for the overlay area to avoid tiling over entire canvas */
    background-size: 120% 120%, 120% 120%, 160% 160%, 100% 100%;
    background-blend-mode: multiply, multiply, multiply, multiply;
     
    /* Mullion softness + diffusion */
    box-shadow: inset 0 8px 30px rgba(0,0,0,0.45); /* keep a subtle inner depth inside the overlay only */
    filter: blur(var(--pane-softness));
    opacity: 1;
    transition: background-position 0.35s linear, filter 0.25s linear, opacity 0.25s;
}

.fs-overlay-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(0, 192, 255, 0.1);
  color: var(--accent);
  padding: 8px; /* Reduced padding for icon */
  width: 40px; /* Fixed size for square button */
  height: 40px;
  border-radius: 6px;
  display: flex; /* center icon */
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
  border: 1px solid var(--accent);
  z-index: 10;
}
.fs-overlay-btn:hover {
  background: rgba(0, 192, 255, 0.3);
}


/* Status row */
.status-row{
  /* Rely on d-flex justify-content-between align-items-center */
  gap:12px;
  align-items:center;
  margin-top:8px;
  color:var(--muted);
  font-size:15px;
}

/* Sharing UI row overrides */
.share-row {
    /* Overriding BS card p-3, d-flex defaults */
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 15px !important; 
}
.share-row h3 {
    padding-bottom: 0;
    border-bottom: none;
    flex-shrink: 0;
}
.share-row label {
    font-size: 16px; 
    color: var(--muted);
    flex-shrink: 0;
    min-width: 120px; /* Give label enough space */
}
.share-row button {
    flex-shrink: 0;
    min-width: 80px;
}

/* Responsive adjustments for controls */
@media (max-width: 992px) {
  .controls {
    grid-template-columns: 1fr 260px;
  }
  .control-row label { min-width: 140px; font-size:14px; }
}
@media (max-width: 992px) {
  /* Switch to 2 columns on medium screens */
  .control-groups-container {
    grid-template-columns: 1fr 1fr; 
  }
  .control-row label { min-width: 140px; font-size:14px; }
}
@media (max-width: 720px) {
  .controls {
    grid-template-columns: 1fr;
    padding:16px;
    gap:12px;
  }
  
  .control-groups-container {
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: 16px;
    margin-bottom: 10px;
  }

  .control-group h4 {
      font-size: 16px;
      padding-bottom: 6px;
  }
  
  .control-group.style-selectors {
  }

  .control-stack { order: 1; }
  .control-actions { order: 2; }
  .control-row {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 0;
  }
  .control-row label { min-width:0; font-size:15px; margin-bottom:6px; color:var(--muted); }
  .control-row .value-badge { align-self:flex-end; }
  .control-actions .actions-row { justify-content:space-between; }
  .custom-dropdown-trigger { min-width:0; }
  .segmented-control { width:100%; justify-content:space-between; }
  /* Ensure mobile buttons fit natural icon sizes per earlier requirement */
  .btn, button { width: auto; }

  /* Ensure checkbox row is vertically stacked correctly */
  .control-row.checkbox-row {
      display: flex; /* Override previous block setting */
      align-items: center;
      justify-content: space-between;
      border-top: 1px solid var(--border-color);
      padding: 10px 0;
  }
  .control-row.checkbox-row .checkbox-control {
      padding: 0;
  }
  .control-row.checkbox-row label {
      margin-bottom: 0;
  }
  
  .control-group .control-row.intensity-row {
      margin-bottom: 0;
      padding-bottom: 10px;
      border-bottom: 1px solid var(--border-color);
  }
  .control-group .control-row.intensity-row label {
      margin-bottom: 6px;
  }
  
}

@media (max-width: 720px) {
  button[data-icon-src] .btn-text { display: none !important; }
  .custom-dropdown-trigger .label,
  .custom-dropdown-trigger #currentWaveStyleName,
  .custom-dropdown-trigger #currentDisplayStyleName { display: none !important; }
  
  /* Make icon images show at the icon's natural size (no cropping), but cap to comfortable size */
  .btn .icon-img, .icon-btn .icon-img, .custom-dropdown-trigger .icon-img, .fs-overlay-btn .icon-img {
      width: auto;
      height: 40px;
      margin-right: 0;
      display: block;
  }
  /* For icon-only buttons make them size to their content */
  .btn.icon-btn { width: auto; height: auto; padding: 8px; }
}

/* Custom Range Input Styling for high-tech look (Overriding BS .form-range) */
.form-range{ 
    accent-color: var(--accent); 
    width: 100%; 
    height: 6px; 
    background: var(--input-bg);
    border-radius: 3px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
    -webkit-appearance: none;
    appearance: none;
    transition: box-shadow 0.2s;
    /* Reset BS default background image for custom track */
    background-image: none; 
}

.form-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--input-bg);
    border-radius: 3px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 192, 255, 0.8), 0 0 1px #000;
    margin-top: -6px; 
    transition: box-shadow 0.2s, background 0.2s;
}

.form-range:focus {
    outline: none;
}

.form-range:active::-webkit-slider-thumb {
    background: color-mix(in srgb, var(--accent), #fff 20%);
    box-shadow: 0 0 12px rgba(0, 192, 255, 1);
}

.form-range::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--input-bg);
    border-radius: 3px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}

.form-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 192, 255, 0.8);
}

/* Custom Range Input Styling for high-tech look (Overriding BS .form-range) */
.form-control-sm.numeric-control {
    max-width: 160px;
    padding: 6px 8px;
    font-weight: 700;
    text-align: center;
    border-radius: 8px;
}