/* ── App shell ─────────────────────────────────────────────────────────────── */

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  min-height: 100dvh;
}

/* ── Top bar ───────────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-4) clamp(16px, 2.4vw, 32px) var(--space-3);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  z-index: 20;
}

.brand {
  min-width: 0;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
}

.brand .subtitle {
  margin-top: 6px;
  font-size: var(--step--1);
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}

.credit {
  margin-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.credit a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.credit a:hover {
  color: var(--ink);
  text-decoration-color: var(--accent);
}

.finding {
  max-width: 62ch;
  margin-top: var(--space-3);
  font-size: var(--step-1);
  line-height: 1.4;
  /* Reserved at the tallest wrap any locale/year produces (3 lines below
     1024px, 2 lines above), so the year ticking over cannot reflow the header
     and nudge the donut. The 2px absorbs sub-pixel line-box rounding. Keep in
     sync with the finding template in the locale files — a longer template
     needs a bigger reservation. */
  min-height: calc(3 * 1.4em + 2px);
  color: var(--ink-soft);
  text-wrap: pretty;
}

@media (min-width: 1024px) {
  .finding {
    min-height: calc(2 * 1.4em + 2px);
  }
}

.finding em {
  font-style: normal;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ink);
}

.finding .finding-year {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.finding .finding-sep {
  margin: 0 0.55em;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink-soft);
  font-size: var(--step--1);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.btn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  background: var(--panel-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn[aria-pressed="true"],
.btn.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.btn.icon {
  width: 36px;
  padding: 0;
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn.ghost:hover {
  background: var(--panel-2);
  border-color: var(--line);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn .lbl {
  display: none;
}

@media (min-width: 900px) {
  .btn .lbl {
    display: inline;
  }

  /* The Display label is the only variable-width text in the toolbar and the
     toolbar is right-aligned, so without this the language switch slides left
     and right as the label changes length ("Display" → "Visualizzazione", 44 to
     95px). Reserved at the widest locale, plus a little slack for font
     fallback, so the selector never moves. */
  #btnDisplay {
    min-width: 152px;
  }
}

/* Language switch */
.lang {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--panel);
}

.lang button {
  height: 34px;
  padding: 0 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: background var(--dur-fast), color var(--dur-fast);
}

.lang button + button {
  border-left: 1px solid var(--line);
}

.lang button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.lang button:hover:not([aria-pressed="true"]) {
  background: var(--panel-2);
  color: var(--ink);
}

/* ── Stage ─────────────────────────────────────────────────────────────────── */

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
  padding: 10px clamp(12px, 2.4vw, 32px);
  transition: padding-right var(--dur-slow) var(--ease-out);
}

.donut-host {
  position: relative;
  width: min(var(--donut-size), 100%, calc(100dvh - 250px));
  aspect-ratio: 1;
  max-height: 100%;
}

body[data-size="sm"] {
  --donut-size: 440px;
}
body[data-size="md"] {
  --donut-size: 600px;
}
body[data-size="lg"] {
  --donut-size: 780px;
}

.donut-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  touch-action: manipulation;
}

.donut-svg text {
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.005em;
  paint-order: stroke;
}

.donut-svg .band-title {
  fill: var(--ring-ink);
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.donut-svg .banner {
  fill: var(--body-ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0.01em;
  opacity: 0.9;
}

.donut-svg .hole-label {
  fill: var(--ink);
  stroke: var(--label-halo);
  stroke-width: 2.4px;
  stroke-linejoin: round;
  paint-order: stroke;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.donut-svg .eco-label {
  fill: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  text-anchor: middle;
  stroke: var(--label-halo);
  stroke-width: 2.2px;
  stroke-linejoin: round;
  paint-order: stroke;
}

.donut-svg .arrow-label {
  fill: var(--paper);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.donut-svg .layer-wash,
.donut-svg .layer-body,
.donut-svg .layer-ticks,
.donut-svg .layer-titles,
.donut-svg .layer-labels,
.donut-svg .layer-arrows {
  pointer-events: none;
}

.donut-svg .wedge {
  transition: filter var(--dur-fast) var(--ease-out), opacity var(--dur-fast);
  cursor: pointer;
}

.donut-svg.is-hovering .wedge {
  opacity: 0.42;
}

.donut-svg.is-hovering .wedge.is-active {
  opacity: 1;
}

.donut-svg .hit {
  cursor: pointer;
}

/* Hover and selection both outline the sector; selection also dashes it. */
.donut-svg .hit.is-active {
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linejoin: round;
}

.donut-svg .hit.is-selected {
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-dasharray: 6 4;
}

.donut-svg text {
  user-select: none;
}

.toolbar-item {
  position: relative;
}

.stage-hint {
  display: flex;
  align-items: center;
  gap: 7px;
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: opacity var(--dur-mid) var(--ease-out);
}

.stage-hint.is-hidden,
.stage:has(.strip.is-open) .stage-hint {
  opacity: 0;
  pointer-events: none;
}

.stage-hint .hint-arrow {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--accent);
}

.stage-hint .hint-mobile {
  display: none;
}

@media (max-width: 640px) {
  .stage-hint .hint-desktop {
    display: none;
  }

  .stage-hint .hint-mobile {
    display: inline;
  }
}

/* ── Tooltip ───────────────────────────────────────────────────────────────── */

.tooltip {
  position: absolute;
  z-index: 30;
  left: 0;
  top: 0;
  min-width: 150px;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--tooltip-bg);
  color: var(--tooltip-ink);
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 12px)) scale(0.98);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.35);
}

