/* ===================================================================
   VUOSIRENGASLASKURI · "Almanakka" design system
   =================================================================== */

:root {
  /* --- LIGHT · birch paper / field journal --- */
  --paper: #f1e9d8;
  --paper-2: #e8ddc6;
  --card: #fbf6eb;
  --card-2: #f4ecdb;
  --ink: #232a1e;
  --ink-2: #4d5440;
  --muted: #797f66;
  --faint: #9a9c82;
  --line: #dfd3b9;
  --line-soft: #ebe1cc;

  --forest: #2e5a39;
  --forest-2: #3d7049;
  --forest-ink: #1c3c25;
  --amber: #b9772a; /* warm / dry summers, wood */
  --amber-2: #d69a4c;
  --blue: #45788f; /* cool / wet summers */
  --blue-2: #6ca0b6;
  --rust: #ad4f2c; /* historical events */

  --on-forest: #fbf6eb;

  --shadow: 0 1px 2px rgba(40, 32, 16, 0.06), 0 8px 28px -14px rgba(40, 32, 16, 0.28);
  --shadow-sm: 0 1px 2px rgba(40, 32, 16, 0.08);
  --ring-focus: 0 0 0 3px var(--paper), 0 0 0 5.5px var(--forest-2);

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;

  --font-display: "Spectral", Georgia, serif;
  --font-ui: "Hanken Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --maxw: 660px;
}

[data-theme="dark"] {
  /* --- DARK · forest night --- */
  --paper: #131c16;
  --paper-2: #0e1611;
  --card: #1a2620;
  --card-2: #16201a;
  --ink: #e9efe2;
  --ink-2: #b4bfaa;
  --muted: #8a977f;
  --faint: #69745e;
  --line: #2b3a30;
  --line-soft: #243029;

  --forest: #7fc894;
  --forest-2: #94d6a6;
  --forest-ink: #0e1611;
  --amber: #d9a95c;
  --amber-2: #e7c083;
  --blue: #79b0cb;
  --blue-2: #97c4d9;
  --rust: #e08962;

  --on-forest: #0e1611;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 34px -16px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --ring-focus: 0 0 0 3px var(--paper), 0 0 0 5.5px var(--forest);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(
      1200px 600px at 50% -10%,
      color-mix(in oklab, var(--paper) 88%, var(--card)) 0%,
      transparent 70%
    ),
    var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

/* faint paper grain via layered gradients */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0 3px,
    color-mix(in oklab, var(--ink) 4%, transparent) 3px 4px
  );
  mix-blend-mode: multiply;
  z-index: 0;
}
[data-theme="dark"] body::before {
  mix-blend-mode: screen;
  opacity: 0.28;
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(18px, 5vw, 40px) clamp(16px, 5vw, 32px) 64px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--forest);
  color: var(--on-forest);
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 50;
  text-decoration: none;
  font-weight: 600;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 12px;
}

/* ---------------- MASTHEAD ---------------- */
.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.ringmark {
  width: clamp(46px, 13vw, 60px);
  height: auto;
  flex: none;
  color: var(--forest);
}
.eyebrow {
  margin: 0 0 2px;
  font-family: var(--font-mono);
  font-size: clamp(0.62rem, 2.6vw, 0.72rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 500;
}
[data-theme="dark"] .eyebrow {
  color: var(--amber-2);
}
h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.85rem, 7.8vw, 2.9rem);
  line-height: 1.02;
  letter-spacing: -0.012em;
  color: var(--ink);
  hyphens: auto;
}

.theme-toggle {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}
.theme-toggle:hover {
  color: var(--forest);
  border-color: var(--forest-2);
}
.theme-toggle:active {
  transform: scale(0.94);
}
.theme-toggle .ico {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
}
.ico-moon {
  display: none;
}
[data-theme="dark"] .ico-sun {
  display: none;
}
[data-theme="dark"] .ico-moon {
  display: block;
}

