/* ==========================================================================
   Grupr — visual system
   Concept: "team vests on a gym floor". Groups are colored like the pinnies
   a coach hands out; members are magnet-board chips; the primary action is
   court green. Light = daylight hall (warm maple + chalk), dark = evening
   hall (warm charcoal). Two self-hosted variable fonts, no frameworks.
   ========================================================================== */

@font-face {
    font-family: 'Figtree';
    src: url('/static/fonts/figtree.woff2') format('woff2');
    font-weight: 300 900;
    font-display: swap;
}
@font-face {
    font-family: 'Bricolage Grotesque';
    src: url('/static/fonts/bricolage-grotesque.woff2') format('woff2');
    font-weight: 200 800;
    font-display: swap;
}

/* ---- tokens ---- */
:root {
    --bg: #F6F4EF;
    --surface: #FFFFFF;
    --surface-2: #EFECE4;
    --ink: #22201B;
    --ink-muted: #6E6858;
    --line: #E3DED2;
    --line-strong: #CFC8B8;

    --primary: #177B52;
    --primary-strong: #116243;
    --primary-ink: #FFFFFF;
    --primary-soft: #DDEFE5;

    --danger: #BC4238;
    --danger-ink: #8F2F27;
    --danger-soft: #F6E2DF;

    --together: #17627B;
    --apart: #8A5FC4;

    /* team vest colors (group identity) */
    --team-0: #D9534F;
    --team-1: #3E6FC4;
    --team-2: #D9982B;
    --team-3: #8A5FC4;
    --team-4: #2E9C94;
    --team-5: #C75B9B;

    /* category markers (muted, distinct from team colors) */
    --cat-0: #5B7BA6;
    --cat-1: #B07A6E;
    --cat-2: #7E9464;
    --cat-3: #9C7BA6;
    --cat-4: #A6935B;
    --cat-5: #6EA096;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(34, 32, 27, 0.05), 0 4px 16px rgba(34, 32, 27, 0.05);

    --font-body: 'Figtree', system-ui, sans-serif;
    --font-display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
}

[data-theme="dark"] {
    --bg: #171512;
    --surface: #211E19;
    --surface-2: #2B2721;
    --ink: #EFEBE2;
    --ink-muted: #A19A8B;
    --line: #363126;
    --line-strong: #4A4436;

    --primary: #37B380;
    --primary-strong: #4BC791;
    --primary-ink: #0E2519;
    --primary-soft: #23372C;

    --danger: #E06B62;
    --danger-ink: #F0968F;
    --danger-soft: #3A2523;

    --together: #4FA6C4;
    --apart: #AC8BE0;

    --team-0: #E57373;
    --team-1: #7096E0;
    --team-2: #E5B45C;
    --team-3: #AC8BE0;
    --team-4: #5BBDB5;
    --team-5: #DE8ABE;

    --cat-0: #7E9CC7;
    --cat-1: #CC9A8D;
    --cat-2: #9DB582;
    --cat-3: #BB9CC7;
    --cat-4: #C7B37E;
    --cat-5: #8FC1B6;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* ---- base ---- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--font-display);
    line-height: 1.15;
    margin: 0 0 0.6rem;
}
h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
h4, h5 { font-family: var(--font-body); font-weight: 600; margin: 0 0 0.5rem; }

a { color: var(--primary); }

main { padding: 1.5rem 1.25rem 4rem; margin: 0 auto; }
.page-default { max-width: 900px; }
.page-wide { max-width: 1400px; }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* ---- header / nav ---- */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.site-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.site-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: -0.02em;
    color: var(--ink);
    text-decoration: none;
}
.logo-mark { flex: none; transform: translateY(2px); }
/* Logo dots mirror the first three team vests (red/blue/yellow) and must stay
   in lockstep with the favicon data URI in base.html (fixed hues there). */
.logo-dot-0 { fill: var(--team-0); }
.logo-dot-1 { fill: var(--team-1); }
.logo-dot-2 { fill: var(--team-2); }

.nav-roster-name {
    color: var(--ink-muted);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 30ch;
    padding-left: 0.75rem;
    border-left: 1px solid var(--line);
}

.site-nav { display: flex; align-items: center; gap: 0.35rem; }

