/* ============================================================
   Brainzie Snugstar — the product's own pages (projects list, project workspace: data grid, analysis, graph).
   Built on palette.css + theme.css; chart tokens are mapped onto the app's ink/surface so the figures follow the theme.
   ============================================================ */

:root {
  --tcc-chart-ink: var(--ink);
  --tcc-chart-surface: var(--white);
  --tcc-chart-grid: var(--line);
  --tcc-chart-fg: var(--muted);
  --tcc-chart-axis: color-mix(in srgb, var(--ink) 28%, var(--paper));
  --cell-bad: color-mix(in srgb, var(--accent-coral) 16%, transparent);
}

/* Categorical chart slots, dark steps (validated on this app's dark surface #1E1834: all checks pass). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tcc-chart-series-1: #3987e5; --tcc-chart-series-2: #d95926; --tcc-chart-series-3: #199e70; --tcc-chart-series-4: #c98500;
    --tcc-chart-series-5: #d55181; --tcc-chart-series-6: #008300; --tcc-chart-series-7: #9085e9; --tcc-chart-series-8: #e66767;
  }
}
:root[data-theme="dark"] {
  --tcc-chart-series-1: #3987e5; --tcc-chart-series-2: #d95926; --tcc-chart-series-3: #199e70; --tcc-chart-series-4: #c98500;
  --tcc-chart-series-5: #d55181; --tcc-chart-series-6: #008300; --tcc-chart-series-7: #9085e9; --tcc-chart-series-8: #e66767;
}

/* ---- Projects list ---- */
.project-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .6rem; }
.project-card { display: flex; align-items: center; gap: 1rem; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-s); padding: .8rem 1rem; }
.project-card__main { flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.project-card__name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.project-card__meta { color: var(--muted); font-size: .85rem; margin-top: .15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { background: var(--white); border: 1px dashed var(--line); border-radius: var(--radius); padding: 2rem 1.5rem; text-align: center; color: var(--ink-soft); }
.empty-state h2 { margin-top: 0; color: var(--ink); font-family: var(--font-display); }

/* ---- Project workspace ---- */
.proj-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-bottom: 1rem; }
.proj-head__name { flex: 1 1 18rem; min-width: 0; font: 600 1.5rem/1.2 var(--font-display); color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: var(--radius-s); padding: .25rem .4rem; }
.proj-head__name:hover, .proj-head__name:focus { border-color: var(--line); background: var(--white); outline: none; }
.save-state { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.save-state--failed { color: var(--accent-coral); }

.proj-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) {
  .proj-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; }
  .proj-layout__wide { grid-column: 1 / -1; }
}
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; min-width: 0; }
.panel h2 { margin: 0 0 .75rem; font: 600 1.05rem var(--font-display); color: var(--ink); display: flex; align-items: center; gap: .5rem; }
.panel h3 { margin: 1.1rem 0 .5rem; font: 600 .95rem var(--font-display); color: var(--ink); }
.panel__tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.panel__hint { color: var(--muted); font-size: .85rem; margin: .5rem 0 0; }

/* The data grid: a spreadsheet a Prism user recognises — one column per group, row numbers, paste-able. */
.data-grid-wrap { overflow: auto; max-height: 60vh; border: 1px solid var(--line); border-radius: var(--radius-s); }
.data-grid { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; table-layout: fixed; width: max(100%, calc(2.6rem + var(--groups, 2) * 6.5rem)); }
.data-grid th, .data-grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; background: var(--white); }
.data-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--paper-2); }
.data-grid__rownum { position: sticky; left: 0; z-index: 1; width: 2.6rem; min-width: 2.6rem; text-align: right; color: var(--muted); font-size: .8rem; padding: 0 .45rem !important; background: var(--paper-2) !important; }
.data-grid thead .data-grid__rownum { z-index: 3; }
.data-grid__head { display: flex; align-items: center; min-width: 0; }
.data-grid__title { flex: 1; min-width: 0; width: 100%; font-weight: 600; color: var(--ink); background: transparent; border: 0; padding: .45rem .5rem; }
.data-grid__remove { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: .2rem .45rem; font-size: 1rem; line-height: 1; }
.data-grid__remove:hover { color: var(--accent-coral); }
.data-grid__cell { width: 100%; min-width: 0; border: 0; background: transparent; color: var(--ink); padding: .4rem .5rem; text-align: right; font: inherit; }
.data-grid__cell--bad { background: var(--cell-bad); }
.data-grid input { box-sizing: border-box; }
.data-grid__title:focus, .data-grid__cell:focus { outline: 2px solid var(--brand); outline-offset: -2px; background: var(--white); }
.data-grid__swatch { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-left: .45rem; flex: none; }
.grid-error { color: var(--accent-coral); font-size: .85rem; margin: .5rem 0 0; }

