/* N4DU Studio — the editor.
   The three-column workspace: tools on the left, the picture in the middle,
   what comes out of it on the right. Nothing here is on screen until the
   editor is, which is why it is a file of its own. */

/* ── WORKSPACE ── */
.workspace {
  display: grid;
  grid-template-columns: 210px 1fr 250px;
  min-height: 0;
}

/* Panels are static: everything fits, nothing scrolls — until the window is
   too short for that to be true. At 1400x500 the Weight section was sliced
   through the middle: the "Never exceed" field cut in half, the KB/MB
   dropdown and the size estimate simply gone, with nothing to scroll. The
   one-column fallback only covers windows under 900px wide, so every wide
   short window fell through the gap. A scrollbar is a far smaller price
   than an unreachable control. */
.panel {
  background: var(--surface);
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.panel-left  { border-right: 1px solid var(--border); }
.panel-right { border-left: 1px solid var(--border); }

.section { display: flex; flex-direction: column; gap: 8px; }
.section-title {
  font-family: var(--fh);
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}

/* Sections stay inert until an image is loaded */
body:not(.has-image) .gated { opacity: .3; pointer-events: none; }

/* ── TOOL PALETTE ── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: var(--fb);
  font-size: .7rem;
  padding: 8px 2px 6px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.tool svg { width: 19px; height: 19px; }
.tool:hover { border-color: var(--accent); color: var(--text); }
.tool.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

.icon-row { display: flex; gap: 5px; }

/* Tool options: each block declares which tools it belongs to */
.opt { display: none; flex-direction: column; gap: 6px; }
.opt.visible { display: flex; }
.opt label {
  font-size: .72rem; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
}
.opt input[type=range] { width: 100%; accent-color: var(--accent); cursor: pointer; }
.opt-val { color: var(--accent); font-family: var(--fh); font-size: .7rem; white-space: nowrap; }

.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type=color] {
  width: 38px; height: 26px; padding: 0;
  background: none; border: 1px solid var(--border2);
  border-radius: 6px; cursor: pointer;
}
.color-hex { font-family: var(--fh); font-size: .75rem; color: var(--text); flex: 1; }
.icon-btn.small-icon {
  width: 26px; height: 26px;
  border-color: var(--border2);
}
.icon-btn.small-icon svg { width: 15px; height: 15px; }
.icon-btn.armed {
  background: var(--accent); border-color: var(--accent); color: #000;
}

.check {
  display: flex; align-items: center; gap: 7px;
  font-size: .74rem; color: var(--text);
  cursor: pointer; user-select: none;
  justify-content: flex-start;
}
.check input[type=checkbox] {
  width: 14px; height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── STAGE ── */
.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #101010 0%, var(--bg) 70%);
  min-width: 0;
  min-height: 0;
  padding: 12px;
}

/* Empty state */
.dropzone {
  border: 2px dashed var(--border2);
  border-radius: 14px;
  padding: 32px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
  max-width: 460px;
  color: var(--muted);
}
.dropzone.over, .dropzone:hover {
  border-color: var(--accent);
  background: rgba(232,255,71,.03);
}
.dropzone.over { transform: scale(1.02); }
.dropzone > * { pointer-events: none; }
.drop-icon { width: 42px; height: 42px; color: var(--faint); }
.drop-label { font-family: var(--fh); font-weight: 700; font-size: 1.05rem; color: var(--text); margin-top: 8px; }
.drop-sub   { font-size: .8rem; margin-top: 4px; }
.drop-steps {
  list-style: none;
  margin: 18px auto 0;
  display: inline-flex; flex-direction: column; gap: 6px;
  text-align: left;
  font-size: .78rem;
}
.drop-steps li { display: flex; align-items: center; gap: 9px; }
.drop-steps .hl { color: var(--accent); }
.drop-steps b {
  width: 18px; height: 18px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--accent);
  font-family: var(--fh);
  font-size: .66rem;
  display: flex; align-items: center; justify-content: center;
}
.drop-formats {
  color: var(--faint); font-size: .68rem; margin-top: 18px;
  letter-spacing: .04em;
}
body.has-image .dropzone { display: none; }

/* Canvas column: instruction on top, canvas, bars underneath */
.canvas-stack {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  min-height: 0;
}
body.has-image .canvas-stack { display: flex; }

