

/* ============================================================
   VARIABILI DI TEMA (Colori Esatti e Accurati)
   ============================================================ */

/* START MODIFICATION: Nuovo Tema di Default "SpectraX" (Premium Glass) */
:root, body[data-theme="default"], body[data-theme="spectrax"] {
  --bg:           #050507 !important;
  --card:         rgba(13, 13, 18, 0.65) !important;
  --card-deep:    rgba(0, 0, 0, 0.4) !important;
  --txt:          #e0e0e0 !important;
  --mut:          #8b8b99 !important;
  --br:           rgba(255, 255, 255, 0.08) !important;
  --acc:          #00f0ff !important; /* Ciano */
  --acc-hover:    #9f55ff !important; /* Viola */
  --acc-glow:     rgba(0, 240, 255, 0.2) !important;
  --input-bg:     rgba(18, 18, 24, 0.5) !important;
  --btn-bg:       rgba(255, 255, 255, 0.03) !important;
  --btn-border:   rgba(255, 255, 255, 0.08) !important;
  --hover-bg:     rgba(255, 255, 255, 0.08) !important;
  --stage-bg:     #000000 !important;
  --btn-txt:      #e0e0e0 !important;
  --action-txt:   #000000 !important;
  --danger:       #ff3c7a !important;
  --font-main:    'Inter', sans-serif !important;
}
/* END MODIFICATION */

/* 2. TEMA GOOGLE AI STUDIO (Colori Ufficiali Material 3 Dark) */
body[data-theme="google"] {
  --bg:           #131314 !important;
  --card:         #1e1f20 !important;
  --card-deep:    #131314 !important;
  --txt:          #e3e3e3 !important;
  --mut:          #c4c7c5 !important;
  --br:           #444746 !important;
  --acc:          #a8c7fa !important;
  --acc-hover:    #d3e3fd !important;
  --acc-glow:     rgba(168, 199, 250, 0.15) !important;
  --input-bg:     #131314 !important;
  --btn-bg:       #282a2c !important;
  --btn-border:   #444746 !important;
  --hover-bg:     #333537 !important;
  --stage-bg:     #000000 !important;
  --btn-txt:      #e3e3e3 !important;
  --action-txt:   #041e49 !important;
  --danger:       #f28b82 !important;
}

/* 3. TEMA PROFESSIONAL LIGHT (Stile SaaS / Apple) */
body[data-theme="light"] {
  --bg:           #f3f4f6 !important;
  --card:         #ffffff !important;
  --card-deep:    #f9fafb !important;
  --txt:          #111827 !important;
  --mut:          #6b7280 !important;
  --br:           #e5e7eb !important;
  --acc:          #2563eb !important;
  --acc-hover:    #1d4ed8 !important;
  --acc-glow:     rgba(37, 99, 235, 0.15) !important;
  --input-bg:     #f9fafb !important;
  --btn-bg:       #ffffff !important;
  --btn-border:   #d1d5db !important;
  --hover-bg:     #f3f4f6 !important;
  --stage-bg:     #e5e7eb !important;
  --btn-txt:      #374151 !important;
  --action-txt:   #ffffff !important;
  --danger:       #ef4444 !important;
}

/* 4. TEMA HIGH CONTRAST (Giallo su Nero) */
body[data-theme="hc-yellow"] {
  --bg:           #000000 !important;
  --card:         #000000 !important;
  --card-deep:    #000000 !important;
  --txt:          #ffff00 !important;
  --mut:          #cccc00 !important;
  --br:           #ffff00 !important;
  --acc:          #ffff00 !important;
  --acc-hover:    #ffffff !important;
  --acc-glow:     rgba(255, 255, 0, 0.2) !important;
  --input-bg:     #000000 !important;
  --btn-bg:       #000000 !important;
  --btn-border:   #ffff00 !important;
  --hover-bg:     #333300 !important;
  --stage-bg:     #000000 !important;
  --btn-txt:      #ffff00 !important;
  --action-txt:   #000000 !important;
  --danger:       #ff3300 !important;
}

/* ============================================================
   RESET & BASE
   ============================================================ */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-main, system-ui, -apple-system, Segoe UI, Roboto, sans-serif);
  background: var(--bg);
  color: var(--txt);
  height: 100vh;
  overflow: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