.tooltip.is-visible {
  opacity: 1;
  transform: translate(-50%, calc(-100% - 12px)) scale(1);
}

.tooltip strong {
  font-weight: 600;
}

.tooltip .t-value {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.8;
  display: block;
  margin-top: 2px;
}

.tooltip .t-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}

.tooltip .t-cta svg {
  width: 11px;
  height: 11px;
}

/* ── Transport ─────────────────────────────────────────────────────────────── */

.transport {
  display: grid;
  grid-template-columns: auto auto minmax(120px, 1fr) auto auto;
  align-items: center;
  gap: clamp(10px, 1.6vw, 22px);
  padding: 12px clamp(16px, 2.4vw, 32px) 14px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  z-index: 20;
}

.play {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  display: grid;
  place-items: center;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast);
}

.play:hover {
  transform: scale(1.05);
}

.play:active {
  transform: scale(0.97);
}

.play svg {
  width: 17px;
  height: 17px;
}

.year-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 74px;
}

.year {
  font-family: var(--font-mono);
  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.year-block .kicker {
  font-size: 9px;
  letter-spacing: 0.12em;
}

.scrub {
  position: relative;
  display: flex;
  align-items: center;
  height: 46px;
}

.scrub input[type="range"] {
  position: relative;
  z-index: 2;
  width: calc(100% - 16px);
  margin: 0 8px;
  height: 46px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.scrub input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line-strong);
  border-radius: 1px;
}

.scrub input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--line-strong);
  border-radius: 1px;
}

.scrub input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--ink-soft);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--line-strong);
  transition: transform var(--dur-fast) var(--ease-out);
}

.scrub input[type="range"]::-moz-range-thumb {
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink-soft);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--line-strong);
}

.scrub input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.15);
}

