:root {
  --ink: #160526;
  --paper: #fbf6ff;
  --paper-deep: #efe4ff;
  --lime: #ff5bd6;
  --lime-dark: #8f39ff;
  --mint: #82ecff;
  --rule: #c9b6ea;
  --muted: #5f4b7f;
  --danger: #c43472;
  --white: #fffaff;
  --shadow: 8px 10px 26px rgba(22, 5, 38, 0.16);
  font-family: "Aptos Narrow", "Bahnschrift Condensed", "Franklin Gothic Medium", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
}

button, input { font: inherit; }

button { color: inherit; }

button:focus-visible, input:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.masthead {
  min-height: 74px;
  padding: 0 3.5vw;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--ink);
  background: rgba(251, 246, 255, 0.94);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  font-size: .82rem;
  font-weight: 900;
  letter-spacing: .12em;
}

.brand-mark {
  display: flex;
  align-items: end;
  width: 25px;
  height: 26px;
  gap: 2px;
}

.brand-mark i { width: 5px; background: var(--ink); }
.brand-mark i:nth-child(1) { height: 9px; background: var(--mint); }
.brand-mark i:nth-child(2) { height: 18px; background: var(--lime); }
.brand-mark i:nth-child(3) { height: 13px; background: var(--white); }
.brand-mark i:nth-child(4) { height: 24px; background: var(--lime-dark); }

.masthead p {
  margin: 0;
  font-size: .9rem;
  color: var(--muted);
}

.privacy-stamp {
  justify-self: end;
  border: 1px solid var(--ink);
  padding: 8px 11px;
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: var(--white);
}

.privacy-stamp span { color: var(--lime-dark); }

main { min-height: calc(100vh - 140px); }

.intake {
  min-height: calc(100vh - 74px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(390px, .95fr);
  align-items: stretch;
  border-bottom: 1px solid var(--ink);
}

.intake-copy {
  padding: clamp(54px, 10vh, 112px) 5vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--ink);
  color: var(--paper);
  position: relative;
  overflow: hidden;
}

.intake-copy::after {
  content: "";
  position: absolute;
  width: 310px;
  height: 310px;
  right: -80px;
  bottom: -155px;
  border: 56px solid var(--lime);
  border-radius: 50%;
  opacity: .9;
}

h1, h2, p { text-wrap: balance; }

h1 {
  max-width: 760px;
  margin: 0 0 30px;
  font-size: clamp(3.4rem, 7vw, 6rem);
  line-height: .89;
  letter-spacing: -.035em;
  text-transform: uppercase;
}

.intake-copy p {
  max-width: 58ch;
  margin: 0;
  color: #e8dcff;
  font-size: clamp(1rem, 1.4vw, 1.2rem);
  line-height: 1.55;
}

.drop-zone {
  margin: clamp(30px, 7vw, 88px);
  min-height: 420px;
  padding: 45px;
  border: 2px dashed var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(251, 252, 247, .68);
  transition: background .2s ease-out, box-shadow .2s ease-out, transform .2s ease-out;
}

.drop-zone.dragging {
  background: var(--lime);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.drop-zone input { position: absolute; opacity: 0; pointer-events: none; }

.drop-zone strong {
  display: block;
  font-size: clamp(1.8rem, 3vw, 3.1rem);
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 12px;
}

.drop-zone span {
  display: block;
  color: var(--muted);
  margin-bottom: 34px;
}

.button {
  min-height: 44px;
  border: 1px solid var(--ink);
  padding: 11px 17px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .045em;
  cursor: pointer;
}

.button.primary { background: var(--lime); box-shadow: 4px 4px 0 var(--ink); }
.button.primary:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.button.secondary { background: transparent; }
.button.secondary:hover { background: var(--ink); color: var(--paper); }

.text-button {
  border: 0;
  padding: 6px 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.drop-zone .text-button { margin-top: 24px; }

.file-state {
  position: fixed;
  left: 50%;
  top: 92px;
  z-index: 50;
  transform: translateX(-50%);
  width: min(540px, calc(100% - 32px));
  padding: 16px 20px;
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow);
  border: 1px solid var(--paper);
}

.file-state.error { background: var(--danger); }

.workspace {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  align-items: start;
}

.query-panel {
  position: sticky;
  top: 74px;
  min-height: calc(100vh - 74px);
  max-height: calc(100vh - 74px);
  overflow-y: auto;
  border-right: 1px solid var(--ink);
  background: var(--paper-deep);
}

.query-heading {
  padding: 26px 24px 20px;
  border-bottom: 1px solid var(--rule);
}

.query-heading h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
  text-transform: uppercase;
}

