/* ═══════════════════════════════════════════════════
   Component Styles
   ═══════════════════════════════════════════════════ */

/* ── Header ── */
.header {
  height: calc(var(--header-height) + var(--safe-area-top));
  padding-top: var(--safe-area-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: var(--space-16);
  padding-right: var(--space-16);
  background: var(--base);
  z-index: var(--z-header);
  flex-shrink: 0;
}

.header__btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.header__btn svg {
  width: 18px;
  height: 18px;
}

.header__btn--disabled {
  color: var(--text-disabled);
  pointer-events: none;
}

.header__btn--mode {
  color: var(--text-secondary);
  transition: color 0.2s;
}

.header__btn--mode-active {
  color: var(--accent);
}

/* ── Duotone Panel ── */

.header__title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.header__actions {
  display: flex;
  gap: var(--space-4);
}

/* ── Image View ── */
.image-view {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  position: relative;
  touch-action: none;
}

.image-view canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Tab Switcher ── */
.tab-switcher {
  height: var(--tab-switcher-height);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-24);
  background: var(--base);
  flex-shrink: 0;
}

.tab-switcher__tab {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: var(--space-8) 0;
  border-bottom: 1.5px solid transparent;
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.tab-switcher__tab--active {
  color: var(--text-primary);
  border-bottom-color: var(--white-100);
}

/* ── Slider ── */
.slider-area {
  height: calc(var(--slider-area-height) + 18px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0 var(--space-24);
  background: var(--base);
  flex-shrink: 0;
}

.slider-area__label {
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

.slider {
  width: 100%;
  height: var(--slider-touch-target);
  position: relative;
  display: flex;
  align-items: center;
  touch-action: none;
}

.slider__track {
  width: 100%;
  height: var(--slider-track-height);
  background: var(--slider-track);
  border-radius: 1px;
  position: relative;
}

.slider__fill {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--slider-track-active);
  border-radius: 1px;
}

.slider__thumb {
  width: var(--slider-thumb-size);
  height: var(--slider-thumb-size);
  background: var(--slider-thumb);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  transition: transform var(--duration-fast) var(--ease-out);
}

.slider__thumb--active {
  transform: translate(-50%, -50%) scale(1.15);
}

.slider__label {
  display: none;
}

.slider__zero-mark {
  position: absolute;
  top: 50%;
  width: 1px;
  height: 8px;
  background: var(--white-20);
  transform: translateY(-50%);
}

/* ── Tools Bar ── */
.tools-bar {
  height: var(--tools-bar-height);
  display: flex;
  align-items: flex-start;
  padding: var(--space-8) 0;
  background: var(--base);
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}

.tools-bar__scroll {
  display: flex;
  gap: var(--space-4);
  padding: 0 var(--space-16);
}

.tool-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  min-width: 56px;
  padding: var(--space-8) var(--space-4);
  border-radius: var(--radius-md);
  scroll-snap-align: center;
}

.tool-item--active {
  background: var(--white-06);
}

.tool-item__icon {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.tool-item--active .tool-item__icon {
  color: var(--text-primary);
}

.tool-item__label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.tool-item--active .tool-item__label {
  color: var(--text-secondary);
}

/* ── Bottom Safe Area ── */
.safe-area-bottom {
  height: var(--safe-area-bottom);
  background: var(--base);
  flex-shrink: 0;
}

/* ── Library ── */
.library {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-2);
}

.library__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5px;
}

.library__item {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--elevated);
}

.library__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--space-16);
  color: var(--text-tertiary);
}

.library__empty-icon {
  width: 48px;
  height: 48px;
  opacity: 0.3;
}

/* ── Import Button (FAB) ── */
.fab {
  position: fixed;
  bottom: calc(var(--tab-bar-height) + var(--safe-area-bottom) + var(--space-16));
  right: var(--space-16);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--white-100);
  color: var(--base);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  z-index: var(--z-overlay);
}