.lede {
  margin: clamp(18px, 4.5vw, 26px) 0 clamp(20px, 5vw, 30px);
  font-size: clamp(1.02rem, 4vw, 1.14rem);
  line-height: 1.58;
  color: var(--ink-2);
  max-width: 56ch;
  text-wrap: pretty;
}
.lede__em {
  color: var(--ink);
  font-weight: 500;
}

/* ---------------- CARDS ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(18px, 5vw, 28px);
  margin-bottom: clamp(16px, 4vw, 22px);
  box-shadow: var(--shadow);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-label .rule {
  width: 22px;
  height: 1.5px;
  background: var(--amber);
  border-radius: 2px;
  flex: none;
}

/* ---------------- PHOTO ---------------- */
.photo {
  position: relative;
  margin: 0;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--card-2);
  border: 1px solid var(--line);
}
.photo__zoom {
  position: absolute;
  inset: 0;
  transform: scale(1);
  transform-origin: 50% 50%;
}
/* f12: once a result exists, the image is clickable to explore a ring. */
.photo--has-result #stump {
  cursor: pointer;
}
.photo--focus .photo__zoom {
  transition: transform 0.42s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.photo #stump,
.photo #ringOverlay {
  display: block;
  width: 100%;
  height: 100%;
}
.photo #ringOverlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
/* The Y/R markers live outside the zoomed wrapper, so hide them in focus mode. */
.photo--focus .overlay {
  display: none;
}

.radius-line {
  position: absolute;
  top: 49%;
  left: 42%;
  width: 45%;
  height: 0;
  border-top: 2px dashed rgba(255, 255, 255, 0.85);
  transform: translateY(-50%);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}
.marker {
  position: absolute;
  top: 49%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
}
.marker b {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.45),
    0 0 0 3px rgba(0, 0, 0, 0.18);
}
.marker--y {
  left: 42%;
}
.marker--y b {
  background: var(--amber-2);
  color: #2a1c08;
}
.marker--r {
  left: 87%;
}
.marker--r b {
  background: #bfe8d4;
  color: var(--forest-ink);
}
.marker__tip {
  position: absolute;
  bottom: -19px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}
.photo-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: color-mix(in oklab, var(--ink) 78%, transparent);
  color: var(--paper);
  padding: 4px 9px;
  border-radius: 6px;
  backdrop-filter: blur(3px);
}

.photo-caption {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 14px 2px 0;
  font-size: 0.92rem;
  color: var(--muted);
  text-wrap: pretty;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: none;
  margin-top: 6px;
  background: var(--faint);
}
.dot.ok {
  background: var(--forest);
}

/* ---------------- EMPTY PLACEHOLDER / CLEAR ---------------- */
/* Shown inside .photo when no image is loaded. */
.photo-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
}
.photo-empty[hidden] {
  display: none;
}
/* faint ring mark — signals "no image yet" in the app's brand motif */
.photo-empty__rings {
  position: absolute;
  width: min(74%, 230px);
  height: auto;
  color: var(--line);
  opacity: 0.85;
  pointer-events: none;
}
[data-theme="dark"] .photo-empty__rings {
  color: var(--line);
  opacity: 0.7;
}
.photo-empty__add {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 18px 22px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--ink-2);
  border-radius: var(--r-md);
  transition:
    transform 0.15s ease,
    color 0.15s ease;
}
.photo-empty__add:hover {
  color: var(--forest);
}
.photo-empty__add:active {
  transform: scale(0.97);
}
.photo-empty__add:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus);
}
.photo-empty__ico {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--forest);
}
.photo-empty__ico svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
}
.photo-empty__t {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.08rem;
  color: var(--ink);
}
.photo-empty__s {
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 24ch;
}