.nav-link {
    color: var(--ink-muted);
    text-decoration: none;
    font-weight: 500;
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-sm);
}
.nav-link:hover { color: var(--ink); background: var(--surface-2); }
.nav-active { color: var(--ink); font-weight: 600; }
.nav-disabled { color: var(--line-strong); cursor: not-allowed; padding: 0.4rem 0.65rem; }

.nav-generate {
    display: inline-block;
    background: var(--primary);
    color: var(--primary-ink);
    font-weight: 600;
    text-decoration: none;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    margin-left: 0.35rem;
}
.nav-generate:hover { background: var(--primary-strong); color: var(--primary-ink); }
.nav-generate.nav-disabled {
    background: var(--surface-2);
    color: var(--ink-muted);
    cursor: not-allowed;
}

.nav-leave-form { display: inline; margin: 0; }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--line);
    color: var(--ink-muted);
    border-radius: 999px;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    margin-left: 0.35rem;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--line-strong); }

/* overflow menu (mobile) */
.nav-overflow { position: relative; display: none; }
.nav-overflow-btn {
    list-style: none;
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--ink-muted);
    font-size: 1.2rem;
    user-select: none;
}
.nav-overflow-btn::-webkit-details-marker { display: none; }
.nav-overflow-btn:hover { background: var(--surface-2); color: var(--ink); }
.nav-overflow-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    min-width: 11rem;
    padding: 0.3rem;
    z-index: 30;
}
.nav-overflow-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--ink);
    font: inherit;
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    cursor: pointer;
}
.nav-overflow-item:hover { background: var(--surface-2); }
.nav-overflow form { margin: 0; }

/* ---- buttons ---- */
.btn {
    display: inline-block;
    background: var(--primary);
    color: var(--primary-ink);
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s ease, transform 0.06s ease;
}
.btn:hover { background: var(--primary-strong); }
.btn:active { transform: translateY(1px); }

.btn-secondary {
    background: transparent;
    color: var(--ink);
    border-color: var(--line-strong);
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger-ink);
    border-color: transparent;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-small { padding: 0.3rem 0.75rem; font-size: 0.9rem; }

.btn-generate { font-size: 1.05rem; padding: 0.65rem 1.5rem; }
.btn-disabled, .btn-disabled:hover {
    background: var(--surface-2);
    color: var(--ink-muted);
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--ink-muted);
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.35rem 0.45rem;
    border-radius: 6px;
    line-height: 1;
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon-danger:hover { background: var(--danger-soft); color: var(--danger-ink); }

/* ---- forms ---- */
label { display: block; font-weight: 500; margin: 0.9rem 0 0.3rem; }
label:first-child { margin-top: 0; }

input[type="text"], input[type="password"], input[type="number"], select {
    width: 100%;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem;
    font: inherit;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
::placeholder { color: var(--ink-muted); opacity: 0.7; }

/* :where() keeps this at specificity (0,0,1) so the per-row
   "margin-top: 0" overrides (.inline-form .btn, .draft-bar .btn, ...) win */
form :where(.btn[type="submit"]) { margin-top: 1rem; }

.hint { color: var(--ink-muted); font-size: 0.88rem; }
.field-hint { color: var(--ink-muted); font-size: 0.88rem; margin: 0.3rem 0 0; }

.checkbox-label, .radio-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 400;
    margin: 0.3rem 0.9rem 0.3rem 0;
    cursor: pointer;
}
.checkbox-label input, .radio-label input { width: auto; margin: 0; accent-color: var(--primary); }

.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.inline-form input[type="text"] { flex: 1; min-width: 0; }
.inline-form .btn { margin-top: 0; flex: none; align-self: stretch; }
.inline-form-sm { max-width: 22rem; }

/* password field with show/hide toggle */
.pw-field { position: relative; }
.pw-field input { padding-right: 3.6rem; }
.pw-toggle {
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--ink-muted);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}
.pw-toggle:hover { color: var(--ink); background: var(--surface-2); }

/* ---- cards & banners ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.error, .success {
    border-radius: var(--radius-sm);
    padding: 0.7rem 1rem;
    margin: 0 0 1rem;
    font-size: 0.95rem;
}
.error { background: var(--danger-soft); color: var(--danger-ink); }
.success { background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .success { color: var(--primary-strong); }

/* Quiet, neutral one-shot notice (e.g. "Roster deleted.") - deliberately
   not celebratory, so it reads as a plain status confirmation. */