header {
  padding: 0 16px;
  border-bottom: 1px solid var(--br);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  flex-shrink: 0;
  transition: background 0.3s ease, border-color 0.3s ease;
  z-index: 100;
}

header h1 { 
    font-size: 16px; 
    font-weight: 600; 
    margin: 0; 
    color: var(--txt); 
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-logo-img {
    height: 28px;
}

header .hint { font-size: 12px; color: var(--mut); }

.header-actions { display: flex; align-items: center; gap: 8px; }
#langSelector { width: auto; padding: 6px 10px; font-size: 12px; cursor: pointer; }

/* START MODIFICATION: Stili per il selettore di temi personalizzato */
.custom-select-wrapper {
  position: relative;
  user-select: none;
  width: 200px;
}

.custom-select-trigger {
  background: var(--input-bg);
  border: 1px solid var(--br);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.2s;
}
.custom-select-trigger:hover {
  border-color: var(--mut);
}
.custom-select-trigger::after {
  content: '▼';
  font-size: 10px;
  opacity: 0.5;
}

.custom-select-options {
  position: absolute;
  top: 110%;
  left: 0;
  right: 0;
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--br);
  border-radius: 8px;
  z-index: 100;
  display: none;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  overflow: hidden;
}
.custom-select-options.open {
  display: block;
}

.custom-select-option {
  padding: 10px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}
.custom-select-option:hover {
  background-color: var(--hover-bg);
  color: var(--acc);
}
/* END MODIFICATION */


/* ============================================================
   LAYOUT PRINCIPALE
   ============================================================ */

.wrap {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 12px;
  padding: 12px;
  height: calc(100vh - 60px);
  transition: filter 0.3s ease;
}

.panel {
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--br) transparent;
}

.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: var(--br); border-radius: 3px; }

/* ============================================================
   ACCORDION (details/summary)
   ============================================================ */

details {
  background: var(--card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--br);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

summary {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--mut);
  background: var(--card-deep);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: all 0.2s ease;
}

summary:hover { background: var(--hover-bg); color: var(--txt); }
summary::-webkit-details-marker { display: none; }
summary::after { content: '+'; font-size: 18px; font-weight: 400; color: var(--mut); }
details[open] summary::after { content: '−'; }
details[open] summary { color: var(--acc); background: var(--hover-bg); border-bottom: 1px solid var(--br); }

.grp-content { padding: 12px 16px; font-size: 13px; }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */

.row { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin: 12px 0; }
.row label { font-size: 13px; color: var(--txt); min-width: 110px; }
.row input[type="range"] { width: 180px; accent-color: var(--acc); }
.row output { font-variant-numeric: tabular-nums; color: var(--mut); font-size: 13px; min-width: 48px; text-align: right; }

select, textarea, input[type="text"], input[type="password"], input[type="number"] {
  background: var(--input-bg);
  color: var(--txt);
  border: 1px solid var(--br);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
}

textarea { resize: vertical; min-height: 80px; }
select:hover, textarea:hover, input:hover { border-color: var(--mut); }
select:focus, textarea:focus, input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-glow); }

.row.disabled {
  opacity: 0.35;
  pointer-events: none;
  user-select: none;
}

/* ============================================================
   BUTTONS & GRIDS
   ============================================================ */

.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.btns3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.btns4 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

button, .filebtn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--btn-txt);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

button:hover, .filebtn:hover { 
  background: var(--hover-bg); 
  border-color: var(--acc); 
  color: var(--acc);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.25);
}
button:active, .filebtn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
button:disabled { opacity: 0.38; cursor: not-allowed; border-color: var(--br); color: var(--mut); transform: none; box-shadow: none; }

.modeOn { border-color: var(--acc); color: var(--acc); background: var(--acc-glow); }
.danger { border-color: var(--danger); color: var(--danger); }
.danger:hover { background: var(--danger); color: white; border-color: var(--danger); }

.action-btn {
  background: linear-gradient(135deg, var(--acc-hover) 0%, var(--acc) 100%) !important;
  color: var(--action-txt) !important;
  border: none !important;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0, 240, 255, 0.2);
}
.action-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0, 240, 255, 0.3); }

input[type="file"] { display: none; }

/* ============================================================
   VIEWER & CANVAS
   ============================================================ */