/* Trashcan: clear the loaded image */
.photo-clear {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--ink) 16%, transparent);
  background: color-mix(in oklab, var(--ink) 62%, transparent);
  color: var(--paper);
  cursor: pointer;
  backdrop-filter: blur(3px);
  transition:
    transform 0.15s ease,
    background 0.15s ease;
}
.photo-clear[hidden] {
  display: none;
}
.photo-clear:hover {
  background: color-mix(in oklab, var(--rust) 82%, black 5%);
}
.photo-clear:active {
  transform: scale(0.92);
}
.photo-clear:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus);
}
.photo-clear svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Confirmation popover for clearing the image */
.photo-confirm {
  position: absolute;
  top: 56px;
  right: 10px;
  z-index: 5;
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  max-width: min(260px, calc(100% - 20px));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}
.photo-confirm[hidden] {
  display: none;
}
.photo-confirm__q {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
  font-size: 0.95rem;
}
.photo-confirm__row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.btn--danger {
  background: var(--rust);
  color: #fff;
  border: 1px solid color-mix(in oklab, var(--rust) 70%, black);
}
.btn--danger:hover {
  background: color-mix(in oklab, var(--rust) 88%, black 8%);
}

/* ---------------- FOCUS-MODE OVERLAY (selected ring) ---------------- */
.focus-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: #fff;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.82),
    rgba(0, 0, 0, 0.62) 60%,
    rgba(0, 0, 0, 0)
  );
}
.focus-overlay[hidden] {
  display: none;
}
.focus-overlay__text {
  flex: 1 1 auto;
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  text-wrap: pretty;
}
.focus-overlay__yr {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--amber-2);
  margin-right: 8px;
}
.focus-overlay__tone {
  display: inline-block;
  margin-right: 8px;
  font-weight: 600;
}
.focus-overlay__note {
  display: block;
  color: rgba(255, 255, 255, 0.9);
}
.focus-overlay__ctrls {
  flex: none;
  display: flex;
  gap: 6px;
}
.focus-btn {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  cursor: pointer;
}
.focus-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.focus-btn:hover {
  background: rgba(255, 255, 255, 0.26);
}
.focus-btn:focus-visible {
  outline: 2px solid var(--amber-2);
  outline-offset: 2px;
}
.focus-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
@media (max-width: 420px) {
  .focus-btn {
    width: 34px;
    height: 34px;
  }
  .focus-overlay__text {
    font-size: 0.8rem;
  }
}