fieldset {
  margin: 0;
  padding: 22px 24px 25px;
  border: 0;
  border-bottom: 1px solid var(--rule);
}

legend {
  padding: 0;
  font-size: .76rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .09em;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

input[type="time"], input[type="date"] {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 7px 8px;
  color: var(--ink);
  background: var(--white);
}

.time-pair, .date-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: end;
  margin-top: 12px;
}

.date-pair { grid-template-columns: 1fr 1fr; }
.time-pair > span { padding-bottom: 12px; }

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.presets button {
  border: 1px solid var(--rule);
  padding: 6px 8px;
  background: transparent;
  cursor: pointer;
  font-size: .72rem;
}

.presets button:hover, .presets button.active { border-color: var(--ink); background: var(--lime); }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 12px;
  border: 1px solid var(--ink);
}

.segmented label { display: block; }
.segmented input { position: absolute; opacity: 0; }
.segmented span {
  display: block;
  padding: 10px 6px;
  text-align: center;
  color: var(--ink);
  cursor: pointer;
}
.segmented label + label span { border-left: 1px solid var(--ink); }
.segmented input:checked + span { background: var(--ink); color: var(--paper); }

.data-note {
  display: grid;
  gap: 7px;
  padding: 20px 24px;
  color: var(--muted);
  font-size: .76rem;
}

.analysis { min-width: 0; }

.profile, .trend-section, .heatmap-section, .findings {
  padding: 34px clamp(22px, 3.5vw, 52px);
  border-bottom: 1px solid var(--ink);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.section-heading h2, .findings h2 {
  margin: 0 0 7px;
  font-size: clamp(1.45rem, 2.2vw, 2.1rem);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: -.02em;
}

.section-heading p {
  margin: 0;
  max-width: 65ch;
  color: var(--muted);
  line-height: 1.45;
}

.profile-key {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  white-space: nowrap;
}

.profile-key span { width: 15px; height: 15px; background: var(--lime); border: 1px solid var(--ink); }

.chart {
  width: 100%;
  min-height: 260px;
  overflow: hidden;
}

.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-family: inherit; font-size: 11px; }
.chart .grid-line { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 5; }
.chart .axis-line { stroke: var(--ink); stroke-width: 1; }
.chart .profile-bar { fill: var(--mint); }
.chart .profile-bar.in-window { fill: var(--lime); stroke: var(--ink); stroke-width: 1; }
.chart .trend-area { fill: rgba(130, 236, 255, .35); }
.chart .trend-line { fill: none; stroke: var(--ink); stroke-width: 3; vector-effect: non-scaling-stroke; }
.chart .trend-point { fill: var(--lime); stroke: var(--ink); stroke-width: 2; }

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--ink);
  color: var(--paper);
  border-bottom: 1px solid var(--ink);
}

.summary-strip > div {
  min-width: 0;
  padding: 24px clamp(16px, 2vw, 28px);
}

