:root {
  --bg:       oklch(0.975 0.007 75);
  --bg2:      oklch(0.955 0.007 75);
  --bg3:      oklch(0.930 0.008 75);
  --line:     oklch(0.875 0.006 75);
  --text:     oklch(0.14  0.012 250);
  --text-dim: oklch(0.46  0.010 250);
  --text-sub: oklch(0.52  0.010 250);
  --accent:   oklch(0.34  0.08  162);
  --accent-l: oklch(0.34  0.08  162 / 0.09);
  --danger:   oklch(0.55  0.18  25);
  --f-serif:  Georgia, Garamond, "Palatino Linotype", "Times New Roman", serif;
  --f-sans:   system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-mono:   "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --pad:      max(20px, 4vw);
  --r:        4px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:       oklch(0.10  0.010 200);
    --bg2:      oklch(0.135 0.010 200);
    --bg3:      oklch(0.165 0.010 200);
    --line:     oklch(0.24  0.008 200);
    --text:     oklch(0.93  0.005 75);
    --text-dim: oklch(0.66  0.008 200);
    --text-sub: oklch(0.60  0.008 200);
    --accent:   oklch(0.72  0.14  162);
    --accent-l: oklch(0.72  0.14  162 / 0.10);
    --danger:   oklch(0.72  0.18  25);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
::selection { background: var(--accent); color: var(--bg); }
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

/* ── HEADER ── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 500;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--pad);
  background: oklch(0.975 0.007 75 / 0.92);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
@media (prefers-color-scheme: dark) {
  .site-header { background: oklch(0.10 0.010 200 / 0.92); }
}
.logo-link {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
}
.logo-mark { display: block; flex-shrink: 0; }
.logo-name {
  font-size: 15px; font-weight: 700; letter-spacing: .02em; line-height: 1;
}
.logo-name small {
  display: block; font-size: 10px; font-weight: 400;
  color: var(--text-dim); letter-spacing: .04em; margin-top: 2px;
}
.back-link {
  font-size: 13px; color: var(--text-dim);
  transition: color .15s;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

/* ── LAYOUT ── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 80px var(--pad) 64px;
}
.page-title {
  font-family: var(--f-serif);
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 400;
  color: var(--text);
  margin-bottom: 4px;
}
.page-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 32px;
}

/* ── DROP ZONE ── */
.drop-zone {
  border: 2px dashed var(--line);
  border-radius: var(--r);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--bg2);
  position: relative;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-l);
}
.drop-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-icon { font-size: 32px; margin-bottom: 10px; }
.drop-label { font-size: 15px; color: var(--text-dim); }
.drop-label strong { color: var(--accent); }
.drop-hint { font-size: 12px; color: var(--text-sub); margin-top: 6px; }

/* ── GLOBAL OPTIONS ── */
.global-panel {
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg2);
  overflow: hidden;
}
.global-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
}
.global-panel-header h2 {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-dim); flex: 1;
}
.global-panel-body {
  padding: 16px;
  display: grid;
  gap: 10px;
}

/* ── OPTION ROW ── */
.opt-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg);
}
.opt-row.disabled { opacity: .4; pointer-events: none; }
.opt-check { flex-shrink: 0; margin-top: 2px; }
.opt-body { flex: 1; }
.opt-label { font-size: 14px; font-weight: 600; cursor: pointer; }
.opt-controls {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-top: 8px;
}
.opt-controls.hidden { display: none; }

/* ── FORM ELEMENTS ── */
label.field-label {
  font-size: 12px; color: var(--text-dim);
  display: flex; flex-direction: column; gap: 3px;
}
input[type="number"], select {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--r);
  padding: 5px 8px;
  font-size: 13px;
  font-family: var(--f-mono);
  width: 90px;
  outline: none;
  transition: border-color .15s;
}
input[type="number"]:focus, select:focus { border-color: var(--accent); }
select { width: auto; cursor: pointer; }
input[type="range"] {
  accent-color: var(--accent);
  width: 120px; cursor: pointer;
}
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px; height: 15px; cursor: pointer;
}
.ratio-lock {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-dim); cursor: pointer;
}
.quality-val {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--accent);
  min-width: 28px;
}

/* ── APPLY-ALL TOGGLE ── */
.apply-all-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-dim);
  margin-bottom: 4px;
}
.apply-all-row label { cursor: pointer; }

/* ── IMAGE LIST ── */
.image-list {
  margin-top: 28px;
  display: grid;
  gap: 12px;
}
.img-card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg2);
  overflow: hidden;
  display: grid;
  grid-template-columns: 80px 1fr;
}
.img-thumb-wrap {
  width: 80px;
  height: 80px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--line);
}
.img-thumb {
  width: 80px; height: 80px;
  object-fit: cover;
  display: block;
}
.img-card-body {
  padding: 10px 14px;
}
.img-card-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.img-name {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1;
  font-family: var(--f-mono);
}
.img-meta {
  font-size: 11px; color: var(--text-sub);
  font-family: var(--f-mono);
}
.img-preview-btn {
  background: none; border: 1px solid var(--line); cursor: pointer;
  color: var(--text-dim); font-size: 12px; font-weight: 600;
  padding: 2px 9px; border-radius: 20px;
  transition: border-color .15s, color .15s;
  font-family: var(--f-sans); white-space: nowrap;
}
.img-preview-btn:hover { border-color: var(--accent); color: var(--accent); }