/* ---------------- STEPS ---------------- */
.steps {
  list-style: none;
  margin: clamp(18px, 4vw, 24px) 0 0;
  padding: 0;
  border-top: 1px solid var(--line-soft);
}
.step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
}
.step:last-child {
  border-bottom: 0;
  padding-bottom: 2px;
}
.step__num {
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--card-2);
}
.step.is-done .step__num {
  border-color: var(--forest);
  color: var(--on-forest);
  background: var(--forest);
}
.step--action .step__num {
  border-color: var(--amber);
  color: var(--amber);
  background: transparent;
}
.step__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.step__body--row {
  flex-direction: row;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.step__hint {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------------- BUTTONS ---------------- */
.btn {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 20px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1.1;
  min-height: 48px;
  transition:
    transform 0.12s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active {
  transform: translateY(1px) scale(0.995);
}
.btn-ico {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.btn--ghost {
  background: var(--card-2);
  color: var(--ink);
  border-color: var(--line);
  align-self: flex-start;
}
.btn--ghost:hover {
  border-color: var(--forest-2);
  color: var(--forest);
  background: color-mix(in oklab, var(--forest) 7%, var(--card-2));
}

.btn--primary {
  background: var(--forest);
  color: var(--on-forest);
  border-color: var(--forest);
  box-shadow:
    0 1px 2px rgba(20, 40, 24, 0.25),
    0 8px 20px -10px color-mix(in oklab, var(--forest) 70%, transparent);
  flex: 1 1 auto;
}
.btn--primary:hover {
  background: var(--forest-2);
}

.btn--quiet {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 10px 12px;
  min-height: 40px;
}
.btn--quiet:hover {
  color: var(--ink);
}

.btn--auto {
  background: transparent;
  color: var(--forest);
  border-color: var(--forest);
  padding: 9px 14px;
  min-height: 40px;
  font-size: 0.9rem;
}
.btn--auto:hover {
  background: color-mix(in oklab, var(--forest) 12%, transparent);
}

/* ---------------- FIELD ---------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
}
.input {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--ink);
  width: 9.5ch; /* fit a 4-digit year plus the number-input spinner */
  padding: 11px 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  min-height: 48px;
}
.input:focus-visible,
.field:focus-within .input {
  outline: none;
  border-color: var(--forest-2);
}

/* ---------------- RESULTS animation ---------------- */
.results {
  display: block;
}
.results.is-hidden {
  display: none;
}

/* ---------------- READOUT ---------------- */
.readout {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: nowrap;
}
.readout__num {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(3.4rem, 18vw, 5rem);
  line-height: 0.86;
  letter-spacing: -0.02em;
  color: var(--forest);
  font-variant-numeric: tabular-nums;
  flex: none;
}
[data-theme="dark"] .readout__num {
  color: var(--forest-2);
}
.readout__meta {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.readout__unit {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.readout__germ {
  font-size: 1rem;
  color: var(--ink-2);
  white-space: nowrap;
}
.readout__germ b {
  color: var(--ink);
  font-weight: 600;
  font-family: var(--font-display);
}

/* ---------------- SENSITIVITY ---------------- */
.sensitivity {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}
.sensitivity__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sensitivity__top label {
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
}
#sensVal {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--forest);
  background: var(--card-2);
  padding: 3px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.sensitivity__hint {
  margin: 12px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
  text-wrap: pretty;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
}
.slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--amber) 0%, var(--line) 0%);
}
.slider::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -10px;
  border-radius: 999px;
  background: var(--card);
  border: 2px solid var(--forest);
  box-shadow:
    var(--shadow-sm),
    inset 0 0 0 3px var(--forest);
}
.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--card);
  border: 2px solid var(--forest);
  box-shadow: inset 0 0 0 3px var(--forest);
}

/* ---------------- INSTRUMENT data ---------------- */
.instrument {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin: 22px 0 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--faint);
}
.instrument span {
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

/* ---------------- INTERPRETATION ---------------- */
.interp__body {
  margin: 0;
  font-size: 1.04rem;
  line-height: 1.62;
  color: var(--ink-2);
  text-wrap: pretty;
}
.interp__body b {
  color: var(--ink);
  font-weight: 600;
}
.key {
  color: var(--forest);
  font-weight: 600;
  box-shadow: inset 0 -0.5em 0 color-mix(in oklab, var(--forest) 14%, transparent);
}
[data-theme="dark"] .key {
  color: var(--forest-2);
  box-shadow: inset 0 -0.5em 0 color-mix(in oklab, var(--forest) 22%, transparent);
}

.disclosure {
  margin-top: 18px;
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}
.disclosure summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--forest);
  font-family: var(--font-ui);
}
.disclosure summary::-webkit-details-marker {
  display: none;
}
.disclosure summary::before {
  content: "▸";
  color: var(--amber);
  font-size: 0.8rem;
  transition: transform 0.18s ease;
}
.disclosure[open] summary::before {
  transform: rotate(90deg);
}
.disclosure__inner {
  padding: 10px 2px 2px 20px;
}
.disclosure__inner p {
  margin: 0 0 10px;
  font-size: 0.94rem;
  line-height: 1.58;
  color: var(--muted);
}
.disclosure__note {
  background: var(--card-2);
  border-left: 2px solid var(--amber);
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
}
.disclosure__note b {
  color: var(--ink-2);
}

