/* Digital Opus Image Processing Lab — Pure CSS, offline */
:root {
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-panel: #1c2029;
  --border: #2a303c;
  --border-focus: #c47a3a;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --accent: #c47a3a; /* copper */
  --accent-hover: #d48a4a;
  --accent-dim: rgba(196, 122, 58, 0.15);
  --success: #34a853;
  --warning: #fbbc04;
  --danger: #ea4335;
  --info: #4285f4;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* Layout */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}
.brand .btn-icon {
  margin-left: auto;
}

.brand-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #c47a3a, #8b4513);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}

.brand-text h1 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.brand-text p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.nav-group {
  margin-bottom: 18px;
}
.nav-group-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 10px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
  font-size: 13px;
  user-select: none;
  /* button reset */
  width: 100%;
  background: transparent;
  border: none;
  text-align: left;
  font-family: inherit;
}
.nav-item:hover {
  background: var(--bg-panel);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 550;
}
.nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.nav-item .num {
  font-family: var(--mono);
  font-size: 11px;
  width: 22px;
  opacity: 0.7;
  flex-shrink: 0;
}

.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-elevated);
}

.topbar h2 {
  font-size: 16px;
  font-weight: 600;
}
.topbar .meta {
  font-size: 12px;
  color: var(--text-muted);
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Shared components */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  background: rgba(0,0,0,0.15);
}
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.dropzone p {
  color: var(--text-muted);
  margin-top: 8px;
  font-size: 13px;
}
.dropzone .icon {
  font-size: 28px;
  opacity: 0.6;
}

.file-list {
  margin-top: 14px;
  max-height: 180px;
  overflow-y: auto;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 12px;
}
.file-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .size { color: var(--text-muted); font-family: var(--mono); }
.file-item .remove {
  background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px;
}
.file-item .remove:hover { color: var(--danger); }

.controls {
  display: grid;
  gap: 14px;
}
.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 120px;
}
.field label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input[type="number"],
.field input[type="text"],
.field select,
.field input[type="color"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border 0.15s;
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
}
.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 7px;
  border: none;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--text-muted); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.preview-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
/* Icon buttons (menu / close) */
.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.mobile-only { display: none; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 40;
}

@media (max-width: 900px) {
  .preview-area { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .mobile-only { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 88vw);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop.visible {
    display: block;
  }
}

.preview-box {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 220px;
  display: flex;
  flex-direction: column;
}
.preview-box .label {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.preview-box .canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: auto;
  position: relative;
}
.preview-box canvas,
.preview-box img {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  image-rendering: auto;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
}
.stats strong { color: var(--text); font-family: var(--mono); }

.progress-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}
.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s;
}

.queue-status {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.alert {
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 14px;
}
.alert-info { background: rgba(66,133,244,0.12); border: 1px solid rgba(66,133,244,0.3); color: #8ab4f8; }
.alert-warn { background: rgba(251,188,4,0.1); border: 1px solid rgba(251,188,4,0.3); color: #fdd663; }
.alert-success { background: rgba(52,168,83,0.12); border: 1px solid rgba(52,168,83,0.3); color: #81c995; }

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-heuristic { background: rgba(251,188,4,0.2); color: #fdd663; }
.badge-batch { background: rgba(66,133,244,0.2); color: #8ab4f8; }
.badge-offline { background: rgba(52,168,83,0.2); color: #81c995; }

/* Tool specific helpers */
.focal-point {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 0 3px rgba(196,122,58,0.35);
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid var(--border);
  cursor: pointer;
}

.palette-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.palette-preview span {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
}

.grid-preview {
  display: grid;
  gap: 2px;
  background: #000;
  padding: 4px;
  border-radius: 6px;
}

/* Mobile file workflow note */
.mobile-tip {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a4150; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

/* Footer status */
.status-bar {
  height: 32px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-size: 11px;
  color: var(--text-muted);
  gap: 16px;
}
.status-bar .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--success);
}

/* Preset chips */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.preset-chip {
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.preset-chip:hover, .preset-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* Repair hardening: accessibility + narrow loaded states */
button, input, select { font-family: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, .dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.dropzone { min-height: 120px; }
.file-item .remove { min-width: 32px; min-height: 32px; border-radius: 6px; }

@media (max-width: 600px) {
  html, body { overflow: hidden; }
  .topbar {
    height: auto;
    min-height: 64px;
    padding: 8px 10px;
    gap: 8px;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .topbar > div:first-child { flex: 1 1 180px; }
  .topbar > div:last-child { flex: 1 1 100%; justify-content: flex-end; }
  .topbar h2 { font-size: 15px; overflow-wrap: anywhere; }
  .topbar .meta { font-size: 11px; overflow-wrap: anywhere; }
  .content { padding: 12px; }
  .panel { padding: 14px; margin-bottom: 12px; }
  .control-row { align-items: stretch; }
  .field { min-width: 0 !important; width: 100%; }
  .field input[type="number"], .field input[type="text"], .field select { width: 100%; min-height: 44px; }
  .btn { min-height: 44px; justify-content: center; }
  .btn-sm { min-height: 40px; }
  .btn-icon { width: 44px; height: 44px; }
  .nav-item { min-height: 44px; }
  .dropzone { padding: 24px 12px; }
  .file-item { align-items: flex-start; flex-wrap: wrap; }
  .file-item .name { flex: 1 1 calc(100% - 50px); min-width: 0; }
  .file-item .size { margin-left: 0; }
  .file-item .remove { min-width: 44px; min-height: 44px; margin-left: auto; }
  .preview-box { min-height: 180px; }
  .preview-box .canvas-wrap { padding: 8px; }
  .status-bar { min-height: 36px; height: auto; padding: 6px 10px; gap: 8px; flex-wrap: wrap; }
  #memHint { display: none; }
  .empty-state { padding: 36px 8px; }
}
