/* Fettle. Chrome is strictly neutral grey so it never tints your judgement of a photo's colour;
   the one accent is film-box yellow. */
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --stage: #171717;
  --panel: #232323;
  --raise: #2e2e2e;
  --raise-2: #393939;
  --line: #3b3b3b;
  --text: #eeeeee;
  --dim: #a3a3a3;
  --accent: #f7b500;
  --accent-ink: #1d1500;
  --danger: #ff7a6b;
  --r: 6px;
  --bar-h: 48px;
  --side-w: 304px;
  font-family: "Schibsted Grotesk", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--stage); color: var(--text); overflow: hidden; }
body { -webkit-font-smoothing: antialiased; }
h1, h2, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-rows: var(--bar-h) minmax(0, 1fr) auto; height: 100dvh; }
.grow { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--raise);
  cursor: pointer; white-space: nowrap; text-decoration: none; font-weight: 500;
}
.btn:hover { background: var(--raise-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: default; pointer-events: none; }
.btn.icon { width: 32px; padding: 0; }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn.ghost:hover { background: var(--raise); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { background: #ffc61f; }
.btn.pro { border-color: #6b5410; color: var(--accent); background: transparent; }
.btn.pro:hover { background: #2c2508; }
.btn.pro.on { border-color: transparent; color: var(--dim); }
.btn.wide { width: 100%; height: 38px; }
.pro-tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em; padding: 1px 5px; border-radius: 3px;
  background: var(--accent); color: var(--accent-ink); vertical-align: 1px;
}
.is-pro .pro-tag { display: none; }

/* ---------- top bar ---------- */
.bar {
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--panel); border-bottom: 1px solid #111;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 17px; letter-spacing: -.01em; margin-right: 8px; }
.rule { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.app.no-doc .needs-doc { opacity: .38; pointer-events: none; }

/* ---------- workspace ---------- */
.work { display: grid; grid-template-columns: minmax(0, 1fr) var(--side-w); min-height: 0; }
.stage { position: relative; overflow: hidden; background: var(--stage); touch-action: none; user-select: none; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#gl.panning { cursor: grabbing; }

.stage-tools {
  position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; gap: 6px; pointer-events: none;
}
.chip {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border-radius: var(--r); border: 1px solid #000; background: rgba(35, 35, 35, .92); cursor: pointer; font-size: 13px;
}
.chip:hover { background: var(--raise-2); }
.chip.sq { width: 30px; padding: 0; justify-content: center; font-size: 17px; }
.chip.num { min-width: 58px; justify-content: center; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* before / after divider */
.split { position: absolute; top: 0; bottom: 0; width: 0; left: 50%; pointer-events: none; }
.split::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); }
.split-knob {
  position: absolute; top: 50%; left: -18px; width: 36px; height: 36px; margin-top: -18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .6); cursor: ew-resize; pointer-events: auto; touch-action: none;
}
.split-knob::before, .split-knob::after {
  content: ""; position: absolute; top: 12px; border: 6px solid transparent;
}
.split-knob::before { left: 1px; border-right-color: #222; }
.split-knob::after { right: 1px; border-left-color: #222; }
.tag {
  position: absolute; top: 12px; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600;
  background: rgba(0, 0, 0, .7); white-space: nowrap;
}
.tag-before { right: 10px; }
.tag-after { left: 10px; }

/* crop overlay */
.crop-layer { position: absolute; pointer-events: none; }
.crop-shade { position: absolute; inset: 0; overflow: hidden; }
.crop-shade i { position: absolute; box-shadow: 0 0 0 9999px rgba(10, 10, 10, .68); }
.crop-box {
  position: absolute; pointer-events: auto; cursor: move; touch-action: none;
  outline: 1px solid rgba(255, 255, 255, .9);
}
.third { position: absolute; background: rgba(255, 255, 255, .28); pointer-events: none; }
.third.v1, .third.v2 { top: 0; bottom: 0; width: 1px; }
.third.h1, .third.h2 { left: 0; right: 0; height: 1px; }
.third.v1 { left: 33.333%; } .third.v2 { left: 66.666%; }
.third.h1 { top: 33.333%; } .third.h2 { top: 66.666%; }
.crop-box b { position: absolute; width: 28px; height: 28px; margin: -14px; touch-action: none; }
.crop-box b::after { content: ""; position: absolute; inset: 9px; background: #fff; border-radius: 1px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55); }
.crop-box b[data-h="-1,-1"] { left: 0; top: 0; cursor: nwse-resize; }
.crop-box b[data-h="0,-1"] { left: 50%; top: 0; cursor: ns-resize; }
.crop-box b[data-h="1,-1"] { left: 100%; top: 0; cursor: nesw-resize; }
.crop-box b[data-h="-1,0"] { left: 0; top: 50%; cursor: ew-resize; }
.crop-box b[data-h="1,0"] { left: 100%; top: 50%; cursor: ew-resize; }
.crop-box b[data-h="-1,1"] { left: 0; top: 100%; cursor: nesw-resize; }
.crop-box b[data-h="0,1"] { left: 50%; top: 100%; cursor: ns-resize; }
.crop-box b[data-h="1,1"] { left: 100%; top: 100%; cursor: nwse-resize; }

/* empty state: the drop zone is drawn as a crop frame */
.empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; }
.frame { position: relative; width: min(560px, 100%); padding: 56px 44px; text-align: left; }
.frame .c { position: absolute; width: 34px; height: 34px; border: 3px solid var(--accent); }
.frame .tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.frame .tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.frame .bl { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.frame .br { bottom: 0; right: 0; border-left: 0; border-top: 0; }
.frame h1 { font-size: clamp(34px, 5.2vw, 54px); line-height: 1; font-weight: 800; letter-spacing: -.035em; margin-bottom: 16px; }
.frame p { color: var(--dim); font-size: 16px; max-width: 44ch; }
.frame .row { margin: 24px 0 18px; }
.frame .btn { height: 38px; padding: 0 16px; }
.frame .fine { font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.drop-hint { position: absolute; inset: 10px; border: 2px dashed var(--accent); border-radius: 10px; background: rgba(23, 23, 23, .86); display: grid; place-items: center; pointer-events: none; z-index: 5; }
.drop-hint span { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.busy { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.busy span { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .2); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- sidebar ---------- */
.side { background: var(--panel); border-left: 1px solid #111; display: flex; flex-direction: column; min-height: 0; }
.app.no-doc .side .panel { opacity: .35; pointer-events: none; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); flex: none; }
.tabs button {
  height: 42px; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--dim); font-weight: 600; cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.panel { padding: 14px 16px 24px; overflow-y: auto; min-height: 0; flex: 1; scrollbar-width: thin; scrollbar-color: #4a4a4a transparent; }
.panel h2 { font-size: 12.5px; font-weight: 650; color: var(--dim); margin: 18px 0 8px; }
.panel h2:first-child { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.hint { color: #7d7d7d; font-size: 12px; margin-top: 12px; }

/* sliders: the track shows what the control does */
.sl { display: grid; grid-template-columns: 1fr auto; align-items: baseline; padding: 5px 0 3px; }
.sl label { font-size: 13px; }
.sl output { font-size: 12.5px; color: var(--dim); font-variant-numeric: tabular-nums; min-width: 4ch; text-align: right; }
.sl.changed output { color: var(--accent); }
.sl input { grid-column: 1 / -1; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer;
  --track: #555;
}
input[type="range"].bipolar { background: linear-gradient(#8a8a8a, #8a8a8a) center / 1px 12px no-repeat; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--track); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--track); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 8px; height: 18px; margin-top: -7px; border-radius: 2px;
  background: #fff; border: 1px solid #111; box-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}
input[type="range"]::-moz-range-thumb {
  width: 6px; height: 16px; border-radius: 2px; background: #fff; border: 1px solid #111; box-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}
.group-title { font-size: 12.5px; font-weight: 650; color: var(--dim); margin: 16px 0 4px; }

/* crop panel */
.ratios { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 8px; }
.ratio {
  display: flex; align-items: center; gap: 9px; height: 42px; padding: 0 9px; text-align: left;
  border-radius: var(--r); border: 1px solid var(--line); background: var(--raise); cursor: pointer;
}
.ratio:hover { background: var(--raise-2); }
.ratio i { flex: none; border: 1.5px solid var(--dim); border-radius: 1px; }
.ratio span { display: block; font-size: 13px; font-weight: 600; line-height: 1.15; }
.ratio small { display: block; font-size: 11.5px; color: var(--dim); font-weight: 400; }
.ratio[aria-pressed="true"] { border-color: var(--accent); background: #2c2508; }
.ratio[aria-pressed="true"] i { border-color: var(--accent); }
.turns { display: flex; gap: 6px; margin-bottom: 10px; }
.turns .btn { flex: 1; }
.size-line { margin: 14px 0 10px; color: var(--dim); font-size: 13px; }
.size-line strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* filters */
.filter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 6px; margin-bottom: 12px; }
.filter { position: relative; min-width: 0; }
.pick { display: block; width: 100%; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.filter canvas { display: block; width: 100%; aspect-ratio: 1; border-radius: 4px; background: #111; outline: 2px solid transparent; outline-offset: 1px; }
.filter span { display: block; font-size: 12px; color: var(--dim); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick[aria-pressed="true"] canvas { outline-color: var(--accent); }
.pick[aria-pressed="true"] span { color: var(--text); font-weight: 600; }
.filter .del, .preset .del {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; padding: 3px;
  background: rgba(0, 0, 0, .75); color: #fff; cursor: pointer; display: none;
}
.filter .del svg, .preset .del svg { width: 14px; height: 14px; display: block; }
.filter:hover .del, .filter:focus-within .del { display: block; }
.presets { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.presets:empty::before { content: "Looks you save appear here."; color: #7d7d7d; font-size: 12.5px; }
.preset { position: relative; display: flex; }
.preset > button:first-child {
  flex: 1; height: 32px; text-align: left; padding: 0 34px 0 10px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--raise); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preset > button:first-child:hover { background: var(--raise-2); }
.preset .del { display: block; top: 6px; right: 6px; background: transparent; color: var(--dim); }
.preset .del:hover { color: #fff; }

/* ---------- filmstrip ---------- */
.strip { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel); border-top: 1px solid #111; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0; padding: 3px; scrollbar-width: thin; scrollbar-color: #4a4a4a transparent; }
.thumb { position: relative; flex: none; height: 56px; padding: 0; border: 0; background: #111; border-radius: 3px; cursor: pointer; outline: 2px solid transparent; outline-offset: 1px; }
.thumb canvas { display: block; height: 56px; width: auto; min-width: 40px; border-radius: 3px; }
.thumb[aria-current="true"] { outline-color: var(--accent); }
.thumb .del { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; padding: 3px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .75); color: #fff; cursor: pointer; display: none; }
.thumb .del svg { width: 12px; height: 12px; display: block; }
.thumb:hover .del, .thumb:focus-within .del { display: block; }

/* ---------- dialogs ---------- */
.dlg {
  width: min(430px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
}
.dlg.narrow { width: min(340px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(0, 0, 0, .6); }
.dlg form { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.dlg header { display: flex; align-items: center; justify-content: space-between; margin-right: -8px; }
.dlg h2 { font-size: 19px; font-weight: 750; letter-spacing: -.015em; }
.dlg footer { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.dlg #proLocked, .dlg #proOpen { display: flex; flex-direction: column; gap: 12px; }
.field { display: grid; grid-template-columns: 112px 1fr; align-items: center; gap: 8px; }
.field.two { grid-template-columns: 112px 1fr 92px; }
.field.dims { grid-template-columns: auto 1fr auto 1fr auto; color: var(--dim); }
.field > label { font-size: 13px; }
.dlg .sl { padding: 0; }
select, input[type="text"], input[type="number"], textarea {
  height: 32px; padding: 0 9px; border-radius: var(--r); border: 1px solid var(--line); background: #1a1a1a; min-width: 0; width: 100%;
}
textarea { height: auto; padding: 8px 9px; resize: vertical; font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }
#dlgPro .field { grid-template-columns: 1fr; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: grid; place-items: center; height: 30px; background: #1a1a1a; font-weight: 500; }
.seg label + label span { border-left: 1px solid var(--line); }
.seg input:checked + span { background: var(--raise-2); box-shadow: inset 0 -2px var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.note { font-size: 12.5px; color: var(--dim); }
.note.err { color: var(--danger); }
.note a, .note button.link { color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.est { flex: 1; font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; }
.lede { font-size: 15px; }
.perks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.perks li { padding-left: 14px; border-left: 2px solid var(--accent); color: var(--dim); font-size: 13.5px; }
.perks strong { display: block; color: var(--text); font-size: 14.5px; }
.price { color: var(--dim); }
.price strong { color: var(--text); font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin-right: 2px; }
.progress { height: 6px; border-radius: 3px; background: #1a1a1a; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 50; pointer-events: none; }
.toast { padding: 8px 14px; border-radius: var(--r); background: #f2f2f2; color: #161616; font-weight: 550; font-size: 13.5px; box-shadow: 0 6px 24px rgba(0, 0, 0, .5); max-width: min(480px, 90vw); }
.toast.err { background: #ffd9d3; }

/* ---------- small screens ---------- */
@media (max-width: 780px) {
  .work { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 44dvh); }
  .side { border-left: 0; border-top: 1px solid #111; }
  .bar { gap: 6px; padding: 0 8px; }
  .brand span, .rule, #btnHold { display: none; }
  .brand { margin-right: 0; }
  #btnReset { font-size: 0; width: 32px; padding: 0; }
  #btnReset::before { content: "↺"; font-size: 16px; }
  .btn.pro { padding: 0 8px; }
  .frame { padding: 36px 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .busy span { animation-duration: 2s; }
  .progress i { transition: none; }
}