/* ── Toast / Feedback ── */
.toast {
  position: fixed;
  bottom: calc(var(--safe-area-bottom) + 80px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  padding: var(--space-8) var(--space-16);
  border-radius: var(--radius-full);
  z-index: var(--z-modal);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.toast--visible {
  opacity: 1;
}

/* ── Skin Tone Panel ── */
.skin-tone-panel {
  padding: var(--space-8) var(--space-16);
}

.skin-tone-tabs {
  display: flex;
  gap: var(--space-8);
  margin-bottom: var(--space-8);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.skin-tone-tab {
  background: var(--surface);
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-full);
  padding: var(--space-4) var(--space-12);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  white-space: nowrap;
  cursor: pointer;
}

.skin-tone-tab--active {
  background: var(--accent);
  color: var(--base);
}

/* ── Border Panel ── */
.border-panel {
  padding: var(--space-8) var(--space-16);
}

.border-colors {
  display: flex;
  gap: var(--space-8);
  margin-bottom: var(--space-8);
  padding: 0 var(--space-16);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.border-color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--stroke);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out);
}

.border-color-btn--active {
  border-color: var(--accent);
  transform: scale(1.2);
}

.border-tabs {
  display: flex;
  gap: var(--space-8);
  margin-bottom: var(--space-8);
  padding: 0 var(--space-16);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.border-tab {
  background: var(--surface);
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-full);
  padding: var(--space-4) var(--space-12);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  white-space: nowrap;
  cursor: pointer;
}

.border-tab--active {
  background: var(--accent);
  color: var(--base);
}

/* ── Dodge & Burn Panel ── */
.dodge-burn-panel {
  padding: var(--space-8) var(--space-16);
}

.db-mode-toggle {
  display: flex;
  gap: var(--space-8);
  margin-bottom: var(--space-8);
  padding: 0 var(--space-16);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.db-mode-btn {
  background: var(--surface);
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-full);
  padding: var(--space-8) var(--space-16);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  cursor: pointer;
}

.db-mode-btn--active {
  background: var(--accent);
  color: var(--base);
}

.db-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.db-control {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.db-control label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  width: 100px;
  flex-shrink: 0;
}

.db-control input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 2px;
  background: var(--stroke);
  border-radius: 1px;
  outline: none;
}

.db-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.db-actions {
  display: flex;
  gap: var(--space-8);
  padding: 0 var(--space-16);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.db-overlay-canvas {
  opacity: 0;
}

/* ── Compare Hint (before/after) ── */
.image-view__compare-hint {
  position: absolute;
  top: var(--space-16);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: var(--white-100);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-4) var(--space-12);
  border-radius: var(--radius-full);
  z-index: 10;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
  pointer-events: none;
}

.image-view__compare-hint--visible {
  opacity: 1;
}

/* ── Library Delete Button ── */
.library__item {
  position: relative;
}

.library__delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: var(--white-100);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
  z-index: 2;
}

.library__delete svg {
  width: 14px;
  height: 14px;
}

.library__item:hover .library__delete,
.library__item:focus .library__delete {
  opacity: 1;
}

/* Show on touch devices via long-press area */
@media (hover: none) {
  .library__delete {
    opacity: 0.8;
  }
}

/* ── Unified Panel System ── */
.panel-body {
  padding: var(--space-4) 0;
}

.panel-chips {
  display: flex;
  gap: var(--space-8);
  margin-bottom: var(--space-8);
  padding: 0 var(--space-16);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.panel-chips::-webkit-scrollbar { display: none; }

.panel-chip {
  flex-shrink: 0;
  background: var(--surface);
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-full);
  padding: var(--space-4) var(--space-12);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.panel-chip--active {
  background: var(--accent);
  color: var(--base);
}

/* ── Settings Panel ── */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: var(--base);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
}