/* ---------------- TIMELINE ---------------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 20px;
}
.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--muted);
}
.swatch {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  flex: none;
}
.swatch--neutral {
  background: var(--forest);
}
.swatch--warm {
  background: var(--amber);
}
.swatch--cool {
  background: var(--blue);
}
.swatch--event {
  background: var(--rust);
  border-radius: 999px;
  width: 11px;
  height: 11px;
}

.years {
  list-style: none;
  margin: 0;
  padding: 0;
}
.year {
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  grid-template-areas: "yr bar";
  align-items: center;
  gap: 4px 12px;
  padding: 7px 8px;
  border-top: 1px solid var(--line-soft);
  width: 100%;
  text-align: left;
  background: none;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
}
.year:hover {
  background: var(--card-2);
}
.year:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: -2px;
}
.year--selected {
  background: color-mix(in oklab, var(--amber) 18%, transparent);
}
.years li:first-child .year {
  border-top: 0;
}
.year--event {
  padding: 9px 8px;
}
.year__yr {
  grid-area: yr;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-2);
}
.year--event .year__yr {
  color: var(--rust);
  font-weight: 600;
}
.year__bar {
  grid-area: bar;
  display: flex;
  align-items: center;
}
.year__track {
  height: 13px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    currentColor,
    color-mix(in oklab, currentColor 72%, transparent)
  );
  min-width: 4px;
  transform-origin: left center;
}
.results.is-revealing .year__track {
  animation: grow 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.year--warm .year__track {
  color: var(--amber);
}
.year--cool .year__track {
  color: var(--blue);
}
.year--neutral .year__track {
  color: var(--forest);
}
.year__event {
  grid-area: evt;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--ink-2);
  line-height: 1.4;
  text-wrap: pretty;
}
.year__event::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--rust);
  flex: none;
  margin-top: 6px;
}
.year--event {
  grid-template-areas: "yr bar" "yr evt";
}
.year--event .year__yr {
  align-self: start;
  padding-top: 1px;
}
.year--selected .year__yr {
  color: var(--amber);
  font-weight: 700;
}

.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.85rem;
  color: var(--muted);
  text-wrap: pretty;
}
.warn {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 1px;
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* ---------------- COLOPHON ---------------- */
.colophon {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 4px 4px;
  color: var(--faint);
  font-size: 0.82rem;
}
.colophon__mark svg {
  width: 30px;
  height: 30px;
  color: var(--line);
}
.colophon p {
  margin: 0;
}
.colophon a {
  color: var(--forest-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.colophon a:hover {
  color: var(--forest);
}
.nowrap {
  white-space: nowrap;
}

/* ===================================================================
   ADD-PHOTO SHEET
   =================================================================== */
.sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: color-mix(in oklab, var(--ink) 50%, transparent);
  backdrop-filter: blur(2px);
  animation: fade 0.2s ease;
}
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 61;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--maxw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  padding: 14px clamp(18px, 5vw, 28px) calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px -16px rgba(0, 0, 0, 0.4);
  animation: sheet-up 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@media (min-width: 560px) {
  .sheet {
    bottom: 24px;
    border-radius: 22px;
    max-width: 440px;
    animation: sheet-pop 0.24s cubic-bezier(0.22, 0.61, 0.36, 1);
  }
}
.sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 2px auto 14px;
}
.sheet__title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
}
.sheet__sub {
  margin: 0 0 18px;
  font-size: 0.92rem;
  color: var(--muted);
}
.sheet__choices {
  display: grid;
  gap: 12px;
}
.choice {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  text-align: left;
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--card-2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.12s ease;
}
.choice:hover {
  border-color: var(--forest-2);
  background: color-mix(in oklab, var(--forest) 6%, var(--card-2));
}
.choice:active {
  transform: scale(0.99);
}
.choice svg {
  grid-row: 1 / 3;
  width: 30px;
  height: 30px;
  color: var(--forest);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.choice__t {
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--ink);
}
.choice__s {
  font-size: 0.85rem;
  color: var(--muted);
}
.sheet__cancel {
  width: 100%;
  margin-top: 12px;
}

