@font-face {
  font-family: "Lato";
  src: url("../assets/fonts/lato-100.woff2") format("woff2");
  font-style: normal;
  font-weight: 100;
  font-display: swap;
}

@font-face {
  font-family: "Lato";
  src: url("../assets/fonts/lato-300.woff2") format("woff2");
  font-style: normal;
  font-weight: 300;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --ink: #000;
  --soft-ink: #d7d7d7;
  --background: #fff;
  --line: #222;
  --panel: #fff;
  --control: transparent;
  --border: #111;
  --muted: #6e6e73;
  --accent: #256b58;
  --panel-width: min(88vw, 380px);
  --open-control-reserve: 44px;
  --formation-duration: .9s;
  --formation-curve: cubic-bezier(.65, 0, .35, 1);
  font-family: "Lato", ui-sans-serif, system-ui, sans-serif;
  font-weight: 300;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--background);
  color: var(--ink);
  overflow: hidden;
  transition: background-color .6s ease;
}

body.intro-active {
  background: #000;
}

body.intro-active aside,
body.intro-active .panel-dot,
body.intro-active .panel-backdrop {
  display: none;
}

body.intro-active .viewport { cursor: pointer; }

.panel-dot {
  position: fixed;
  z-index: 40;
  top: calc(16px + env(safe-area-inset-top));
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  transition:
    transform var(--formation-duration) var(--formation-curve),
    opacity var(--formation-duration) var(--formation-curve);
}

.panel-dot.history-dot { left: calc(16px + env(safe-area-inset-left)); }
.panel-dot.settings-dot { right: calc(16px + env(safe-area-inset-right)); }
.panel-dot.data-dot { left: calc(16px + env(safe-area-inset-left)); top: auto; bottom: calc(16px + env(safe-area-inset-bottom)); }
.panel-dot.about-dot { right: calc(16px + env(safe-area-inset-right)); top: auto; bottom: calc(16px + env(safe-area-inset-bottom)); }

.panel-dot::before {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ink) 18%, transparent);
  transform: translate(-50%, -50%);
  transition: transform .2s ease, box-shadow .2s ease;
}

.panel-dot:hover::before,
.panel-dot:focus-visible::before {
  transform: translate(-50%, -50%) scale(1.35);
  box-shadow: 0 0 0 7px color-mix(in srgb, var(--ink) 12%, transparent);
}

.dot-identity {
  position: absolute;
  color: var(--ink);
  font-size: 10px;
  font-weight: 300;
  letter-spacing: .16em;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.history-dot .dot-identity { left: 48px; top: 17px; }
.settings-dot .dot-identity { right: 48px; top: 17px; }
.data-dot .dot-identity { left: 48px; bottom: 17px; }
.about-dot .dot-identity { right: 48px; bottom: 17px; }

body.reveal-navigation .dot-identity { animation: identify-name 3s ease-in-out both; }
body.reveal-navigation .panel-dot::before { animation: identify-dot 1s ease-in-out both; }

@keyframes identify-dot {
  0% { opacity: 0; filter: blur(3px); }
  100% { opacity: 1; filter: blur(0); }
}

@keyframes identify-name {
  0% { opacity: 0; filter: blur(3px); }
  33%, 66% { opacity: 1; filter: blur(0); }
  100% { opacity: 0; filter: blur(3px); }
}

body.history-open .history-dot {
  transform: translateX(calc(var(--panel-width) - 60px - env(safe-area-inset-left)));
}

body.settings-open .settings-dot {
  transform: translateX(calc(-1 * (var(--panel-width) - 60px - env(safe-area-inset-right))));
}

body.data-open .data-dot {
  transform: translateX(calc(var(--panel-width) - 60px - env(safe-area-inset-left)));
}

body.about-open .about-dot {
  transform: translateX(calc(-1 * (var(--panel-width) - 60px - env(safe-area-inset-right))));
}

body.history-open .data-dot,
body.data-open .history-dot,
body.settings-open .about-dot,
body.about-open .settings-dot {
  opacity: 0;
  pointer-events: none;
}

.side-panel {
  position: fixed;
  z-index: 30;
  width: var(--panel-width);
  height: 100dvh;
  padding: 22px;
  background: var(--background);
  overflow: auto;
  overscroll-behavior: contain;
  transition: transform var(--formation-duration) var(--formation-curve);
  box-shadow: none;
}

#historyPanel { inset: 0 auto 0 0; transform: translateX(-105%); }
#settingsPanel { inset: 0 0 0 auto; transform: translateX(105%); }
#dataPanel { inset: 0 auto 0 0; transform: translateX(-105%); }
#aboutPanel { inset: 0 0 0 auto; transform: translateX(105%); }
#dataPanel, #aboutPanel { display: flex; flex-direction: column; justify-content: flex-end; }
.panel-bottom-content { width: 100%; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
#historyPanel > h1 { padding-right: var(--open-control-reserve); }
#settingsPanel .panel-title-row { padding-left: var(--open-control-reserve); }
#dataPanel .panel-bottom-content,
#aboutPanel .panel-bottom-content { padding-bottom: max(var(--open-control-reserve), env(safe-area-inset-bottom)); }
body.history-open #historyPanel,
body.settings-open #settingsPanel,
body.data-open #dataPanel,
body.about-open #aboutPanel { transform: translateX(0); }

.panel-backdrop {
  display: none;
  position: fixed;
  z-index: 25;
  inset: 0;
  background: transparent;
}

body.history-open .panel-backdrop,
body.settings-open .panel-backdrop,
body.data-open .panel-backdrop,
body.about-open .panel-backdrop {
  display: block;
}

main {
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

h1 {
  margin: 0 0 22px;
  font-size: 25px;
  font-weight: 300;
  letter-spacing: 0;
}

h2 {
  margin: 26px 0 10px;
  font-size: 13px;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  font-size: 13px;
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 72%, transparent);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 0 2px;
  font: inherit;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-bottom-color: var(--ink);
  box-shadow: 0 1px 0 var(--ink);
}

input,
select {
  height: 38px;
}

textarea {
  min-height: 76px;
  padding: 9px 2px;
  resize: vertical;
  line-height: 1.35;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 20px;
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  outline: 0;
  box-shadow: none !important;
  background: linear-gradient(to right, var(--ink) 0 var(--range-fill, 50%), color-mix(in srgb, var(--ink) 25%, transparent) var(--range-fill, 50%) 100%) center / 100% 1px no-repeat;
}

input[type="range"]:focus,
input[type="range"]:focus-visible {
  border: 0 !important;
  outline: 0;
  box-shadow: none !important;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: transparent;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5.5px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}

input[type="range"]::-moz-range-track {
  height: 1px;
  background: color-mix(in srgb, var(--ink) 25%, transparent);
}

input[type="range"]::-moz-range-progress {
  height: 1px;
  background: var(--ink);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}

input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--ink);
  background: transparent;
}