.flash-notice {
    border-radius: var(--radius-sm);
    padding: 0.7rem 1rem;
    margin: 0 0 1rem;
    font-size: 0.95rem;
    background: var(--surface-2);
    color: var(--ink-muted);
    border: 1px solid var(--line);
}

/* ---- landing ---- */
.hero { text-align: center; padding: 2.5rem 0 1.5rem; }
.hero-headline {
    font-size: clamp(2.2rem, 6vw, 3.4rem);
    font-weight: 750;
    letter-spacing: -0.025em;
    margin-bottom: 1rem;
}
.hero-sub { max-width: 40rem; margin: 0 auto; color: var(--ink-muted); }
.hero-sub p { margin: 0.3rem 0; }
.hero-usecases {
    margin-top: 1.2rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

/* ---- error pages (404/500/400, shared with minimal_error_page) ---- */
.error-page {
    text-align: center;
    padding: 3rem 0;
}
.error-code {
    font-family: var(--font-display);
    font-size: clamp(2.8rem, 8vw, 4.5rem);
    font-weight: 750;
    letter-spacing: -0.02em;
    color: var(--ink-muted);
    margin: 0 0 0.5rem;
}
.error-heading {
    margin: 0 0 0.75rem;
}
.error-message {
    max-width: 32rem;
    margin: 0 auto 1.75rem;
    color: var(--ink-muted);
}

/* decorative mini magnet-board: three tilted vest-topped group cards */
.hero-board {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 1.1rem;
    margin: 2.2rem auto 0.5rem;
}
.mini-card {
    width: 128px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.85rem 0.75rem 0.75rem;
    box-shadow: var(--shadow);
    border-top: 4px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.mini-team-0 { border-top-color: var(--team-0); transform: rotate(-2.5deg); }
.mini-team-1 { border-top-color: var(--team-1); transform: rotate(1.5deg) translateY(6px); }
.mini-team-2 { border-top-color: var(--team-2); transform: rotate(-1deg); }
.mini-chip { display: flex; align-items: center; gap: 6px; }
.mini-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.mini-cat-0 { background: var(--cat-0); }
.mini-cat-1 { background: var(--cat-1); }
.mini-chip b { height: 7px; border-radius: 4px; background: var(--surface-2); }
[data-theme="dark"] .mini-chip b { background: var(--line); }

.landing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin: 1.5rem 0;
    align-items: start; /* cards size to content: no hollow stretched card */
}
.landing-grid .card form { display: flex; flex-direction: column; }
.landing-grid .card form .btn { margin-top: 1.25rem; align-self: flex-start; }

/* welcome band (returning session): one full-width row, not a grid cell */
.welcome-band {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin: 1.5rem 0 1.25rem;
    border-color: var(--primary);
    border-width: 1.5px;
}
.welcome-text h2 { margin-bottom: 0.25rem; }
.welcome-text p { margin: 0; color: var(--ink-muted); }
.welcome-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 0.6rem; }
.continue-leave { font-size: 0.88rem; color: var(--ink-muted); }
.continue-leave button {
    background: none;
    border: none;
    color: var(--ink-muted);
    font: inherit;
    font-size: 0.88rem;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}
.continue-leave button:hover { color: var(--ink); }

/* collapsed create form for signed-in visitors */
.new-roster-details { padding: 0; overflow: hidden; }
.new-roster-details summary {
    cursor: pointer;
    padding: 1rem 1.5rem;
    font-family: var(--font-display);
    font-weight: 650;
    font-size: 1.05rem;
    list-style-position: inside;
}
.new-roster-details summary:hover { background: var(--surface-2); }
.new-roster-body { padding: 0.25rem 1.5rem 1.5rem; max-width: 30rem; }
.new-roster-body form { display: flex; flex-direction: column; }
.new-roster-body form .btn { margin-top: 1.25rem; align-self: flex-start; }