.speed {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.speed button {
  padding: 0 9px;
  height: 30px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.speed button + button {
  border-left: 1px solid var(--line);
}

.speed button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.loop {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.loop[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.loop svg {
  width: 15px;
  height: 15px;
}

/* ── Detail rail ───────────────────────────────────────────────────────────── */

.detail {
  visibility: hidden;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(var(--rail-w), 92vw);
  background: var(--panel);
  border-left: 1px solid var(--line);
  clip-path: inset(0 0 0 100%);
  transition: clip-path var(--dur-slow) var(--ease-out),
    visibility 0s linear var(--dur-slow);
  z-index: 25;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.detail.is-open {
  visibility: visible;
  clip-path: inset(0 0 0 0);
  transition: clip-path var(--dur-slow) var(--ease-out), visibility 0s;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-3);
  border-bottom: 1px solid var(--line);
}

.detail-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.detail h2 {
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-top: 4px;
}

.detail .dim {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: var(--step--1);
  color: var(--muted);
  margin-top: 4px;
}

.rel-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  line-height: 1.6;
}

.rel-chip.is-direct {
  color: var(--ring);
  border-color: currentColor;
}

.rel-chip.is-proxy {
  color: var(--accent);
  border-color: currentColor;
}

.rel-note {
  margin-top: 10px;
  font-size: var(--step--1);
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
}

.data-table .rel-chip {
  font-size: 8.5px;
  margin-top: 3px;
}

.detail-intro .kicker {
  font-size: 9px;
  letter-spacing: 0.1em;
}

.detail-intro p {
  margin-top: 6px;
  font-size: var(--step-0);
  line-height: 1.5;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.detail-intro .intro-unit {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin-top: var(--space-4);
}

.stat {
  background: var(--panel);
  padding: 12px 14px;
}

.stat .kicker {
  font-size: 9px;
  letter-spacing: 0.1em;
}

.stat .v {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 500;
  margin-top: 3px;
  letter-spacing: -0.02em;
}

.stat .u {
  font-size: 10px;
  color: var(--muted);
  margin-top: 1px;
  display: block;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--space-4);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: var(--step--1);
  font-weight: 600;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.status-pill.is-over .dot {
  background: var(--alarm);
}

.status-pill.is-under .dot {
  background: var(--accent);
}

.status-pill.is-good .dot {
  background: var(--ring);
}

.spark {
  margin-top: var(--space-5);
  width: 100%;
  height: 96px;
}

.spark-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

.detail-note {
  margin-top: var(--space-4);
  padding: 10px 12px;
  border-left: 2px solid var(--line-strong);
  font-size: var(--step--1);
  color: var(--muted);
  line-height: 1.45;
}

/* Doughnut 3.0 mapping — deliberately the quietest block in the rail */

.dim-block {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.dim-block .dim {
  margin-top: 0;
  font-size: 11px;
  opacity: 0.85;
}

.dim-block .rel-note {
  margin-top: 6px;
  font-size: 11px;
}

/* ── Popover ───────────────────────────────────────────────────────────────── */

.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  padding: var(--space-4);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 50;
  opacity: 0;
  transform: translateY(-6px) scale(0.99);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.popover.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.control-group + .control-group {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.control-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.segmented {
  display: flex;
  gap: 4px;
}

.segmented button {
  flex: 1;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 11px;
  color: var(--muted);
  transition: all var(--dur-fast);
}

.segmented button[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.swatches {
  display: flex;
  gap: 8px;
}

.swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  position: relative;
  transition: transform var(--dur-fast) var(--ease-out);
}

.swatch::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: linear-gradient(
    90deg,
    var(--ring) 0 33%,
    var(--body) 33% 66%,
    var(--alarm) 66%
  );
}

.swatch:hover {
  transform: scale(1.08);
}

.swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 5px 0;
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.switch {
  position: relative;
  width: 34px;
  height: 20px;
  flex: none;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background var(--dur-fast);
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform var(--dur-fast) var(--ease-out);
}

.switch input:checked ~ .knob {
  transform: translateX(14px);
}

.switch input:checked {
  background: transparent;
}

.switch:has(input:checked) {
  background: var(--ink);
}

.switch input:focus-visible ~ .knob {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Drawer ────────────────────────────────────────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-mid) var(--ease-out);
  z-index: 55;
}

.scrim.is-on {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  visibility: hidden;
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(620px, 94vw);
  background: var(--panel);
  border-left: 1px solid var(--line);
  clip-path: inset(0 0 0 100%);
  transition: clip-path var(--dur-slow) var(--ease-out),
    visibility 0s linear var(--dur-slow);
  z-index: 60;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.drawer.is-open {
  visibility: visible;
  clip-path: inset(0 0 0 0);
  transition: clip-path var(--dur-slow) var(--ease-out), visibility 0s;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  font-family: var(--font-display);
  font-size: var(--step-2);
  letter-spacing: -0.03em;
}

.drawer-body {
  overflow-y: auto;
  padding: var(--space-5);
  font-size: var(--step-0);
  color: var(--ink-soft);
}

.drawer-body h3 {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: var(--space-5) 0 6px;
}

.drawer-body h3:first-child {
  margin-top: 0;
}

.drawer-body p {
  line-height: 1.6;
  max-width: 62ch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-3);
  font-size: 12px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

.data-table th {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.data-table td.num {
  font-family: var(--font-mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tr.is-eco td:first-child {
  box-shadow: inset 3px 0 0 var(--alarm);
}

.data-table tr.is-social td:first-child {
  box-shadow: inset 3px 0 0 var(--ring);
}

.term-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  font-size: 12px;
  margin-top: 8px;
}

.term-list dt {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.term-list dd {
  margin: 0;
}

.link {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}

.link:hover {
  text-decoration-color: var(--accent);
}

/* ── Trend strip ───────────────────────────────────────────────────────────── */

.strip {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 8px;
  width: auto;
  max-width: 920px;
  margin-inline: auto;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px 14px 12px;
  z-index: 15;
  opacity: 0;
  translate: 0 12px;
  pointer-events: none;
  transition: opacity var(--dur-mid) var(--ease-out), translate var(--dur-mid) var(--ease-out);
}

.strip.is-open {
  opacity: 1;
  translate: 0 0;
  pointer-events: auto;
}

.strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.strip-head .kicker {
  font-size: 9px;
}

.strip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 4px 10px;
}

.mini {
  display: block;
  text-align: left;
  padding: 3px 0;
  border-radius: 4px;
}

.mini svg {
  width: 100%;
  height: 22px;
  overflow: visible;
}

.mini .mini-label {
  display: block;
  font-size: 9.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.mini:hover .mini-label,
.mini[aria-pressed="true"] .mini-label {
  color: var(--ink);
}

.strip-caption {
  margin-top: 6px;
  font-size: 10px;
  color: var(--muted);
}

/* ── Tour ──────────────────────────────────────────────────────────────────── */

.tour-scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-mid);
}

.tour-scrim.is-on {
  opacity: 1;
  pointer-events: auto;
}

.tour-card {
  position: fixed;
  z-index: 71;
  left: 50%;
  bottom: 116px;
  transform: translate(-50%, 12px);
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: var(--space-5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-mid) var(--ease-out), transform var(--dur-mid) var(--ease-out);
}

.tour-card.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.tour-card h3 {
  font-family: var(--font-display);
  font-size: var(--step-2);
  letter-spacing: -0.03em;
  margin: 6px 0 6px;
}

.tour-card p {
  font-size: var(--step-0);
  color: var(--ink-soft);
  line-height: 1.55;
}

.tour-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

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

.tour-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}

.tour-dots span.is-on {
  background: var(--accent);
}

.tour-progress {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}

/* ── Toast ─────────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 108px;
  transform: translate(-50%, 8px);
  background: var(--ink);
  color: var(--paper);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12px;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast), transform var(--dur-fast);
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── Breakpoints ───────────────────────────────────────────────────────────── */

@media (min-width: 1024px) {
  body.detail-open .stage {
    padding-right: calc(min(var(--rail-w), 92vw) + 8px);
  }

  body.detail-open .strip {
    right: calc(min(var(--rail-w), 92vw) + 16px);
  }
}

@media (max-width: 1023px) {
  .detail {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: min(72vh, 620px);
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    clip-path: inset(100% 0 0 0);
  }

  .detail.is-open {
    clip-path: inset(0 0 0 0);
  }

  .detail-body {
    padding-bottom: 28px;
  }
}

@media (max-width: 767px) {
  .topbar {
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: 12px 16px 10px;
  }

  .brand h1 {
    font-size: clamp(1.5rem, 7vw, 2rem);
  }

  .finding {
    font-size: var(--step-0);
    margin-top: 8px;
  }

  .toolbar {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .toolbar::-webkit-scrollbar {
    display: none;
  }

  .donut-host {
    width: min(100%, calc(100dvh - 300px));
    min-width: 260px;
  }

  .transport {
    grid-template-columns: auto auto 1fr auto;
    grid-template-areas:
      "play year speed loop"
      "scrub scrub scrub scrub";
    gap: 6px 10px;
    padding: 10px 16px 12px;
  }

  .play {
    grid-area: play;
    width: 42px;
    height: 42px;
  }

  .year-block {
    grid-area: year;
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
  }

  .loop {
    grid-area: loop;
  }

  .scrub {
    grid-area: scrub;
  }

  .speed {
    grid-area: speed;
    justify-self: end;
  }

  .speed button {
    padding: 0 7px;
  }

  .strip {
    bottom: 6px;
    left: 10px;
    right: 10px;
    max-height: 34vh;
    overflow-y: auto;
  }

  .popover {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 12px;
    width: auto;
    max-height: 80vh;
    overflow-y: auto;
    transform-origin: bottom center;
    transform: translateY(10px) scale(0.99);
  }

  .popover.is-open {
    transform: none;
  }
}

@media (max-width: 700px) {
  .donut-svg .layer-arrows {
    display: none !important;
  }
}

@media (max-height: 700px) and (min-width: 768px) {
  .donut-host {
    width: min(var(--donut-size), 100%, calc(100dvh - 230px));
  }

  .strip {
    display: none;
  }
}
