/* MindNorth — component stylesheet.
 *
 * One application shell, one spacing rhythm, one card system, one type scale.
 * Every screen is composed from these parts, so the app reads as one thing.
 *
 * Rules that keep the interface coherent:
 *   • Every page sits in the same column and starts at the same left edge.
 *   • Sections are separated by --section-gap, never by arbitrary margins.
 *   • A card is a surface with a border and a heading. It is not a KPI tile,
 *     and cards are not stacked in endless identical grids.
 *   • Colour is used to mark a thing's kind, not to decorate.
 *
 * Layout repair notes (the causes of the original broken dashboard):
 *   1. Headings wrapped one letter per line because text was placed in
 *      unconstrained, over-narrow boxes. Every text container here has a
 *      defined width, and headings use normal horizontal wrapping.
 *   2. Excessive empty space came from a narrow centred column inside a
 *      flex column that also carried a fixed-width rail. The rail is gone;
 *      the column is now the page.
 *   3. Cards were clipped because a grid used auto-fit tracks with no width
 *      floor. Grids here declare their minimum track and cards may grow.
 *   4. The shell and the content had no shared alignment. They share one
 *      column and one gutter now.
 */

/* ═══════════════ Base ═══════════════ */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: var(--fs-base);
    line-height: var(--lh-body);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; }

/* ═══════════════ Typography ═══════════════ */
h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: var(--lh-tight);
    letter-spacing: var(--tracking-tight);
    color: var(--text);
    margin: 0 0 var(--sp-3);
    /* Headings wrap as words, never one letter per line. */
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
}
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }

p { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
}
a:hover { color: var(--accent-hover); }

strong { font-weight: 650; }

ul, ol { margin: 0 0 var(--sp-4); padding-left: var(--sp-5); }
li { margin-bottom: var(--sp-2); }
li:last-child { margin-bottom: 0; }

code {
    font-family: ui-monospace, 'Cascadia Mono', 'SF Mono', Menlo, monospace;
    font-size: 0.9em;
    background: var(--bg-sunken);
    padding: 0.1em 0.35em;
    border-radius: var(--r-sm);
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: var(--sp-6) 0;
}

/* Text roles */
.kicker {
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-faint);
    margin: 0 0 var(--sp-2);
}
.lead {
    font-size: var(--fs-md);
    color: var(--text-muted);
    max-width: 40rem;
    line-height: 1.5;
}
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--fs-sm); }
.quote-text {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--text-muted);
}

/* ═══════════════ App shell ═══════════════ */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── The bar ── */
.app-nav {
    position: sticky;
    top: 0;
    z-index: 60;
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
}

.app-nav__bar {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    max-width: var(--page-max-wide);
    margin: 0 auto;
    padding: 0 var(--gutter);
    min-height: 3.5rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    text-decoration: none;
    color: var(--text);
    flex-shrink: 0;
}
.brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: var(--r-sm);
    background: var(--accent-soft);
    color: var(--accent);
    flex-shrink: 0;
}
.brand__name {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    white-space: nowrap;
}

.nav-primary {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    flex: 1;
    min-width: 0;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 550;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--bg-sunken); color: var(--text); }
.nav-link.is-current,
.nav-link[aria-current='page'] {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 650;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
}

.theme-switcher {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
}
.theme-switcher button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.6rem;
    padding: 0;
    border: 0;
    border-radius: var(--r-pill);
    background: transparent;
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.55;
    filter: grayscale(60%);
    transition: opacity 0.15s ease, background-color 0.15s ease, filter 0.15s ease;
}
.theme-switcher button:hover { opacity: 0.9; }
.theme-switcher button.is-active {
    opacity: 1;
    filter: none;
    background: var(--bg-raised);
    box-shadow: var(--shadow-sm);
}

