/* Atlas — widgets (static/js/explore/widgets/, docs/WIDGETS.md).

   A widget is a sheet of cream paper laid on the page, a torn strip of its
   colour across the top and a red label pinned over the title; inside it,
   the drawing is cut from flat colour — every shape throws a small hard
   shadow, the way paper laid on paper does — and the controls are the
   Atlas's own chips and buttons.

   Every colour is a token from static/explore/tokens.css. The widget's own
   colour is the theme family (--theme-h, set by the page or by the spec's
   hue), or the place's / the era's with .by-place / .by-era; each part of a
   drawing that has a colour of its own (a side on a map, a ring on a clock,
   a layer of a tower) declares its own --theme-h and gets the theme family
   worked out again right there (tokens.css, "⚠️ A custom property…"). So the
   dark theme is the same drawing, and the contrast test covers the text. */

.xw {
  --w-fill: var(--theme-fill); --w-ink: var(--theme-ink); --w-mark: var(--theme-mark);
  --w-soft: var(--theme-soft); --w-wash: var(--theme-wash); --w-on: var(--theme-on);
  --xw-cut: rgba(70, 45, 10, 0.26);      /* the shadow under a cut-out */
  position: relative; margin: 30px 0; padding: 26px 20px 16px;
  background: var(--x-paper-2) var(--x-grain); color: var(--text);
  border-radius: var(--x-radius); box-shadow: var(--x-shadow);
  min-width: 0; max-width: 100%;
}
.xw.by-place { --w-fill: var(--place-fill); --w-ink: var(--place-ink); --w-mark: var(--place-mark); --w-soft: var(--place-soft); --w-wash: var(--place-wash); --w-on: var(--place-on); }
.xw.by-era { --w-fill: var(--era-fill); --w-ink: var(--era-ink); --w-mark: var(--era-mark); --w-soft: var(--era-soft); --w-wash: var(--era-wash); --w-on: var(--era-on); }
/* on the dark theme land is lifted a little off the sea, or a map is one dark sheet */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .xw { --xw-cut: rgba(0, 0, 0, 0.55); --xw-land: color-mix(in srgb, var(--x-paper-3) 80%, var(--x-navy)); } }
:root[data-theme="dark"] .xw { --xw-cut: rgba(0, 0, 0, 0.55); --xw-land: color-mix(in srgb, var(--x-paper-3) 80%, var(--x-navy)); }