.settings-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-header {
  height: calc(var(--header-height) + var(--safe-area-top));
  padding-top: var(--safe-area-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: var(--space-16);
  padding-right: var(--space-16);
  flex-shrink: 0;
  border-bottom: 1px solid var(--white-06);
}

.settings-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.settings-title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.settings-reset {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
  letter-spacing: 0.04em;
  padding: var(--space-8);
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-16);
  padding-bottom: calc(var(--safe-area-bottom) + 32px);
}

.settings-section {
  margin-bottom: var(--space-24);
}

.settings-section__title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-8);
}

.settings-tool {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-8) 0;
  border-bottom: 1px solid var(--white-06);
}

.settings-tool__vis {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.settings-tool__vis svg {
  width: 18px;
  height: 18px;
}

.settings-tool__label {
  flex: 1;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.settings-tool__label--hidden {
  color: var(--text-disabled);
  text-decoration: line-through;
}

/* ── Drag Handle ── */
.settings-tool__drag-handle {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
}

.settings-tool__drag-handle svg {
  width: 18px;
  height: 18px;
}

.settings-tool--placeholder {
  opacity: 0.25;
  background: var(--white-06);
  border-radius: var(--radius-sm);
}

.settings-tool--dragging-ghost {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  background: var(--elevated);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  padding: var(--space-8) var(--space-12);
  display: flex;
  align-items: center;
  gap: var(--space-8);
  opacity: 0.9;
}

/* ── Dust Panel ── */
.dust-panel {
  padding: var(--space-4) 0;
}

.dust-section-tabs {
  display: flex;
  gap: var(--space-4);
  padding: 0 var(--space-16) var(--space-8);
}

.dust-section-tab {
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: var(--space-4) var(--space-12);
  border-radius: var(--radius-full);
  cursor: pointer;
}

.dust-section-tab--active {
  background: var(--white-10);
  color: var(--text-primary);
}

.dust-texture-grid {
  display: flex;
  gap: var(--space-8);
  padding: 0 var(--space-12);
  margin-bottom: var(--space-8);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.dust-texture-item {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  background: none;
  border: none;
  cursor: pointer;
}

.dust-texture-item__thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid transparent;
  background: var(--surface);
}

.dust-texture-item--active .dust-texture-item__thumb {
  border-color: var(--white-100);
}

.dust-texture-item__thumb--none {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

.dust-texture-item__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dust-texture-item__name {
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  white-space: nowrap;
  max-width: 52px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dust-texture-item--active .dust-texture-item__name {
  color: var(--text-primary);
}

/* ── Duotone Controls ── */
.duotone-presets {
  display: flex;
  gap: 8px;
  padding: 0 var(--space-12);
  margin-bottom: var(--space-12);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.duotone-presets::-webkit-scrollbar {
  display: none;
}

.duotone-preset {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  flex-shrink: 0;
}

.duotone-preset:active {
  transform: scale(0.9);
}

.duotone-pickers {
  display: flex;
  gap: var(--space-16);
  justify-content: center;
  padding: 0 var(--space-12);
  margin-top: var(--space-8);
}

.duotone-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
}

.duo-color-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: border-color 0.15s, transform 0.15s;
}

.duotone-picker:active .duo-color-circle {
  transform: scale(0.92);
}

.duotone-picker input[type="color"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* ── Export View ── */
.export-section {
  margin-bottom: var(--space-16);
}

.export-section__title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-8);
}

.export-chips {
  display: flex;
  gap: var(--space-8);
  flex-wrap: wrap;
}

.export-chip {
  padding: var(--space-8) var(--space-16);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
  border: 1px solid var(--white-12);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.export-chip--active {
  background: var(--white-100);
  color: var(--base);
  border-color: var(--white-100);
}

.export-summary {
  background: var(--elevated);
  border-radius: var(--radius-md);
  padding: var(--space-12) var(--space-16);
  margin-bottom: var(--space-16);
}

.export-summary__row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-4) 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.export-summary__row span:first-child {
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.export-summary__row span:last-child {
  color: var(--text-primary);
}