.nav-profile {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 2px var(--sp-2) 2px 2px;
    border-radius: var(--r-pill);
    text-decoration: none;
    color: var(--text);
    border: 1px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.nav-profile:hover { background: var(--bg-sunken); border-color: var(--border); }
.nav-profile__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: var(--r-pill);
    background: var(--accent);
    color: var(--text-invert);
    font-size: var(--fs-xs);
    font-weight: 700;
}
.nav-profile__name {
    font-size: var(--fs-sm);
    font-weight: 550;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2rem;
    min-width: 2rem;
    padding: 0 var(--sp-2);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: var(--fs-sm);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.nav-icon:hover { background: var(--bg-sunken); color: var(--text); border-color: var(--border); }
.nav-icon--text { padding: 0 var(--sp-3); }

/* ── Support dropdown ── */
.nav-menu { position: relative; }
.nav-menu__caret { font-size: 0.6rem; opacity: 0.7; }
.nav-menu__panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 15rem;
    display: none;
    flex-direction: column;
    padding: var(--sp-1);
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    z-index: 70;
}
.nav-menu.is-open .nav-menu__panel { display: flex; }
.nav-menu__item {
    display: block;
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 550;
    text-decoration: none;
}
.nav-menu__item:hover { background: var(--bg-sunken); color: var(--text); }
.nav-menu__item.is-current { color: var(--accent); background: var(--accent-soft); }

/* ── Small-screen drawer ── */
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    margin-left: auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-raised);
    color: var(--text);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.nav-toggle:hover { background: var(--bg-sunken); }

.nav-drawer {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(19rem, 84vw);
    background: var(--bg-raised);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 90;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.nav-drawer.is-open { transform: translateX(0); }
.nav-drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border-bottom: 1px solid var(--border);
}
.nav-drawer__close {
    width: 2rem; height: 2rem;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-sunken);
    color: var(--text);
    cursor: pointer;
    line-height: 1;
}
.nav-drawer__body { padding: var(--sp-3) var(--sp-4) var(--sp-6); }
.nav-drawer__label {
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-faint);
    margin: var(--sp-4) 0 var(--sp-2);
}
.nav-drawer__label:first-child { margin-top: 0; }
.drawer-link {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--sp-3);
    margin-bottom: 2px;
    border: 0;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 550;
    text-decoration: none;
    cursor: pointer;
}
.drawer-link:hover { background: var(--bg-sunken); color: var(--text); }
.drawer-link.is-current,
.drawer-link[aria-current='page'] { background: var(--accent-soft); color: var(--accent); }
.drawer-link--action { color: var(--danger); }

.nav-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-scrim);
    z-index: 80;
}
.nav-scrim.is-open { display: block; }
body.has-drawer { overflow: hidden; }

/* ═══════════════ Main column & footer ═══════════════ */
.app-main {
    flex: 1;
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: var(--sp-8) var(--gutter) var(--sp-10);
}
.app-main--narrow { max-width: var(--page-max-narrow); }
.app-main--wide { max-width: var(--page-max-wide); }

.app-footer {
    border-top: 1px solid var(--border);
    background: var(--bg-nav);
    color: var(--text-faint);
    font-size: var(--fs-sm);
}
.app-footer p {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: var(--sp-4) var(--gutter);
}
.app-footer p + p { padding-top: 0; padding-bottom: var(--sp-6); }
.app-footer a { color: var(--text-muted); }

/* ═══════════════ Page structure ═══════════════ */
.page { display: flex; flex-direction: column; gap: var(--section-gap); }

.page__head {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    max-width: 44rem;
}
.page__head h1 { margin-bottom: 0; }
.page__head .lead { margin-bottom: 0; }

.page__actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    margin-top: var(--sp-2);
}

/* A row that runs side by side and wraps — the workhorse for toolbars. */
.cluster {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
}
.cluster--between { justify-content: space-between; }
.cluster--end { justify-content: flex-end; }

/* A stack of blocks with one consistent gap. */
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack--lg { gap: var(--sp-6); }
.stack--sm { gap: var(--sp-2); }

