:root {
  --bg: #12141a;
  --panel: #1b1e27;
  --panel-2: #232734;
  --border: #2f3442;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --accent: #5b8cff;
  --danger: #ff6b6b;
  --warn: #f5c542;
  --ok: #4ade80;
  --stage-bg: #0a0b0f;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }
.app-header { padding: 12px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: baseline; gap: 16px; }
.app-header h1 { margin: 0; font-size: 20px; }
.tagline { margin: 0; color: var(--muted); font-size: 13px; }
.layout { display: grid; grid-template-columns: 260px 1fr 320px; gap: 12px; padding: 12px; height: calc(100vh - 60px); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.filmstrip .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.filmstrip h2, .export-panel h2 { margin: 0; font-size: 15px; }
.add-btn { background: var(--accent); color: #fff; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.dropzone { border: 2px dashed var(--border); border-radius: 8px; padding: 16px; text-align: center; color: var(--muted); }
.dropzone.drag { border-color: var(--accent); background: var(--panel-2); }
.thumbs { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.thumb { display: flex; gap: 8px; align-items: center; padding: 6px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--panel-2); }
.thumb.active { border-color: var(--accent); }
.thumb img { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; background: #000; }
.thumb .meta { flex: 1; min-width: 0; }
.thumb .name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb .dims { font-size: 11px; color: var(--muted); }
.thumb .status { font-size: 11px; }
.status-ready { color: var(--muted); }
.status-warning { color: var(--warn); }
.status-exported { color: var(--ok); }
.status-error { color: var(--danger); }
.thumb .remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.batch-summary { font-size: 12px; color: var(--muted); text-align: center; margin-top: auto; }

/* stage */
.stage-panel { padding: 12px; }
.ratio-tabs { display: flex; gap: 8px; }
.ratio-tab { flex: 1; padding: 8px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: 6px; cursor: pointer; font-size: 12px; }
.ratio-tab.active { background: var(--accent); border-color: var(--accent); }
.stage-wrap-outer { flex: 1; background: var(--stage-bg); border-radius: 8px; display: flex; align-items: center; justify-content: center; position: relative; min-height: 300px; overflow: hidden; margin: 8px 0; }
.stage-empty { color: var(--muted); }
.stage-canvas { position: relative; display: inline-block; max-width: 100%; max-height: 100%; outline: none; }
.stage-canvas img, .stage-canvas canvas, .stage-image { display: block; max-width: 100%; max-height: calc(100vh - 260px); }
.crop-layer { position: absolute; inset: 0; pointer-events: none; }
.crop-frame { position: absolute; border: 1px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,0.55); pointer-events: auto; cursor: move; }
.crop-dim { position: absolute; inset: 0; }
.grid-thirds { position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(to right, rgba(255,255,255,0.25) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,255,255,0.25) 1px, transparent 1px); background-size: 33.333% 33.333%; }
.crosshair { position: absolute; inset: 0; pointer-events: none; }
.crosshair::before, .crosshair::after { content: ''; position: absolute; background: rgba(255,255,255,0.6); }
.crosshair::before { left: 50%; top: 0; bottom: 0; width: 1px; transform: translateX(-0.5px); }
.crosshair::after { top: 50%; left: 0; right: 0; height: 1px; transform: translateY(-0.5px); }
.handle { position: absolute; width: 16px; height: 16px; background: #fff; border: 1px solid #333; pointer-events: auto; border-radius: 2px; }
.handle.nw { left: -8px; top: -8px; cursor: nwse-resize; }
.handle.n { left: 50%; top: -8px; transform: translateX(-50%); cursor: ns-resize; }
.handle.ne { right: -8px; top: -8px; cursor: nesw-resize; }
.handle.e { right: -8px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.handle.se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.handle.s { left: 50%; bottom: -8px; transform: translateX(-50%); cursor: ns-resize; }
.handle.sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.handle.w { left: -8px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.status-line { font-size: 12px; color: var(--muted); min-height: 16px; }
.stage-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.stage-actions button { padding: 6px 10px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: 6px; cursor: pointer; font-size: 12px; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* export */
.export-panel fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin: 0; }
.export-panel legend { color: var(--muted); font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.row select { margin-left: auto; }
.export-panel input[type=text], .export-panel select { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 6px; }
.export-panel input[type=text] { width: 100%; }
.preview { font-size: 12px; color: var(--muted); margin: 4px 0; word-break: break-all; }
.folder-info { font-size: 12px; color: var(--muted); margin-top: 6px; }
.adj-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.adj-grid label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.adj-grid input[type=range] { width: 100%; }
.adj-grid span { align-self: flex-end; font-size: 11px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.primary { background: var(--accent); color: #fff; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; }
.actions button:not(.primary) { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 6px; cursor: pointer; }
.progress { font-size: 12px; color: var(--accent); margin-top: 8px; }
.results { list-style: none; padding: 0; margin: 8px 0 0; font-size: 12px; max-height: 200px; overflow: auto; }
.results li { padding: 2px 0; }
.res-ok { color: var(--ok); }
.res-err { color: var(--danger); }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; height: auto; }
}