/* the torn strip of colour along the top of the sheet */
.xw::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 13px; border-radius: var(--x-radius) var(--x-radius) 0 0;
  background: var(--w-mark);
  -webkit-mask: var(--x-tear-b) left bottom / 240px 12px repeat-x, linear-gradient(#000 0 0) left top / 100% calc(100% - 11px) no-repeat;
  mask: var(--x-tear-b) left bottom / 240px 12px repeat-x, linear-gradient(#000 0 0) left top / 100% calc(100% - 11px) no-repeat;
}
.xw :focus-visible { outline: 2.5px solid var(--x-red); outline-offset: 2px; }

/* ── the caption: label, title, one line ── */
.xw-cap { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 14px; }
.xw-kicker {
  display: inline-block; padding: 4px 14px 5px; transform: rotate(-1.4deg); margin-left: -4px;
  background: var(--x-red); color: var(--x-on);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  -webkit-mask: var(--x-tear-l) left top / 8px 160px repeat-y, var(--x-tear-r) right top / 8px 160px repeat-y, linear-gradient(#000 0 0) center / calc(100% - 14px) 100% no-repeat;
  mask: var(--x-tear-l) left top / 8px 160px repeat-y, var(--x-tear-r) right top / 8px 160px repeat-y, linear-gradient(#000 0 0) center / calc(100% - 14px) 100% no-repeat;
}
.xw-badge {
  display: inline-flex; align-items: center; min-height: 22px; padding: 0 9px; border-radius: 999px;
  border: 1.5px solid var(--w-mark); color: var(--w-ink); font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em;
}
.xw-badge.is-draft { border-style: dashed; border-color: var(--x-ink-2); color: var(--x-ink-2); }
.xw-title {
  flex: 1 1 100%; display: block; margin-top: 4px;
  font-family: var(--serif); font-size: clamp(21px, 2.4vw, 26px); font-weight: 600; line-height: 1.15; color: var(--x-navy);
}
.xw-lede { flex: 1 1 100%; display: block; font-size: 15px; line-height: 1.5; color: var(--x-ink-2); }

.xw-body { container-type: inline-size; min-width: 0; }
.xw-body.is-waiting { min-height: 240px; border-radius: 4px; background: var(--w-wash); opacity: 0.6; }
.xw-fallback { margin: 0; padding: 14px; border-radius: 4px; background: var(--w-wash); font-size: 15px; line-height: 1.55; }

/* ── buttons, chips, sliders ── */
.xw-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; min-width: 42px; padding: 0 15px;
  border: 0; border-radius: 999px; background: transparent; color: var(--x-navy);
  box-shadow: inset 0 0 0 1.5px var(--x-line); font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.xw-btn:hover { box-shadow: inset 0 0 0 1.5px var(--x-navy); }
.xw-btn.is-primary { background: var(--x-navy); color: var(--x-paper-2); box-shadow: none; }
.xw-btn.is-primary:hover { background: var(--x-red); color: var(--x-on); }
.xw-btn:disabled { opacity: 0.38; cursor: default; box-shadow: inset 0 0 0 1.5px var(--x-line); }
.xw-btn.is-primary:disabled { background: var(--x-ink-2); }
.xw-btn[aria-pressed="true"] { background: var(--w-fill); color: var(--w-on); box-shadow: none; }
.xw-btn .icon { flex: none; }
.xw-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 10px 0 0; }

.xw-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.xw-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border: 1.5px solid var(--w-mark); border-radius: 999px; background: var(--w-wash); color: var(--w-ink);
  font: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer; white-space: nowrap;
}
.xw-chip.x-theme { border-color: var(--theme-mark); background: var(--theme-wash); color: var(--theme-ink); }
.xw-chip[aria-pressed="true"] { background: var(--w-fill); border-color: var(--w-fill); color: var(--w-on); }
.xw-chip.x-theme[aria-pressed="true"] { background: var(--theme-fill); border-color: var(--theme-fill); color: var(--theme-on); }
.xw-chip-nat { font-family: var(--serif); font-style: italic; font-weight: 500; }

.xw-range { width: 100%; min-width: 0; height: 30px; margin: 0; accent-color: var(--x-red); cursor: pointer; }
.xw-range-label { display: grid; gap: 2px; margin: 12px 0 0; font-size: 13px; font-weight: 650; color: var(--x-ink-2); }
.xw-range-value { font-weight: 500; font-size: 13px; color: var(--x-ink-2); }

.xw-segs { display: inline-flex; flex-wrap: wrap; gap: 2px; max-width: 100%; margin: 0 0 10px; padding: 3px; border-radius: 20px; background: var(--x-paper-3); }
.xw-seg {
  flex: 1 1 auto; min-height: 36px; padding: 0 14px; border: 0; border-radius: 17px; background: transparent; color: var(--x-navy);
  font: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer;
}
.xw-seg[aria-pressed="true"] { background: var(--x-navy); color: var(--x-paper-2); }

/* ── the drawing's sheet ── */
.xw-stage { position: relative; isolation: isolate; border-radius: 3px; touch-action: pan-y; }
.xw-stage::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--w-wash) var(--x-grain);
  -webkit-mask: var(--x-tear-t) left top / 240px 12px repeat-x, var(--x-tear-b) left bottom / 240px 12px repeat-x, linear-gradient(#000 0 0) left center / 100% calc(100% - 22px) no-repeat;
  mask: var(--x-tear-t) left top / 240px 12px repeat-x, var(--x-tear-b) left bottom / 240px 12px repeat-x, linear-gradient(#000 0 0) left center / 100% calc(100% - 22px) no-repeat;
}
.xw-svg { display: block; width: 100%; height: auto; overflow: visible; }
.xw-scene { padding: 10px 6px; }

/* scene shapes: the tone says which tier of the colour; the colour is the
   widget's, or the shape's own hue */
.sc { color: var(--w-soft); transition: opacity 0.35s ease, filter 0.35s ease; filter: drop-shadow(0 1.6px 0 var(--xw-cut)); }
.sc.is-flat, .sc-dots, .sc-wave, .sc-steam, .sc-line, .sc-text { filter: none; }
.sc :is(path, rect, circle, ellipse, polygon) { fill: currentColor; }
.sc.t-fill { color: var(--w-fill); }  .sc.has-h.t-fill { color: var(--theme-fill); }
.sc.t-soft { color: var(--w-soft); }  .sc.has-h.t-soft { color: var(--theme-soft); }
.sc.t-mark { color: var(--w-mark); }  .sc.has-h.t-mark { color: var(--theme-mark); }
.sc.t-wash { color: var(--w-wash); }  .sc.has-h.t-wash { color: var(--theme-wash); }
.sc.t-on { color: var(--w-on); }
.sc.t-paper { color: var(--x-paper-2); }
.sc.t-kraft { color: var(--x-paper-3); }
.sc.t-ink { color: var(--x-navy); }
.sc.t-red { color: var(--x-red); }
.sc.t-sea { color: var(--x-sea); }
.sc.t-line { color: var(--x-navy); filter: none; }
.sc.t-line :is(path, rect, circle, ellipse), .sc .sc-stroke {
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.sc line { stroke: currentColor; stroke-linecap: round; }
.sc text { fill: currentColor; font-family: var(--serif); font-style: italic; font-weight: 600; }
.sc .sc-core { fill: var(--w-fill); }
.sc.has-h .sc-core { fill: var(--theme-fill); }
.sc .sc-flame { fill: var(--x-red); }
.sc-flag { color: var(--theme-soft); }
.sc .sc-flag .sc-hole { fill: var(--w-wash); }
.sc.is-dim { opacity: 0.55; filter: none; }
.sc.is-focus { opacity: 1; filter: drop-shadow(0 2.5px 0 var(--xw-cut)) drop-shadow(0 0 1.5px var(--x-red)); }
.sc.is-off, .sc.is-off.is-focus, .sc.is-off.is-dim { opacity: 0; pointer-events: none; }

/* ── a step's or a point's words ── */
.xw-detail { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0 0; min-height: 84px; }
.xw-num {
  flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--x-red); color: var(--x-on); font-size: 14px; font-weight: 750;
}
.xw-detail-text { min-width: 0; display: grid; gap: 2px; }
.xw-detail-text p { margin: 2px 0 0; font-size: 15.5px; line-height: 1.55; }
.xw-detail-title { font-size: 16.5px; line-height: 1.3; color: var(--x-navy); }
.xw-nat { font-family: var(--serif); font-style: italic; font-size: 17px; font-weight: 600; color: var(--w-ink); }
.xw-tag { justify-self: start; font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--x-red); }
.xw-hint { margin: 0; font-size: 14.5px; color: var(--x-ink-2); font-style: italic; }
.xw-say { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 8px 0 0; padding: 8px 12px; border-radius: 4px; background: var(--w-wash); }
.xw-say-text { font-family: var(--serif); font-size: 17px; }
.xw-say-tr { font-size: 13.5px; color: var(--x-ink-2); }
.xw-say-play { min-height: 34px; min-width: 34px; padding: 0; }

