/* ============================================================
   Windows 98, played straight — but laid out with 30 years of
   hindsight: real spacing, 32px hit targets, one clear hierarchy,
   responsive, and a status bar that actually carries information.

   The bevels are pure box-shadow (no images, no extra requests) and
   nothing animates except transforms, so the chrome never competes
   with the GPU that is running the upscaler.
   ============================================================ */

:root {
  --face: #c0c0c0;
  --face-lite: #dfdfdf;
  --shadow: #808080;
  --dark: #0a0a0a;
  --white: #ffffff;
  --navy: #000080;
  --navy-lite: #1084d0;
  --desk: #3a6ea5;          /* the 98 default desktop blue */
  --sel: #000080;
  --ink: #0a0a0a;
  --dim: #4a4a4a;
  --font: Tahoma, Verdana, Geneva, "DejaVu Sans", sans-serif;

  /* the two canonical bevels */
  --out: inset -1px -1px var(--dark), inset 1px 1px var(--white),
         inset -2px -2px var(--shadow), inset 2px 2px var(--face-lite);
  --in:  inset -1px -1px var(--white), inset 1px 1px var(--shadow),
         inset -2px -2px var(--face-lite), inset 2px 2px var(--dark);
  --press: inset -1px -1px var(--white), inset 1px 1px var(--dark),
           inset -2px -2px var(--face-lite), inset 2px 2px var(--shadow);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font: 12px/1.45 var(--font);
  color: var(--ink);
  background: var(--desk);
  /* a faint plaid, the way the old desktop patterns worked */
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .03) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .04) 0 1px, transparent 1px 4px);
  padding-bottom: 40px;      /* room for the taskbar */
}

/* ---------- window ---------- */

.desktop { padding: 18px 18px 8px; max-width: 1320px; margin: 0 auto; }
body.wide .desktop { max-width: none; padding: 8px 8px 4px; }

.window {
  background: var(--face);
  box-shadow: var(--out), 4px 4px 0 rgba(0, 0, 0, .28);
  padding: 3px;
  display: flex; flex-direction: column;
  animation: open .16s steps(3, end);
}
@keyframes open { from { transform: scale(.97); opacity: .4; } }

.titlebar {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 6px;
  background: linear-gradient(90deg, var(--navy), var(--navy-lite));
  color: #fff;
}
svg.icon, .titlebar-icon, .tray-icon, .dz-icon {
  shape-rendering: crispEdges;      /* keep the pixel grid honest */
  image-rendering: pixelated;
  flex: none;
}
.titlebar-icon { width: 16px; height: 16px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.titlebar-text { flex: 1; font-weight: 700; font-size: 12px; letter-spacing: .01em; }
.titlebar-buttons { display: flex; gap: 3px; }
.tb-btn {
  width: 26px; height: 24px; padding: 0; flex: none;
  display: grid; place-items: center;
  font: 700 11px/1 var(--font); color: var(--ink);
  background: var(--face); border: 0; cursor: pointer;
  box-shadow: var(--out);
}
.tb-btn:active { box-shadow: var(--press); }
.tb-btn:active span { transform: translate(1px, 1px); }

/* ---------- toolbar ---------- */

.toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-bottom: 1px solid var(--shadow);
  box-shadow: 0 1px 0 var(--white);
}
.toolbar-sep {
  width: 2px; height: 24px; margin: 0 2px;
  box-shadow: inset 1px 0 var(--shadow), inset -1px 0 var(--white);
}
.toolbar-file {
  font-size: 12px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.btn {
  position: relative;
  min-height: 34px; min-width: 84px; padding: 6px 14px;
  font: 13px/1 var(--font); color: var(--ink);
  background: var(--face); border: 0; cursor: pointer;
  box-shadow: var(--out);
  display: inline-grid; place-items: center; text-decoration: none;
}
.btn:focus-visible { outline: 1px dotted var(--ink); outline-offset: -5px; }
.btn:active:not(:disabled) { box-shadow: var(--press); padding: 7px 13px 5px 15px; }
.btn:disabled {
  color: var(--shadow); text-shadow: 1px 1px 0 var(--white); cursor: not-allowed;
}
/* the 50% stipple every greyed-out surface used to wear */
.btn:disabled::after {
  content: ''; position: absolute; inset: 3px; pointer-events: none;
  background-image: repeating-conic-gradient(rgba(255, 255, 255, .6) 0% 25%, transparent 0% 50%);
  background-size: 2px 2px;
}
.btn-default:disabled { box-shadow: var(--out); }   /* loses the default ring */
.btn-default { box-shadow: var(--out), 0 0 0 1px var(--dark); font-weight: 700; }
.btn-default:active:not(:disabled) { box-shadow: var(--press), 0 0 0 1px var(--dark); }

/* ---------- body ---------- */

.body {
  display: grid; grid-template-columns: minmax(0, 1fr) 258px;
  gap: 10px; padding: 10px;
}
@media (max-width: 900px) { .body { grid-template-columns: 1fr; } }

.canvas {
  position: relative;
  display: grid; place-items: center;
  min-height: 56vh; padding: 12px;
  background: #6e7d8c;      /* the old "workspace" grey-blue */
  background-image:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .05) 0 6px, transparent 6px 12px);
  box-shadow: var(--in);
}

