.freshness-lab {
  --freshness-yellow: #c59a32;
  --freshness-orange: #b95f45;
  --freshness-green: #6f9f68;
  --freshness-panel: #101010;
  --freshness-panel-raised: #151515;
  --freshness-border: #2a2a2a;
  --freshness-muted: #aaaaaa;
  overflow: hidden;
}

.freshness-lab .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;
}

.freshness-intro {
  max-width: 1240px;
  margin: 0 auto;
  padding: 3.25rem 1.5rem 1.75rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
}

.freshness-intro > div {
  max-width: 850px;
}

.freshness-intro h1 {
  color: #f5f5f5;
  font-size: clamp(2rem, 4vw, 3.35rem);
  line-height: 1.08;
  margin: 0 0 1rem;
  letter-spacing: -0.035em;
}

.freshness-intro p {
  color: #cccccc;
  max-width: 780px;
  margin: 0 0 0.65rem;
}

.freshness-intro .freshness-kicker {
  color: var(--freshness-yellow);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.freshness-intro .freshness-caveat {
  color: #9d9d9d;
  font-size: 0.88rem;
}

.freshness-intro-link {
  flex: 0 0 auto;
  margin: 0 0 0.65rem;
  white-space: nowrap;
}

.freshness-workspace {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.freshness-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  align-items: end;
  padding: 1rem;
  background: var(--freshness-panel);
  border: 1px solid var(--freshness-border);
  border-radius: 14px;
}


.freshness-field label,
.freshness-toolbar label {
  display: block;
  color: #cfcfcf;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
}

.freshness-field input,
.freshness-field select,
.freshness-toolbar select {
  width: 100%;
  min-height: 40px;
  padding: 0.48rem 0.65rem;
  color: #e5e5e5;
  background: #0e0e0e;
  border: 1px solid #343434;
  border-radius: 7px;
  font: inherit;
  font-size: 0.88rem;
}

.freshness-field input:focus,
.freshness-field select:focus,
.freshness-toolbar select:focus {
  border-color: var(--freshness-yellow);
  outline: 2px solid rgba(255, 201, 49, 0.2);
  outline-offset: 1px;
}

.freshness-field input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(82%) sepia(63%) saturate(1021%) hue-rotate(339deg) brightness(103%) contrast(103%);
}

.freshness-apply,
.freshness-secondary-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.freshness-apply {
  border: 1px solid var(--freshness-orange);
  background: var(--freshness-orange);
  color: #090909;
}

.freshness-apply:hover {
  background: var(--freshness-yellow);
  border-color: var(--freshness-yellow);
}

.freshness-secondary-button {
  border: 1px solid #393939;
  background: #171717;
  color: #e5e5e5;
}

.freshness-secondary-button:hover {
  color: var(--freshness-yellow);
  border-color: var(--freshness-orange);
}

.freshness-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.freshness-stat {
  min-width: 0;
  padding: 0.9rem 1rem;
  background: var(--freshness-panel);
  border: 1px solid var(--freshness-border);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0.15rem 1rem;
}

.freshness-stat-label {
  color: #cccccc;
  font-size: 0.84rem;
  font-weight: 600;
}

.freshness-stat strong {
  grid-row: span 2;
  color: var(--freshness-yellow);
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1;
  letter-spacing: -0.025em;
}

.freshness-stat > span:last-child {
  color: var(--freshness-muted);
  font-size: 0.75rem;
}

.freshness-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.15rem 0 0.65rem;
}

.freshness-toolbar-controls,
.freshness-toolbar-actions {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
}

.freshness-toolbar-controls {
  flex-wrap: wrap;
}

.freshness-toolbar-controls > label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.freshness-toolbar select {
  width: auto;
  min-width: 175px;
}

.freshness-interval-tabs {
  display: inline-flex;
  flex: 0 1 auto;
  min-height: 40px;
  padding: 2px;
  background: #0e0e0e;
  border: 1px solid #343434;
  border-radius: 7px;
}