/* the stepper: previous · 1 2 3 · next */
.xw-stepper { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; }
.xw-dots { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; min-width: 0; justify-content: center; }
.xw-dot {
  width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 1.5px solid var(--w-mark);
  background: var(--x-paper-2); color: var(--w-ink); font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.xw-dot.is-done { background: var(--w-wash); }
.xw-dot.is-on { background: var(--w-fill); border-color: var(--w-fill); color: var(--w-on); transform: scale(1.1); }
.xw-next { padding: 0 12px 0 16px; }
@container (max-width: 420px) {
  .xw-dots { gap: 3px; }
  .xw-dot { width: 26px; height: 26px; font-size: 11.5px; }
  .xw-next span { display: none; }
  .xw-next { padding: 0; }
}

/* ── hotspots ── */
.xw-hot-stage { overflow: visible; }
.xw-pins { position: absolute; inset: 0; pointer-events: none; }
.xw-pin {
  position: absolute; transform: translate(-50%, -50%); pointer-events: auto;
  width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid var(--x-paper-2);
  background: var(--x-navy); color: var(--x-paper-2); font: inherit; font-size: 12.5px; font-weight: 750; cursor: pointer;
  box-shadow: 0 2px 0 var(--xw-cut);
}
.xw-pin:hover, .xw-pin.is-on { background: var(--x-red); color: var(--x-on); transform: translate(-50%, -50%) scale(1.15); }
@media (prefers-reduced-motion: no-preference) {
  .xw-hot-stage:not(:has(.is-on)) .xw-pin { animation: xw-pulse 2.4s ease-in-out infinite; }
  .xw-pin:nth-child(2n) { animation-delay: 0.6s !important; }
}
@keyframes xw-pulse { 0%, 100% { box-shadow: 0 2px 0 var(--xw-cut), 0 0 0 0 transparent; } 50% { box-shadow: 0 2px 0 var(--xw-cut), 0 0 0 5px color-mix(in srgb, var(--x-red) 30%, transparent); } }
.xw-hot-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.xw-hot-item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 4px 10px 4px 5px; text-align: left;
  border: 1.5px solid var(--x-line); border-radius: 999px; background: transparent; color: var(--x-navy);
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.xw-hot-item .xw-num { width: 24px; height: 24px; font-size: 12px; background: var(--x-navy); color: var(--x-paper-2); }
.xw-hot-item[aria-pressed="true"] { border-color: var(--x-red); background: var(--w-wash); }
.xw-hot-item[aria-pressed="true"] .xw-num { background: var(--x-red); color: var(--x-on); }

/* ── layers ── */
.xw-layers { display: grid; gap: 14px; }
.xw-layers-draw { container-type: inline-size; min-width: 0; }
@container (min-width: 640px) { .xw-layers { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; } }
.xw-layers-stage .xw-svg { max-height: 440px; padding: 8px 0; }
.xw-layer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; counter-reset: none; }
.xw-layer { border-radius: 4px; transition: background 0.3s; }
.xw-layer.is-on { background: var(--theme-wash); }
.xw-layer-head {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 44px; padding: 5px 8px; text-align: left;
  border: 0; background: transparent; color: var(--x-navy); font: inherit; cursor: pointer;
}
.xw-layer-head .xw-swatch { width: 10px; align-self: stretch; border-radius: 2px; background: var(--theme-mark); flex: none; }
.xw-layer-head .xw-num { width: 24px; height: 24px; font-size: 12px; background: var(--x-paper-3); color: var(--x-navy); }
.xw-layer.is-on .xw-num { background: var(--x-red); color: var(--x-on); }
.xw-layer.is-built .xw-num { background: var(--theme-soft); color: var(--x-navy); }
.xw-layer-title { display: grid; min-width: 0; font-size: 15px; line-height: 1.25; }
.xw-layer-title .xw-nat { font-size: 16px; color: var(--theme-ink); }
.xw-layer-body { margin: 0; padding: 0 12px 10px 51px; font-size: 15px; line-height: 1.55; }
.xw-year { font-size: 12px; font-weight: 750; letter-spacing: 0.06em; color: var(--x-red); }
/* the tower */
.xw-stack .sc-ground { fill: var(--x-paper-3); filter: drop-shadow(0 1.5px 0 var(--xw-cut)); }
.xw-lay { transition: opacity 0.45s ease; }
.xw-lay .xw-band { fill: var(--theme-wash); opacity: 0.9; }
.xw-lay .xw-core { fill: var(--theme-mark); filter: drop-shadow(0 1.4px 0 var(--xw-cut)); }
.xw-lay .xw-crowd { fill: var(--theme-soft); opacity: 0.85; }
.xw-lay.is-on .xw-band { fill: var(--theme-soft); opacity: 0.55; }
.xw-lay.is-on .xw-core { fill: var(--theme-fill); }
.xw-lay.is-on .xw-crowd { fill: var(--theme-mark); opacity: 1; }
.xw-lay .xw-lay-n { fill: var(--x-paper-2); stroke: var(--theme-mark); stroke-width: 1.5; }
.xw-lay.is-on .xw-lay-n { fill: var(--x-red); stroke: var(--x-red); }
.xw-lay .xw-lay-nt { fill: var(--x-navy); font-size: 11px; font-weight: 750; }
.xw-lay.is-on .xw-lay-nt { fill: var(--x-on); }
.xw-lay.is-ahead { opacity: 0.13; }
.xw-lay.is-ahead .xw-core, .xw-lay.is-ahead .xw-crowd { filter: none; }
.xw-lay .sc.t-fill { color: var(--theme-fill); }
.xw-lay .sc.t-soft { color: var(--theme-soft); }
.xw-lay .sc.t-mark { color: var(--theme-mark); }
.xw-lay .sc.t-wash { color: var(--theme-wash); }
.xw-plan .xw-lay.is-built { opacity: 0.8; }
.xw-plan .xw-lay.is-on { filter: drop-shadow(0 0 1.5px var(--x-red)) drop-shadow(0 0 1px var(--x-red)); }
.xw-plan .xw-lay.is-ahead { opacity: 0; }