.dropzone {
  width: 100%; height: 100%; min-height: inherit;
  display: grid; place-items: center;
  border: 0; background: none; cursor: pointer; font: inherit; color: inherit;
  padding: 0;
}
.dz-inner {
  display: grid; justify-items: center; gap: 3px;
  text-align: center; padding: 30px 40px; background: var(--face);
  box-shadow: var(--out);
  transition: transform .1s steps(2, end);
}
.dropzone:hover .dz-inner { transform: scale(1.03); }
.dropzone:active .dz-inner { box-shadow: var(--press); transform: scale(1); }
.dropzone:focus-visible .dz-inner { outline: 1px dotted var(--ink); outline-offset: -6px; }
.dropzone.hot .dz-inner { transform: scale(1.05); }
.dz-icon { width: 48px; height: 48px; margin-bottom: 10px; }
.dz-title { font-size: 15px; font-weight: 700; }
.dz-sub { font-size: 12px; color: var(--dim); }

.compare {
  position: relative; overflow: hidden;
  aspect-ratio: var(--ar, 1);
  width: min(100%, calc(52vh * var(--ar, 1)));
  max-height: 52vh;
  touch-action: none; user-select: none; line-height: 0;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #c8c8c8 25%, transparent 25%),
    linear-gradient(-45deg, #c8c8c8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c8c8c8 75%),
    linear-gradient(-45deg, transparent 75%, #c8c8c8 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  box-shadow: var(--in), 2px 2px 0 rgba(0, 0, 0, .25);
}
.compare img {
  width: 100%; height: 100%; display: block; object-fit: fill;
  pointer-events: none; -webkit-user-drag: none;   /* else native image drag kills the split */
}
.after-wrap { position: absolute; inset: 0; clip-path: inset(0 0 0 50%); }

.compare.ready { cursor: col-resize; }
.handle { display: none; }
.compare.ready .handle { display: block; }
.handle {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 4px; margin-left: -2px;
  background: var(--face);
  box-shadow: inset 1px 0 var(--white), inset -1px 0 var(--shadow), 0 0 0 1px var(--dark);
  pointer-events: none;
}
.grip {
  position: absolute; top: 50%; left: 50%;
  width: 22px; height: 46px; margin: -23px 0 0 -11px;
  background: var(--face); box-shadow: var(--out), 0 0 0 1px var(--dark);
}
.grip::before, .grip::after {
  content: ''; position: absolute; top: 50%; margin-top: -4px;
  width: 0; height: 0; border: 4px solid transparent;
}
.grip::before { left: 3px; border-right-color: var(--ink); }
.grip::after { right: 3px; border-left-color: var(--ink); }

/* A static "busy" band. It deliberately does not animate: inference saturates
   the GPU, so even compositor-driven animation stutters — a bar that judders is
   worse than one that simply marks the image as in progress. The visible signal
   of completion is the one-shot wipe in js/app.js. */
.scanline {
  position: absolute; left: 0; right: 0; top: 0; height: 10px; z-index: 3;
  background: var(--face); box-shadow: var(--in);
  overflow: hidden;
}
.scanline::after {
  content: ''; position: absolute; inset: 2px;
  background: repeating-linear-gradient(90deg, var(--navy) 0 8px, transparent 8px 10px);
}

/* ---------- file list (Explorer "details" view) ---------- */

.work { width: 100%; height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); }
.work.has-list { grid-template-columns: 252px minmax(0, 1fr); gap: 10px; }
.preview { display: grid; place-items: center; min-width: 0; min-height: 0; }

.filelist {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--white); box-shadow: var(--in);
}
.fl-head {
  display: grid; grid-template-columns: minmax(0, 1fr) 62px 66px;
  background: var(--face);
}
.fl-col {
  padding: 5px 7px; font-size: 11px; font-weight: 700; text-align: left;
  box-shadow: var(--out);
}
.fl-rows { flex: 1; overflow-y: auto; min-height: 0; }

