/* ─── Retouche Editor Screen ─── */

#retoucheScreen {
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.retouche-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 20;
}

.retouche-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eae6e1;
  position: relative;
  overflow: hidden;
}

body.dark-mode .retouche-preview {
  background: #1e1e22;
}

#retoucheCanvas {
  max-width: calc(100% - 40px);
  max-height: 100%;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.retouche-config {
  width: 320px;
  min-width: 320px;
  max-height: 100%;
  overflow-y: auto;
}

/* ─── Histogram (inline panel) ─── */
.retouche-histogram {
  margin-bottom: 12px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0,0,0,0.03);
}

.histogram-canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* ─── Histogram (overlay on preview) ─── */
.histogram-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.histogram-overlay-canvas {
  border-radius: 6px;
  display: block;
  opacity: 0.85;
}

.histogram-toggle {
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.6rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.15s;
}

.histogram-toggle:hover {
  background: rgba(0,0,0,0.7);
}

/* ─── Slider groups ─── */
.retouche-sliders {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.retouche-group {
  border-radius: 8px;
  overflow: hidden;
}

.retouche-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent);
  padding: 10px 12px 6px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.retouche-group-title::before {
  content: '▾';
  font-size: 0.7rem;
  transition: transform 0.15s;
}

.retouche-group.collapsed .retouche-group-title::before {
  transform: rotate(-90deg);
}

.retouche-group-body {
  padding: 0 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.retouche-group.collapsed .retouche-group-body {
  display: none;
}

/* ─── Individual sliders ─── */
.slider-control {
  cursor: default;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.slider-value {
  font-weight: 600;
  color: var(--text);
  font-size: 0.75rem;
  min-width: 36px;
  text-align: right;
}

.slider-control input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.slider-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.slider-control input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Highlight when value != 0 */
.slider-control input[type="range"]:not([value="0"]) {
  accent-color: var(--accent);
}

/* ─── Tone Curve Widget ─── */
.tone-curve-container {
  width: 100%;
}

.tc-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.tc-tab {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.tc-tab:hover { background: var(--surface-hover); }
.tc-tab.active { background: var(--bg); border-color: var(--text-secondary); }

.tc-svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  cursor: crosshair;
}

/* ─── HSL Panel ─── */
.hsl-panel {
  width: 100%;
}

.hsl-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  justify-content: center;
}

.hsl-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  padding: 0;
}

.hsl-dot:hover { transform: scale(1.15); }
.hsl-dot.active { border-color: var(--text); transform: scale(1.2); }

.hsl-channel-label {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.hsl-sliders {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ─── Color Grading Panel ─── */
.cg-panel {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: flex-start;
}

.cg-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.cg-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.cg-wheel-wrap {
  position: relative;
  width: 80px;
  height: 80px;
}

.cg-wheel {
  border-radius: 50%;
  cursor: crosshair;
  display: block;
}

.cg-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border: 1.5px solid #333;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.cg-reset {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.7rem;
  padding: 2px 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: inherit;
}

.cg-reset:hover { background: var(--surface-hover); }

/* ─── Crop Overlay ─── */
.crop-container {
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
}

.crop-container.hidden { display: none; }

.crop-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
}

.crop-ratios {
  display: flex;
  gap: 4px;
}

.crop-ratio-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.crop-ratio-btn:hover { background: var(--surface-hover); }
.crop-ratio-btn.active { border-color: var(--accent); background: var(--accent-light); }

.crop-rot-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.crop-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ─── Filmstrip ─── */
.filmstrip {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  align-items: stretch;
  min-height: 110px;
}

.filmstrip::-webkit-scrollbar {
  height: 4px;
}

.filmstrip::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.filmstrip-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
  max-width: 100px;
  cursor: pointer;
  border-radius: 6px;
  border: 2px solid transparent;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.15s, border-color 0.15s;
}

.filmstrip-item:hover {
  opacity: 0.85;
}

.filmstrip-item.active {
  border-color: var(--accent);
  opacity: 1;
}

.filmstrip-thumb {
  width: 100%;
  height: 64px;
  border-radius: 4px;
  object-fit: cover;
  display: block;
}

.filmstrip-info {
  width: 100%;
  text-align: center;
  padding-top: 2px;
}

.filmstrip-name {
  display: block;
  font-size: 0.55rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.filmstrip-stars {
  display: flex;
  justify-content: center;
  gap: 0;
}

.fs-star {
  font-size: 0.6rem;
  color: var(--border);
  cursor: pointer;
  line-height: 1;
  transition: color 0.1s;
}

.fs-star:hover,
.fs-star.active {
  color: #f5a623;
}

/* ─── Compare button ─── */
.active-compare {
  background: var(--accent-light) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* ─── Reset button ─── */
.retouche-reset-wrap {
  padding: 12px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.retouche-reset-btn {
  width: 100%;
  text-align: center;
  padding: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.retouche-reset-btn:hover {
  color: #c44;
  border-color: #c44;
}

/* ─── Presets Grid ─── */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 0;
}

.preset-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 4px;
  font-size: 0.65rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.2;
}

.preset-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.preset-btn.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .retouche-config {
    width: 100%;
    min-width: 100%;
    max-height: 50vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .retouche-preview {
    min-height: 250px;
  }

  .filmstrip {
    min-height: 50px;
  }

  .filmstrip-thumb {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  .presets-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