/* ── maps: timemap and flow ── */
.xw-map-stage { overflow: hidden; border-radius: 4px; }
.xw-map-stage::before { display: none; }
.xw-map { width: 100%; height: 100%; }
.xw-sea { fill: var(--x-sea); }
.xw-land { fill: var(--xw-land, var(--x-paper-3)); stroke: var(--x-paper-2); stroke-width: 0.25; }
.xw-land.is-focus { fill: var(--x-paper-2); }
.xw-region { fill: transparent; stroke: var(--x-paper-2); stroke-width: 1.2; transition: fill 0.6s ease; }
.xw-region.is-held { fill: var(--theme-soft); }
.xw-region.is-new { stroke: var(--x-red); stroke-width: 2.6; }
.xw-coast { fill: none; stroke: var(--x-navy); stroke-width: 1.2; opacity: 0.55; }
.xw-front { fill: none; stroke: var(--x-red); stroke-width: 2.5; stroke-dasharray: 5 4; }
.xw-city {
  position: absolute; transform: translate(-6px, -6px); display: flex; align-items: center; gap: 5px; padding: 0;
  border: 0; background: none; color: var(--x-navy); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.xw-city.is-static { cursor: default; pointer-events: none; }
.xw-city.is-left { flex-direction: row-reverse; transform: translate(calc(-100% + 6px), -6px); }
.xw-city.is-above { flex-direction: column-reverse; align-items: center; gap: 2px; transform: translate(-50%, calc(-100% + 6px)); }
.xw-city.is-below { flex-direction: column; align-items: center; gap: 2px; transform: translate(-50%, -6px); }
@container (max-width: 480px) { .xw-city { font-size: 11px; } .xw-city-dot { width: 10px; height: 10px; } .xw-city-name { padding: 0 4px 1px; } }
.xw-city-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--x-navy); box-shadow: 0 0 0 2px var(--x-paper-2); }
.xw-city-name {
  padding: 1px 6px 2px; border-radius: 3px; background: color-mix(in srgb, var(--x-paper-2) 88%, transparent);
  line-height: 1.2;
}
.xw-city.is-past .xw-city-dot { background: var(--x-red); }
.xw-city.is-now .xw-city-dot { transform: scale(1.35); box-shadow: 0 0 0 2px var(--x-paper-2), 0 0 0 4px var(--x-red); }
.xw-city.is-now .xw-city-name { background: var(--x-red); color: var(--x-on); }
.xw-city:not(.is-static):hover .xw-city-name { text-decoration: underline; }
.xw-city-note { margin: 8px 0 0; min-height: 1.5em; font-size: 14px; line-height: 1.45; }
.xw-city-note .xw-nat { font-size: 15px; }
.xw-key { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 0; padding: 0; font-size: 13px; font-weight: 600; color: var(--x-ink-2); }
.xw-key li { display: inline-flex; align-items: center; gap: 6px; }
.xw-key .xw-swatch { width: 16px; height: 12px; border-radius: 2px; background: var(--theme-soft); box-shadow: inset 0 0 0 1px var(--x-line); }
.xw-tm { display: grid; gap: 14px; }
@container (min-width: 720px) { .xw-tm { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; } }
.xw-time-row { display: flex; align-items: center; gap: 10px; }
.xw-play { flex: none; }
.xw-frame { margin: 12px 0 0; padding: 12px 14px; border-radius: 4px; background: var(--w-wash); min-height: 120px; }
.xw-frame-year { display: block; font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1; color: var(--x-red); }
.xw-frame-title { display: block; margin: 6px 0 0; font-size: 16.5px; color: var(--x-navy); }
.xw-frame p { margin: 6px 0 0; font-size: 15px; line-height: 1.55; }
.xw-frame-links { font-size: 14px; }

