/* Photo editor — builds on styles.css */
body.ed { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
body.ed > section { flex: 1; min-height: 0; }
body.ed #screen-open { overflow-y: auto; min-height: 0; }

/* Top bar */
#e-top {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; flex: none;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.e-title { flex: 1; min-width: 0; }
.e-title > div:first-child { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.e-title .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.e-nav, .e-hist { display: flex; align-items: center; gap: 2px; }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; border-color: transparent; }
.icon-btn { font-size: 20px; }
.small-btn { padding: 6px 11px; font-size: 13px; }
#e-before.on { background: var(--bg-3); color: var(--accent); }

/* Open screen */
.drop {
  display: grid; justify-items: center; gap: 6px; padding: 28px 16px; text-align: center; cursor: pointer;
  border: 1.5px dashed #4a4a4a; border-radius: 14px; background: var(--bg-2); transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: #211e17; }
.drop svg { color: var(--accent); }
.or { display: flex; align-items: center; gap: 12px; margin: 22px 0 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#drive-form { display: flex; gap: 8px; }
#drive-form input {
  flex: 1; min-width: 0; padding: 11px 13px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-2); outline: none;
}
#drive-form input:focus { border-color: #666; }

/* Folder picker */
#screen-folder { display: flex; flex-direction: column; }
#screen-folder[hidden] { display: none !important; }
.f-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.f-grid {
  flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px; padding: 14px; align-content: start;
}
.f-item {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg-2);
  border: 0; padding: 0; box-shadow: 0 0 0 1px rgba(255,255,255,.06);
}
.f-item:hover { box-shadow: 0 0 0 2px var(--accent); }
.f-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.f-item span {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 6px 4px; font-size: 11px; text-align: left;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Workspace */
#screen-edit { display: flex; min-height: 0; }
#screen-edit[hidden] { display: none !important; }
#stage {
  position: relative; flex: 1; min-width: 0; overflow: hidden; touch-action: none;
  background:
    repeating-conic-gradient(#1a1a1a 0% 25%, #151515 0% 50%) 0 0 / 22px 22px;
}
#view { position: absolute; left: 0; top: 0; box-shadow: 0 4px 30px rgba(0,0,0,.5); image-rendering: auto; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#busy {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px;
  background: rgba(0,0,0,.45); color: var(--text); z-index: 3;
}
.zoom {
  position: absolute; left: 12px; bottom: 12px; z-index: 2; display: flex; align-items: center; gap: 2px;
  background: rgba(20,20,20,.85); border: 1px solid var(--line); border-radius: 10px; padding: 2px; backdrop-filter: blur(6px);
}
.zoom-val { min-width: 54px; border: 0; background: none; font-size: 12px; color: var(--muted); padding: 6px; }
.zoom-val:hover { color: var(--text); }

#panel {
  width: 320px; flex: none; display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--line); background: var(--bg);
}
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 8px; border-bottom: 1px solid var(--line); }
.tabs button {
  display: grid; justify-items: center; gap: 3px; padding: 7px 2px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font-size: 11.5px;
}
.tabs button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs button:hover { color: var(--text); background: var(--bg-2); }
.tabs button.on { color: var(--accent); background: var(--bg-3); }
.pane { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }
.pane h4, .x-drive h4 { margin: 18px 0 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.pane h4:first-child { margin-top: 0; }
.hint { color: var(--muted); font-size: 12.5px; margin: 16px 0 0; }
.wide { width: 100%; }
.danger { color: #f3a69f; }

.row-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tool-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 11px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-2); font-size: 13px; flex: 1 1 auto;
}
.tool-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tool-btn:hover { background: var(--bg-3); }
.tool-btn.accent { color: var(--accent); border-color: rgba(240,195,90,.35); }
.ghost.wide { margin-top: 14px; }

/* Sliders */
.sl { margin: 12px 0 2px; }
.sl label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; cursor: default; user-select: none; }
.sl label span { cursor: pointer; }
.sl output { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
.sl output.changed { color: var(--accent); }
.sl input[type=range] { width: 100%; }
.group-title { margin: 20px 0 2px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.group-title:first-child { margin-top: 6px; }
input[type=range] { accent-color: var(--accent); height: 22px; }
/* Centered sliders (−100…100) show a centre tick */
.sl.center { position: relative; }
.sl.center::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 1px; height: 6px; background: #666; pointer-events: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); font-size: 12.5px; color: var(--muted); }
.chips button.on { color: var(--text); border-color: var(--accent); background: var(--bg-3); }
.seg.wide { display: flex; width: 100%; margin-bottom: 6px; }
.seg.wide button { flex: 1; }

/* Filter grid */
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset { border: 0; padding: 0; background: none; display: grid; gap: 4px; font-size: 11.5px; color: var(--muted); }
.preset canvas, .preset .ph { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; background: var(--bg-2); box-shadow: 0 0 0 1px rgba(255,255,255,.06); }
.preset.on { color: var(--accent); }
.preset.on canvas { box-shadow: 0 0 0 2px var(--accent); }

/* Text */
textarea {
  width: 100%; resize: vertical; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg-2); color: inherit; font: inherit; outline: none; margin-top: 12px;
}
textarea:focus { border-color: #666; }
.field-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.field-row select { flex: 1; min-width: 90px; padding: 7px 9px; }
.field-row .seg button { padding: 5px 9px; }
.field-row.checks { gap: 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.sw {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.15); padding: 0; cursor: pointer;
}
.sw.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw-custom { position: relative; overflow: hidden; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.sw-custom input { position: absolute; inset: -4px; opacity: 0; cursor: pointer; width: 40px; height: 40px; }

/* Export */
.x-body { display: grid; gap: 14px; }
.x-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.x-label { font-size: 13px; }
.x-row select { min-width: 220px; }
.sl#x-q-wrap { margin: 0; }
.x-drive { border-top: 1px solid var(--line); padding-top: 4px; display: grid; gap: 8px; }
.x-drive h4 { margin: 10px 0 2px; }
.x-drive p { margin: 0; }
.r-result a { word-break: break-all; }

/* Mobile: panel below the photo */
@media (max-width: 760px) {
  #screen-edit { flex-direction: column; }
  #panel { width: auto; height: 44vh; height: 44dvh; border-left: 0; border-top: 1px solid var(--line); }
  .tabs { display: flex; overflow-x: auto; scrollbar-width: none; padding: 6px; }
  .tabs button { flex: 0 0 auto; min-width: 70px; }
  .pane { padding: 10px 14px 20px; }
  #e-top { gap: 4px; padding: 6px 8px; }
  .zoom { left: 8px; bottom: 8px; }
  .presets { grid-template-columns: repeat(4, 1fr); }
}
