/*
 * VSCO Film Studio - Leica / Analog Darkroom Design System
 * Supports resizable panels, left vertical filmstrip, bottom preset shelf,
 * master filter strength bar, collapsible sidebar, and keyboard shortcuts.
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg-main: #0c0d0f;
  --bg-surface: #141619;
  --bg-card: #1b1e22;
  --bg-card-hover: #22262c;
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-active: rgba(255, 255, 255, 0.22);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent-gold: #e5a964;
  --accent-glow: rgba(229, 169, 100, 0.28);
  --accent-blue: #3b82f6;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;
  --header-height: 56px;
  --left-width: 240px;
  --sidebar-width: 360px;
  --preset-shelf-height: 124px;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Grotesk', monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ==========================================================================
   Header Bar
   ========================================================================== */

.app-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 50;
  flex-shrink: 0;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-gold);
  box-shadow: 0 0 10px var(--accent-gold);
}

.badge-version {
  font-size: 9px;
  font-family: var(--font-mono);
  letter-spacing: 1px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.header-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-accent {
  background: var(--accent-gold);
  color: #0c0d0f;
  font-weight: 600;
  border-color: transparent;
}

.btn-accent:hover {
  background: #f0b573;
  box-shadow: 0 0 14px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.btn-mini {
  padding: 3px 8px;
  font-size: 11px;
}

/* ==========================================================================
   Main Viewport
   ========================================================================== */

.app-main {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Resizer Handles */
.resizer-handle {
  background: transparent;
  z-index: 30;
  transition: background 0.15s;
  flex-shrink: 0;
  position: relative;
}

.resizer-col {
  width: 5px;
  cursor: col-resize;
}

.resizer-row {
  height: 5px;
  cursor: row-resize;
}

.resizer-handle:hover,
.resizer-handle.resizing {
  background: var(--accent-gold);
}

/* ==========================================================================
   LEFT: Vertical Filmstrip Queue
   ========================================================================== */

.vertical-filmstrip {
  width: var(--left-width);
  min-width: 170px;
  max-width: 400px;
  background: #090a0c;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.filmstrip-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.filmstrip-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filmstrip-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

.badge-count {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.filmstrip-hint {
  font-size: 10px;
  font-family: var(--font-mono);
  color: #555c69;
}

.vertical-filmstrip-items {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vertical-filmstrip-items::-webkit-scrollbar {
  width: 4px;
}
.vertical-filmstrip-items::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

.filmstrip-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filmstrip-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateX(2px);
}

.filmstrip-card.active {
  background: #232830;
  border-color: var(--accent-gold);
  box-shadow: 0 0 12px var(--accent-glow);
}

.filmstrip-thumb-box {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  overflow: hidden;
  background: #111;
  flex-shrink: 0;
}

.filmstrip-thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.filmstrip-meta-box {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.filmstrip-filename {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filmstrip-preset-tag {
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.filmstrip-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

/* ==========================================================================
   CENTER: Darkroom Workspace
   ========================================================================== */

.darkroom-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 40%, #171a1f 0%, #0c0d0f 80%);
  position: relative;
  overflow: hidden;
  min-width: 320px;
}

.workspace-toolbar {
  height: 40px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(20, 22, 25, 0.65);
  backdrop-filter: blur(8px);
  z-index: 10;
  flex-shrink: 0;
}

.meta-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.meta-pill {
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-hint {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Canvas Stage */
.canvas-stage-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.canvas-stage {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
  background: #000;
  user-select: none;
}

.canvas-stage canvas {
  display: block;
  max-width: calc(100vw - var(--left-width) - var(--sidebar-width) - 60px);
  max-height: calc(100vh - var(--header-height) - var(--preset-shelf-height) - 140px);
  width: auto;
  height: auto;
  object-fit: contain;
}

#canvas-graded {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  transition: clip-path 0.02s linear;
}

/* Split Handle */
.split-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: #ffffff;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.95), 0 0 4px rgba(255, 255, 255, 0.8);
  z-index: 25;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.15s ease;
}

/* Wide invisible hit area so dragging is effortless */
.split-handle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -24px;
  width: 52px;
  cursor: ew-resize;
}

/* Prominent ergonomic drag grabber pill */
.split-grabber {
  width: 44px;
  height: 62px;
  background: rgba(14, 16, 20, 0.95);
  backdrop-filter: blur(12px);
  border: 2.5px solid #ffffff;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85), 0 0 14px rgba(255, 255, 255, 0.3);
  pointer-events: none;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.split-handle:hover .split-grabber,
.split-handle.dragging .split-grabber {
  transform: scale(1.08);
  border-color: var(--accent-gold);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.9), 0 0 20px var(--accent-gold);
}

.canvas-stage.show-original-only #canvas-graded {
  opacity: 0 !important;
}

.canvas-stage.show-original-only .split-handle {
  display: none !important;
}

/* Interactive On-Canvas Crop Overlay */
.crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: auto;
  user-select: none;
}

.canvas-stage.crop-active .split-handle {
  display: none !important;
}

.crop-box {
  position: absolute;
  border: 2px solid var(--accent-gold);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65), 0 0 15px rgba(229, 169, 79, 0.35);
  cursor: move;
  box-sizing: border-box;
}

.crop-grid-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.crop-grid-h {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.35);
}
.crop-grid-h.h1 { top: 33.333%; }
.crop-grid-h.h2 { top: 66.666%; }

.crop-grid-v {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.35);
}
.crop-grid-v.v1 { left: 33.333%; }
.crop-grid-v.v2 { left: 66.666%; }

/* Corner and Edge Resize Handles */
.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border: 2px solid var(--accent-gold);
  border-radius: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  z-index: 25;
}

.handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-n  { top: -6px; left: calc(50% - 6px); cursor: ns-resize; }
.handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-e  { top: calc(50% - 6px); right: -6px; cursor: ew-resize; }
.handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.handle-s  { bottom: -6px; left: calc(50% - 6px); cursor: ns-resize; }
.handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-w  { top: calc(50% - 6px); left: -6px; cursor: ew-resize; }

.crop-dimension-badge {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 15, 18, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 12px;
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.crop-floating-toolbar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 21, 28, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.75);
  border-radius: 20px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 30;
  backdrop-filter: blur(10px);
}

/* ==========================================================================
   MASTER FILTER BAR (Atop the Presets Shelf)
   ========================================================================== */

.master-filter-bar {
  height: 52px;
  background: #111317;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 20px;
  flex-shrink: 0;
  z-index: 15;
}

.master-filter-info {
  display: flex;
  flex-direction: column;
  min-width: 170px;
}

.master-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.master-label-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 1px;
}

.master-current-preset {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.master-key-hint {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.master-slider-control {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 16px;
}

.master-range-input {
  flex: 1;
  height: 6px !important;
  accent-color: var(--accent-gold);
}

.master-quick-buttons {
  display: flex;
  gap: 4px;
}

.btn-quick-strength {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s;
}

.btn-quick-strength:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-quick-strength.active {
  background: var(--accent-gold);
  color: #0c0d0f;
  font-weight: 600;
  border-color: transparent;
}

.master-val-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.master-strength-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-gold);
  color: #0c0d0f;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ==========================================================================
   BOTTOM: Preset Shelf (Horizontal)
   ========================================================================== */

.preset-shelf {
  height: var(--preset-shelf-height);
  min-height: 90px;
  max-height: 240px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 8px 16px;
  flex-shrink: 0;
  overflow: hidden;
}

.preset-grid {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
  align-items: stretch;
  padding-bottom: 4px;
}

.preset-grid::-webkit-scrollbar {
  height: 4px;
}
.preset-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.preset-card {
  min-width: 160px;
  max-width: 180px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  flex-shrink: 0;
}

.preset-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.preset-card.active {
  background: #252b34;
  border-color: var(--accent-gold);
  box-shadow: 0 0 14px var(--accent-glow);
}

.preset-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.preset-badge {
  font-size: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid;
}

.preset-key-indicator {
  font-size: 9px;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 1px 4px;
  border-radius: 3px;
}

.preset-name {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
}

.preset-desc {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   RIGHT: Fine-Tuning Sidebar (Collapsible)
   ========================================================================== */

.darkroom-sidebar {
  width: var(--sidebar-width);
  min-width: 280px;
  max-width: 500px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1px;
  font-weight: 700;
  text-transform: uppercase;
}

.controls-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.controls-scrollable::-webkit-scrollbar {
  width: 4px;
}
.controls-scrollable::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 4px;
}

/* Distinct Card-Style Control Sections */
.control-section {
  background: #181c24;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid rgba(229, 169, 100, 0.45);
  border-radius: 8px;
  padding: 14px 14px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.control-section:hover {
  border-color: rgba(255, 255, 255, 0.16);
  border-left-color: var(--accent-gold);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  background: #1c212a;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 2px;
}

.section-badge {
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent-gold);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.section-label {
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent-gold);
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 2px;
}

.btn-section-reset {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-mono);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.btn-section-reset:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

/* Geometry & Framing Controls */
.geometry-tools-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.btn-geo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: #1c2028;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-geo:hover {
  background: #262b36;
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.btn-geo:active {
  transform: translateY(0);
}

.crop-section-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.btn-crop-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(229, 169, 79, 0.12);
  border: 1px solid rgba(229, 169, 79, 0.35);
  color: var(--accent-gold);
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-crop-toggle:hover, .btn-crop-toggle.active {
  background: var(--accent-gold);
  color: #0d0f12;
  border-color: var(--accent-gold);
  font-weight: 600;
}

.aspect-ratio-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.btn-ratio {
  background: #1a1e26;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  padding: 6px 2px;
  border-radius: 5px;
  font-size: 9.5px;
  font-family: var(--font-mono);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.btn-ratio:hover {
  background: #232833;
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-ratio.active {
  background: rgba(229, 169, 79, 0.22);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  font-weight: 600;
  box-shadow: 0 0 8px rgba(229, 169, 79, 0.2);
}

.crop-actions-bar {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.control-name {
  color: var(--text-primary);
  font-weight: 500;
}

.control-val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-gold);
}

/* Range Inputs */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: #282c34;
  border-radius: 2px;
  outline: none;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #141619;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
  transition: transform 0.1s ease, background 0.1s ease;
}

input[type='range']::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  background: var(--accent-gold);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-shrink: 0;
}