/* Two columns that collapse. */
.split {
    display: grid;
    gap: var(--sp-6);
    grid-template-columns: 1fr;
}
@media (min-width: 60rem) {
    .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .split--wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
    .split--wide-right { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
}

/* A grid with a declared track floor, so a card is never squeezed. */
.grid {
    display: grid;
    gap: var(--sp-4);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
.grid--full > * { grid-column: 1 / -1; }

/* ═══════════════ Card ═══════════════ */
.card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}
.card--flush { padding: 0; overflow: hidden; }
.card--quiet { background: transparent; box-shadow: none; }
.card--sunken { background: var(--bg-sunken); box-shadow: none; }
.card--accent { border-left: 3px solid var(--accent); }
.card--danger { border-left: 3px solid var(--danger); }
.card__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-3);
    flex-wrap: wrap;
    margin-bottom: var(--sp-4);
}
.card__head h2, .card__head h3 { margin: 0; }
.card__body > *:last-child { margin-bottom: 0; }
.card__foot {
    margin-top: var(--sp-5);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--border);
}

/* A panel: the same surface, but it groups related content in a page. */
.panel {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.panel__head {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border);
    background: var(--bg-sunken);
}
.panel__head h2, .panel__head h3 { margin: 0; }
.panel__body { padding: var(--sp-5); }
.panel__body > *:last-child { margin-bottom: 0; }

/* ═══════════════ Native elements ═══════════════
 * The app does not use a CSS framework. Every element is styled here, so
 * there is exactly one opinion about padding, radius, colour and focus.
 *
 * This matters more than it sounds: a framework that styles `article` as a
 * boxed surface will put a card around every piece of content on the page,
 * which is what turns an application into a grid of unrelated panels.
 */
article, address, dl, figure, form, ol, p, pre, table, ul {
    margin-block: 0;
}

/* Buttons ───────────────────────────────────────────────────────── */
button,
.btn,
a[role='button'] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    min-height: 2.25rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--bg-raised);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
button:hover, .btn:hover, a[role='button']:hover {
    background: var(--bg-sunken);
    border-color: var(--text-faint);
}
button:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }

.btn--primary, button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-invert);
}
.btn--primary:hover, button.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--text-invert);
}
.btn--quiet, button.quiet {
    background: transparent;
    border-color: transparent;
    color: var(--text-muted);
}
.btn--quiet:hover, button.quiet:hover {
    background: var(--bg-sunken);
    border-color: transparent;
    color: var(--text);
}
.btn--danger, button.danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.btn--sm, button.small { min-height: 1.9rem; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); }
.btn--block, button.block { width: 100%; }

/* The one legacy alias the older pages still use. */
.outline {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text);
}
.outline:hover { border-color: var(--accent); color: var(--accent); background: transparent; }

/* Form controls ─────────────────────────────────────────────────── */
label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--sp-3);
}
label small { font-weight: 400; color: var(--text-muted); }

input[type='text'], input[type='password'], input[type='email'],
input[type='number'], input[type='date'], input[type='file'],
input[type='search'], input[type='tel'], input[type='url'], select, textarea {
    display: block;
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    min-height: 2.4rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--bg-raised);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; }

input[type='checkbox'], input[type='radio'] {
    accent-color: var(--accent);
    width: 1rem;
    height: 1rem;
    margin: 0;
    flex-shrink: 0;
}
input[type='range'] {
    width: 100%;
    accent-color: var(--accent);
    height: 1.5rem;
}
input[type='file'] {
    padding: var(--sp-2);
    font-size: var(--fs-xs);
}
input[type='file']::file-selector-button {
    margin-right: var(--sp-3);
    padding: var(--sp-1) var(--sp-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--bg-sunken);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-xs);
    cursor: pointer;
}

.check {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 500;
    margin-bottom: var(--sp-2);
}
.check input { width: 1rem; height: 1rem; }

/* Disclosure ─────────────────────────────────────────────────────── */
details {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--bg-raised);
    padding: 0 var(--sp-5);
}
details + details { margin-top: var(--sp-3); }
details[open] { padding-bottom: var(--sp-5); }
summary {
    cursor: pointer;
    font-weight: 600;
    padding: var(--sp-4) 0;
    margin: 0 calc(var(--sp-5) * -1);
    padding-inline: var(--sp-5);
    list-style-position: outside;
    color: var(--text);
}
summary:hover { color: var(--accent); }
details > *:last-child { margin-bottom: 0; }

/* Lists ─────────────────────────────────────────────────────────── */
ul, ol { margin: 0 0 var(--sp-4); padding-left: var(--sp-5); }
li { margin-bottom: var(--sp-2); }
li:last-child { margin-bottom: 0; }

