:root {
  --ink: #151814;
  --muted: #6e736a;
  --paper: #f2f0e9;
  --paper-deep: #e8e5dc;
  --line: rgb(21 24 20 / 15%);
  --dark: #111412;
  --dark-soft: #1a1e1a;
  --acid: #e3ef63;
  --cream: #f7f4ec;
  --spectrum: linear-gradient(90deg,
    #ff4236 0%, #ff2d76 8%, #c737df 17%, #6947df 27%, #315cda 35%,
    #16a9de 44%, #14a79b 52%, #18a65c 61%, #8cc744 70%, #f2dc2d 78%,
    #fa9a2a 86%, #eee9df 86%, #eee9df 95%, #121412 95%, #121412 100%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html { min-width: 320px; scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 78% -12%, rgb(218 231 174 / 44%), transparent 30rem),
    var(--paper);
}

button,
input { font: inherit; }

button { color: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

.upload-button,
.save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 18px;
  color: var(--cream);
  background: var(--dark);
  border: 1px solid var(--dark);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .03em;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

.upload-button:hover,
.save-button:hover { background: #2b302b; transform: translateY(-1px); }

.upload-button.large { min-height: 48px; padding: 0 24px; }

main { overflow: hidden; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.atlas-section {
  min-height: 100vh;
  background: var(--dark);
  border-top: 1px solid rgb(255 255 255 / 8%);
}

.atlas-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 78px;
  padding: 0 42px;
  color: var(--cream);
  background: var(--dark);
  border-bottom: 1px solid rgb(255 255 255 / 11%);
}

.atlas-title {
  margin: 0 0 5px;
  color: #e3e5df;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.range-readout { margin: 0; color: #d6d8d1; font-family: Georgia, serif; font-size: 15px; }

.toolbar-actions,
.zoom-controls { display: flex; align-items: center; gap: 7px; }

.toolbar-actions { gap: 12px; }

.text-button,
.icon-button {
  padding: 9px 12px;
  color: #d2d6ce;
  background: transparent;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 999px;
  font-size: 11px;
  cursor: pointer;
}

.text-button:hover { border-color: rgb(255 255 255 / 36%); }
.text-button:disabled { opacity: .36; cursor: default; }

.zoom-controls .icon-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
}

.zoom-controls .text-button { min-height: 32px; padding: 0 11px; font-size: 10px; }

.timeline-direction-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
}

.atlas-scroll {
  height: calc(100vh - 79px);
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--dark);
  scrollbar-color: #3a403a var(--dark);
}

.atlas {
  color: var(--cream);
  background: var(--dark);
}

.color-axis {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 112px 1fr;
  min-height: 80px;
  background: rgb(17 20 18 / 94%);
  border-bottom: 1px solid rgb(255 255 255 / 12%);
  backdrop-filter: blur(12px);
}

.axis-corner {
  position: sticky;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  padding: 0 14px 16px 20px;
  color: #8f968d;
  border-right: 1px solid rgb(255 255 255 / 12%);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.color-scale {
  display: grid;
  grid-template-columns: repeat(11, 1fr) .9fr .9fr;
  gap: 3px;
  padding: 10px 12px 11px;
}

.color-scale span {
  position: relative;
  min-width: 0;
  min-height: 58px;
  overflow: hidden;
  background: var(--segment);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 3px;
}

.color-scale span::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgb(255 255 255 / 20%), transparent 48%, rgb(0 0 0 / 18%));
  content: "";
}

.timeline-body {
  display: grid;
  grid-template-columns: 112px 1fr;
  min-height: 780px;
}

.time-axis {
  position: sticky;
  left: 0;
  z-index: 10;
  min-height: inherit;
  background: #141714;
  border-right: 1px solid rgb(255 255 255 / 12%);
}

.time-direction {
  position: absolute;
  top: 21px;
  left: 20px;
  color: #747c73;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .17em;
  text-transform: uppercase;
}

.time-direction.older {
  top: auto;
  bottom: 21px;
}