.fl-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 62px 66px;
  align-items: center; width: 100%; text-align: left;
  padding: 0; border: 0; background: none; cursor: pointer;
  font: 12px var(--font); color: var(--ink);
}
.fl-row > span {
  padding: 5px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fl-row .fl-size, .fl-row .fl-status { font-size: 11px; color: var(--dim); }
.fl-row:hover { background: #e8e8e8; }
.fl-row[aria-selected="true"] { background: var(--navy); color: var(--white); }
.fl-row[aria-selected="true"] .fl-size,
.fl-row[aria-selected="true"] .fl-status { color: #cfe0ff; }
.fl-row:focus-visible { outline: 1px dotted var(--ink); outline-offset: -3px; }
.fl-row.is-working .fl-status { color: var(--navy); font-weight: 700; }
.fl-row.is-failed .fl-status { color: #a00000; font-weight: 700; }
.fl-row[aria-selected="true"].is-working .fl-status,
.fl-row[aria-selected="true"].is-failed .fl-status { color: #ffd0c0; }
.fl-row .fl-name { display: flex; align-items: center; gap: 6px; }
.fl-row .fl-icon { width: 14px; height: 14px; flex: none; }



/* ---------- rail ---------- */

.rail { display: flex; flex-direction: column; gap: 12px; }
.rail[aria-disabled="true"] { pointer-events: none; }
.rail[aria-disabled="true"] .group legend,
.rail[aria-disabled="true"] .opt span,
.rail[aria-disabled="true"] .tabs span,
.rail[aria-disabled="true"] .dims-x {
  color: var(--shadow); text-shadow: 1px 1px 0 var(--white);
}
.rail[aria-disabled="true"] .opt span::before { background: var(--face); }
.rail[aria-disabled="true"] .opt input:checked + span::after { background: var(--shadow); }
.rail[aria-disabled="true"] .dims input { color: var(--shadow); background: var(--face); }

.tabs { display: flex; gap: 2px; margin-bottom: -2px; position: relative; z-index: 1; }
.tabs label { flex: 1; }
.tabs input { position: absolute; opacity: 0; pointer-events: none; }
.tabs span {
  display: block; margin-top: 4px; padding: 8px 6px 9px;
  text-align: center; cursor: pointer;
  font-size: 13px; color: #3a3a3a;
  background: #b2b2b2;
  box-shadow: inset 1px 1px #cfcfcf, inset -1px -1px var(--shadow), inset 0 -2px var(--shadow);
  border-radius: 3px 3px 0 0;
  transition: background .1s steps(2, end), color .1s steps(2, end);
}
.tabs label:hover span { background: #c6c6c6; color: var(--ink); }
/* the selected tab is taller, lighter and bold -- reads as the sheet in front */
.tabs input:checked + span {
  margin-top: 0; padding: 10px 6px 11px;
  font-weight: 700; color: var(--ink);
  background: var(--face-lite);
  box-shadow: inset 1px 1px var(--white), inset -1px 0 var(--shadow), inset -2px 0 var(--dark);
}
.tabs input:focus-visible + span { outline: 1px dotted var(--ink); outline-offset: -4px; }

.group {
  margin: 0; padding: 14px 13px 15px; border: 0;
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--white);
}
/* the shadow "border" runs behind the legend, so give the legend the face
   colour to punch a hole in it the way a real group box does */
.group legend {
  padding: 0 6px; margin-left: 3px;
  background: var(--face);
  font-size: 12px; font-weight: 700; color: var(--ink);
}

.options { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.opt {
  display: inline-flex; align-items: center; cursor: pointer;
  min-height: 30px; padding: 4px 8px 4px 4px; margin: -4px -4px -4px -4px;
}
.opt:hover { background: rgba(0, 0, 0, .055); }
.opt:active span::before { box-shadow: var(--press); }
.opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.opt span { position: relative; padding-left: 22px; font-size: 13px; }
/* authentic sunken radio, drawn with shadows only */
.opt span::before {
  content: ''; position: absolute; left: 0; top: 50%; margin-top: -7px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--white); box-shadow: var(--in);
}
/* always present so it can snap in; steps() keeps the retro feel */
.opt span::after {
  content: ''; position: absolute; left: 4px; top: 50%; margin-top: -3px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--ink);
  transform: scale(0); transition: transform .1s steps(3, end);
}
.opt input:checked + span::after { transform: scale(1); }
.opt input:focus-visible + span { outline: 1px dotted var(--ink); outline-offset: 1px; }
.opt input:disabled + span { color: var(--shadow); text-shadow: 1px 1px 0 var(--white); }
.opt input:disabled + span::before { background: var(--face); }

.dims { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.dims input {
  width: 100%; min-width: 0; min-height: 30px; padding: 5px 7px;
  font: 12px var(--font); color: var(--ink);
  background: var(--white); border: 0; box-shadow: var(--in);
  -moz-appearance: textfield;
}
.dims input::-webkit-outer-spin-button,
.dims input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dims input:focus { outline: 1px dotted var(--ink); outline-offset: -4px; }
.dims-x { color: var(--dim); }
.lock { min-width: 34px; min-height: 30px; padding: 0; font-size: 12px; }
.lock[aria-pressed="true"] { box-shadow: var(--press); background: var(--face-lite); }

.actions { display: flex; flex-direction: column; gap: 8px; }
.actions .btn { width: 100%; min-height: 38px; }

.progress { height: 20px; padding: 2px; background: var(--face); box-shadow: var(--in); }
.progress-fill {
  height: 100%; width: 0;
  background: repeating-linear-gradient(90deg, var(--navy) 0 12px, transparent 12px 14px);
  transition: width .15s steps(6, end);
}

/* ---------- status bar ---------- */

.statusbar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 3px; padding: 3px 3px 4px;
}
.status-panel {
  padding: 6px 10px; font-size: 12px; color: var(--dim); min-width: 0;
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--white);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status-panel:not(.status-grow) { text-align: center; min-width: 62px; }
.status-grow { color: var(--ink); }
.status-panel:empty { display: none; }
.status-panel.warn { color: #a00000; }
.status-panel.live { color: var(--ink); }

/* ---------- banner ---------- */

.banner {
  display: flex; align-items: center; gap: 10px;
  margin: 8px; padding: 10px 12px;
  background: var(--face); box-shadow: var(--out);
  font-size: 12px;
}
.banner-icon {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: #d40000; color: #fff; font-weight: 700;
}
.banner-text { flex: 1; min-width: 0; }
.banner-action, .banner-close { min-width: 0; }
.banner-close { min-width: 34px; padding: 6px 8px; }

/* ---------- taskbar ---------- */

.taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; align-items: center; gap: 6px;
  height: 34px; padding: 3px 4px;
  background: var(--face); box-shadow: inset 0 1px 0 var(--white), 0 -1px 0 var(--shadow);
}
.start {
  display: flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 9px 0 6px; border: 0; cursor: pointer;
  font: 700 12px var(--font); color: var(--ink);
  background: var(--face); box-shadow: var(--out);
}
.start:active { box-shadow: var(--press); }
.start-flag {
  width: 15px; height: 14px;
  background:
    linear-gradient(135deg, #ff3b30 0 50%, #ffcc00 0) left top / 8px 7px no-repeat,
    linear-gradient(135deg, #34c759 0 50%, #0a84ff 0) right bottom / 8px 7px no-repeat,
    linear-gradient(135deg, #ffcc00 0 50%, #ff3b30 0) right top / 8px 7px no-repeat,
    linear-gradient(135deg, #0a84ff 0 50%, #34c759 0) left bottom / 8px 7px no-repeat;
}
.task-list { flex: 1; display: flex; gap: 4px; min-width: 0; }
.task {
  height: 26px; padding: 0 12px; border: 0; cursor: default;
  font: 12px var(--font); color: var(--ink); background: var(--face);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  box-shadow: var(--out);
}
.task.active { box-shadow: var(--press); font-weight: 700; }
.tray {
  display: flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 9px; font-size: 11px;
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--white);
}
.tray-icon { width: 14px; height: 14px; }

/* ---------- about dialog ---------- */

.dialog-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, .28);
}
.dialog {
  width: min(420px, calc(100vw - 32px));
  animation: none;                 /* a modal appears, it does not fade in */
}
.dialog-body { padding: 18px; display: grid; gap: 10px; justify-items: start; }
.dialog-body.batch-body { justify-items: stretch; }
.dialog-body.batch-body p { margin: 0; }
.dialog-body.batch-body .progress { width: 100%; margin: 4px 0 2px; }
.dialog-body.batch-body .btn { justify-self: end; margin-top: 6px; }
.dialog-body p { margin: 0; }
.dialog-body .dim { color: var(--dim); font-size: 11px; }
.dialog-body .btn { margin-top: 6px; justify-self: end; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
