/* Design language conforms to Easy-MP2RAGE-T1-Map. */
:root {
  --bg: #0d1014; --bg2: #0f1319; --panel: #161b22; --panel2: #1d242d; --line: #28313c;
  --ink: #e9eef4; --dim: #93a1b0; --accent: #5aa2ff; --accent2: #7c5cff;
  --good: #3ac07f; --warn: #f0b03a; --bad: #e5604d; --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 78% -8%, rgba(124, 92, 255, .14), transparent 60%),
    radial-gradient(900px 460px at 10% -6%, rgba(90, 162, 255, .14), transparent 55%),
    var(--bg);
  min-height: 100vh;
}
a { color: var(--accent); }
code { background: var(--panel2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

header { padding: 22px 22px 16px; border-bottom: 1px solid var(--line); }
.head-in { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.mark {
  width: 42px; height: 42px; border-radius: 11px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; font-weight: 800; color: #08101c;
  box-shadow: 0 6px 20px rgba(90, 162, 255, .35);
}
h1 { font-size: 22px; margin: 0; font-weight: 750; letter-spacing: -.01em; }
h1 .g { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.header-link {
  color: var(--ink); text-decoration: none; border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 12px; font-weight: 600; white-space: nowrap;
}
.header-link:hover { border-color: var(--accent); }

main { max-width: 1080px; margin: 0 auto; padding: 20px; display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { main { grid-template-columns: 1fr; } }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.viewer-col { position: sticky; top: 12px; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: 0 1px 0 rgba(255, 255, 255, .02) inset;
}
.card h2 {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim);
  margin: 0 0 12px; display: flex; align-items: center; gap: 2px;
}
.hidden { display: none !important; }
.muted, .note { color: var(--dim); }
.small { font-size: 12px; }

/* Drop zone */
#dropZone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 24px; text-align: center;
  color: var(--dim); cursor: pointer; transition: .15s; background: rgba(255, 255, 255, .01);
}
#dropZone.drag { border-color: var(--accent); background: rgba(90, 162, 255, .07); color: var(--ink); }
#dropZone b, #dropZone strong { color: var(--ink); }
.pick-row { display: flex; gap: 10px; justify-content: center; margin: 12px 0; }

/* Buttons and inputs */
.btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #08101c;
  border: 0; border-radius: 9px; padding: 10px 16px; font-weight: 700; cursor: pointer;
  font: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { filter: brightness(1.06); }

label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--dim); }
select, input {
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 9px; font: inherit; font-size: 13px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; margin-top: 12px; }
label.check input { width: auto; }
label.check.inline { margin: 0; }
.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* Frame size readout and the 4D (mosaic) control, both below the options grid. */
#outputSize { margin: 10px 0 0; }
#mosaicRow { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
#mosaicRow.hidden { display: none; }
#mosaicNote { margin: 6px 0 0; }

.result { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.result video { width: 100%; background: #000; border-radius: 8px; max-height: 320px; }
.downloads a, #downloadLink { text-decoration: none; }

/* Series list */
.series-list { display: flex; flex-direction: column; gap: 8px; }
.series-item { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 9px; padding: 10px; cursor: pointer; }
.series-item.selected { border-color: var(--accent); background: rgba(90, 162, 255, .09); }
.series-item input { margin-top: 3px; }
.series-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.series-title { font-size: 13px; color: var(--ink); word-break: break-word; }
.chip { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); }
.chip.t1 { color: #7fd1ff; border-color: rgba(90, 162, 255, .5); }
.chip.color { color: #ff9d7f; border-color: rgba(229, 96, 77, .5); }

/* Viewer + histogram */
.nv-wrap { background: #000; border: 1px solid var(--line); border-radius: 10px; padding: 8px; height: 400px; }
#nvCanvas { width: 100%; height: 100%; display: block; background: #000; border-radius: 6px; }
@media (max-width: 900px) { .nv-wrap { height: 320px; } }
.win-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 6px; }
.win-head h3 { font-size: 12px; margin: 0; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; }
#hist { display: block; width: 100%; height: 120px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; touch-action: none; }
.win-readout { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Preview modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .68); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal-box { background: linear-gradient(180deg, var(--panel), var(--bg2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; width: min(760px, 100%); max-height: 92vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 16px; }
.recon-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.recon-label { font-size: 12px; color: var(--dim); }
.ori.active { color: var(--nd-color-primary); border-color: var(--nd-color-primary); }
.scrub-wrap { background: #000; border-radius: 8px; padding: 6px; display: flex; justify-content: center; align-items: center; min-height: 120px; }
/* The display size is set in JS to preserve the frame aspect ratio; do not force width:100%. */
.scrub { display: block; margin: 0 auto; background: #000; border-radius: 6px; image-rendering: pixelated; }
.scrub-controls { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.scrub-controls input[type=range] { flex: 1; accent-color: var(--accent); }
.stretch { flex-direction: row; align-items: center; gap: 6px; color: var(--dim); }
.stretch input[type=range] { width: 96px; accent-color: var(--accent); }
.stretch span { font-variant-numeric: tabular-nums; min-width: 40px; }

#dropZone { padding: 16px; }
.nd-field > label { flex-direction: row; align-items: center; gap: 6px; }

/* Pin the shared status footer to the bottom of the window. */
body { display: flex; flex-direction: column; }
main { flex: 1 0 auto; width: 100%; }
#status { position: sticky; bottom: 0; z-index: 50; }

#aboutDialog, #privacyDialog { max-width:min(760px,calc(100vw - 24px)); max-height:calc(100dvh - 24px); overflow:auto; }