/* Misc ──────────────────────────────────────────────────────────── */
code {
    font-family: ui-monospace, 'Cascadia Mono', 'SF Mono', Menlo, monospace;
    font-size: 0.9em;
    background: var(--bg-sunken);
    padding: 0.1em 0.35em;
    border-radius: var(--r-sm);
}
small { font-size: var(--fs-xs); }
em { font-style: italic; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-6) 0; }
img { max-width: 100%; height: auto; }
svg { vertical-align: middle; }

/* ═══════════════ Buttons ═══════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    min-height: 2.25rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--bg-raised);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--bg-sunken); border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-invert);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--text-invert); }

.btn--quiet {
    background: transparent;
    border-color: transparent;
    color: var(--text-muted);
}
.btn--quiet:hover { background: var(--bg-sunken); color: var(--text); border-color: transparent; }

.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger); opacity: 0.9; color: #fff; }

.btn--sm { min-height: 1.9rem; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); }
.btn--block { width: 100%; }

/* Legacy alias kept for pages that predate the component set. */
.outline { composes: btn; }

/* ═══════════════ Form controls ═══════════════ */
label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin-bottom: var(--sp-3); }
label small { font-weight: 400; color: var(--text-muted); }

input[type='text'], input[type='password'], input[type='email'],
input[type='number'], input[type='date'], input[type='file'],
input[type='search'], input[type='tel'], select, textarea {
    display: block;
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    min-height: 2.4rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--bg-raised);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type='range'] { width: 100%; accent-color: var(--accent); }
input[type='checkbox'], input[type='radio'] { accent-color: var(--accent); }

.field { margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }
.field__hint { display: block; margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--text-muted); font-weight: 400; }

.check {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 500;
    margin-bottom: var(--sp-2);
}
.check input { width: auto; min-height: 0; }

/* ═══════════════ Bits and pieces ═══════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--sp-2);
    border-radius: var(--r-pill);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: var(--fs-xs);
    font-weight: 650;
    white-space: nowrap;
}
.badge--sage   { background: var(--sage-soft);   color: var(--sage); }
.badge--amber  { background: var(--amber-soft);  color: var(--amber); }
.badge--blue   { background: var(--blue-soft);   color: var(--blue); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--clay   { background: var(--terracotta-soft); color: var(--terracotta); }

/* Semantic names used by the trackers and the resource finder. They are
   aliases of the tones above, so the two spellings cannot look different. */
.badge.none    { background: var(--success-soft); color: var(--success); }
.badge.low     { background: var(--amber-soft);  color: var(--amber); }
.badge.moderate{ background: var(--amber-soft);  color: var(--amber); }
.badge.high    { background: var(--danger-soft); color: var(--danger); }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__value {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
}
.stat__label { font-size: var(--fs-xs); color: var(--text-muted); }

.note {
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-md);
    background: var(--bg-sunken);
    font-size: var(--fs-sm);
    color: var(--text-muted);
}
.note--danger { border-left-color: var(--danger); background: var(--danger-soft); color: var(--text); }
.note--amber  { border-left-color: var(--amber);  background: var(--amber-soft); color: var(--text); }
.note--blue   { border-left-color: var(--blue);   background: var(--blue-soft); color: var(--text); }