.freshness-interval-tab {
  min-width: 0;
  padding: 0.45rem 0.62rem;
  color: #bdbdbd;
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  transition: color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.freshness-interval-tab:hover:not(:disabled):not([aria-pressed="true"]) {
  color: #f1f1f1;
  background: #242424;
}

.freshness-interval-tab[aria-pressed="true"] {
  color: #111111;
  background: var(--freshness-yellow);
  box-shadow: 0 1px 5px rgba(197, 154, 50, 0.22);
}

.freshness-interval-tab:focus-visible {
  outline: 2px solid var(--freshness-yellow);
  outline-offset: 2px;
}

.freshness-interval-tab:disabled {
  color: #666666;
  cursor: not-allowed;
  opacity: 0.55;
}

.freshness-bot-picker {
  position: relative;
  min-width: 220px;
}

.freshness-format-picker {
  min-width: 165px;
}

.freshness-bot-picker summary {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 40px;
  padding: 0.48rem 0.65rem;
  color: #e5e5e5;
  background: #0e0e0e;
  border: 1px solid #343434;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.88rem;
  list-style: none;
  white-space: nowrap;
}

.freshness-bot-picker summary::-webkit-details-marker {
  display: none;
}

.freshness-bot-picker summary::after {
  content: '';
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-left: auto;
  border: solid #a9a9a9;
  border-width: 0 1px 1px 0;
  transform: translateY(-2px) rotate(45deg);
}

.freshness-bot-picker[open] summary {
  border-color: var(--freshness-yellow);
  outline: 2px solid rgba(197, 154, 50, 0.18);
  outline-offset: 1px;
}

.freshness-bot-picker[open] summary::after {
  transform: translateY(2px) rotate(225deg);
}

.freshness-bot-options {
  position: absolute;
  z-index: 9;
  top: calc(100% + 0.4rem);
  left: 0;
  width: max-content;
  min-width: 100%;
  max-width: min(360px, calc(100vw - 2rem));
  max-height: 300px;
  overflow: auto;
  box-sizing: border-box;
  padding: 0.35rem;
  background: var(--freshness-panel-raised);
  border: 1px solid #3b3b3b;
  border-radius: 9px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45);
}

.freshness-bot-option {
  display: flex !important;
  align-items: center;
  gap: 0.55rem;
  margin: 0 !important;
  padding: 0.5rem 0.55rem;
  border-radius: 6px;
  color: #d9d9d9 !important;
  cursor: pointer;
  font-size: 0.82rem !important;
  white-space: nowrap;
}

.freshness-bot-option:first-child {
  margin-bottom: 0.2rem !important;
  border-bottom: 1px solid #333333;
  border-radius: 5px 5px 0 0;
}

.freshness-bot-option:hover {
  background: #242424;
}

.freshness-bot-option input {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--freshness-yellow);
}

.freshness-load-status {
  color: var(--freshness-muted);
  font-size: 0.8rem;
  align-self: center;
}

.freshness-load-status.is-error {
  color: #ff8a80;
}

.freshness-stage {
  position: relative;
  min-height: 660px;
  overflow: hidden;
  border: 1px solid var(--freshness-border);
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 28%, rgba(217, 93, 57, 0.12), transparent 34%),
    linear-gradient(180deg, #14110f 0%, #0a0a0a 74%);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.025);
}

#freshnessScene {
  display: block;
  width: 100%;
  height: 660px;
  cursor: grab;
  touch-action: none;
}

#freshnessScene:active {
  cursor: grabbing;
}

.freshness-stage-message {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  max-width: min(90%, 520px);
  padding: 0.8rem 1rem;
  color: #dddddd;
  background: rgba(14, 14, 14, 0.92);
  border: 1px solid #353535;
  border-radius: 9px;
  text-align: center;
  pointer-events: none;
}

.freshness-axis,
.freshness-stage-hint {
  position: absolute;
  z-index: 2;
  color: #9d9d9d;
  font-size: 0.74rem;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

.freshness-axis-time {
  left: 1rem;
  top: 1rem;
}

.freshness-axis-height {
  right: 1rem;
  top: 1rem;
}

.freshness-stage-hint {
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 2rem);
  text-align: center;
}

.freshness-legend {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #bdbdbd;
  font-size: 0.72rem;
  pointer-events: none;
}

.freshness-legend-ramp {
  width: 82px;
  height: 7px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--freshness-green), var(--freshness-yellow), var(--freshness-orange));
}