/* how it works: three steps numbered in the first three vest colors */
.steps-section {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.25rem;
    margin: 3rem 0 0;
}
.step h3 { margin: 0.75rem 0 0.3rem; }
.step p { margin: 0; color: var(--ink-muted); font-size: 0.95rem; }
.step-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-family: var(--font-display);
    font-weight: 700;
    color: #FFFFFF;
}
[data-theme="dark"] .step-dot { color: #171512; }
.step-team-0 { background: var(--team-0); }
.step-team-1 { background: var(--team-1); }
.step-team-2 { background: var(--team-2); }

.comparison-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin: 2.5rem 0 1.5rem;
}
.comparison-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
}
.comparison-before { border-left-color: var(--danger); }
.comparison-after { border-left-color: var(--primary); }
.comparison-card h3 { margin-bottom: 0.6rem; }
.comparison-card ul { list-style: none; margin: 0; padding: 0; }
.comparison-card li {
    position: relative;
    padding-left: 1.5rem;
    margin: 0.45rem 0;
    font-size: 0.95rem;
    color: var(--ink-muted);
}
.comparison-card li::before {
    position: absolute;
    left: 0;
    font-weight: 700;
}
.comparison-before li::before { content: "\2715"; color: var(--danger); }
.comparison-after li::before { content: "\2713"; color: var(--primary); }

.privacy-note {
    text-align: center;
    color: var(--ink-muted);
    font-size: 0.88rem;
    margin: 2rem auto;
    max-width: 36rem;
}

/* ---- dashboard ---- */
.roster-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.roster-nav { display: flex; gap: 0.5rem; }

.roster-summary { color: var(--ink-muted); margin: 0.2rem 0 1.1rem; }

.roster-info { color: var(--ink-muted); font-size: 0.92rem; margin: 0 0 0.5rem; }
.roster-categories { margin: 1.5rem 0; }

.roster-section { max-width: 900px; margin-top: 2.5rem; }
.roster-section > h2 { margin-bottom: 0.8rem; }

.empty-state-helper { color: var(--ink-muted); }
.cta-helper { display: block; color: var(--ink-muted); font-size: 0.88rem; margin-top: 0.4rem; }

/* category grid + member lists */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.category-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem 1.1rem 0.8rem;
    box-shadow: var(--shadow);
}
.category-card-uncategorized { border-style: dashed; }

.category-heading {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.8rem;
}
.category-heading h3 {
    margin: 0;
    padding-bottom: 0.15rem;
    border-bottom: 2.5px solid var(--primary);
}
.category-actions { display: inline-flex; }

.member-list { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.member-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.42rem 0.3rem;
    border-bottom: 1px solid var(--line);
}
.member-item:last-child { border-bottom: none; }
.member-index {
    color: var(--ink-muted);
    font-size: 0.78rem;
    min-width: 1.3rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.member-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-item.inactive .member-name { color: var(--ink-muted); text-decoration: line-through; }
.member-actions { display: inline-flex; opacity: 0.75; }
.member-item:hover .member-actions { opacity: 1; }

.edit-form input[type="text"] { padding: 0.35rem 0.6rem; }
/* the rename form is display:contents inside .category-heading (flex, centered);
   buttons stretch to the input's height instead of floating shorter beside it */
.edit-form .btn { margin-top: 0; align-self: stretch; }
.edit-form-extra { display: flex; gap: 0.4rem; align-items: stretch; align-self: stretch; }
.edit-form-extra select { width: auto; padding: 0.35rem 0.5rem; }
.edit-form-extra .btn { margin-top: 0; }

/* ---- contextual help popovers ---- */
.section-heading { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; }
.section-heading h1, .section-heading h2 { margin-bottom: 0; }
.help-details { position: relative; display: inline-block; }
.help-details > summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    border: 1.5px solid var(--line-strong);
    color: var(--ink-muted);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
}
.help-details > summary::-webkit-details-marker { display: none; }
.help-details > summary:hover { color: var(--ink); border-color: var(--ink-muted); }
.help-details[open] > summary { background: var(--surface-2); color: var(--ink); }
.help-panel {
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    z-index: 30;
    width: min(88vw, 26rem);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    padding: 1rem 1.1rem;
    font-size: 0.92rem;
    font-weight: 400;
}
.help-panel p { margin: 0 0 0.6rem; color: var(--ink-muted); }
.help-panel p:last-child { margin-bottom: 0; }
.help-panel strong { color: var(--ink); }
@media (max-width: 480px) {
    /* fixed to the viewport; JS in base.html sets the exact top from the
       summary's position (5rem is only the no-JS fallback) */
    .help-panel { position: fixed; left: 1rem; right: 1rem; width: auto; top: 5rem; max-height: 70vh; overflow-y: auto; }
}