/* A list of things a person wrote — the reading unit of the journal. */
.entries { display: flex; flex-direction: column; }
.entry {
    display: flex;
    gap: var(--sp-4);
    padding: var(--sp-4) 0;
    border-top: 1px solid var(--border);
    align-items: flex-start;
}
.entry:first-child { border-top: 0; padding-top: 0; }
.entry__meta {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;   /* the badge keeps its own width */
    gap: var(--sp-1);
    min-width: 8.5rem;
}
.entry__date { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.entry__body { min-width: 0; flex: 1; }
.entry__body p { margin: 0 0 var(--sp-2); color: var(--text); }
.entry__body p:last-child { margin-bottom: 0; }

/* ═══════════════ Original illustrations ═══════════════ */
.art { display: block; }
.art svg { display: block; width: 100%; height: 100%; }
.art--sm { width: 2.25rem; height: 2.25rem; }
.art--md { width: 3.25rem; height: 3.25rem; }
.art--lg { width: 4.5rem; height: 4.5rem; }
.art--accent { color: var(--terracotta); }
.art--sage { color: var(--sage); }
.art--blue { color: var(--blue); }
.art--faint { color: var(--text-faint); }

/* ═══════════════ Mood picker ═══════════════ */
.mood-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
    gap: var(--sp-2);
    /* The buttons keep their own size instead of stretching to fill a wide
       page: fifteen moods across a 68rem column is unreadable. */
    max-width: 34rem;
}
.mood-btn {
    padding: var(--sp-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-raised);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.mood-btn:hover { border-color: var(--accent); }
.mood-btn.selected,
.mood-btn[aria-pressed='true'] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-invert);
    font-weight: 600;
}

/* ═══════════════ Tabs ═══════════════ */
.tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
}
.tab {
    padding: var(--sp-2) var(--sp-4);
    border: 0;
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active,
.tab[aria-selected='true'] {
    background: var(--bg-raised);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* ═══════════════ Tables ═══════════════ */
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: var(--sp-2) var(--sp-3); text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 650; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; }

/* ═══════════════ Hero (about, onboarding, sign-in) ═══════════════ */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    text-align: center;
    padding: var(--sp-8) var(--sp-5);
}
.hero h1 { margin-bottom: 0; }
.hero p { color: var(--text-muted); max-width: 34rem; margin-bottom: 0; }
.hero__slogan {
    font-size: var(--fs-xs);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-faint);
}

/* ═══════════════ Sign-in / register (centred, narrow) ═══════════════ */
.form-page {
    max-width: 26rem;
    margin: 0 auto;
    padding: var(--sp-10) var(--gutter) var(--sp-8);
}
.form-page .brand { justify-content: center; }
.form-page__title { text-align: center; margin-bottom: var(--sp-6); }
.form-page__foot { text-align: center; font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--sp-6); }

/* ═══════════════ Focus & motion ═══════════════ */
:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ═══════════════ Responsive ═══════════════ */
@media (max-width: 60rem) {
    .nav-primary { display: none; }
    .nav-toggle { display: inline-flex; }
    .nav-profile__name { display: none; }
    .nav-profile { padding: 2px; }
}

@media (max-width: 48rem) {
    :root { --gutter: var(--sp-4); --section-gap: var(--sp-6); }
    .app-main { padding-top: var(--sp-6); }
    .grid, .grid--2, .grid--3 { grid-template-columns: 1fr; }
    .split { gap: var(--sp-5); }
    .entry { flex-direction: column; gap: var(--sp-2); }
    .entry__meta { flex-direction: row; align-items: center; gap: var(--sp-2); min-width: 0; }
    .page__head h1 { font-size: var(--fs-lg); }
}

@media (max-width: 30rem) {
    .brand__name { display: none; }
    .theme-switcher button { width: 1.7rem; }
    .nav-icon--text { padding: 0 var(--sp-2); font-size: var(--fs-xs); }
}