.xw-fl { display: grid; gap: 14px; }
@container (min-width: 720px) { .xw-fl { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; } }
.xw-route { color: var(--theme-mark); }
.xw-route-under { fill: none; stroke: var(--x-paper-2); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.xw-route-line { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-dasharray: 7 5; stroke-linecap: round; stroke-linejoin: round; }
.xw-route.is-on .xw-route-line { stroke-width: 3.4; stroke-dasharray: none; color: var(--theme-fill); }
.xw-route.is-off { opacity: 0.55; }
.xw-ship { transition: none; }
.xw-hull { fill: var(--x-navy); }
.xw-sail { fill: var(--x-paper-2); stroke: var(--x-navy); stroke-width: 0.8; }
.xw-mast { fill: var(--x-navy); }
.xw-route-tabs .xw-chip { white-space: normal; text-align: left; }
.xw-route-card { display: grid; gap: 6px; align-content: start; }
.xw-route-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.xw-route-head .xw-swatch { width: 14px; height: 14px; border-radius: 50%; background: var(--theme-fill); }
.xw-route-card > p { margin: 0; font-size: 15px; line-height: 1.55; }
.xw-route-time { display: flex; align-items: center; gap: 6px; font-weight: 650; color: var(--x-ink-2); }
.xw-cargo { padding: 10px 12px; border-radius: 4px; background: var(--w-wash); }
.xw-cargo-h, .xw-groups-h { display: block; font-size: 11.5px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--x-red); }
.xw-cargo ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; padding: 0; }
.xw-cargo-item {
  display: inline-flex; flex-direction: column; padding: 4px 10px 5px; border-radius: 3px; background: var(--x-paper-2);
  box-shadow: 0 1.5px 0 var(--xw-cut); font-size: 13px; line-height: 1.25; transform: rotate(-0.6deg);
}
.xw-cargo-item:nth-child(2n) { transform: rotate(0.7deg); }
.xw-cargo-item .xw-nat { font-size: 14.5px; }
.xw-voyage { display: flex; align-items: center; gap: 10px; margin: 4px 0 0; }
.xw-stops { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; }
.xw-stops li { display: flex; gap: 9px; align-items: baseline; padding: 4px 6px; border-radius: 3px; font-size: 14px; line-height: 1.4; cursor: pointer; }
.xw-stop-dot { flex: none; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--x-ink-2); transform: translateY(1px); }
.xw-stops li.is-passed .xw-stop-dot { background: var(--x-red); border-color: var(--x-red); }
.xw-stop-note { color: var(--x-ink-2); }

/* ── wheels ── */
.xw-wheel { display: grid; gap: 16px; }
@container (min-width: 640px) { .xw-wheel { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; } }
.xw-face-stage { max-width: 380px; width: 100%; justify-self: center; }
.xw-face-stage::before { border-radius: 50%; -webkit-mask: none; mask: none; inset: 3%; }
.xw-face { padding: 4px; touch-action: none; }
.xw-tick { stroke: var(--x-ink-2); stroke-width: 1.2; }
.xw-hour { fill: var(--x-ink-2); font-size: 11.5px; font-weight: 700; }
.xw-track { fill: var(--x-paper-3); }
.xw-ring { transform-origin: 160px 160px; transition: transform 0.8s cubic-bezier(.3, .9, .3, 1); }
.xw-span { fill: var(--theme-soft); }
.xw-span.k-sleep { fill: var(--theme-mark); }
.xw-mark circle { fill: var(--theme-fill); filter: drop-shadow(0 1.4px 0 var(--xw-cut)); }
.xw-mark .xw-mark-in { fill: var(--x-paper-2); filter: none; }
.xw-ring-name { fill: var(--x-paper-2); font-size: 9px; font-weight: 800; letter-spacing: 0.14em; }
.xw-sun { fill: var(--x-red); }
.xw-moon { fill: var(--x-ink-2); }
.xw-hand line { stroke: var(--x-red); stroke-width: 3; stroke-linecap: round; }
.xw-knob { fill: var(--x-red); stroke: var(--x-paper-2); stroke-width: 2.5; cursor: grab; }
.xw-hub { fill: var(--x-paper-2); stroke: var(--x-line); }
.xw-face-time { fill: var(--x-navy); font-family: var(--serif); font-size: 26px; font-weight: 600; }
.xw-face-sub { fill: var(--x-ink-2); font-size: 11px; font-weight: 650; letter-spacing: 0.04em; }
.xw-readout { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.xw-readout li { display: grid; gap: 1px; padding: 8px 12px; border-radius: 4px; background: var(--w-wash); font-size: 14.5px; line-height: 1.4; }
.xw-readout strong { color: var(--x-navy); }
.xw-ro-clock { font-size: 13px; color: var(--x-ink-2); }
.xw-ro-what { color: var(--x-navy); }
.xw-ro-mark { display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; color: var(--x-ink-2); font-size: 14px; }
.xw-ro-mark .xw-nat { font-size: 15.5px; color: var(--x-red); }
.xw-sun-note { margin: 8px 0 0; font-size: 13.5px; color: var(--x-ink-2); }
.xw-sun-note:empty { display: none; }
.xw-wheel-side .xw-key { margin-top: 12px; }
/* the compás */
.xw-track-ring { fill: none; stroke: var(--x-paper-3); stroke-width: 38; opacity: 0.6; }
.xw-group { filter: drop-shadow(0 1.4px 0 var(--xw-cut)); }
.xw-group.g-0 { fill: var(--w-soft); opacity: 0.55; }
.xw-group.g-1 { fill: var(--w-mark); opacity: 0.5; }
.xw-beat circle { fill: var(--x-paper-2); stroke: var(--x-navy); stroke-width: 1.6; transition: transform 0.12s; transform-box: fill-box; transform-origin: center; }
.xw-beat text { fill: var(--x-navy); font-size: 11.5px; font-weight: 750; }
.xw-beat.is-accent circle { fill: var(--x-red); stroke: var(--x-red); filter: drop-shadow(0 1.6px 0 var(--xw-cut)); }
.xw-beat.is-accent text { fill: var(--x-on); font-size: 13.5px; }
.xw-beat.is-now circle { fill: var(--x-navy); stroke: var(--x-navy); transform: scale(1.25); }
.xw-beat.is-now text { fill: var(--x-paper-2); }
.xw-beat.is-accent.is-now circle { fill: var(--x-red); stroke: var(--x-navy); stroke-width: 3; transform: scale(1.4); }
.xw-beat.is-hit circle { stroke: var(--w-fill); stroke-width: 6; }
.xw-beat-hand { stroke: var(--x-navy); stroke-width: 2.5; stroke-linecap: round; opacity: 0.6; }
.xw-rhythm.is-accent .xw-beat-now { fill: var(--x-red); }
.xw-beat-now { font-size: 40px; }
.xw-groups { margin: 12px 0 0; font-size: 15px; }
.xw-groups-h { display: inline; margin-right: 6px; }
.xw-gnum { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 4px; font-family: var(--serif); font-size: 18px; font-weight: 700; color: var(--x-navy); }
.xw-gnum.g-0 { background: color-mix(in srgb, var(--w-soft) 55%, var(--x-paper-2)); }
.xw-gnum.g-1 { background: color-mix(in srgb, var(--w-mark) 50%, var(--x-paper-2)); }
.xw-plus { color: var(--x-ink-2); }
.xw-about { margin: 8px 0 0; font-size: 15px; line-height: 1.55; }
.xw-about:empty { display: none; }
.xw-tap {
  display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 22px; border: 0; border-radius: 999px;
  background: var(--x-red); color: var(--x-on); font: inherit; font-size: 16px; font-weight: 750; cursor: pointer;
  box-shadow: 0 3px 0 var(--xw-cut);
}
.xw-tap:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--xw-cut); }
.xw-feedback { margin: 0; font-size: 14.5px; font-weight: 650; color: var(--x-navy); }
/* the year and the gears */
.xw-month.m-0 { fill: var(--w-wash); }
.xw-month.m-1 { fill: var(--w-soft); opacity: 0.6; }
.xw-ymark circle { fill: var(--theme-fill); stroke: var(--x-paper-2); stroke-width: 2; }
.xw-ymark text { fill: var(--theme-on); font-size: 10.5px; font-weight: 750; }
.xw-ymark.is-on circle { fill: var(--x-red); }
.xw-gear-ptr { stroke-width: 3.5; stroke-linecap: round; }
.xw-gear-ptr.g-0 { stroke: var(--x-red); }
.xw-gear-ptr.g-1 { stroke: var(--x-navy); }
.xw-readout-p { margin: 0; font-size: 15px; line-height: 1.55; }