/* ---- dialogs ---- */
.app-dialog {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
    padding: 1.5rem;
    width: min(92vw, 24rem);
}
.app-dialog::backdrop { background: rgba(20, 18, 14, 0.45); }
.app-dialog .dialog-title { margin-bottom: 0.75rem; }
.app-dialog p { margin: 0; color: var(--ink-muted); }
.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1.4rem;
}
.dialog-actions .btn { margin-top: 0; }

/* ---- generate: settings ---- */
.gen-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.gen-settings-grid label { margin-top: 0; }
.split-hint {
    margin: 0.8rem 0 0;
    font-size: 0.95rem;
    color: var(--ink-muted);
}
.split-hint strong { color: var(--ink); font-weight: 600; }
.gen-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
}
.gen-actions .btn { margin-top: 0; }

/* ---- draft view ---- */
.draft-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    position: sticky;
    top: 3.6rem;
    z-index: 10;
    box-shadow: var(--shadow);
}
.draft-bar { justify-content: space-between; }
.draft-bar form { display: contents; }
.draft-bar .btn { margin-top: 0; }
/* keep chip+Regenerate and note+Save as intact clusters when the bar wraps;
   items stretch so chip, note input and buttons share one height */
.draft-cluster { display: flex; align-items: stretch; gap: 0.6rem; }
.draft-cluster-save { flex: 1; justify-content: flex-end; }
.unsaved-chip {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--team-2);
    border: 1.5px dashed var(--team-2);
    border-radius: 999px;
    padding: 0.15rem 0.7rem;
    white-space: nowrap;
}
.note-input {
    display: flex;
    flex: 1;
    min-width: 9rem;
    max-width: 20rem;
}
.note-input input { padding: 0.45rem 0.7rem; font-size: 0.92rem; height: 100%; }
.swap-hint { color: var(--ink-muted); font-size: 0.9rem; margin: 0.4rem 0 1rem; }

.set-heading {
    font-family: var(--font-display);
    font-weight: 650;
    font-size: 1.05rem;
    margin: 1.4rem 0 0.7rem;
}

.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem;
}

.group-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 4px solid var(--team, var(--line-strong));
    border-radius: var(--radius);
    padding: 0.85rem 0.9rem;
    box-shadow: var(--shadow);
}
.group-card.team-0 { --team: var(--team-0); }
.group-card.team-1 { --team: var(--team-1); }
.group-card.team-2 { --team: var(--team-2); }
.group-card.team-3 { --team: var(--team-3); }
.group-card.team-4 { --team: var(--team-4); }
.group-card.team-5 { --team: var(--team-5); }

.group-card h4, .group-card h5 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.55rem;
    font-size: 0.95rem;
}
.group-card h4::before, .group-card h5::before {
    content: "";
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--team, var(--line-strong));
    flex: none;
}
.group-card .hint { font-weight: 400; }

.group-card ul { list-style: none; margin: 0; padding: 0; }
.group-card li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.55rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.25rem;
    background: var(--surface-2);
}

/* clickable chips in the draft */
.member-swap { cursor: pointer; border: 1.5px solid transparent; user-select: none; }
.member-swap:hover { border-color: var(--line-strong); }
.member-swap.selected {
    border-color: var(--primary);
    background: var(--primary-soft);
    font-weight: 600;
}

/* category marker dot on draft chips */
.cat-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    flex: none;
    background: var(--line-strong);
}
.cat-dot.cat-0 { background: var(--cat-0); }
.cat-dot.cat-1 { background: var(--cat-1); }
.cat-dot.cat-2 { background: var(--cat-2); }
.cat-dot.cat-3 { background: var(--cat-3); }
.cat-dot.cat-4 { background: var(--cat-4); }
.cat-dot.cat-5 { background: var(--cat-5); }

/* flash the two chips that just swapped */
@keyframes swap-flash {
    0% { background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
    100% { background: var(--surface-2); box-shadow: none; }
}
.swap-flash { animation: swap-flash 0.9s ease-out; }

/* ---- history ---- */
.round-list { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1rem; }
.round-card { padding: 1rem 1.2rem; }
.round-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.round-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.55rem; }
.round-title strong { font-family: var(--font-display); font-weight: 650; }
.round-note {
    background: var(--surface-2);
    border-radius: 999px;
    padding: 0.1rem 0.7rem;
    font-size: 0.85rem;
}
.round-actions { display: flex; align-items: center; gap: 0.4rem; }
/* Delete/Reset are submit buttons in display:contents forms — without this,
   the global form submit margin-top shifts them below their row's centerline */