.viewer {
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--br);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--br);
  background: var(--card);
  flex-shrink: 0;
}
.topbar .left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.pill {
  border: 1px solid var(--br);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  background: var(--card-deep);
  color: var(--txt);
}

.stage {
  position: relative;
  flex: 1;
  background: var(--stage-bg);
  overflow: hidden;
  transition: background 0.3s ease;
}

canvas {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.overlay-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(120,120,140,0.18) 0, rgba(120,120,140,0.18) 1px, transparent 1px, transparent 40px),
              repeating-linear-gradient(90deg, rgba(120,120,140,0.18) 0, rgba(120,120,140,0.18) 1px, transparent 1px, transparent 40px);
  opacity: 0;
  transition: opacity 0.2s;
}
.overlay-grid.on { opacity: 0.7; }

.split { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--acc); left: 50%; transform: translateX(-1px); display: none; pointer-events: none; z-index: 10; }
.split.on { display: block; }
.splitlabel { position: absolute; top: 10px; left: 10px; font-size: 12px; color: #fff; background: rgba(0,0,0,.6); border: 1px solid rgba(255,255,255,0.2); border-radius: 10px; padding: 6px 10px; pointer-events: none; z-index: 10; display: none; }

/* ============================================================
   MISC & UTILITIES
   ============================================================ */

#histo { width: 100%; height: 100px; background: var(--card-deep); border: 1px solid var(--br); border-radius: 8px; margin-top: 8px; transition: background 0.3s ease, border-color 0.3s ease; }
.small { font-size: 11px; color: var(--mut); line-height: 1.35; }
.tag { font-size: 11px; color: var(--mut); margin-top: 6px; }
.inline { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin: 8px 0; }
.inline .left { display: flex; gap: 10px; align-items: center; }
input[type="color"] { width: 46px; height: 32px; border: 1px solid var(--btn-border); background: var(--input-bg); border-radius: 8px; padding: 2px; cursor: pointer; }
.kbd { font-size: 11px; color: var(--txt); border: 1px solid var(--br); border-radius: 6px; padding: 2px 6px; background: var(--card-deep); }

/* ============================================================
   MODAL / DIALOG
   ============================================================ */

dialog {
  background: var(--card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  color: var(--txt);
  border: 1px solid var(--br);
  border-radius: 20px;
  padding: 0;
  width: 86vw;
  max-width: 1100px;
  height: 82vh;
  box-shadow: 0 32px 80px rgba(0,0,0,0.8);
}

dialog::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); }
.modal-header { padding: 14px 20px; border-bottom: 1px solid var(--br); display: flex; justify-content: space-between; align-items: center; background: var(--card-deep); }
.modal-body { height: calc(100% - 54px); position: relative; overflow: hidden; background: var(--stage-bg); }
#canvas3d { width: 100%; height: 100%; display: block; cursor: move; }
.overlay-3d-controls { position: absolute; bottom: 16px; left: 16px; right: 16px; pointer-events: none; display: flex; justify-content: center; gap: 10px; }
.overlay-3d-controls button { pointer-events: auto; background: var(--card); border: 1px solid var(--br); color: var(--txt); }

/* ============================================================
   LOADER & RESPONSIVE
   ============================================================ */

.loader {
  border: 3px solid rgba(180,180,180,0.2);
  border-left-color: var(--action-txt);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  animation: spin 1s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

#license-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--txt);
  padding: 20px;
}