/* ── trees ── */
.xw-tree { position: relative; margin: 12px 0 0; }
.xw-tree-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.xw-tree-couple { stroke: var(--x-navy); stroke-width: 2; stroke-dasharray: 2 4; stroke-linecap: round; }
.xw-tree-line { fill: none; stroke: var(--x-ink-2); stroke-width: 2; }
.xw-tree-pass { fill: none; stroke: var(--theme-fill); stroke-width: 4; stroke-linecap: round; transition: d 0.4s; }
.xw-tree-cards { list-style: none; margin: 0; padding: 0; }
.xw-tree-card { position: absolute; padding: 0 5px; box-sizing: border-box; }
.xw-tree-in {
  height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 8px 10px; overflow: hidden;
  border-radius: 4px; background: var(--x-paper-2); box-shadow: 0 0 0 1.5px var(--x-line), 0 2px 0 var(--xw-cut);
}
.xw-tree-card.is-derived .xw-tree-in { background: var(--w-wash); box-shadow: 0 0 0 1.5px var(--w-mark), 0 2px 0 var(--xw-cut); }
.xw-tree-role { font-size: 11px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--x-red); }
.xw-tree-name { font-family: var(--serif); font-size: 17px; line-height: 1.1; color: var(--x-navy); }
.xw-tree-years, .xw-tree-note { font-size: 12.5px; color: var(--x-ink-2); }
.xw-surnames { display: flex; flex-wrap: wrap; gap: 4px; }
.xw-surname {
  display: inline-block; padding: 2px 8px 3px; background: var(--theme-soft); color: var(--x-navy);
  font-size: 13px; font-weight: 750; line-height: 1.2; transform: rotate(-1deg);
  -webkit-mask: var(--x-tear-l) left top / 6px 160px repeat-y, var(--x-tear-r) right top / 6px 160px repeat-y, linear-gradient(#000 0 0) center / calc(100% - 10px) 100% no-repeat;
  mask: var(--x-tear-l) left top / 6px 160px repeat-y, var(--x-tear-r) right top / 6px 160px repeat-y, linear-gradient(#000 0 0) center / calc(100% - 10px) 100% no-repeat;
}
.xw-surname:nth-child(2) { transform: rotate(1deg); }
.xw-tree.is-narrow .xw-tree-in { padding: 6px 7px; }
.xw-tree.is-narrow .xw-tree-name { font-size: 15px; }
.xw-tree.is-narrow .xw-surname { font-size: 12px; padding: 2px 6px; }
.xw-rule { margin: 14px 0 0; font-size: 15px; line-height: 1.6; }
.xw-try { margin: 12px 0 0; padding: 10px 14px; border-radius: 4px; background: var(--w-wash); }
.xw-try summary { cursor: pointer; font-weight: 700; color: var(--x-navy); min-height: 32px; display: flex; align-items: center; }
.xw-try-grid { display: grid; gap: 10px; margin: 8px 0 10px; }
@container (min-width: 560px) { .xw-try-grid { grid-template-columns: 1fr 1fr; } .xw-try-grid > .xw-field { grid-column: 1 / -1; max-width: 260px; } }
.xw-try fieldset { margin: 0; padding: 8px 10px 10px; border: 1.5px solid var(--x-line); border-radius: 4px; display: grid; gap: 6px; }
.xw-try legend { padding: 0 4px; font-size: 12px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; color: var(--x-ink-2); }
.xw-field { display: grid; gap: 2px; font-size: 13px; font-weight: 600; color: var(--x-ink-2); }
.xw-input {
  min-height: 38px; padding: 0 10px; border: 1.5px solid var(--x-line); border-radius: 4px;
  background: var(--x-paper-2); color: var(--text); font: inherit; font-size: 15px;
}
.xw-input:focus { outline: 2px solid var(--x-red); outline-offset: 1px; }
.xw-try-res { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 6px 0 0; }
.xw-try-h { font-size: 13px; font-weight: 650; color: var(--x-ink-2); }
.xw-try-out { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.xw-try-name { font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--x-navy); }

/* ── slider ── */
.xw-slide { position: relative; overflow: hidden; cursor: ew-resize; user-select: none; -webkit-user-select: none; border-radius: 4px; }
.xw-slide::before { -webkit-mask: none; mask: none; }
.xw-slide-a { position: relative; background: var(--w-wash) var(--x-grain); }
.xw-slide-b { position: absolute; inset: 0; background: var(--x-paper-3) var(--x-grain); }
.xw-slide-a .xw-svg, .xw-slide-b .xw-svg { height: 100%; padding: 0; }
.xw-slide-bar { position: absolute; top: 0; bottom: 0; width: 0; border-left: 3px solid var(--x-paper-2); box-shadow: 0 0 0 1px var(--x-line); pointer-events: none; }
.xw-slide-grip {
  position: absolute; top: 50%; left: -1.5px; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%;
  background: var(--x-red); box-shadow: 0 0 0 3px var(--x-paper-2), 0 2px 0 3px var(--xw-cut);
}
.xw-slide-grip::before, .xw-slide-grip::after { content: ""; position: absolute; top: 50%; width: 0; height: 0; border: 5px solid transparent; transform: translateY(-50%); }
.xw-slide-grip::before { left: 5px; border-right-color: var(--x-on); }
.xw-slide-grip::after { right: 5px; border-left-color: var(--x-on); }
.xw-slide-tag {
  position: absolute; top: 10px; padding: 3px 10px 4px; background: var(--x-navy); color: var(--x-paper-2);
  font-size: 12px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; pointer-events: none;
}
.xw-slide-tag.is-a { left: 10px; transform: rotate(-1.5deg); }
.xw-slide-tag.is-b { right: 10px; transform: rotate(1.5deg); background: var(--x-red); color: var(--x-on); }
/* on a phone: the two pictures one above the other, whole */
.xw-slide.is-stacked { cursor: default; display: grid; gap: 8px; overflow: visible; }
.xw-slide.is-stacked .xw-slide-b { position: relative; inset: auto; }
.xw-slide.is-stacked .xw-slide-a, .xw-slide.is-stacked .xw-slide-b { border-radius: 4px; overflow: hidden; }
.xw-slide.is-stacked .xw-slide-tag.is-b { right: auto; left: 10px; transform: rotate(-1.5deg); }
.xw-slide.is-stacked .xw-slide-bar { display: none; }
.xw-slide-ctl { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; font-size: 12.5px; font-weight: 750; color: var(--x-ink-2); }
.xw-slide-caps { display: grid; gap: 10px; margin: 12px 0 0; }
@container (min-width: 520px) { .xw-slide-caps { grid-template-columns: 1fr 1fr; } }
.xw-slide-cap { padding: 10px 12px; border-radius: 4px; background: var(--w-wash); }
.xw-slide-cap.is-b { background: var(--x-paper-3); }
.xw-slide-cap strong { color: var(--x-navy); }
.xw-slide-cap p { margin: 4px 0 0; font-size: 15px; line-height: 1.55; }
.xw-compare { width: 100%; margin: 12px 0 0; border-collapse: collapse; font-size: 14.5px; }
.xw-compare th, .xw-compare td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--x-line); }
.xw-compare thead th { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--x-ink-2); }
.xw-compare tbody th { color: var(--x-navy); font-weight: 700; }
@container (max-width: 520px) {
  .xw-compare thead { display: none; }
  .xw-compare tr { display: block; padding: 6px 0; border-bottom: 1px solid var(--x-line); }
  .xw-compare th, .xw-compare td { display: block; border: 0; padding: 2px 0; }
  .xw-compare td::before { content: attr(data-col) ": "; font-weight: 700; color: var(--x-ink-2); }
}