/* Analysis */
.advisor { border-left: 4px solid var(--brand); background: var(--paper-2); border-radius: var(--radius-s); padding: .75rem 1rem; }
.advisor__test { font: 600 1.05rem var(--font-display); color: var(--ink); }
.advisor__badge { display: inline-block; font: 600 .7rem var(--font-body); text-transform: uppercase; letter-spacing: .04em; padding: .15rem .45rem; border-radius: 999px; margin-left: .5rem; vertical-align: middle; background: var(--brand-tint); color: var(--brand-deep); }
.advisor__badge--override { background: color-mix(in srgb, var(--secondary) 14%, transparent); color: var(--secondary); }
.advisor ul { margin: .5rem 0 0; padding-left: 1.1rem; color: var(--ink-soft); }
.advisor li + li { margin-top: .3rem; }
.finding { font-size: 1rem; color: var(--ink); margin: .9rem 0 0; line-height: 1.5; }
.choices { display: grid; gap: .6rem 1rem; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); margin: .9rem 0 .25rem; }
.choices label { display: grid; gap: .25rem; font-size: .8rem; color: var(--muted); font-weight: 500; }
.choices select, .choices input[type=text] { font: inherit; font-size: .9rem; color: var(--ink); background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .5rem; }
.choices .check { display: flex; align-items: center; gap: .45rem; color: var(--ink); font-size: .9rem; }
.notice { border-radius: var(--radius-s); padding: .6rem .8rem; background: color-mix(in srgb, var(--accent-orange) 14%, transparent); color: var(--ink); font-size: .9rem; margin: .5rem 0 0; }
.notice--muted { background: var(--paper-2); color: var(--ink-soft); }

.kv { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.kv th, .kv td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv th { color: var(--ink-soft); font-weight: 500; width: 50%; }
.kv td { color: var(--ink); }
.stats-table-wrap { overflow-x: auto; }
.stats-table { border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; min-width: 100%; }
.stats-table th, .stats-table td { padding: .35rem .6rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; color: var(--ink-soft); font-weight: 500; }
.stats-table thead th { color: var(--ink); font-weight: 600; background: var(--paper-2); position: sticky; top: 0; }
.stats-table .ns { color: var(--muted); }
.methods { background: var(--paper-2); border-radius: var(--radius-s); padding: .75rem .9rem; line-height: 1.55; color: var(--ink); font-size: .92rem; }
.figure-box { display: flex; justify-content: center; background: var(--white); border-radius: var(--radius-s); padding: .25rem 0; }

/* ---- Two ways to anything: the section bar (straight) and "What next?" (guided) ---- */
:root { --tcc-nextstep-accent: var(--brand); --tcc-nextstep-muted: var(--muted); --tcc-paid-badge-bg: var(--brand-tint); --tcc-paid-badge-fg: var(--brand-deep); }
.proj-sections { position: sticky; top: var(--tcc-shell-banners-height, 0px); z-index: 5; display: flex; flex-wrap: wrap; gap: .25rem; margin: 0 0 1rem; padding: .35rem; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 999px; width: fit-content; max-width: 100%; }
.proj-sections a { padding: .3rem .8rem; border-radius: 999px; color: var(--ink-soft); text-decoration: none; font-weight: 500; font-size: .9rem; }
.proj-sections a:hover { background: var(--brand-tint); color: var(--brand-deep); }
.proj-nextsteps { margin-bottom: 1rem; }
/* The section bar stops below team.core's ShellBanners (the demo / storage warnings) when they show; a jump lands below both. */
section[id], h3[id], #design { scroll-margin-top: calc(4rem + var(--tcc-shell-banners-height, 0px)); }

/* The design question: two big buttons, the chosen one filled. */
.design { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: 0 0 .75rem; }
.design__label { font: 600 .95rem var(--font-display); color: var(--ink); }
.design__options { display: flex; flex-wrap: wrap; gap: .5rem; }
.design__option { display: grid; text-align: left; gap: .1rem; padding: .5rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--white); color: var(--ink); cursor: pointer; font: inherit; }
.design__option span { font-size: .8rem; color: var(--muted); }
.design__option:hover { border-color: var(--brand); }
.design__option--on { border-color: var(--brand); background: var(--brand-tint); box-shadow: inset 0 0 0 1px var(--brand); }
.design__hint { color: var(--muted); font-size: .85rem; }