.license-content {
  background: var(--card);
  border: 1px solid var(--br);
  border-radius: 16px;
  padding: 40px;
  max-width: 480px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.license-content h2 {
  margin-top: 0;
  color: var(--acc);
}

.license-content p {
  color: var(--mut);
  margin-bottom: 24px;
  line-height: 1.6;
}

body.locked .wrap {
  filter: blur(8px);
  pointer-events: none;
}


@media (max-width: 980px) {
  .wrap { grid-template-columns: 1fr; height: auto; display: block; padding: 8px; }
  .panel { max-height: none; overflow: visible; }
  .stage { height: 55vh; min-height: 380px; }
  dialog { width: 94vw; height: 78vh; }
}

/* ============================================================
   ENTRY ANIMATIONS
   ============================================================ */

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

header {
  animation: fadeSlideIn 0.4s ease both;
}

.wrap {
  animation: fadeSlideIn 0.5s 0.1s ease both;
}

details {
  animation: fadeSlideIn 0.4s ease both;
}

details:nth-child(1)  { animation-delay: 0.05s; }
details:nth-child(2)  { animation-delay: 0.10s; }
details:nth-child(3)  { animation-delay: 0.15s; }
details:nth-child(4)  { animation-delay: 0.20s; }
details:nth-child(5)  { animation-delay: 0.25s; }
details:nth-child(6)  { animation-delay: 0.30s; }
details:nth-child(7)  { animation-delay: 0.35s; }
details:nth-child(8)  { animation-delay: 0.40s; }
details:nth-child(9)  { animation-delay: 0.45s; }
details:nth-child(10) { animation-delay: 0.50s; }
details:nth-child(11) { animation-delay: 0.55s; }
details:nth-child(12) { animation-delay: 0.60s; }

/* ============================================================
   SMOOTH THEME TRANSITIONS (all properties)
   ============================================================ */

*, *::before, *::after {
  transition-property: background-color, border-color, color, box-shadow;
  transition-duration: 0.25s;
  transition-timing-function: ease;
}

/* But keep transform transitions from being overridden */
button, .filebtn, .action-btn, details, summary, select, input, .custom-select-trigger {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease,
              box-shadow 0.25s ease, transform 0.2s ease, opacity 0.2s ease;
}

/* ============================================================
   CUSTOM CURSORS PER MODALITÀ
   ============================================================ */

.stage { cursor: grab; }
.stage:active { cursor: grabbing; }

body[data-mode="roi"] .stage,
body[data-mode="roiFree"] .stage  { cursor: crosshair; }

body[data-mode="draw"] .stage     { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='8' fill='none' stroke='%2300f0ff' stroke-width='2'/%3E%3Ccircle cx='10' cy='10' r='2' fill='%2300f0ff'/%3E%3C/svg%3E") 10 10, crosshair; }

body[data-mode="mask"] .stage     { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='8' fill='rgba(255,255,255,0.15)' stroke='white' stroke-width='2'/%3E%3C/svg%3E") 10 10, crosshair; }

body[data-mode="eraser"] .stage   { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='8' fill='none' stroke='%23ff4466' stroke-width='2' stroke-dasharray='3,2'/%3E%3C/svg%3E") 10 10, crosshair; }

body[data-mode="wand"] .stage     { cursor: cell; }

body[data-mode="measureDist"] .stage,
body[data-mode="measureAngle"] .stage { cursor: crosshair; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  border: 1px solid transparent;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  backdrop-filter: blur(12px);
}

.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast-success { background: rgba(0, 200, 100, 0.12); border-color: rgba(0, 200, 100, 0.4); color: #5fff9a; }
.toast-error   { background: rgba(255, 60, 100, 0.12); border-color: rgba(255, 60, 100, 0.4); color: #ff7096; }
.toast-warning { background: rgba(255, 180, 0, 0.12); border-color: rgba(255, 180, 0, 0.4); color: #ffd060; }
.toast-info    { background: rgba(0, 200, 255, 0.12); border-color: rgba(0, 200, 255, 0.4); color: #5eeaff; }

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-msg  { flex: 1; line-height: 1.4; }
.toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
  flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }

/* ============================================================
   AUTOSAVE RESTORE BANNER
   ============================================================ */

#restore-banner {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: var(--card);
  border: 1px solid var(--acc);
  border-radius: 10px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  z-index: 10000;
  box-shadow: 0 8px 30px rgba(0,240,255,0.15);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#restore-banner.restore-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#restore-banner button {
  padding: 6px 12px;
  font-size: 12px;
}

/* ============================================================
   TONE CURVES PANEL
   ============================================================ */

#panelToneCurves .curve-ch-btns {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.curve-ch-btn {
  flex: 1;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 600;
}

.curve-ch-btn[data-ch="luma"]  { border-color: var(--acc); }
.curve-ch-btn[data-ch="luma"].modeOn { background: rgba(0,240,255,0.15); color: var(--acc); }
.curve-ch-btn[data-ch="r"].modeOn { background: rgba(255,68,102,0.15); color: #ff4466; border-color: #ff4466; }
.curve-ch-btn[data-ch="g"].modeOn { background: rgba(68,255,136,0.15); color: #44ff88; border-color: #44ff88; }
.curve-ch-btn[data-ch="b"].modeOn { background: rgba(68,136,255,0.15); color: #4488ff; border-color: #4488ff; }

#curvesCanvas {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--br);
  cursor: crosshair;
  display: block;
}

.curve-hint {
  font-size: 10px;
  color: var(--mut);
  text-align: center;
  margin-top: 6px;
  line-height: 1.4;
}

/* ============================================================
   EXPORT MODAL
   ============================================================ */

#exportModal {
  width: min(480px, 90vw);
  height: auto;
  border-radius: 16px;
}

#exportModal .modal-body {
  height: auto;
  padding: 24px;
  overflow: visible;
}

.export-format-btns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.export-fmt-btn {
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
}

.export-fmt-btn.modeOn {
  border-color: var(--acc);
  color: var(--acc);
  background: var(--acc-glow);
}

#exportQualityRow {
  margin: 12px 0;
}

/* ============================================================
   KEYBOARD SHORTCUTS OVERLAY
   ============================================================ */

#kbd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(10px);
  z-index: 88888;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

#kbd-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.kbd-card {
  background: var(--card);
  border: 1px solid var(--br);
  border-radius: 16px;
  padding: 32px;
  max-width: 560px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.kbd-card h3 {
  margin: 0 0 20px;
  color: var(--acc);
  font-size: 15px;
}

.kbd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
}

.kbd-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--mut);
  padding: 4px 0;
  border-bottom: 1px solid var(--br);
}

.kbd-row .kbd { font-size: 11px; flex-shrink: 0; }
.kbd-row span { color: var(--txt); }

/* ============================================================
   DRAG & DROP OVERLAY
   ============================================================ */

#drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,240,255,0.08);
  border: 3px dashed var(--acc);
  border-radius: 12px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  font-size: 18px;
  color: var(--acc);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#drop-overlay.active { opacity: 1; }

/* ============================================================
   PANEL QUICK NAV
   ============================================================ */

#panel-quicknav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--br);
  border-radius: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.qnav-btn {
  font-size: 16px;
  padding: 6px 10px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--mut);
  transition: all 0.2s;
  line-height: 1;
}