.img-remove {
  background: none; border: none; cursor: pointer;
  color: var(--text-sub); font-size: 16px; line-height: 1;
  padding: 2px 4px;
  border-radius: 2px;
  transition: color .15s;
}
.img-remove:hover { color: var(--danger); }
.img-opts {
  border-top: 1px solid var(--line);
  padding: 8px 14px;
  background: var(--bg);
  grid-column: 1 / -1;
}
.img-opts.hidden { display: none; }
.per-image-opts {
  display: grid; gap: 6px;
}
.per-opt-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 13px;
}
.per-opt-row .opt-label { font-size: 13px; min-width: 110px; }

/* ── STATUS BADGE ── */
.img-status {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: .03em;
  border: 1px solid var(--line);
  color: var(--text-sub);
  background: var(--bg3);
}
.img-status.done {
  color: var(--accent);
  border-color: var(--accent-l);
  background: var(--accent-l);
}
.img-status.processing {
  color: oklch(0.6 0.12 85);
  border-color: oklch(0.6 0.12 85 / 0.2);
  background: oklch(0.6 0.12 85 / 0.08);
}
.img-status.error {
  color: var(--danger);
  border-color: oklch(0.55 0.18 25 / 0.2);
  background: oklch(0.55 0.18 25 / 0.08);
}

/* ── ACTIONS ── */
.actions-bar {
  display: flex; gap: 10px; align-items: center;
  margin-top: 24px; flex-wrap: wrap;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px;
  border-radius: var(--r);
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  transition: opacity .15s, background .15s;
  font-family: var(--f-sans);
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: oklch(0.97 0.007 75);
}
.btn-primary:hover:not(:disabled) { opacity: .85; }
.btn-ghost {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.progress-text {
  font-size: 13px; color: var(--text-dim);
  font-family: var(--f-mono);
}

/* ── EMPTY STATE ── */
.empty-state {
  display: none;
  text-align: center;
  padding: 32px;
  color: var(--text-sub);
  font-size: 13px;
}
.image-list:empty + .empty-state,
.image-list.is-empty + .empty-state { display: block; }

/* ── FOOTER ── */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px var(--pad);
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-sub);
}
.site-footer-links { display: flex; gap: 16px; }
.site-footer-links a { color: var(--text-sub); }
.site-footer-links a:hover { color: var(--accent); text-decoration: none; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .img-card { grid-template-columns: 64px 1fr; }
  .img-thumb-wrap { width: 64px; height: 64px; }
  .img-thumb { width: 64px; height: 64px; }
  .opt-controls { flex-direction: column; align-items: flex-start; }
}

/* ── MODAL OVERLAY ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: oklch(0.04 0.006 250 / 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay[hidden] { display: none; }

.modal-box {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  width: 100%;
  max-width: 860px;
  max-height: 92dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px oklch(0 0 0 / 0.35);
}

.modal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg3);
  flex-shrink: 0;
}
.modal-title {
  font-size: 14px; font-weight: 700; letter-spacing: .02em;
}
.modal-hint {
  font-size: 12px; color: var(--text-sub); flex: 1;
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 22px; line-height: 1;
  padding: 2px 6px; border-radius: 3px;
  transition: color .15s;
}
.modal-close:hover { color: var(--danger); }

.modal-body {
  flex: 1; overflow: hidden;
  display: flex; flex-direction: column;
  padding: 20px;
  gap: 12px;
}

/* ── COMPARISON CONTAINER ── */
.cmp-container {
  position: relative;
  flex: 1;
  overflow: hidden;
  border-radius: var(--r);
  background: var(--bg3);
  cursor: col-resize;
  user-select: none;
  -webkit-user-select: none;
  min-height: 200px;
  max-height: calc(92dvh - 140px);
  opacity: 0;
  transition: opacity .25s;
}

.cmp-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  draggable: false;
}
.cmp-after {
  clip-path: inset(0 0 0 50%);
}

/* ── DIVIDER ── */
.cmp-divider {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 6px oklch(0 0 0 / 0.5);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 10;
}

.cmp-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 10px oklch(0 0 0 / 0.35);
  display: flex; align-items: center; justify-content: center;
  color: oklch(0.25 0.01 250);
}

/* ── LABELS ── */
.cmp-label {
  position: absolute;
  top: 12px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  background: oklch(0 0 0 / 0.45);
  color: #fff;
  pointer-events: none;
  z-index: 5;
}
.cmp-label-l { left: 12px; }
.cmp-label-r { right: 12px; }

/* ── LOADING STATE ── */
.cmp-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text-sub);
  background: var(--bg3);
  z-index: 20;
}
.cmp-loading[hidden] { display: none; }

/* ── META ROW ── */
.cmp-meta {
  display: flex; justify-content: space-between;
  font-size: 12px; font-family: var(--f-mono); color: var(--text-dim);
  flex-shrink: 0;
  padding: 0 2px;
}
.cmp-meta span::before { color: var(--text-sub); margin-right: 4px; }
#cmp-size-before::before { content: 'Before:'; }
#cmp-size-after::before  { content: 'After:'; }

@media (max-width: 600px) {
  .modal-hint { display: none; }
  .modal-body { padding: 12px; }
  .cmp-handle { width: 32px; height: 32px; }
}
