/* Dunkles, ruhiges Foto-Editor-Design: neutrale Grautöne, ein Akzent, viel Luft. */
:root {
  --bg: #161616;
  --canvas: #1d1d1d;
  --panel: #232323;
  --panel-2: #2b2b2b;
  --hover: #333333;
  --line: #383838;
  --line-soft: #2e2e2e;
  --text: #e3e3e3;
  --text-2: #b4b4b4;
  --muted: #8a8a8a;
  --accent: #3d8ff5;
  --accent-2: #5aa2f8;
  --warn: #e8a33d;
  --thumb: #d8d8d8;
  --radius: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 12.5px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) 92px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 14px; height: 14px; }
.ic.big { width: 34px; height: 34px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* --- Kopfzeile --------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 12px 0 16px; background: var(--panel); border-bottom: 1px solid #111;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { color: var(--accent-2); width: 20px; height: 20px; }
.brand .app { font-weight: 600; font-size: 13px; }
.brand .sep { width: 1px; height: 16px; background: var(--line); }
.brand .doc { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 30px; padding: 0 14px; border-radius: 15px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.wide { width: 100%; height: 34px; border-radius: 17px; margin: 14px 0 4px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

/* --- Arbeitsfläche ------------------------------------------------------ */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 320px 60px; min-height: 0; }

.canvas-area {
  position: relative; display: flex; align-items: center; justify-content: center;
  background: var(--canvas); padding: 28px; min-height: 0; min-width: 0; overflow: hidden;
}
.stage { position: relative; display: flex; max-width: 100%; max-height: 100%; }
#view {
  display: block; max-width: 100%; max-height: calc(100vh - 48px - 92px - 56px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45); touch-action: none;
}
.split-line { position: absolute; top: 0; width: 0; border-left: 1.5px solid rgba(255, 255, 255, 0.9); pointer-events: none; display: none; }
.split-line .knob {
  position: absolute; top: 50%; left: 0; width: 26px; height: 26px; transform: translate(-50%, -50%);
  border-radius: 50%; background: rgba(30, 30, 30, 0.85); border: 1.5px solid #fff;
}
.split-line .knob::before, .split-line .knob::after {
  content: ""; position: absolute; top: 8px; border: 4px solid transparent;
}
.split-line .knob::before { left: 2px; border-right-color: #fff; }
.split-line .knob::after { right: 2px; border-left-color: #fff; }
.tag {
  position: absolute; top: 10px; font-size: 11px; padding: 3px 8px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.55); color: #f0f0f0; pointer-events: none; display: none;
}
.tag-left { left: 10px; }
.tag-right { right: 10px; }
.split .tag { display: block; }

.hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); max-width: min(640px, calc(100% - 32px));
  font-size: 12px; color: var(--text-2); background: rgba(22, 22, 22, 0.9); border: 1px solid var(--line);
  border-radius: 16px; padding: 6px 14px; display: none; text-align: center;
}
.hint.show { display: block; }
.hint.warn { color: #f3d7a8; border-color: var(--warn); }
.drop {
  position: absolute; inset: 14px; border: 1.5px dashed var(--accent); border-radius: 12px; display: none;
  flex-direction: column; gap: 10px; align-items: center; justify-content: center; font-size: 15px;
  background: rgba(22, 22, 22, 0.88); color: var(--text);
}
.drop.show { display: flex; }

/* --- Werkzeugleiste rechts --------------------------------------------- */
.rail {
  background: var(--panel); border-left: 1px solid #111; display: flex; flex-direction: column;
  align-items: center; gap: 4px; padding: 10px 0;
}
.rail button {
  width: 50px; padding: 8px 0 6px; border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; font-size: 10px;
}
.rail button:hover { color: var(--text); background: var(--hover); }
.rail button.active { color: #fff; background: var(--panel-2); }
.rail button.active .ic { color: var(--accent-2); }

/* --- Bedienfeld --------------------------------------------------------- */
.panel { background: var(--panel); border-left: 1px solid #111; overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.tab { padding: 0 0 40px; }
.tab-title { font-size: 14px; font-weight: 600; padding: 16px 16px 8px; }
.tab-title.sm { font-size: 12.5px; padding: 18px 0 6px; }
.tab > p, .tab > .field, .tab > .switch, .tab > .btn, .tab > .steps, .tab > .row, .tab > .saved, .tab > .recipe, .tab > .preset-grid { margin-left: 16px; margin-right: 16px; }
.tab > .btn.wide { width: calc(100% - 32px); }
.tab[data-tab="export"] > .tab-title.sm { padding-left: 16px; }

.histo-wrap { padding: 12px 14px 6px; }
#histo { width: 100%; height: 75px; display: block; background: #1a1a1a; border-radius: 4px; }

.profile-row { display: flex; align-items: center; gap: 8px; padding: 6px 14px 10px; border-bottom: 1px solid var(--line-soft); }
.profile {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; text-align: left;
}
.profile:hover { background: var(--hover); }
.profile #profileName { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 500; }
.profile .ic { color: var(--muted); }

.seg { display: inline-flex; background: #1b1b1b; border: 1px solid var(--line); border-radius: 15px; padding: 2px; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border: 0; border-radius: 13px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--hover); color: #fff; }
.seg.small button { height: 24px; padding: 0 9px; }

/* Abschnitte */
.section { border-bottom: 1px solid var(--line-soft); }
.sec-head {
  display: flex; align-items: center; gap: 6px; padding: 0 8px 0 12px; height: 40px; cursor: pointer; user-select: none;
  font-weight: 600; font-size: 13px;
}
.sec-head > span { flex: 1; }
.sec-head .icon-btn { opacity: 0; transition: opacity 0.15s; }
.sec-head:hover .icon-btn { opacity: 1; }
.chev { color: var(--muted); transition: transform 0.15s; width: 14px; height: 14px; }
.section.open > .sec-head .chev { transform: rotate(90deg); }
.sec-body { display: none; padding: 0 16px 14px; }
.section.open > .sec-body { display: block; }
.sub-label { color: var(--text-2); font-size: 11.5px; margin: 6px 0 2px; }

.sub-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0; padding: 10px 0 4px;
  color: var(--text-2); cursor: pointer; font-weight: 500;
}
.sub-toggle:hover { color: var(--text); }
.sub-toggle.open .chev { transform: rotate(90deg); }
.curve-wrap, .mixer { display: none; }
.curve-wrap.open, .mixer.open { display: block; }
#curve { width: 100%; height: auto; display: block; background: #1a1a1a; border-radius: 4px; margin-top: 6px; cursor: crosshair; touch-action: none; }
.curve-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; }
.curve-chans { margin-top: 0; }
.curve-chans .chip { height: 24px; padding: 0 9px; font-size: 12px; display: inline-flex; align-items: center; gap: 5px; }
.curve-chans .swatch { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.curve-hint { margin: 6px 0 0; }

/* Regler */
.slider { margin: 9px 0 3px; }
.slider .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 18px; }
.slider label { color: var(--text-2); cursor: default; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slider .val {
  width: 62px; text-align: right; background: transparent; border: 1px solid transparent; border-radius: 3px;
  color: var(--text); font: inherit; font-variant-numeric: tabular-nums; padding: 0 3px; height: 18px;
}
.slider .val:hover { border-color: var(--line); }
.slider .val:focus { outline: none; border-color: var(--accent); background: #1a1a1a; }
.slider input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 16px; margin: 2px 0 0; background: transparent; cursor: pointer;
  --track: linear-gradient(#4a4a4a, #4a4a4a);
}
.slider input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--track); }
.slider input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--track); }
.slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%;
  background: var(--thumb); border: 0; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.slider input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--thumb); border: 0; }