.freshness-scene-tooltip {
  position: absolute;
  z-index: 4;
  min-width: 150px;
  max-width: 245px;
  padding: 0.55rem 0.65rem;
  color: #e8e8e8;
  background: rgba(10, 10, 10, 0.94);
  border: 1px solid #3b3b3b;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 0.76rem;
  line-height: 1.4;
  pointer-events: none;
}

.freshness-scene-tooltip strong {
  display: block;
  color: var(--freshness-yellow);
  margin-bottom: 0.15rem;
}

.freshness-analysis {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.freshness-selection,
.freshness-distribution {
  min-width: 0;
  padding: 1rem;
  background: var(--freshness-panel);
  border: 1px solid var(--freshness-border);
  border-radius: 12px;
}

.freshness-selection-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.freshness-selection-label {
  color: var(--freshness-muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.freshness-selection h3,
.freshness-distribution h3 {
  color: #f1f1f1;
  font-size: 1.05rem;
  margin: 0.1rem 0 0;
}

.freshness-selection p {
  color: #bdbdbd;
  margin: 0.65rem 0 0;
  font-size: 0.86rem;
}

.freshness-selection-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem 1rem;
  margin: 0.9rem 0 0;
}

.freshness-selection-grid div {
  min-width: 0;
}

.freshness-selection-grid dt {
  color: var(--freshness-muted);
  font-size: 0.72rem;
}

.freshness-selection-grid dd {
  color: #eeeeee;
  font-size: 1rem;
  font-weight: 700;
  margin: 0.1rem 0 0;
  overflow-wrap: anywhere;
}

.freshness-band-chart {
  display: flex;
  width: 100%;
  height: 18px;
  margin-top: 1rem;
  overflow: hidden;
  border-radius: 99px;
  background: #242424;
}

.freshness-band-chart span {
  min-width: 2px;
  height: 100%;
}

.freshness-band-chart .band-fresh { background: var(--freshness-green); }
.freshness-band-chart .band-recent { background: var(--freshness-yellow); }
.freshness-band-chart .band-older { background: var(--freshness-orange); }

.freshness-band-legend {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem 1rem;
  margin-top: 0.75rem;
  color: #bdbdbd;
  font-size: 0.76rem;
}

.freshness-band-legend span {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.freshness-band-legend strong {
  color: #e4e4e4;
}

.freshness-footnote {
  color: #888888;
  font-size: 0.75rem;
  margin: 0.75rem 0 0;
  text-align: right;
}

@media (max-width: 1050px) {
  .freshness-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

}

@media (max-width: 760px) {
  .freshness-intro {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 2.2rem;
    gap: 0.5rem;
  }

  .freshness-intro-link {
    margin-top: 0.4rem;
  }

  .freshness-workspace {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }

  .freshness-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .freshness-stats,
  .freshness-analysis {
    grid-template-columns: 1fr;
  }

  .freshness-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .freshness-toolbar-controls,
  .freshness-toolbar-actions {
    justify-content: space-between;
  }

  .freshness-toolbar select {
    flex: 1 1 0;
    min-width: 0;
  }

  .freshness-bot-picker {
    flex: 1 1 0;
    min-width: 0;
  }

  .freshness-interval-tabs {
    flex: 1 1 240px;
  }

  .freshness-stage,
  #freshnessScene {
    min-height: 520px;
    height: 520px;
  }

  .freshness-legend {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 2.65rem;
    justify-content: center;
    flex-wrap: wrap;
  }

  .freshness-selection-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .freshness-intro {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .freshness-filters {
    grid-template-columns: 1fr;
  }

  .freshness-toolbar-controls,
  .freshness-toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .freshness-bot-picker {
    width: 100%;
    min-width: 0;
  }

  .freshness-interval-tabs {
    display: flex;
    width: 100%;
  }

  .freshness-interval-tab {
    flex: 1 1 0;
  }

  .freshness-stat {
    grid-template-columns: 1fr auto;
  }

  .freshness-stage,
  #freshnessScene {
    min-height: 470px;
    height: 470px;
  }

  .freshness-axis-height {
    top: 2.2rem;
  }

  .freshness-band-legend {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .freshness-lab *,
  .freshness-lab *::before,
  .freshness-lab *::after {
    scroll-behavior: auto !important;
  }
}