/* ── reveal ── */
.xw-prompt { margin: 0 0 10px; font-family: var(--serif); font-size: 19px; line-height: 1.4; color: var(--x-navy); }
.xw-guess-box { padding: 14px; border-radius: 4px; background: var(--w-wash); }
.xw-guess { display: block; text-align: center; font-family: var(--serif); font-size: 46px; font-weight: 600; line-height: 1; color: var(--x-navy); }
.xw-scale { display: flex; justify-content: space-between; font-size: 12px; font-weight: 650; color: var(--x-ink-2); }
.xw-result:empty { display: none; }
.xw-result { margin: 14px 0 0; }
.xw-answer-line { position: relative; height: 54px; margin: 6px 12px 0; border-bottom: 3px solid var(--x-paper-3); }
.xw-answer-gap { position: absolute; bottom: -3px; height: 3px; background: var(--x-red); }
.xw-answer-mark { position: absolute; bottom: -9px; width: 15px; height: 15px; margin-left: -7.5px; border-radius: 50%; border: 2.5px solid var(--x-paper-2); }
.xw-answer-mark span { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 13px; font-weight: 750; }
.xw-answer-mark.is-guess { background: var(--x-navy); }
.xw-answer-mark.is-guess span { color: var(--x-navy); }
.xw-answer-mark.is-answer { background: var(--x-red); }
.xw-answer-mark.is-answer span { color: var(--x-red); font-family: var(--serif); font-size: 17px; bottom: 22px; }
.xw-answer-mark.is-answer.is-under span { bottom: auto; top: 18px; }
.xw-answer-line:has(.is-under) { margin-bottom: 30px; }
.xw-verdict { margin: 14px 0 0; font-size: 16px; line-height: 1.45; }
.xw-verdict strong { color: var(--x-red); }
.xw-why p { margin: 8px 0 0; font-size: 15.5px; line-height: 1.6; }
.xw-options { display: grid; gap: 8px; }
.xw-option {
  min-height: 46px; padding: 8px 14px; text-align: left; border: 1.5px solid var(--x-line); border-radius: 6px;
  background: var(--x-paper-2); color: var(--x-navy); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.xw-option.is-right { border-color: var(--w-fill); background: var(--w-fill); color: var(--w-on); }
.xw-option.is-wrong { border-color: var(--x-red); text-decoration: line-through; text-decoration-color: var(--x-red); }

/* ── chain ── */
.xw-chain { list-style: none; margin: 0; padding: 0 0 0 20px; position: relative; display: grid; gap: 0; }
.xw-chain::before { content: ""; position: absolute; left: 6px; top: 12px; bottom: 12px; width: 3px; background: var(--x-red); border-radius: 2px; }
.xw-knot { position: relative; }
.xw-knot::before {
  content: ""; position: absolute; left: -20px; top: 22px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--x-red); box-shadow: 0 0 0 3px var(--x-paper-2);
}
.xw-knot:not(:first-child) { padding-top: 0; }
.xw-because { display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 0 8px 4px; font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--x-red); }
.xw-knot-card {
  padding: 10px 14px 12px; border-radius: 4px; background: var(--x-paper-2); box-shadow: 0 0 0 1.5px var(--x-line), 0 2px 0 var(--xw-cut);
  transform: rotate(-0.4deg);
}
.xw-knot.is-right .xw-knot-card { transform: rotate(0.45deg); }
.xw-knot-card .xw-year { display: block; font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1.1; color: var(--x-red); letter-spacing: 0; }
.xw-knot-title { display: block; margin: 2px 0 0; font-size: 16.5px; line-height: 1.3; color: var(--x-navy); }
.xw-knot-card p { margin: 4px 0 0; font-size: 15px; line-height: 1.55; }
@container (min-width: 700px) {
  .xw-chain { padding-left: 0; }
  .xw-chain::before { left: 50%; margin-left: -1.5px; }
  .xw-knot { width: calc(50% - 26px); }
  .xw-knot.is-right { margin-left: calc(50% + 26px); }
  .xw-knot::before { left: auto; right: -34px; }
  .xw-knot.is-right::before { right: auto; left: -34px; }
  .xw-knot:not(:first-child) { margin-top: -36px; }
  .xw-because { justify-content: flex-end; text-align: right; }
  .xw-knot.is-right .xw-because { justify-content: flex-start; text-align: left; }
}
.xw-chain-ctl { margin-top: 14px; }
@media (prefers-reduced-motion: no-preference) {
  .xw-knot.is-new { animation: xw-in 0.45s ease-out both; }
}
@keyframes xw-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ── the foot: a note, the sources ── */
.xw-foot { display: grid; gap: 6px; margin: 16px 0 0; padding: 10px 0 0; border-top: 1px dashed var(--x-line); }
.xw-note { display: flex; gap: 7px; align-items: flex-start; margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--x-ink-2); }
.xw-note .icon { flex: none; margin-top: 2px; color: var(--x-red); }
.xw-src { font-size: 13px; color: var(--x-ink-2); }
.xw-src summary { cursor: pointer; font-weight: 700; min-height: 30px; display: flex; align-items: center; gap: 4px; color: var(--x-navy); }
.xw-src ol { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 3px; line-height: 1.45; }
.xw-src a { color: var(--x-navy); text-decoration-color: var(--w-mark); overflow-wrap: anywhere; }
.xw-src-pub { color: var(--x-ink-2); }

@media (prefers-reduced-motion: reduce) {
  .xw *, .xw *::before, .xw *::after { transition: none !important; animation: none !important; }
  .xw-kicker, .xw-cargo-item, .xw-surname, .xw-knot-card, .xw-slide-tag { transform: none !important; }
}
