/* rooql.com/play. Everything is nested under .play so it cannot touch the rest of the site;
   the page keeps style.css for the header, footer, fonts and brand tokens.
   Layout: a column of answers (question picker, then cards of chart + generated SQL)
   beside a narrow rail that holds the model's metric definitions. */
.play {
  --paper: #f9f6ee;
  --surface: #fffdf8;
  --ink: #153f2b;
  --muted: #576b58;
  --line: #d8d5c3;
  --line-strong: #315b40;
  --green: #26734d;
  --orange: #d66b39;
  --wash: #eef0e2;
  --code-bg: #153f2b;
  --code-fg: #f3efe2;
  --code-dim: #a9c0ad;
  --bad: #a3341c;
  --s1: #1f8553;
  --s2: #2a78d6;
  --s3: #eb6834;
  --s4: #6250d6;
  --s5: #eda100;
  --s6: #e87ba4;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding-block: 56px 96px;
  font-size: 15px;
  line-height: 1.55;

  .intro {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--line);
  }
  .intro .eyebrow {
    margin: 0;
  }
  .intro h1 {
    font-size: clamp(40px, 5vw, 60px);
    line-height: 1.05;
  }
  .picker {
    background: var(--surface);
    border: 1.5px solid var(--line-strong);
    border-radius: 10px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  #metrics {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  * {
    box-sizing: border-box;
  }
  h1,
  h2,
  h3,
  p {
    margin: 0;
  }
  button,
  input,
  select {
    font: inherit;
    color: inherit;
  }
  :focus-visible {
    outline: 2px solid var(--orange);
    outline-offset: 2px;
  }

  .lede {
    max-width: 66ch;
    color: var(--muted);
    font-size: 16px;
  }
  .status {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
  }
  .status span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
  }
  .status b {
    font-weight: 500;
    color: var(--ink);
  }
  .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line-strong);
    flex: none;
  }
  .dot.ok {
    background: var(--s1);
  }
  .dot.wait {
    background: var(--s5);
  }
  .dot.bad {
    background: var(--bad);
  }

  .cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 36px;
    align-items: start;
  }
  .main {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
  }
  @media (max-width: 920px) {
    .cols {
      grid-template-columns: minmax(0, 1fr);
    }
  }

  .btn {
    padding: 10px 18px;
    border-radius: 7px;
    border: 1.5px solid var(--ink);
    background: var(--ink);
    color: var(--paper);
    font-weight: 600;
    cursor: pointer;
  }
  .btn:hover {
    background: var(--green);
    border-color: var(--green);
  }
  .btn:disabled {
    opacity: 0.45;
    cursor: default;
    background: var(--ink);
    border-color: var(--ink);
  }
  .btn.quiet {
    background: transparent;
    color: var(--ink);
  }
  .btn.quiet:hover {
    background: var(--wash);
    border-color: var(--ink);
  }
  .hint {
    font-size: 13px;
    color: var(--muted);
  }
  .hint.err {
    color: var(--bad);
  }
  .label {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .chip {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: transparent;
    cursor: pointer;
    font-size: 13.5px;
  }
  .chip:hover {
    background: var(--wash);
  }
  .group {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  details.builder {
    border-top: 1px solid var(--line);
    padding-top: 12px;
  }
  details.builder > summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
  }
  .bgrid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 14px;
  }
  .mchips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .mchips label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 12.5px;
    cursor: pointer;
  }
  .mchips label:has(input:checked) {
    border-color: var(--green);
    background: var(--wash);
  }
  .mchips input {
    accent-color: var(--green);
    margin: 0;
  }
  .selrow {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: end;
  }
  .selrow .f {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
  }
  select {
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper);
    max-width: 100%;
  }

  /* answers */
  .feed {
    display: flex;
    flex-direction: column;
    gap: 24px;
  }
  .answer {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
  }
  .ahead {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }
  .ahead h3 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 22px;
    line-height: 1.2;
    text-wrap: balance;
  }
  .ahead .asked {
    font-size: 13px;
    color: var(--muted);
    margin-top: 3px;
  }
  .x {
    border: 0;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    padding: 2px 4px;
    border-radius: 4px;
    flex: none;
  }
  .x:hover {
    color: var(--ink);
    background: var(--wash);
  }
  .viz {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 22px 28px;
    min-width: 0;
  }
  .viz.single {
    grid-template-columns: minmax(0, 1fr);
  }
  .pending {
    color: var(--muted);
    font-size: 14px;
  }
  .errbox {
    color: var(--bad);
    font-size: 14px;
  }
  .errbox code {
    font-family: var(--mono);
    font-size: 12.5px;
  }
  .chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
  }
  .chart h4 {
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
  }
  .chart h4 small {
    font-weight: 400;
    color: var(--muted);
    font-size: 12.5px;
    margin-left: 6px;
  }
  .plot {
    position: relative;
    min-width: 0;
  }
  .plot svg {
    display: block;
    width: 100%;
    overflow: visible;
  }
  .plot text {
    font-family: var(--sans);
    font-size: 11px;
    fill: var(--muted);
    font-variant-numeric: tabular-nums;
  }
  .grid {
    stroke: var(--line);
    stroke-width: 1;
  }
  .tip {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    background: var(--ink);
    color: var(--paper);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 12px;
    line-height: 1.45;
    white-space: nowrap;
    z-index: 2;
    font-variant-numeric: tabular-nums;
  }
  .tip .th {
    opacity: 0.75;
    margin-bottom: 2px;
  }
  .tip .tr {
    display: flex;
    align-items: center;
    gap: 7px;
  }
  .tip .tr i {
    width: 12px;
    height: 2px;
    border-radius: 1px;
    flex: none;
  }
  .tip .tr b {
    font-weight: 600;
  }
  .tip .tr span {
    opacity: 0.8;
  }
  .legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    font-size: 12.5px;
    color: var(--muted);
  }
  .legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .legend i {
    width: 14px;
    height: 2px;
    border-radius: 1px;
  }
  .bars {
    display: grid;
    grid-template-columns: minmax(70px, max-content) minmax(0, 1fr) max-content;
    gap: 7px 10px;
    align-items: center;
    font-size: 13px;
  }
  .bars .bl {
    color: var(--ink);
    overflow-wrap: anywhere;
    max-width: 150px;
  }
  .bars .bt {
    height: 16px;
    display: flex;
  }
  .bars .bt i {
    display: block;
    height: 100%;
    min-width: 2px;
    background: var(--s1);
    border-radius: 0 4px 4px 0;
  }
  .bars .bv {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    text-align: right;
  }
  .bars .row {
    display: contents;
  }
  .bars .row:hover .bt i {
    filter: brightness(1.15);
  }
  .bars .row:hover .bl {
    font-weight: 600;
  }
  .tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 18px 24px;
  }
  .tile .tv {
    font-family: var(--serif);
    font-size: 34px;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
  }
  .tile .tn {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--green);
    margin-top: 4px;
  }
  .tile .td {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 2px;
  }
  .more {
    font-size: 12.5px;
    color: var(--muted);
  }

  .sql {
    background: var(--code-bg);
    color: var(--code-fg);
    border-radius: 8px;
    min-width: 0;
  }
  .sqlhead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 0 14px;
  }
  .sqlhead span {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--code-dim);
  }
  .sqlhead button {
    border: 1px solid transparent;
    background: none;
    color: var(--code-dim);
    font-family: var(--mono);
    font-size: 11.5px;
    padding: 3px 8px;
    border-radius: 5px;
    cursor: pointer;
  }
  .sqlhead button:hover {
    color: var(--code-fg);
    border-color: var(--code-dim);
  }
  .sql pre {
    margin: 0;
    padding: 8px 14px 14px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.6;
  }
  .sql pre .kw {
    color: var(--code-dim);
  }
  .answer details > summary {
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
  }
  .tablewrap {
    overflow-x: auto;
    margin-top: 10px;
    max-height: 340px;
    overflow-y: auto;
  }
  table {
    border-collapse: collapse;
    font-size: 13px;
    width: 100%;
  }
  th,
  td {
    text-align: left;
    padding: 5px 14px 5px 0;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
  }
  th {
    font-family: var(--mono);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--muted);
    position: sticky;
    top: 0;
    background: var(--surface);
  }
  td.n,
  th.n {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
  .qjson {
    margin: 10px 0 0;
    font-family: var(--mono);
    font-size: 12px;
    overflow-x: auto;
    color: var(--muted);
  }
  .prov {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    padding-top: 12px;
  }
  .prov b {
    font-weight: 500;
    color: var(--ink);
  }

  /* rail */
  .rail {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
  }
  .rail h2 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 22px;
  }
  .rail .sub {
    font-size: 13.5px;
    color: var(--muted);
  }
  .metric {
    border-top: 1px solid var(--line);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
  }
  .metric .mn {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--green);
  }
  .metric .md {
    font-size: 13.5px;
  }
  .metric code {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--muted);
    overflow-wrap: anywhere;
  }
  .rail details {
    border-top: 1px solid var(--line);
    padding-top: 12px;
  }
  .rail details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 13.5px;
  }
  .rail details pre {
    font-family: var(--mono);
    font-size: 11.5px;
    overflow-x: auto;
    max-height: 420px;
    color: var(--muted);
    margin: 10px 0 0;
  }
  .fields {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .fields b {
    color: var(--ink);
    font-weight: 500;
  }
  .rail a {
    color: var(--green);
  }
  @media (prefers-reduced-motion: no-preference) {
    .bars .bt i {
      transition: filter 0.12s;
    }
  }
  [hidden] {
    display: none !important;
  }
  .rail a {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}
