:root {
  --paper: #fff;
  --ink: #161616;
  --ink-2: #5a5a5a;
  --rule: #dadada;
  --field: #b9b9b9;
  --screen: #0f1c38;
  --on-screen: #d9dfea;
  --on-screen-2: #97a3bb;
  --maroon: #7c1f35;
  --maroon-dark: #5f1628;
  --tint: #f5ecee;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Source Sans 3", -apple-system, "Segoe UI", sans-serif;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.45 var(--sans);
}

h1, h2, p { margin: 0; }
:focus-visible { outline: 2px solid var(--maroon); outline-offset: 2px; }

.name { font: 600 21px/1 var(--serif); color: var(--ink); text-decoration: none; }

/* Controls */

.field { display: grid; gap: 6px; font-size: 15px; }

input, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--field);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font: 400 16px/1.4 var(--sans);
}
textarea { resize: vertical; min-height: 7.5em; }
input:focus, textarea:focus { outline: none; border-color: var(--maroon); box-shadow: 0 0 0 1px var(--maroon); }
::placeholder { color: #8a8a8a; }

.button {
  padding: 10px 18px;
  border: 0;
  border-radius: 4px;
  background: var(--maroon);
  color: #fff;
  font: 600 16px/1.2 var(--sans);
  cursor: pointer;
}
.button:hover:not(:disabled) { background: var(--maroon-dark); }
.button:disabled { opacity: 0.6; cursor: progress; }


.note { font-size: 14px; color: var(--ink-2); }
.note:empty, .hint:empty { display: none; }
.note[data-tone="bad"] { color: var(--maroon); }
.hint { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* The file picker keeps the shape of a native one: a button and the name. */
.file { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-button {
  flex: none;
  padding: 7px 12px;
  border: 1px solid var(--field);
  border-radius: 4px;
  background: #f5f5f5;
}
.file:hover .file-button { background: #ececec; }
.file:focus-within .file-button { outline: 2px solid var(--maroon); outline-offset: 2px; }
.file-name { min-width: 0; overflow: hidden; color: var(--ink-2); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.file.loaded .file-name { color: var(--ink); }


/* Workspace */

.app {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  grid-template-rows: 52px auto minmax(0, 1fr);
  grid-template-areas: "bar bar" "controls view" "past view";
  height: 100vh;
}

.bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  border-bottom: 1px solid var(--rule);
}
.bar .name { margin-right: auto; }

.controls {
  grid-area: controls;
  display: grid;
  gap: 16px;
  padding: 20px;
  border-right: 1px solid var(--rule);
}

.past {
  grid-area: past;
  min-height: 0;
  overflow-y: auto;
  padding: 0 20px 20px;
  border-right: 1px solid var(--rule);
}
.past h2 {
  padding: 16px 0 8px;
  border-top: 1px solid var(--rule);
  font: 600 15px/1.2 var(--sans);
}

.history { margin: 0 -8px; padding: 0; list-style: none; }
.history li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.history li:hover { background: #f4f4f4; }
.history li.current { background: var(--tint); }
.history li.none { display: block; color: var(--ink-2); cursor: default; }
.history li.none:hover { background: none; }
.thumb { display: block; width: 44px; height: 44px; border-radius: 2px; background: var(--screen); object-fit: cover; }
.history .prompt { display: block; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.history .meta { display: block; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.history .meta.bad { color: var(--maroon); }

/* The viewport: renders are made on this same blue. */

.view {
  grid-area: view;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  background: var(--screen);
  color: var(--on-screen);
}
.stage { display: grid; place-items: center; min-height: 0; padding: 28px; overflow: hidden; }
/* A finished render: the still, and the live 3D view laid over it. */
.shot { position: relative; width: min(100%, 640px, calc(100vh - 150px)); aspect-ratio: 1; }
.shot img { display: block; width: 100%; height: 100%; }
.shot .view3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  outline: none;
}
.shot .view3d:active { cursor: grabbing; }
.empty, .failed { color: var(--on-screen-2); }

.readout {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--on-screen-2);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* Progress while a render runs. */
.steps { min-width: 280px; margin: 0; padding: 0; list-style: none; color: #6f7c97; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 5px 0; }
.steps li::before {
  content: "";
  flex: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid #3b4968;
  border-radius: 50%;
}
.steps li.done { color: var(--on-screen); }
.steps li.done::before {
  border-color: var(--on-screen);
  background: var(--on-screen) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3.5 7.2l2.3 2.3 4.7-5' fill='none' stroke='%230f1c38' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 11px no-repeat;
}
.steps li.now { color: #fff; }
.steps li.now::before {
  border-color: #3b4968;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
.steps .t { margin-left: auto; padding-left: 24px; color: var(--on-screen-2); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 52px auto auto auto;
    grid-template-areas: "bar" "controls" "view" "past";
    height: auto;
  }
  .controls, .past { border-right: 0; }
  .view { min-height: 70vh; }
  .shot { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .steps li.now::before { animation-duration: 2.4s; }
}