.slider input[type=range]:hover::-webkit-slider-thumb { background: #fff; transform: scale(1.12); }
.slider input[type=range]:focus { outline: none; }
.slider input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(61, 143, 245, 0.5); }

/* Farbmischer */
.dots { display: flex; justify-content: space-between; padding: 8px 2px 6px; }
.dot {
  width: 20px; height: 20px; border-radius: 50%; border: 0; cursor: pointer; position: relative;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
}
.dot.active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px #fff; }
.dot.changed::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--text-2);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  height: 26px; padding: 0 11px; border-radius: 13px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text-2); cursor: pointer;
}
.chip.active { border-color: var(--accent); color: #fff; background: rgba(61, 143, 245, 0.15); }

.section .mono-only { display: none; }
body.mono .section .mono-only { display: block; }
body.mono .section .color-only { display: none; }

/* Farbräder */
.wheels { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 4px 0 4px; }
.wheel-box { text-align: center; }
.wheel-box .sub-label { margin-bottom: 6px; }
.wheel { width: 100%; max-width: 96px; aspect-ratio: 1; cursor: crosshair; touch-action: none; display: block; margin: 0 auto; }
.wheel-val { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; margin-top: 4px; }

/* Looks */
.preset-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.preset-grid h4 {
  grid-column: 1 / -1; margin: 10px 0 -2px; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.preset {
  display: flex; flex-direction: column; align-self: start; min-width: 0;
  border: 0; padding: 0; background: none; cursor: pointer; text-align: left; color: var(--text-2);
}
.preset .thumb {
  display: block; width: 100%; aspect-ratio: 3 / 2; border-radius: 5px; background: #1a1a1a center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.preset .name { display: block; padding: 5px 2px 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preset:hover .thumb { box-shadow: 0 0 0 1.5px #777; }
.preset.active .thumb { box-shadow: 0 0 0 2px var(--accent); }
.preset.active .name { color: #fff; }
.preset-desc { grid-column: 1 / -1; color: var(--muted); font-size: 12px; margin: 2px 0 0; }

/* Formulare */
.field { display: block; color: var(--text-2); margin: 10px 0; }
.field input, .row input {
  display: block; width: 100%; margin-top: 5px; height: 32px; padding: 0 10px; border-radius: var(--radius);
  border: 1px solid var(--line); background: #1a1a1a; color: var(--text); font: inherit;
}
.field input:focus, .row input:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.row input { margin-top: 0; }

.switch { display: flex; gap: 10px; align-items: flex-start; color: var(--text-2); margin: 12px 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  flex: none; width: 30px; height: 17px; border-radius: 9px; background: #4a4a4a; position: relative; transition: background 0.15s; margin-top: 1px;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(13px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(61, 143, 245, 0.4); }

.steps { color: var(--text-2); padding-left: 18px; margin-top: 14px; }
.steps li { margin: 5px 0; }
.steps code { color: var(--text); }

.recipe table { width: 100%; border-collapse: collapse; }
.recipe td { padding: 6px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.recipe td:first-child { color: var(--muted); width: 46%; padding-right: 10px; }
.recipe p { color: var(--muted); }

.saved { list-style: none; padding: 0; }
.saved li { display: flex; align-items: center; gap: 4px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.saved li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved li button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 3px 6px; border-radius: 4px; }
.saved li button:hover { color: var(--text); background: var(--hover); }
.saved .empty { color: var(--muted); border: 0; }

/* --- Filmstreifen ------------------------------------------------------- */
.bottombar {
  display: flex; align-items: center; gap: 16px; padding: 0 14px; background: var(--panel); border-top: 1px solid #111; min-width: 0;
}
.filmstrip { flex: 1; display: flex; gap: 8px; overflow-x: auto; padding: 8px 2px; min-width: 0; scrollbar-width: thin; }
.film {
  flex: none; height: 64px; border: 0; padding: 0; border-radius: 4px; overflow: hidden; cursor: pointer; background: #111;
  opacity: 0.75; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.film:hover { opacity: 1; }
.film.active { opacity: 1; box-shadow: 0 0 0 2px var(--accent); }
.film canvas { height: 100%; display: block; }
.add { width: 38px; height: 38px; border: 1px dashed var(--line); border-radius: 8px; }

/* --- Hinweis-Toast ------------------------------------------------------ */
.toast {
  position: fixed; left: 50%; bottom: 108px; transform: translateX(-50%) translateY(10px); opacity: 0;
  background: #2f2f2f; border: 1px solid var(--line); padding: 8px 16px; border-radius: 18px;
  transition: all 0.2s; pointer-events: none; max-width: calc(100% - 32px); z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* --- Schmale Fenster ---------------------------------------------------- */
@media (max-width: 900px) {
  body { display: block; height: auto; overflow: auto; }
  .topbar { height: 48px; position: sticky; top: 0; z-index: 5; }
  .top-actions .btn span { display: none; }
  .workspace { display: flex; flex-direction: column; }
  .canvas-area { min-height: 46vh; padding: 14px; }
  #view { max-height: 56vh; }
  .rail { order: 2; flex-direction: row; justify-content: center; border-left: 0; border-top: 1px solid #111; padding: 6px; position: sticky; top: 48px; z-index: 4; }
  .rail button { width: 76px; }
  .panel { order: 3; border-left: 0; overflow: visible; }
  .bottombar { height: 84px; }
  .bottombar .seg span { display: none; }
}

/* --- Suche, Favoriten, Abgleich, Verlauf ------------------------------------ */
.search {
  display: block; width: calc(100% - 32px); margin: 0 16px 8px; height: 30px; padding: 0 10px; border-radius: 15px;
  border: 1px solid var(--line); background: #1a1a1a; color: var(--text); font: inherit;
}
.search:focus { outline: none; border-color: var(--accent); }
.preset { position: relative; }
.preset .star {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.45); color: #fff; opacity: 0; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.preset:hover .star, .preset .star.on, .preset .star:focus-visible { opacity: 1; }
.preset .star .ic { width: 13px; height: 13px; }
.preset .star.on .ic { fill: var(--warn); stroke: var(--warn); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn:disabled:hover { background: transparent; color: var(--muted); }
.sec-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }

.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 16px 0; }
.match-drop {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 3 / 2; border-radius: 6px; cursor: pointer;
  border: 1.5px dashed var(--line); color: var(--muted); font-size: 12px; text-align: center; padding: 8px; overflow: hidden; background: #1a1a1a;
}
.match-drop:hover { border-color: var(--accent); }
.match-drop.static { border-style: solid; cursor: default; padding: 0; }
.match-drop.has { border-style: solid; padding: 0; }
.match-drop canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.match-drop.drag { border-color: var(--accent); background: rgba(61, 143, 245, 0.08); }
.progress { height: 4px; margin: 8px 16px 0; background: #2a2a2a; border-radius: 2px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }
.curve-chans .chip.changed::after { content: "•"; color: var(--warn); margin-left: 2px; }

/* --- A/B, Lupe, Referenz-Zähler --------------------------------------------- */
.icon-btn.on { color: var(--accent-2); background: var(--panel-2); }
.canvas-area.loupe { display: block; overflow: auto; padding: 0; }
.canvas-area.loupe .stage { max-width: none; max-height: none; display: inline-flex; }
.canvas-area.loupe #view { max-width: none; max-height: none; box-shadow: none; cursor: grab; }
.canvas-area.loupe.panning #view { cursor: grabbing; }
.badge {
  position: absolute; right: 6px; bottom: 6px; background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 11px;
  padding: 2px 7px; border-radius: 10px;
}
.match-drop { position: relative; }

.cam-result { margin-top: 10px; }
.cam-stats { font-size: 12.5px; color: var(--text-2); }
.cam-stats b { color: var(--text); }
.cam-stats div { padding: 3px 0; border-bottom: 1px solid var(--line-soft); }
.wb-tools { margin: 4px 0 2px; }
.wb-tools .chip { height: 24px; padding: 0 9px; font-size: 12px; }
.canvas-area.picking #view { cursor: crosshair; }
.native-only { display: none; }
body.native .native-only { display: inline; }

/* --- Basis-Bildstil ------------------------------------------------------- */
.base-row { display: flex; align-items: center; gap: 8px; padding: 0 14px 10px; border-bottom: 1px solid var(--line-soft); margin-top: -2px; }
.base-row label { white-space: nowrap; font-size: 12px; }
.base-row select {
  flex: 1; min-width: 0; height: 28px; padding: 0 8px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit;
}
.base-row select:focus { outline: none; border-color: var(--accent); }
.mode-badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: rgba(61, 143, 245, 0.15); color: var(--accent-2); white-space: nowrap; }
.mode-badge.rel { background: rgba(232, 163, 61, 0.15); color: var(--warn); }
.base-note { margin: 0; padding: 8px 14px 10px; font-size: 12px; color: var(--text-2); border-bottom: 1px solid var(--line-soft); }
.credits { margin: 22px 16px 0; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 11.5px; color: var(--muted); }
.credits a { color: var(--text-2); }
.credits a:hover { color: var(--accent-2); }