.photo-field {
  position: relative;
  min-height: inherit;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgb(255 66 54 / 4%), rgb(105 71 223 / 2%) 27%, rgb(20 167 155 / 3%) 52%, rgb(242 220 45 / 3%) 78%, transparent 87%),
    repeating-linear-gradient(90deg, transparent 0, transparent calc(7.692% - 1px), rgb(255 255 255 / 4%) calc(7.692% - 1px), rgb(255 255 255 / 4%) 7.692%),
    #171a17;
  cursor: grab;
  touch-action: none;
}

.photo-field.panning { cursor: grabbing; user-select: none; }

.photo-field.drop-ready::after {
  position: absolute;
  inset: 18px;
  z-index: 50;
  display: grid;
  place-items: center;
  color: var(--acid);
  background: rgb(17 20 18 / 82%);
  border: 2px dashed var(--acid);
  border-radius: 10px;
  font-family: Georgia, serif;
  font-size: 28px;
  content: "Drop photos to add them";
  pointer-events: none;
}

.photo-card {
  position: absolute;
  z-index: 3;
  top: var(--y);
  left: var(--x);
  display: block;
  width: var(--card-size, 118px);
  height: var(--card-size, 118px);
  padding: 0;
  color: var(--cream);
  background: #252a25;
  border: 0;
  border-radius: 1px;
  box-shadow: 0 3px 10px rgb(0 0 0 / 24%);
  cursor: grab;
  transform: translateX(-50%);
  touch-action: none;
  transition: box-shadow 160ms ease, border-color 160ms ease, filter 160ms ease;
}

.photo-card:hover,
.photo-card:focus-visible {
  z-index: 20;
  box-shadow: 0 8px 24px rgb(0 0 0 / 55%);
  outline: 1px solid rgb(255 255 255 / 70%);
  outline-offset: 1px;
}

.photo-card.dragging {
  z-index: 35;
  cursor: grabbing;
  border-color: var(--acid);
  box-shadow: 0 18px 50px rgb(0 0 0 / 70%);
  transition: none;
}

.photo-card img {
  display: block;
  width: 100%;
  height: 100%;
  background: #282d28;
  object-fit: cover;
  pointer-events: none;
}

.shared-photo { pointer-events: none; }

.hue-guide {
  position: absolute;
  z-index: 30;
  top: 0;
  bottom: 0;
  left: var(--guide-x);
  width: 1px;
  background: var(--acid);
  pointer-events: none;
}

.hue-guide span {
  position: sticky;
  top: 102px;
  display: block;
  width: max-content;
  padding: 5px 8px;
  color: var(--dark);
  background: var(--acid);
  border-radius: 3px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  transform: translateX(-50%);
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 80px;
  text-align: center;
}

.empty-state[hidden] { display: none; }

