:root {
  color-scheme: light;
  --sky: #dce8ef;
  --sky-deep: #c7d8e2;
  --ink: #171923;
  --muted: #5b6670;
  --cloth: #11131b;
  --paper: #f5f8f9;
  --pink: #ff6c66;
  --gold: #ffc061;
  --focus: #1d67ff;
  --radius: 20px;
  --shadow: 0 24px 70px rgb(34 49 58 / 14%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--sky);
}

body {
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 4%, rgb(255 255 255 / 85%) 0 1px, transparent 2px) 0 0 / 19px 19px,
    linear-gradient(135deg, #eef5f7 0%, var(--sky) 50%, #ccdee7 100%);
  font-family: "Avenir Next", Avenir, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button,
.file-action,
.drop-zone,
.swatch {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible,
.swatch:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(300px, 1.2fr) minmax(260px, 0.75fr);
  gap: clamp(24px, 4vw, 72px);
  align-items: end;
  width: min(1540px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 18px;
  border-bottom: 1px solid rgb(23 25 35 / 18%);
}

.date-line,
.eyebrow,
.signature-kicker {
  margin: 0 0 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.identity h1 {
  max-width: 510px;
  margin: 0;
  font-size: clamp(1.55rem, 2.45vw, 2.8rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.premise {
  max-width: 670px;
  margin: 0;
  color: #34404a;
  font-size: clamp(0.95rem, 1.25vw, 1.22rem);
  line-height: 1.55;
}

.local-note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  color: #45515b;
  font-size: 0.78rem;
  line-height: 1.5;
}

.local-light {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 999px;
  background: #2bb673;
  box-shadow: 0 0 0 5px rgb(43 182 115 / 14%);
}

.experience {
  display: grid;
  grid-template-columns: minmax(380px, 0.72fr) minmax(580px, 1.4fr);
  min-height: min(780px, calc(100svh - 145px));
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 24px;
  gap: 0;
}

.sources-panel,
.loom-panel {
  min-width: 0;
  border-radius: var(--radius);
}

.sources-panel {
  display: flex;
  flex-direction: column;
  padding: clamp(20px, 2.2vw, 34px);
  background: rgb(248 251 252 / 76%);
  border: 1px solid rgb(255 255 255 / 80%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  border-radius: var(--radius) 0 0 var(--radius);
}

.section-heading {
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: flex-start;
}

.section-heading h2,
.loom-head h2 {
  margin: 0;
  font-size: clamp(1.06rem, 1.4vw, 1.35rem);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.file-action {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 48px;
  padding: 0 16px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(23 25 35 / 22%);
  border-radius: 999px;
  background: white;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.file-action:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

.file-action input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone {
  display: none;
  min-height: 62px;
  margin: 18px 0 0;
  padding: 14px 16px;
  align-items: center;
  gap: 12px;
  border: 1px dashed rgb(23 25 35 / 28%);
  border-radius: 14px;
  color: var(--muted);
  background: rgb(255 255 255 / 46%);
  font-size: 0.78rem;
  line-height: 1.35;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .drop-zone {
    display: flex;
  }
}

.drop-zone.is-over {
  color: var(--ink);
  border-color: var(--focus);
  background: rgb(29 103 255 / 7%);
}

.drop-mark {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  font-size: 1.25rem;
}

.source-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.source-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: 16px;
  background: white;
  box-shadow: 0 8px 24px rgb(46 60 70 / 9%);
}

.source-image-wrap {
  position: relative;
  height: clamp(112px, 14vw, 170px);
  overflow: hidden;
  background: #8ba0ad;
}

.source-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 600ms cubic-bezier(.2, .8, .2, 1), filter 600ms ease;
}

.source-card:has(.swatch.is-connected) .source-image {
  transform: scale(1.035);
  filter: saturate(1.08);
}

.source-name {
  position: absolute;
  inset: auto 10px 9px;
  margin: 0;
  color: white;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 12px rgb(0 0 0 / 80%);
  text-transform: uppercase;
}

.palette {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px;
}

.swatch {
  position: relative;
  display: block;
  min-width: 0;
  height: 48px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 20%);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.swatch:hover {
  transform: translateY(-2px);
}

.swatch.is-selected {
  box-shadow: inset 0 0 0 3px white, 0 0 0 3px var(--ink);
  transform: translateY(-3px);
}

.swatch.is-connected::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 9px;
  height: 9px;
  border: 2px solid white;
  border-radius: 999px;
  background: var(--ink);
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 5px rgb(0 0 0 / 50%);
}

.connection-instruction {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: auto;
  padding-top: 22px;
  color: #44515b;
  font-size: 0.8rem;
  line-height: 1.45;
}

.connection-instruction p {
  margin: 0;
}

.instruction-number {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  font-size: 0.62rem;
}

.loom-panel {
  display: grid;
  grid-template-rows: auto minmax(500px, 1fr) auto auto;
  overflow: hidden;
  color: white;
  background: var(--cloth);
  box-shadow: 0 28px 80px rgb(23 25 35 / 26%);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.loom-head,
.loom-foot {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  background: rgb(17 19 27 / 84%);
  backdrop-filter: blur(14px);
}

.loom-head {
  border-bottom: 1px solid rgb(255 255 255 / 10%);
}

.loom-foot {
  min-height: 64px;
  border-top: 1px solid rgb(255 255 255 / 10%);
  color: rgb(255 255 255 / 72%);
  font-size: 0.78rem;
}

.loom-foot p {
  margin: 0;
}

.eyebrow.light {
  color: rgb(255 255 255 / 52%);
}

.crossing-count {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgb(255 255 255 / 68%);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.count-dots {
  display: flex;
  gap: 5px;
}

.count-dots i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgb(255 255 255 / 18%);
  transition: width 400ms ease, background 400ms ease;
}

.count-dots i.is-filled {
  width: 20px;
  background: var(--gold);
}

.loom-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
}

#loom {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.loom-anchors {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
}

.loom-anchor {
  position: absolute;
  display: grid;
  width: 72px;
  gap: 5px;
  margin: 0;
  filter: drop-shadow(0 8px 18px rgb(0 0 0 / 42%));
  transition: transform 500ms ease, filter 500ms ease;
}

.loom-anchor:nth-child(1) { inset: 18px auto auto 18px; }
.loom-anchor:nth-child(2) { inset: 18px 18px auto auto; }
.loom-anchor:nth-child(3) { inset: auto auto 18px 18px; }
.loom-anchor:nth-child(4) { inset: auto 18px 18px auto; }

.loom-anchor img {
  display: block;
  width: 58px;
  height: 58px;
  object-fit: cover;
  opacity: 0;
  border: 2px solid transparent;
  border-radius: 14px;
}

.loom-anchor:nth-child(even) img {
  justify-self: end;
}

.loom-anchor figcaption {
  overflow: hidden;
  color: rgb(255 255 255 / 76%);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  font-size: 0.48rem;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-shadow: 0 1px 5px rgb(0 0 0 / 80%);
  text-transform: uppercase;
  white-space: nowrap;
}

.loom-anchor:nth-child(even) figcaption {
  text-align: right;
}

.anchor-colors {
  display: flex;
  gap: 3px;
}

.loom-anchor:nth-child(even) .anchor-colors {
  justify-content: flex-end;
}

.anchor-colors i {
  width: 9px;
  height: 9px;
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: 999px;
  background: var(--color);
  box-shadow: 0 1px 5px rgb(0 0 0 / 55%);
}

.loom-anchor.is-connected {
  filter: drop-shadow(0 8px 22px var(--anchor-color));
  transform: scale(1.05);
}

.selection-trace {
  position: absolute;
  z-index: 2;
  width: 18px;
  height: 18px;
  border: 1px solid white;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.5);
}

.selection-trace.is-visible {
  animation: trace-ring 800ms ease-out both;
}

@keyframes trace-ring {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(5); }
}

.signature {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 20px 24px;
  border-top: 1px solid rgb(255 255 255 / 14%);
  background:
    linear-gradient(90deg, rgb(255 108 102 / 14%), transparent 36%),
    rgb(15 17 25);
}

.signature[hidden] {
  display: none;
}

.signature.is-entering {
  animation: signature-in 650ms 250ms cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes signature-in {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

.signature h3 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 2rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.signature-copy > p:not(.signature-kicker) {
  margin: 8px 0 0;
  color: rgb(255 255 255 / 74%);
  font-size: 0.76rem;
  line-height: 1.45;
}

.signature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-action,
.secondary-action,
.quiet-reset {
  min-height: 48px;
  padding: 0 17px;
  border-radius: 999px;
  cursor: pointer;
}

.primary-action {
  border: 0;
  color: var(--ink);
  background: white;
  font-weight: 700;
}

.secondary-action {
  border: 1px solid rgb(255 255 255 / 26%);
  color: white;
  background: transparent;
}

.quiet-reset {
  border: 0;
  color: rgb(255 255 255 / 66%);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  width: min(1540px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 36px;
  color: #52606a;
  font-size: 0.76rem;
}

footer p {
  margin: 0;
}

footer a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: inherit;
  font-weight: 700;
}

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

@media (max-width: 1050px) {
  .masthead {
    grid-template-columns: 1fr 1.2fr;
  }

  .local-note {
    grid-column: 1 / -1;
  }

  .experience {
    grid-template-columns: minmax(330px, 0.75fr) minmax(480px, 1.25fr);
  }
}

@media (max-width: 820px) {
  .masthead {
    display: flex;
    width: calc(100% - 32px);
    padding: 14px 0 10px;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }

  .identity h1 {
    font-size: clamp(1.55rem, 7vw, 2.2rem);
  }

  .premise {
    font-size: 0.84rem;
    line-height: 1.35;
  }

  .local-note {
    font-size: 0.7rem;
  }

  .experience {
    display: flex;
    width: 100%;
    min-height: 0;
    padding: 12px 16px 16px;
    flex-direction: column;
    gap: 12px;
  }

  .sources-panel {
    padding: 14px;
    border-radius: 16px;
  }

  .section-heading {
    align-items: center;
  }

  .section-heading h2 {
    max-width: 230px;
    font-size: 0.96rem;
  }

  .file-action {
    padding-inline: 13px;
    font-size: 0.7rem;
  }

  .source-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    margin: 12px 0 0;
    padding: 0;
    gap: 8px;
    overflow: visible;
  }

  .source-card {
    flex: none;
  }

  .source-image-wrap {
    height: 78px;
  }

  .swatch {
    height: 44px;
    border-radius: 8px;
  }

  .connection-instruction {
    margin-top: 8px;
    padding-top: 8px;
  }

  .loom-panel {
    grid-template-rows: auto minmax(380px, 52svh) auto auto;
    min-height: 0;
    border-radius: 16px;
  }

  .loom-head,
  .loom-foot {
    padding: 16px;
  }

  .loom-head h2 {
    max-width: 220px;
    font-size: 0.96rem;
  }

  .crossing-count {
    flex-direction: column;
    gap: 5px;
    align-items: flex-end;
    font-size: 0.58rem;
  }

  .signature {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 18px 16px;
  }

  .signature h3 {
    max-width: 330px;
    font-size: clamp(1.4rem, 7vw, 2rem);
  }

  .signature-actions {
    justify-content: flex-start;
  }

  footer {
    width: calc(100% - 32px);
    padding: 12px 0 28px;
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-width: 430px) {
  .date-line {
    font-size: 0.59rem;
  }

  .premise {
    line-height: 1.42;
  }

  .sources-panel {
    border-radius: 16px;
  }

  .section-heading {
    gap: 10px;
  }

  .file-action span {
    max-width: 64px;
    line-height: 1.1;
    text-align: center;
  }

  .loom-panel {
    grid-template-rows: auto 500px auto auto;
    border-radius: 16px;
  }

  .loom-anchor {
    width: 64px;
  }

  .loom-anchor img {
    width: 52px;
    height: 52px;
    border-radius: 12px;
  }

  .loom-foot {
    align-items: flex-start;
  }

  .loom-foot p {
    max-width: 230px;
  }
}

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