/* ═══════════════ Print ═══════════════ */
@media print {
    .app-nav, .app-footer, .nav-scrim, .nav-drawer, .tabs { display: none !important; }
    body { background: #fff !important; color: #000 !important; }
    .app-main { max-width: none; padding: 0; }
    .card, .panel, .note { box-shadow: none !important; border-color: #999 !important; break-inside: avoid; }
    a[href^='tel:']::after { content: " (" attr(href) ")"; font-size: 0.75em; }
}

/* Approved raster artwork: retain its natural square proportions. */
.mindnorth-auth-logo{display:block;width:min(176px,55vw);height:auto;object-fit:contain;margin:0 auto 20px;transform:none;border-radius:0}
.brand__mark{background:transparent!important;border:0!important;border-radius:0!important;transform:none!important;overflow:visible!important}
.brand__mark img{display:block;width:100%;height:100%;object-fit:contain;transform:none;border-radius:0}
/* Clear working rhythm across journal, wellbeing and support screens. */
.app-main{display:flex;flex-direction:column;gap:28px;padding-top:40px;padding-bottom:56px;min-width:0}
.app-main>*,.split>*,.grid>*{min-width:0}#riskBanner:empty{display:none}
h1,h2,h3,h4{font-weight:650;letter-spacing:-.025em}h1{font-size:clamp(1.9rem,4vw,2.6rem)}h2{font-size:1.35rem}h3{font-size:1.1rem}
.page__head{gap:14px;max-width:48rem;margin:0}.page__head .lead{line-height:1.8}.page__actions{gap:12px;margin-top:6px}
.card{padding:28px;border-radius:16px;box-shadow:none}.card--flush{padding:0}.card__head{gap:16px;margin-bottom:20px}.stack{gap:24px}.stack--lg{gap:28px}.split{gap:28px}.grid{gap:20px}.card p{line-height:1.75}.card>:last-child{margin-bottom:0}
.btn,button{min-height:44px}.btn--sm,button.small{min-height:38px;padding:8px 12px}.app-main--narrow form{display:grid;gap:20px}.app-main--narrow form label{margin:0}.app-main--narrow form label input,.app-main--narrow form label select{margin-top:8px}
input,select,textarea{border-radius:9px}textarea{line-height:1.8}input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible,button:focus-visible{outline:2px solid var(--border-focus);outline-offset:3px}
.brand__mark{width:44px;height:44px;flex:0 0 44px}.brand__name{font-family:var(--font-ui);font-weight:650;letter-spacing:-.03em}.app-footer p{line-height:1.8;padding-top:20px;padding-bottom:20px}
.auth-shell{display:grid;grid-template-columns:minmax(0,.95fr) minmax(0,1fr);gap:clamp(36px,7vw,88px);max-width:1080px;align-items:center;min-height:100dvh;padding-top:48px;padding-bottom:48px}
.auth-intro{max-width:420px}.auth-intro .mindnorth-auth-logo{width:144px;margin:32px 0 24px}.auth-intro h1{margin:0 0 18px;font-size:clamp(2rem,4vw,2.8rem)}.auth-intro .lead{line-height:1.8;margin-bottom:24px}.auth-back{font-size:.85rem}.auth-intro .kicker{margin-bottom:12px}
.auth-panel{background:var(--bg-raised);border:1px solid var(--border);border-radius:20px;padding:clamp(24px,4vw,40px)}.auth-panel h2{font-size:1.6rem;margin-bottom:10px}.auth-panel>header{margin-bottom:28px}.auth-panel>header p{margin:0;line-height:1.7}.auth-form{padding:0;border:0;background:transparent;border-radius:0}.auth-form form{display:grid;gap:20px}.auth-form label{display:grid;gap:8px;margin:0}.auth-form input{margin:0;padding:12px 14px}.auth-form #error{margin-top:18px}.auth-links{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin-top:26px;font-size:.9rem}.auth-links p{margin:0}.auth-help{border-top:1px solid var(--border);padding-top:20px;margin:24px 0 0;font-size:.8rem;color:var(--text-muted);line-height:1.8}.auth-help a{font-weight:600}
@media(max-width:760px){.app-main{padding:28px 20px 40px;gap:24px}.card{padding:22px}.card--flush{padding:0}.split{gap:24px}.grid{gap:16px}.page__head{gap:12px}.auth-shell{grid-template-columns:1fr;gap:28px;min-height:auto;max-width:540px;padding-top:24px}.auth-intro{max-width:none}.auth-intro .mindnorth-auth-logo{width:100px;margin:24px 0 20px}.auth-intro h1{font-size:2rem}.auth-intro .lead{margin-bottom:16px}.auth-panel{padding:24px}.auth-panel>header{margin-bottom:24px}.auth-form{padding:0}.auth-intro .kicker{font-size:.72rem}.auth-links{gap:12px}.brand__name{display:inline;font-size:1rem}.app-footer p{padding-left:20px;padding-right:20px}}
@media(max-width:760px){.auth-intro .mindnorth-auth-logo{width:72px;margin:18px 0 12px}.auth-intro .kicker{display:none}.auth-intro h1{font-size:1.65rem;margin-bottom:10px}.auth-intro .lead{font-size:.94rem;line-height:1.65;margin-bottom:12px}}
@media(max-width:760px){.app-nav__bar{gap:8px}.app-nav__bar .brand__name{display:none}.app-nav__bar #logoutBtn{display:none}.app-nav__bar .nav-profile__name{display:none}.auth-form form,.auth-form label{min-width:0}.mood-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,6.5rem),1fr))}}

.account-dialog{width:min(92vw,42rem);max-height:88dvh;overflow:auto;background:var(--bg-raised);color:var(--text);border:2px solid var(--border-strong);border-radius:16px;padding:28px}.account-dialog::backdrop{background:rgba(0,0,0,.7)}.account-dialog label{display:block;margin:20px 0}.account-dialog p{line-height:1.75}#accountControls input:not([type=checkbox]),#accountControls textarea{width:100%}#accountControls button{margin-top:12px}

#accountControls label{display:block;margin:18px 0}#accountControls label input:not([type=checkbox]),#accountControls label textarea{margin-top:8px}

/* Stored-data notice (schema.js / layout.js): calm, not alarming. */
.schema-notice {
  margin: var(--sp-4, 16px) auto 0;
  max-width: 72ch;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid currentColor;
  background: color-mix(in srgb, currentColor 6%, transparent);
  line-height: 1.5;
}
/* Version · What's new · Feedback row in the footer (tss-app.js). */
.app-footer .tssx-row { margin: 0 0 var(--sp-6, 24px); }

/* 1.2.0 — comfortable tap targets (WCAG 2.5.8). Crisis numbers are the most
   important thing to tap on a phone, so call/text links get at least 44px of
   height without changing how the text reads; footer links get 32px. */
a[href^="tel:"], a[href^="sms:"] {
  /* Inline padding grows the tap area but leaves the text and line
     spacing exactly as they were. */
  padding: 12px 3px; margin: 0 -3px; text-underline-offset: 3px; white-space: nowrap;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.app-footer p a { display: inline-block; padding: 7px 4px; min-height: 32px; }
.auth-links a, a.link-btn { display: inline-block; padding: 6px 2px; min-height: 32px; }


/* ── 10-second check-in (2026-11-08) ── */
.checkin__moods { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--sp-2); margin-bottom: var(--sp-3); }
.checkin__mood { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--sp-2) 2px; min-height: 4.4rem;
  border: 2px solid var(--border-strong); border-radius: 14px; background: transparent; color: inherit; cursor: pointer; font-size: var(--fs-xs); font-weight: 600; }
.checkin__mood:hover { border-color: var(--accent); }
.checkin__mood[aria-checked="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.checkin__face { font-size: 1.7rem; line-height: 1; }
.checkin__tags { border: 0; padding: 0; margin: 0 0 var(--sp-3); }
.checkin__tags legend { padding: 0; margin-bottom: var(--sp-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border: 1px solid var(--border-strong); border-radius: 999px; cursor: pointer; font-size: var(--fs-sm, .9rem); }
.chip:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.checkin input[type=text] { width: 100%; }
.patterns li { margin: .3rem 0; }
.summary-bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.summary-bars span { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.summary-bars span.none { background: transparent; border: 1px dashed var(--border); height: 4px !important; }
.safety textarea { width: 100%; min-height: 4.5rem; }
@media print {
  .site-nav, .nav, header.site-header, footer, .no-print, .skip-link, nav { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .card { box-shadow: none !important; border: 1px solid #999 !important; break-inside: avoid; }
  .summary-bars span { background: #333 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* One-time "MindNorth updated" banner (layout.js showUpdateNotice) */
.update-notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.25rem;
  max-width: 1100px; margin: 1rem auto 0; padding: .9rem 1.1rem; border-radius: 14px;
  background: #e6f2ee; border: 1px solid #9cc9b9; color: #123b31; }
.update-notice p { margin: 0; flex: 1 1 22rem; line-height: 1.45; }
.update-notice__actions { display: flex; gap: .5rem; }
[data-theme="dark"] .update-notice { background: #16302a; border-color: #2f6b5a; color: #e6f2ee; }