.empty-state h2 { margin: 0; font-family: Georgia, serif; font-size: 38px; font-weight: 400; letter-spacing: -.03em; }
.empty-state > p:not(.empty-kicker) { max-width: 390px; margin: 14px 0 26px; color: #9da39b; font-size: 12px; line-height: 1.6; }

.upload-tray {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  width: min(390px, calc(100vw - 32px));
  padding: 20px;
  color: var(--cream);
  background: #242924;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgb(0 0 0 / 45%);
}

.upload-tray[hidden] { display: none; }
.upload-tray-head { display: flex; justify-content: space-between; gap: 20px; }
.tray-label { margin: 0 0 6px; color: #959d93; font-size: 9px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.upload-tray strong { font-family: Georgia, serif; font-size: 16px; font-weight: 400; }
.upload-tray .icon-button { width: 30px; height: 30px; padding: 0; font-size: 20px; }

.upload-progress { height: 3px; margin: 17px 0 14px; overflow: hidden; background: rgb(255 255 255 / 10%); border-radius: 99px; }
.upload-progress i { display: block; width: 0; height: 100%; background: var(--acid); transition: width 180ms ease; }

.upload-tray ol { display: grid; gap: 8px; max-height: 190px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.upload-tray li { display: grid; grid-template-columns: 1fr auto; gap: 14px; color: #b9bfb7; font-size: 10px; }
.upload-tray li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-tray li b { color: #8d958b; font-size: 9px; font-weight: 600; }
.upload-tray li.done b { color: var(--acid); }
.upload-tray li.failed b { color: #ff8c82; }

.photo-dialog {
  width: min(820px, calc(100vw - 32px));
  max-width: none;
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 40px 100px rgb(0 0 0 / 50%);
}

.photo-dialog::backdrop { background: rgb(8 11 8 / 76%); backdrop-filter: blur(6px); }

.share-dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 14px;
  box-shadow: 0 40px 100px rgb(0 0 0 / 50%);
}

.share-dialog::backdrop { background: rgb(8 11 8 / 76%); backdrop-filter: blur(6px); }

.share-dialog-shell { position: relative; padding: 36px; }
.share-dialog .atlas-title { color: var(--muted); }
.share-dialog-shell h2 { margin: 7px 0 8px; font-family: Georgia, serif; font-size: 25px; font-weight: 400; }
.share-dialog-shell > p:not(.atlas-title) { margin: 0 0 24px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.share-dialog-shell label { display: block; margin: 0 0 8px; color: #555b52; font-size: 9px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.share-dialog-shell input { width: 100%; min-height: 44px; padding: 0 12px; color: var(--ink); background: #faf8f2; border: 1px solid var(--line); border-radius: 7px; }
.share-dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.share-dialog-actions .text-button { display: inline-flex; align-items: center; color: var(--ink); border-color: var(--line); text-decoration: none; }

.dialog-shell { position: relative; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr); }

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--ink);
  background: rgb(247 244 236 / 85%);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
}

.dialog-image-wrap { position: relative; min-height: 540px; background: #272b27; }
.dialog-image-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.dialog-color-dot { position: absolute; bottom: 18px; left: 18px; width: 20px; height: 20px; border: 2px solid white; border-radius: 50%; box-shadow: 0 2px 8px rgb(0 0 0 / 40%); }

.dialog-content { display: flex; flex-direction: column; padding: 48px 38px 34px; }
.dialog-content h2 { margin: 0 0 28px; font-family: Georgia, serif; font-size: 25px; font-weight: 400; }

.dialog-content label { display: grid; gap: 8px; margin-bottom: 22px; color: #555b52; font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.dialog-content input:not([type="range"]) { width: 100%; min-height: 44px; padding: 0 12px; color: var(--ink); background: #faf8f2; border: 1px solid var(--line); border-radius: 7px; outline: none; }
.dialog-content input:not([type="range"]):focus { border-color: #718252; box-shadow: 0 0 0 3px rgb(113 130 82 / 13%); }
.dialog-content small { color: #81867e; font-size: 9px; font-weight: 500; letter-spacing: .01em; text-transform: none; }

.position-control input { width: 100%; accent-color: #222; cursor: ew-resize; }
.mini-spectrum { display: block; height: 8px; margin-top: -3px; background: var(--spectrum); border: 1px solid var(--line); border-radius: 99px; }

.dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: auto; padding-top: 20px; border-top: 1px solid var(--line); }
.delete-button { padding: 9px 0; color: #9b3e38; background: transparent; border: 0; font-size: 10px; font-weight: 700; cursor: pointer; }
.save-button { min-height: 42px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 100;
  padding: 11px 16px;
  color: var(--cream);
  background: #2a2f2a;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 99px;
  box-shadow: 0 12px 35px rgb(0 0 0 / 35%);
  font-size: 11px;
  transform: translateX(-50%);
}

.toast[hidden] { display: none; }

@media (max-width: 900px) {
  .atlas-toolbar { padding: 0 20px; }
  .dialog-shell { grid-template-columns: 1fr; }
  .dialog-image-wrap { min-height: 320px; }
}

@media (max-width: 560px) {
  .upload-button { min-height: 38px; padding: 0 14px; }
  .zoom-controls .text-button { display: none; }
  .photo-dialog { width: calc(100vw - 18px); }
  .dialog-image-wrap { min-height: 280px; }
  .dialog-content { padding: 34px 24px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
