:root {
  color-scheme: light;
  --paper: #f7f6f0;
  --surface: #fffefa;
  --ink: #20243d;
  --secondary-ink: #545971;
  --rule: #dedfd7;
  --purple: #59468d;
  --purple-dark: #3e306b;
  --lavender: #ede8f8;
  --teal: #176558;
  --amber: #80501d;
  --display: "Baskervville", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "DM Sans", "Avenir Next", Avenir, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 16rem; }
button, input, select, textarea { font: inherit; }
button, a, input, textarea, select { touch-action: manipulation; }
button, .primary, .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 2.65rem;
  border: 1px solid var(--rule);
  border-radius: .6rem;
  padding: .58rem .95rem;
  background: var(--surface);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  font-size: .9375rem;
  font-weight: 620;
  line-height: 1.3;
  cursor: pointer;
}
button:hover, .secondary:hover { background: #eeeee8; border-color: #b8b8b9; }
.primary {
  color: white;
  background: var(--purple);
  border-color: var(--purple);
}
.primary:hover { background: var(--purple-dark); border-color: var(--purple-dark); }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid #6b54bb; outline-offset: 3px; }
a { color: var(--purple); text-underline-offset: .18em; }
img { display: block; max-width: 100%; }
::selection { background: #ded2ff; color: var(--ink); }

.shell { width: min(100%, 85rem); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 4.25rem); }
header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .85rem 1.5rem;
  min-height: 5.25rem;
  padding-block: .8rem;
  border-bottom: 1px solid var(--rule);
}
header.top:not(.shell) > .shell { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: .85rem 1.5rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink); font-weight: 750; letter-spacing: -.045em; font-size: 1.4rem; text-decoration: none; }
.brand img, .brand > svg { width: 2.35rem; height: 2.35rem; flex: none; }
.tabs { display: flex; align-items: center; flex-wrap: wrap; gap: .22rem; }
.tabs button { min-height: 2.45rem; color: var(--secondary-ink); background: transparent; border: 1px solid transparent; font-weight: 560; }
.tabs button:hover { color: var(--ink); background: #efeee8; }
.tabs button[aria-current="page"] { background: var(--lavender); color: var(--purple-dark); }

main { min-width: 0; padding-block: clamp(1.45rem, 3.8vw, 3.7rem) 4rem; }
body > main:not(.shell), body > header.top:not(.shell) {
  width: min(calc(100% - clamp(2rem, 8vw, 8.5rem)), 76.5rem);
  margin-inline: auto;
}
h1, h2, h3, h4, p { margin-block: 0; }
h1, h2 { font-family: var(--display); font-weight: 500; }
h1 { font-size: clamp(2.65rem, 5.8vw, 5.15rem); line-height: 1.03; letter-spacing: -.057em; text-wrap: balance; }
h2 { font-size: clamp(1.65rem, 2.55vw, 2.25rem); line-height: 1.12; letter-spacing: -.045em; }
h3 { font-size: 1.1rem; letter-spacing: -.025em; line-height: 1.3; }
p, li { line-height: 1.55; }
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 2rem; margin-bottom: clamp(1.3rem, 2.5vw, 2.35rem); }
.hero > div:first-child { min-width: 0; }
.hero p:not(.eyebrow) { color: var(--secondary-ink); max-width: 65ch; margin-top: .55rem; }
.eyebrow { display: block; font: 650 .76rem/1.45 var(--mono); letter-spacing: .105em; text-transform: uppercase; color: var(--teal); margin-bottom: .65rem; }
.actions, .row { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; min-width: 0; }
.stack { display: grid; gap: 1rem; min-width: 0; }
.actions > *, .row > * { max-width: 100%; }
.muted, small { color: var(--secondary-ink); }
small { font-size: .825rem; line-height: 1.45; }
input:not([type="checkbox"]):not([type="radio"]), textarea, select {
  min-width: 0;
  max-width: 100%;
  min-height: 2.7rem;
  padding: .65rem .85rem;
  border: 1px solid #c6c8c5;
  border-radius: .55rem;
  color: var(--ink);
  background-color: var(--surface);
  font-size: 1rem;
}
input::placeholder, textarea::placeholder { color: #686d7d; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--purple); }
textarea { width: 100%; resize: vertical; line-height: 1.45; }
label.field, div.field { display: grid; gap: .4rem; font-size: .9rem; font-weight: 600; }
.field input, .field select { width: 100%; }
.grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr); align-items: start; gap: clamp(.85rem, 1.6vw, 1.4rem); }
.panel {
  min-width: 0;
  padding: clamp(1rem, 2.2vw, 1.85rem);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 1.05rem;
  box-shadow: 0 2px 4px #28304405;
}
.panel > :where(p, ul, ol, .list, .row, canvas, .graph, .bar-row, .actions, form, .chatlog):not(:first-child) { margin-top: .9rem; }
.panel + .panel:not(.grid > .panel):not(.stack > .panel) { margin-top: 1rem; }
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(.55rem, 1.35vw, 1rem);
  margin-block: 1.2rem;
}
.metric {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .3rem;
  padding: clamp(.85rem, 1.65vw, 1.35rem);
  border: 1px solid var(--rule);
  border-radius: .85rem;
  background: var(--surface);
}
.metric strong { font: 500 clamp(1.85rem, 3.5vw, 3.15rem)/1.02 var(--display); letter-spacing: -.055em; font-variant-numeric: lining-nums tabular-nums; }
.metric small { font-weight: 580; font-size: .875rem; }
.graph {
  display: block;
  position: relative;
  isolation: isolate;
  width: 100%;
  height: clamp(17.5rem, 33vw, 26rem);
  overflow: hidden;
  border-radius: .85rem;
  background-color: #342747;
  background-image: radial-gradient(ellipse at 65% 20%, #59436a60, transparent 63%), radial-gradient(#c7b6ce35 .7px, transparent .8px);
  background-size: auto, 17px 17px;
  color: #f5f0fe;
}
.graph canvas { display: block; width: 100%; height: 100%; }
.bar-row { display: grid; grid-template-columns: minmax(5rem, 1.3fr) minmax(2.2rem, 1fr) auto; align-items: center; gap: .6rem; }
.bar-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.bar-row i { display: block; height: .45rem; border-radius: .3rem; background: #947cbd; }
.bar-row b { color: var(--secondary-ink); font: 580 .83rem var(--mono); font-variant-numeric: tabular-nums; }
.list { min-width: 0; margin: 0; padding: 0; list-style: none; }
.person { display: flex; width: 100%; align-items: center; gap: .8rem; text-align: left; padding: .85rem .25rem; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; background: transparent; min-width: 0; }
.person:last-child { border-bottom-color: transparent; }
.person > div, .person > span { min-width: 0; overflow-wrap: anywhere; }
.person strong, .person small { display: block; }
.person small { margin-top: .18rem; }
button.person { justify-content: flex-start; }
button.person:hover { background: #f5f3fa; }
.person.selected, .selected:not(.person) { background: var(--lavender); color: var(--purple-dark); }
.badge, .sample { display: inline-flex; width: fit-content; max-width: 100%; align-items: center; padding: .3rem .65rem; border-radius: 2rem; font-size: .8rem; font-weight: 620; line-height: 1.3; }
.badge { background: #e1f0e9; color: var(--teal); }
.sample { background: #fbecd6; color: var(--amber); }
.notice, .error { padding: .85rem 1rem; border-radius: .65rem; line-height: 1.5; overflow-wrap: anywhere; }
.notice { color: #3a4c50; background: #e8efea; border: 1px solid #cbdcd0; }
.error { color: #80273d; background: #f9e8ed; border: 1px solid #e8c6cd; }
.notice:empty, .error:empty { display: none; }

dialog { width: min(34rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); padding: clamp(1.15rem, 3vw, 2rem); border: 1px solid var(--rule); border-radius: 1.15rem; background: var(--surface); color: var(--ink); box-shadow: 0 1.5rem 6rem #19192d40; }
dialog::backdrop { background: #201b33a3; }
dialog :where(form, .stack, .actions):not(:first-child) { margin-top: 1rem; }
.chatlog { min-height: 7rem; max-height: 26rem; overflow: auto; display: flex; flex-direction: column; align-items: flex-start; gap: .65rem; padding: .2rem; }
.bubble { max-width: min(90%, 46rem); color: var(--ink); background: #f0edf6; border-radius: .9rem .9rem .9rem .25rem; padding: .65rem .9rem; word-break: break-word; white-space: pre-wrap; }
.bubble small { display: block; margin-bottom: .2rem; }
.bubble.mine, .bubble[data-own="true"] { align-self: flex-end; background: #e2f1e9; border-radius: .9rem .9rem .25rem .9rem; }

@media (max-width: 55rem) {
  .grid { grid-template-columns: 1fr; }
  .hero { align-items: flex-start; }
  .graph { height: clamp(17.5rem, 52vw, 26rem); }
}
@media (max-width: 42rem) {
  header.top { gap: .65rem; }
  .tabs { flex-basis: 100%; order: 3; overflow-x: auto; flex-wrap: nowrap; padding-block: .2rem; scrollbar-width: thin; }
  .tabs button { flex: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero .actions { width: 100%; }
  .panel { border-radius: .85rem; }
}
@media (max-width: 25rem) {
  .tabs button { padding-inline: .65rem; }
  .hero .actions > * { flex: 1 1 auto; }
  .bar-row { grid-template-columns: minmax(4rem, 1.3fr) minmax(1.5rem, .75fr) auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; }
}