/* Always tells you what the current tool does */
.instruction {
  font-size: .78rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 5px 16px;
  text-align: center;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.instruction b { color: var(--accent); font-weight: 600; }

/* The stage takes the shape of the exported picture, so a landscape photo
   gets a landscape frame instead of empty bands. The aspect ratio is set
   from JavaScript; the size is capped by both dimensions of the window. */
.canvas-wrap {
  position: relative;
  flex: 0 0 auto;
  aspect-ratio: 1 / 1;
  max-width: 100%;
  max-height: calc(100% - 84px);
  height: min(calc(100vh - 190px), 100%);
  background: #000;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,.5);
}
.canvas-wrap canvas {
  display: block;
  width: 100%; height: 100%;
  touch-action: none;
}
.canvas-wrap canvas.draggable { cursor: grab; }
.canvas-wrap canvas.dragging  { cursor: grabbing; }

/* Cursors per active tool */
.canvas-wrap canvas.tool-paint  { cursor: none; }   /* the ring is the cursor */
.canvas-wrap canvas.tool-pick   { cursor: crosshair; }
.canvas-wrap canvas.tool-crop   { cursor: crosshair; }
.canvas-wrap canvas.tool-remove { cursor: crosshair; }

/* Ring showing the real brush size */
.brush-cursor {
  position: absolute;
  border: 1.5px solid #fff;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
  z-index: 5;
}

/* Busy indicator for operations that take a moment */
.busy {
  position: absolute;
  inset: 0;
  background: rgba(10,10,10,.55);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--fh); font-size: .85rem; color: var(--accent);
  z-index: 10;
}
.busy span {
  width: 15px; height: 15px;
  border: 2px solid rgba(232,255,71,.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Bars under the canvas */
.stage-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; flex-shrink: 0; }
.float-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 5px 13px;
}
.bar-label { font-size: .7rem; color: var(--muted); }
.float-bar input[type=range] {
  width: 84px;
  accent-color: var(--accent);
  cursor: pointer;
}
.bar-icon { font-size: .75rem; color: var(--muted); line-height: 1; }
.bar-val {
  font-size: .7rem; color: var(--accent);
  font-family: var(--fh); min-width: 54px;
}
.bar-val.narrow { min-width: 34px; }

.reset-btn {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: .78rem;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.reset-btn:hover { border-color: var(--accent); color: var(--accent); transform: rotate(-45deg); }

/* ── CONTROLS ── */
.pills { display: flex; gap: 4px; flex-wrap: wrap; }
.pills.stack { flex-direction: column; }
.pills.stack .pill { text-align: left; padding: 7px 11px; }
.pill {
  font-size: .73rem; padding: 4px 10px; border-radius: 15px;
  border: 1px solid var(--border2); background: var(--bg);
  color: var(--muted); cursor: pointer; transition: all .15s;
  font-family: var(--fb);
}
.pill:hover { border-color: var(--accent); color: var(--text); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 600; }

.row2 { display: flex; gap: 7px; }
.size-row { align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.field label { font-size: .7rem; color: var(--muted); }
.field input[type=number] {
  background: var(--bg); border: 1px solid var(--border2);
  border-radius: 7px; color: var(--text); font-family: var(--fb);
  font-size: .82rem; padding: 5px 8px; width: 100%;
  transition: border-color .15s;
}
.field input[type=number]:focus { outline: none; border-color: var(--accent); }
.field input[type=number]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.lock-btn {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 7px;
  color: var(--muted);
  width: 30px; height: 29px;
  font-size: .8rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
}
.lock-btn:hover  { border-color: var(--accent); }
.lock-btn.active { color: var(--accent); border-color: var(--accent); }

.hint { font-size: .7rem; color: var(--muted); line-height: 1.45; }
.hint:empty { display: none; }
.hint.center { text-align: center; }
.estimate {
  font-size: .75rem;
  font-family: var(--fh);
  color: var(--accent);
}
.estimate.warn { color: var(--danger); }

/* Result block: thumbnail beside the numbers */
.result-row { display: flex; gap: 10px; align-items: flex-start; }
.result-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.preview-frame {
  width: 74px; height: 74px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: repeating-conic-gradient(var(--check-b) 0% 25%, var(--check-a) 0% 50%) 0 0 / 14px 14px;
  border: 1px solid var(--border2);
  border-radius: 7px;
  overflow: hidden;
}
.preview-frame canvas { max-width: 100%; max-height: 100%; display: block; }
.preview-label { font-size: .68rem; color: var(--muted); line-height: 1.4; }

/* File info */
.file-info { font-size: .72rem; color: var(--muted); line-height: 1.45; }
.file-info strong { color: var(--text); word-break: break-all; }

/* ── STATUS BAR ── */
.statusbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 12px;
  background: var(--chrome);
  border-top: 1px solid var(--border);
  font-size: .68rem;
  color: var(--muted);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}
.status-spacer { flex: 1; }
.status-hint { color: var(--faint); overflow: hidden; text-overflow: ellipsis; }