.qnav-btn:hover {
  background: var(--hover-bg);
  border-color: var(--acc);
  color: var(--acc);
}

/* ============================================================
   RGB HISTOGRAM (multi-channel)
   ============================================================ */

#histo {
  width: 100%;
  height: 120px;
  background: var(--card-deep);
  border: 1px solid var(--br);
  border-radius: 8px;
  margin-top: 8px;
  cursor: pointer;
}

.histo-channel-btns {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.histo-ch-btn {
  flex: 1;
  font-size: 11px;
  padding: 4px;
}

.histo-ch-btn.modeOn { color: var(--acc); border-color: var(--acc); }
/* ============================================================
   FINAL DESIGN POLISH (Micro-interactions, Scrollbar, Pulse)
   ============================================================ */

/* macOS Style Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.4);
}

/* Global Font Enforcement */
input, select, textarea, button {
  font-family: 'Inter', sans-serif !important;
  transition: all 0.3s ease !important;
}

/* Button Hovers */
button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
button:active:not(:disabled) {
  transform: translateY(1px);
}

/* Pulse Animations for primary CTAs */
@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 15px rgba(255, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 68, 68, 0); }
}
@keyframes pulse-cyan {
  0% { box-shadow: 0 0 0 0 var(--acc-glow); }
  70% { box-shadow: 0 0 0 15px rgba(0, 240, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0); }
}

#vRecordBtn[style*="color: #fff"] {
  animation: pulse-red 2s infinite !important;
}

#startBatchBtn[style*="opacity: 1"] {
  animation: pulse-cyan 2s infinite !important;
}

/* Improved padding in row sliders */
.row {
  margin-bottom: 8px;
}
.row label {
  font-weight: 500;
}
.row input[type="range"] {
  cursor: pointer;
}

/* Glassmorphism Polish on Aside */
.panel {
  box-shadow: -5px 0 30px rgba(0,0,0,0.5);
  border-left: 1px solid rgba(255,255,255,0.05);
}