.round-actions .btn, .danger-zone .btn { margin-top: 0; }
.round-card .groups-grid { margin-top: 0.75rem; }
.round-card .set-heading { margin: 1rem 0 0.5rem; }

.danger-zone {
    margin-top: 3rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.danger-zone p { margin: 0; color: var(--ink-muted); font-size: 0.9rem; }

/* ---- matrix ---- */
.matrix-scroll { overflow-x: auto; }
.matrix-table {
    border-collapse: collapse;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    margin-top: 0.75rem;
}
.matrix-table th, .matrix-table td {
    border: 1px solid var(--line);
    padding: 0.25rem 0.45rem;
    text-align: center;
    min-width: 2rem;
}
.matrix-table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.matrix-self { background: var(--surface-2); color: var(--ink-muted); }
/* pairing counts shade deeper with repetition (capped at 4+) */
.matrix-c1, .matrix-c2, .matrix-c3, .matrix-c4 { font-weight: 600; }
.matrix-c1 { background: color-mix(in oklab, var(--primary) 14%, var(--surface)); }
.matrix-c2 { background: color-mix(in oklab, var(--primary) 27%, var(--surface)); }
.matrix-c3 { background: color-mix(in oklab, var(--primary) 40%, var(--surface)); }
.matrix-c4 { background: color-mix(in oklab, var(--primary) 54%, var(--surface)); }

.matrix-tip {
    position: fixed;
    z-index: 40;
    background: var(--ink);
    color: var(--bg);
    font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    pointer-events: none;
    max-width: 20rem;
}

/* ---- constraints ---- */
.disclosure {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.disclosure > summary {
    cursor: pointer;
    padding: 0.9rem 1.2rem;
    font-weight: 600;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before {
    content: "";
    border: solid var(--ink-muted);
    border-width: 0 2px 2px 0;
    padding: 3px;
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
}
.disclosure[open] > summary::before { transform: rotate(45deg); }
.disclosure-body { padding: 0 1.2rem 1.2rem; }

.constraint-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.constraint-table th {
    text-align: left;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--line);
}
.constraint-table td { padding: 0.5rem; border-bottom: 1px solid var(--line); }

.constraint-type {
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.12rem 0.65rem;
    color: #fff;
}
[data-theme="dark"] .constraint-type { color: #171512; }
.constraint-type-together { background: var(--together); }
.constraint-type-apart { background: var(--apart); }

.constraint-form .form-row { margin-bottom: 0.9rem; }
.checkbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.1rem 0.8rem;
    max-height: 12rem;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
}
.checkbox-list .checkbox-label { margin: 0.15rem 0; min-width: 0; }
.checkbox-list .checkbox-label input { flex: none; }

/* ---- responsive ---- */
@media (max-width: 768px) {
    .site-nav .nav-leave-form, .site-nav > .theme-toggle { display: none; }
    .nav-overflow { display: block; }
    .nav-roster-name { max-width: 12ch; }
    .nav-generate { padding: 0.4rem 0.8rem; }
    main { padding: 1.25rem 1rem 3rem; }
}

@media (max-width: 600px) {
    .landing-grid, .comparison-section, .steps-section { grid-template-columns: 1fr; }
    .hero { padding: 1.5rem 0 1rem; }
    .hero-board { gap: 0.75rem; }
    .mini-card { width: 104px; padding: 0.7rem 0.6rem 0.6rem; }
    .steps-section { gap: 1.75rem; margin-top: 2.25rem; }
    .welcome-band { flex-direction: column; align-items: stretch; }
    .welcome-actions { align-items: flex-start; }
    .gen-settings-grid { grid-template-columns: 1fr; }
    .groups-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .draft-bar { position: static; }
    .note-input { max-width: none; }
    .category-grid { grid-template-columns: 1fr; }
}

@media (min-width: 769px) {
    .nav-overflow { display: none; }
}

@media (max-width: 480px) {
    /* the page h1 already names the roster; the nav can't fit it too */
    .nav-roster-name { display: none; }
    .site-header { padding: 0.65rem 0.75rem; gap: 0.5rem; }
    .site-nav { gap: 0.15rem; }
    .nav-link, .nav-disabled { padding: 0.4rem 0.45rem; }
}