.summary-strip > div + div { border-left: 1px solid #6e5891; }
.summary-strip span, .summary-strip small { display: block; color: #decfff; }
.summary-strip span { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.summary-strip strong { display: block; margin: 8px 0 5px; font-size: clamp(1.35rem, 2.4vw, 2.25rem); color: var(--lime); }
.summary-strip small { font-size: .76rem; line-height: 1.35; }

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr);
}

.heatmap-section { border-right: 1px solid var(--ink); }

.heatmap {
  display: grid;
  grid-template-columns: 48px repeat(24, minmax(13px, 1fr));
  gap: 3px;
  align-items: center;
  overflow-x: auto;
  padding-bottom: 8px;
}

.heatmap .day-label, .heatmap .hour-label {
  font-size: .67rem;
  color: var(--muted);
}

.heatmap .hour-label { text-align: center; min-width: 13px; }
.heat-cell {
  aspect-ratio: 1;
  min-width: 13px;
  background: var(--paper-deep);
  border: 1px solid rgba(22, 5, 38, .08);
}
.heat-cell:hover { outline: 2px solid var(--ink); outline-offset: 1px; }

.heatmap-scale {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 12px;
  color: var(--muted);
  font-size: .68rem;
}
.heatmap-scale i { width: 17px; height: 11px; border: 1px solid rgba(19,34,24,.1); }
.heatmap-scale i:nth-of-type(1) { background: #f3ebff; }
.heatmap-scale i:nth-of-type(2) { background: #d3c0ff; }
.heatmap-scale i:nth-of-type(3) { background: #ff5bd6; }
.heatmap-scale i:nth-of-type(4) { background: #8f39ff; }
.heatmap-scale i:nth-of-type(5) { background: #24093f; }

.findings { background: var(--white); }
.findings h2 { margin-bottom: 23px; }
.finding {
  padding: 18px 0;
  border-top: 1px solid var(--rule);
}
.finding:first-child { border-top-color: var(--ink); }
.finding strong { display: block; margin-bottom: 6px; font-size: 1.02rem; }
.finding p { margin: 0; color: var(--muted); line-height: 1.45; font-size: .88rem; }
.finding b { background: var(--lime); padding: 1px 4px; }

.standing-note {
  margin: 0;
  padding: 18px clamp(22px, 3.5vw, 52px);
  color: var(--muted);
  font-size: .78rem;
  border-bottom: 1px solid var(--ink);
}

footer {
  min-height: 66px;
  padding: 0 3.5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--lime);
  font-size: .74rem;
  font-weight: 900;
  letter-spacing: .08em;
}

[hidden] { display: none !important; }

@media (max-width: 980px) {
  .masthead { grid-template-columns: 1fr auto; }
  .masthead p { display: none; }
  .intake { grid-template-columns: 1fr; }
  .intake-copy { min-height: 48vh; }
  .drop-zone { min-height: 330px; }
  .workspace { grid-template-columns: 1fr; }
  .query-panel {
    position: static;
    min-height: 0;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--ink);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  .query-heading, .data-note { grid-column: 1 / -1; }
  fieldset { border-right: 1px solid var(--rule); }
  .lower-grid { grid-template-columns: 1fr; }
  .heatmap-section { border-right: 0; }
}

@media (max-width: 680px) {
  .masthead { min-height: 64px; padding: 0 18px; }
  .privacy-stamp { padding: 7px 8px; }
  .intake { min-height: calc(100vh - 64px); }
  .intake-copy { padding: 48px 24px 70px; }
  h1 { font-size: clamp(3rem, 15vw, 4.8rem); }
  .drop-zone { margin: 24px; padding: 30px 20px; }
  .query-panel { grid-template-columns: 1fr; }
  .query-heading, .data-note { grid-column: auto; }
  fieldset { border-right: 0; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-strip > div:nth-child(3) { border-left: 0; border-top: 1px solid #6e5891; }
  .summary-strip > div:nth-child(4) { border-top: 1px solid #6e5891; }
  .section-heading { display: grid; }
  .profile-key { grid-row: 1; }
  .chart { min-height: 210px; overflow-x: auto; }
  .chart svg { min-width: 620px; }
  footer { align-items: flex-start; flex-direction: column; padding: 20px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