/* ===================================================================
   MARK-POINTS EDITOR
   =================================================================== */
.editor {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  background: #0b110d;
  animation: fade 0.2s ease;
}
.editor__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
}
.editor__bar--top {
  background: #0b110d;
}
.editor__bar--bottom {
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  background: #0b110d;
}
.editor__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #e9efe2;
  font-family: var(--font-ui);
}
.editor__title span {
  color: var(--amber-2);
}
.editor .btn--quiet {
  color: #b4bfaa;
}
.editor .btn--quiet:hover {
  color: #fff;
}
.editor .btn--auto {
  color: #bfe8d4;
  border-color: #2f6a47;
}
.editor .btn--auto:hover {
  background: rgba(127, 200, 148, 0.14);
}
.editor__stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #0b110d;
  display: grid;
  place-items: center;
}
.editor__stage canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  touch-action: none;
}
.crosshair {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
}
.crosshair__v {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(255, 255, 255, 0.5);
}
.crosshair__h {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(255, 255, 255, 0.5);
}
.crosshair__ring {
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--amber-2);
  border-radius: 999px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 14px rgba(0, 0, 0, 0.4);
}
.editor__hint {
  margin: 0;
  text-align: center;
  font-size: 0.92rem;
  color: #c8d2bd;
}
.editor__hint b {
  color: var(--amber-2);
}
.editor__hint--keys {
  font-size: 0.8rem;
  opacity: 0.7;
}
.editor__dots {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.edot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
}
.edot.is-active {
  background: var(--amber-2);
}
.editor .btn--primary {
  width: 100%;
  max-width: 360px;
}

/* ===================================================================
   FOCUS / MOTION / ANIMATIONS
   =================================================================== */
:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus);
  border-radius: 8px;
}
.slider:focus-visible::-webkit-slider-thumb {
  box-shadow:
    var(--ring-focus),
    inset 0 0 0 3px var(--forest);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes sheet-up {
  from {
    transform: translate(-50%, 100%);
  }
}
@keyframes sheet-pop {
  from {
    transform: translate(-50%, 14px);
    opacity: 0;
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
@keyframes grow {
  from {
    transform: scaleX(0);
  }
}

.results.is-revealing > * {
  animation: rise 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}
.results.is-revealing > *:nth-child(2) {
  animation-delay: 0.08s;
}
.results.is-revealing > *:nth-child(3) {
  animation-delay: 0.16s;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ===================================================================
   RESPONSIVE — desktop refinements
   =================================================================== */
@media (min-width: 620px) {
  .year {
    grid-template-columns: 3.6rem minmax(90px, 200px) 1fr;
    grid-template-areas: "yr bar evt";
    gap: 14px;
    align-items: center;
  }
  .year--event {
    grid-template-areas: "yr bar evt";
    padding: 8px 0;
  }
  .year__event {
    align-self: center;
  }
  .year--event .year__yr {
    align-self: center;
    padding-top: 0;
  }
}

@media (min-width: 880px) {
  /* f12: single centered column (no two-column split). The .shell stays
     centered via its own margin:0 auto; a slightly wider column makes the
     result image larger while keeping a comfortable reading width. */
  :root {
    --maxw: 720px;
  }
  .shell {
    padding-top: 48px;
  }
  .layout {
    display: block;
  }
  .capture {
    margin-bottom: 18px;
  }
  .results {
    display: flex;
    flex-direction: column;
  }
  /* Let the image grow to use the extra width, but cap its height to the
     viewport so it never overflows or pushes the controls below the fold.
     The 4/3 box derives its height from the column width; max-height caps it
     on short viewports, and max-width (height × 4/3) shrinks the box to keep
     the aspect ratio intact instead of clipping. margin:0 auto re-centers it.
     Mobile (< 880px) is untouched. */
  .photo {
    max-height: min(72vh, 560px);
    max-width: calc(min(72vh, 560px) * 4 / 3);
    margin: 0 auto;
  }
}