input[type="checkbox"]:checked {
  box-shadow: inset 0 0 0 4px var(--background);
  background: var(--ink);
}

.slider-label {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.slider-label span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.toggle-label {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

button {
  height: 36px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 0 12px;
  font-family: inherit;
  font-size: 10px;
      font-weight: 300;
  line-height: 1;
  letter-spacing: .035em;
  white-space: nowrap;
  cursor: pointer;
}

button.primary {
  border-color: var(--ink);
  background: transparent;
  color: var(--ink);
}

.mode {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.mode button {
  padding: 0 6px;
  font-size: 12px;
}

.mode button.active {
  border-color: var(--ink);
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.item {
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 18%, transparent);
}

.item summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: baseline;
  padding: 13px 0;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
}

.item summary::-webkit-details-marker { display: none; }
.item-summary-date { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }

.item-fields {
  display: grid;
  gap: 8px;
  padding: 2px 0 16px;
}

.item-fields label {
  margin: 0;
}

.delete-item { width: auto; justify-self: end; border: 0; color: var(--muted); font-size: 11px; padding: 0; }

.history-create {
  margin: 28px 0 34px;
  padding-bottom: 22px;
}

.history-heading { display: flex; align-items: center; justify-content: space-between; }
.history-heading h2 { margin: 0; }
.add-menu-toggle { width: 36px; padding: 0; border: 0; font-size: 21px; font-weight: 200; }
.add-menu { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .45s var(--formation-curve), opacity .3s ease; }
.add-menu > div { overflow: hidden; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.add-menu.is-open { grid-template-rows: 1fr; opacity: 1; }
.add-menu button {
  height: 38px;
  margin-top: 12px;
  border-color: color-mix(in srgb, var(--ink) 38%, transparent);
  text-align: center;
  padding: 0 10px;
  font-size: 12px;
}

.readout {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.data-actions {
  display: grid;
  gap: 8px;
}

.data-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.data-actions button {
  height: 34px;
  padding-inline: 8px;
  font-size: 9px;
  letter-spacing: .025em;
}

#importVitalFile {
  display: none;
}

.data-status {
  min-height: 1.5em;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
#settingsPanel .panel-title-row { flex-direction: row-reverse; }
#settingsPanel .panel-title-row h1 { text-align: right; }

.panel-title-row h1 { margin: 0; }

.language-select {
  width: auto;
  min-width: 112px;
  height: 30px;
  padding: 0 22px 0 2px;
  border-bottom-color: color-mix(in srgb, var(--ink) 28%, transparent);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.settings-actions {
  display: grid;
  gap: 8px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid color-mix(in srgb, var(--ink) 18%, transparent);
}

.about-copy {
  display: grid;
  gap: 18px;
  margin-top: clamp(28px, 7vh, 72px);
}
.about-panel {
  justify-content: flex-start;
}
.project-weight-link {
  display: grid;
  justify-items: center;
  width: min(100%, 165px);
  margin: clamp(12px, 2.5vh, 26px) auto clamp(9px, 2vh, 20px);
  padding: 8px 9px 7px;
  border: 1px solid color-mix(in srgb, var(--ink) 55%, transparent);
  border-radius: 7px;
  color: inherit;
  text-decoration: none;
}
.project-weight-logo {
  display: block;
  width: min(82%, 119px);
  height: auto;
  margin-bottom: 4px;
  filter: invert(1);
}
.project-weight-label {
  font-size: 5px;
  font-weight: 300;
  line-height: 1;
  letter-spacing: .25em;
  text-transform: uppercase;
}
.project-weight-size {
  margin-top: 3px;
  font-size: 9px;
  font-weight: 300;
  line-height: 1;
  letter-spacing: .09em;
}
.legal-link { display: inline-block; width: max-content; margin-top: 0; justify-self: end; text-align: right; color: var(--ink); font-size: 12px; letter-spacing: .08em; text-decoration: none; border-bottom: 1px solid var(--border); }
.life-readout { margin: 0 0 20px; }

.legal-page { overflow:auto; background:var(--background); color:var(--ink); }
.legal-shell { width:min(760px,100%); min-height:100dvh; margin:auto; padding:clamp(28px,6vw,72px); display:block; }
.legal-shell header { display:flex; justify-content:space-between; align-items:baseline; gap:24px; }
.legal-shell header a { color:inherit; text-decoration:none; font-size:14px; letter-spacing:.12em; }
.legal-tabs { display:flex; gap:22px; margin:clamp(42px,8vh,80px) 0 36px; border-bottom:1px solid var(--border); overflow:auto; }
.legal-tabs button { width:auto; min-width:max-content; height:40px; padding:0; border:0; opacity:.45; font-size:11px; letter-spacing:.06em; }
.legal-tabs button[aria-selected="true"] { opacity:1; border-bottom:1px solid var(--ink); }
.legal-shell article { max-width:620px; }
.legal-shell article h2 { margin:0 0 28px; color:var(--ink); font-size:18px; text-transform:none; letter-spacing:.02em; }
.legal-shell article p { margin:0 0 22px; font-size:14px; line-height:1.8; letter-spacing:.025em; }
.legal-date { margin-top:56px; color:var(--muted); font-size:10px; }

.about-copy p {
  margin: 0;
  font-size: 15px;
  font-weight: 300;
  line-height: 1.8;
  letter-spacing: .035em;
}

.about-copy strong,
.about-copy .about-emphasis {
  font-weight: 300;
}

.reset-settings {
  width: 100%;
  border-color: color-mix(in srgb, var(--ink) 45%, transparent);
  color: var(--muted);
  font-size: 10px;
}

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

.viewport {
  --grid-left: 8%;
  --grid-top: 3%;
  --grid-height: 94%;
  position: relative;
  width: min(calc(100vw - 28px), calc((100dvh - 28px) * 3 / 4));
  aspect-ratio: 3 / 4;
  background: transparent;
  display: grid;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
}

.stage-card {
  position: absolute;
  z-index: 5;
  left: var(--card-x, 50%);
  top: var(--card-y, 50%);
  width: min(310px, calc(100vw - 32px));
  padding: 24px 26px 26px;
  color: var(--ink);
  background: var(--background);
  border: 0;
  border-radius: 32px;
  box-shadow: 0 0 34px 24px var(--background);
  opacity: 0;
  pointer-events: none;
  transform: translate(14px, calc(-50% + 86px)) scale(.97);
  transform-origin: left center;
  transition: opacity var(--formation-duration) var(--formation-curve), transform var(--formation-duration) var(--formation-curve);
}

.stage-card[data-side="left"] {
  transform: translate(calc(-100% - 14px), calc(-50% + 86px)) scale(.97);
  transform-origin: right center;
}

.stage-card.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(14px, -50%) scale(1);
}

.stage-card.is-visible[data-side="left"] {
  transform: translate(calc(-100% - 14px), -50%) scale(1);
}

.stage-card h3 {
  margin: 0 28px 9px 0;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.35;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.stage-card .stage-card-detail {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
  letter-spacing: .08em;
}

.stage-card .stage-card-description {
  margin: 0;
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: .055em;
}

.stage-card-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  font-size: 0;
  line-height: 1;
}

.stage-card-close::before,
.stage-card-close::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  background: var(--ink);
  transform: translate(-50%, -50%);
  transition: opacity .2s ease, transform .2s ease;
}

.stage-card-close::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.stage-card-close::after {
  width: 11px;
  height: 1px;
  opacity: 0;
  box-shadow: 0 0 0 .01px var(--ink);
}

.stage-card-close:hover::before,
.stage-card-close:focus-visible::before {
  width: 11px;
  height: 1px;
  border-radius: 0;
  transform: translate(-50%, -50%) rotate(45deg);
}

.stage-card-close:hover::after,
.stage-card-close:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(-45deg);
}

.ruler-hover-zone {
  position: absolute;
  z-index: 3;
  top: var(--grid-top);
  bottom: calc(100% - var(--grid-top) - var(--grid-height));
  left: 0;
  width: max(48px, var(--grid-left));
}

.life-ruler {
  position: absolute;
  z-index: 2;
  top: var(--grid-top);
  left: max(18px, calc(var(--grid-left) - 12px));
  width: 1px;
  height: var(--grid-height);
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 24%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-6px);
  transition: opacity 1.2s ease, transform 1.2s cubic-bezier(.22, 1, .36, 1);
}

.ruler-hover-zone:hover + .life-ruler {
  opacity: 1;
  transform: translateX(0);
}

.life-ruler-tick {
  position: absolute;
  left: 0;
  width: 7px;
  height: 1px;
  background: color-mix(in srgb, var(--ink) 48%, transparent);
  transform: translateY(-50%);
}

.life-ruler-label {
  position: absolute;
  top: 50%;
  right: 12px;
  color: color-mix(in srgb, var(--ink) 62%, transparent);
  font-size: clamp(8px, 1.1vw, 11px);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transform: translateY(-50%);
  white-space: nowrap;
}

body.intro-active .ruler-hover-zone,
body.intro-active .life-ruler,
body.intro-active .stage-card {
  display: none;
}

@media (max-width: 700px), (hover: none) {
  :root { --panel-width: 100vw; }

  .history-dot .dot-identity,
  .settings-dot .dot-identity {
    top: 50px;
  }

  .data-dot .dot-identity,
  .about-dot .dot-identity {
    bottom: 50px;
  }

  .history-dot .dot-identity {
    left: 17px;
    transform: rotate(90deg);
    transform-origin: left top;
  }

  .settings-dot .dot-identity {
    right: 17px;
    transform: rotate(-90deg);
    transform-origin: right top;
  }

  .data-dot .dot-identity {
    left: 17px;
    transform: rotate(-90deg);
    transform-origin: left bottom;
  }

  .about-dot .dot-identity {
    right: 17px;
    transform: rotate(90deg);
    transform-origin: right bottom;
  }

  body.history-open .panel-dot:not(.history-dot),
  body.settings-open .panel-dot:not(.settings-dot),
  body.data-open .panel-dot:not(.data-dot),
  body.about-open .panel-dot:not(.about-dot) {
    opacity: 0;
    pointer-events: none;
  }

  .side-panel {
    padding-top: max(22px, env(safe-area-inset-top));
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }

  .stage-card,
  .stage-card[data-side="left"],
  .stage-card.is-visible,
  .stage-card.is-visible[data-side="left"] {
    position: fixed;
    left: 16px;
    right: 16px;
    top: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
    width: auto;
    transform: translateY(86px) scale(.97);
    transform-origin: center bottom;
  }

  .stage-card.is-visible,
  .stage-card.is-visible[data-side="left"] {
    transform: translateY(0) scale(1);
  }

  .stage-card[data-zone="top"],
  .stage-card[data-zone="top"][data-side="left"] {
    top: max(16px, env(safe-area-inset-top));
    bottom: auto;
    transform: translateY(86px) scale(.97);
  }

  .stage-card.is-visible[data-zone="top"],
  .stage-card.is-visible[data-zone="top"][data-side="left"] {
    transform: translateY(0) scale(1);
  }

  .stage-card h3 { font-size: 13px; }
  .stage-card .stage-card-detail { font-size: 10px; }
  .stage-card .stage-card-description { font-size: 12px; }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #fff;
  --soft-ink: #3a3a3c;
  --background: #000;
  --line: #f5f5f7;
  --panel: #000;
  --control: transparent;
  --border: #fff;
  --muted: #a1a1a6;
  --accent: #63c7a8;
}

:root[data-theme="dark"] .project-weight-logo {
  filter: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #fff;
    --soft-ink: #3a3a3c;
    --background: #000;
    --line: #f5f5f7;
    --panel: #000;
    --control: transparent;
    --border: #fff;
    --muted: #a1a1a6;
    --accent: #63c7a8;
  }

  :root:not([data-theme="light"]) .project-weight-logo {
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  aside,
  .panel-dot,
  .life-ruler { transition: none; }
}