/* Collapsed State: when user only wants the master slider */
.sidebar-collapsed #darkroom-sidebar {
  width: 0 !important;
  min-width: 0 !important;
  border-left: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.sidebar-collapsed #resizer-right {
  display: none !important;
}

.sidebar-collapsed .canvas-stage canvas {
  max-width: calc(100vw - var(--left-width) - 60px);
}

/* ==========================================================================
   Modals & Overlays
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.visible {
  display: flex;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
  width: 90%;
  max-width: 440px;
}

/* Shortcuts List in Modal */
.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.shortcut-key {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  background: #252a32;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--accent-gold);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

/* Drag overlay */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 13, 15, 0.9);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-overlay.active {
  display: flex;
}

.drop-card {
  padding: 40px 60px;
  background: var(--bg-card);
  border: 2px dashed var(--accent-gold);
  border-radius: var(--radius-lg);
  text-align: center;
}

/* Progress bar */
.progress-track {
  width: 100%;
  height: 7px;
  background: #252830;
  border-radius: 4px;
  overflow: hidden;
  margin: 16px 0;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-gold), #f3c285);
  border-radius: 4px;
  transition: width 0.15s ease;
}

/* Toast */
#toast-notification {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 22, 25, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-active);
  color: #fff;
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 999;
}

#toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   AUTHENTICATION: Private Darkroom Gatekeeper
   ========================================================================== */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #1c1f26 0%, #0b0c0e 75%, #050507 100%);
  padding: 20px;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-overlay.fade-out {
  opacity: 0;
  transform: scale(1.02);
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: rgba(18, 20, 24, 0.88);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(212, 163, 115, 0.25);
  border-radius: 16px;
  padding: 40px 32px 32px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.85), 0 0 50px rgba(212, 163, 115, 0.08);
  text-align: center;
  position: relative;
  animation: authCardFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardFadeIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-emblem {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.auth-emblem-ring {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(212, 163, 115, 0.12);
  border: 1px solid rgba(212, 163, 115, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(212, 163, 115, 0.2);
}

.auth-lock-icon {
  font-size: 24px;
}

.auth-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent-gold);
  background: rgba(212, 163, 115, 0.12);
  border: 1px solid rgba(212, 163, 115, 0.25);
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.auth-title {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #ffffff;
  margin: 0 0 6px 0;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 26px 0;
  line-height: 1.4;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.auth-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.auth-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input {
  width: 100%;
  height: 44px;
  background: #111317;
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 14px;
  font-family: var(--font-sans);
  padding: 0 44px 0 14px;
  outline: none;
  transition: all 0.2s ease;
}

.auth-input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(212, 163, 115, 0.2);
  background: #14171d;
}

.auth-input.input-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

.btn-toggle-eye {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-toggle-eye:hover {
  color: #fff;
}

.auth-error {
  font-size: 12px;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  animation: authCardFadeIn 0.2s ease;
}

.auth-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.auth-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.auth-checkbox-label input[type="checkbox"] {
  accent-color: var(--accent-gold);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.btn-unlock {
  height: 44px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-md);
  margin-top: 6px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 20px rgba(212, 163, 115, 0.3);
}

.btn-unlock:hover {
  box-shadow: 0 6px 24px rgba(212, 163, 115, 0.45);
}

.arrow-glyph {
  font-size: 16px;
  transition: transform 0.2s ease;
}

.btn-unlock:hover .arrow-glyph {
  transform: translateX(3px);
}

.auth-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  font-family: var(--font-mono);
}

.auth-hint code {
  color: var(--accent-gold);
  background: rgba(212, 163, 115, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
}

.auth-dot-sep {
  opacity: 0.4;
}

.shake-anim {
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

.spinner-inline {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

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

