:root {
    --bg: #f3f6f1;
    --surface: #ffffff;
    --surface-strong: #e8f0e9;
    --text: #15231d;
    --muted: #60706a;
    --line: #d7e0da;
    --primary: #194a3a;
    --primary-strong: #0f3327;
    --accent: #b65f32;
    --warning: #efe3c5;
    --success: #dceedd;
    --danger: #f3d8d2;
    --shadow: 0 16px 40px rgba(21, 35, 29, 0.08);
}

html,
body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    letter-spacing: 0;
}

body {
    margin: 0;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-size: 1.9rem;
    line-height: 1.1;
    margin-bottom: 0;
    outline: none;
}

h2 {
    font-size: 1.05rem;
    line-height: 1.25;
    margin-bottom: 0;
}

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

button,
.button-link {
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0.7rem 1rem;
    text-decoration: none;
    font-weight: 700;
}

button:disabled {
    cursor: progress;
    opacity: 0.65;
}

.primary,
.button-link {
    background: var(--primary);
    color: #ffffff;
}

.secondary {
    background: var(--surface-strong);
    color: var(--primary-strong);
    border: 1px solid var(--line);
}

.page-header,
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.page-header p {
    margin-bottom: 0.15rem;
}

.page-header__sub {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 0.25rem;
    margin-bottom: 0;
}

.eyebrow {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
}

.dashboard-grid,
.two-column,
.form-grid,
.bp-session-grid,
.summary-grid {
    display: grid;
    gap: 0.85rem;
}

.dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel,
.metric-panel,
.entry-card,
.preference-list article,
.quick-card,
.settings-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel,
.metric-panel,
.quick-card,
.settings-card {
    padding: 1rem;
}

.metric-panel span,
.entry-card__meta time,
.entry-card small,
.muted,
.status,
small {
    color: var(--muted);
}

.metric-panel strong {
    font-size: 1.4rem;
    line-height: 1.15;
}

.entry-list,
.preference-list,
.toolbar-stack {
    display: grid;
    gap: 0.75rem;
}

.toolbar-stack .button-link {
    width: 100%;
    justify-content: flex-start;
}

.entry-card {
    padding: 0.9rem;
    display: block;
    text-decoration: none;
    color: inherit;
}

a.entry-card:hover,
button.entry-card:hover {
    background: var(--surface-strong);
    cursor: pointer;
}

.entry-card__meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.entry-card__type {
    font-weight: 800;
}

.entry-card__detail {
    display: block;
    margin-bottom: 0.45rem;
}

.form-grid {
    grid-template-columns: 1fr;
}

label {
    display: grid;
    gap: 0.35rem;
    color: var(--muted);
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    padding: 0.75rem 0.8rem;
    background: #fff;
}

textarea {
    resize: vertical;
}

.span-2 {
    grid-column: span 1;
}

.range-value {
    color: var(--text);
    font-weight: 800;
}

.choice-list,
.full-field {
    display: grid;
    gap: 0.55rem;
    margin-bottom: 1rem;
}

.check-row {
    align-items: center;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.7rem;
    padding: 0.7rem;
}

.check-row input {
    width: auto;
}

.summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-grid article,
.compact-bars div {
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.75rem;
}

.summary-grid span,
.compact-bars span {
    color: var(--muted);
    display: block;
}

.compact-bars {
    display: grid;
    gap: 0.55rem;
}

.quick-card,
.settings-card {
    display: grid;
    gap: 0.75rem;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--primary-strong);
    border: 1px solid var(--line);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.hero-card {
    background: var(--primary);
    color: #fff;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.hero-card .muted,
.hero-card small {
    color: #d6e7df;
}

.hero-card__eyebrow {
    color: #cde3da;
    margin-bottom: 0.5rem;
}

.hero-card__sub {
    color: #cde3da;
    font-size: 0.82rem;
    font-weight: 600;
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.pill-row--status {
    margin-bottom: 0;
}

.pill--success {
    background: var(--success);
    color: var(--primary-strong);
    border-color: var(--success);
}

.pill--muted {
    background: var(--surface-strong);
    color: var(--primary-strong);
}

.icon-btn {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    width: 2.625rem;
    height: 2.625rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    flex-shrink: 0;
    padding: 0;
}

.metrics-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.metrics-row--three {
    grid-template-columns: 1fr;
}

.metric-panel {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.metric-panel__label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
}

.metric-panel__sub {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--muted);
}

.metric-panel__header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.metric-panel__header span {
    font-size: 0.78rem;
    font-weight: 600;
}

.info-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.85rem;
    box-shadow: var(--shadow);
}

.info-card__header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.35rem;
    color: var(--muted);
}

.info-card__title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}

.info-card__time {
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 500;
}

.info-card__body {
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 500;
    margin: 0;
}

.toolbar {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.toolbar button,
.toolbar a {
    min-height: 2.5rem;
}

#blazor-error-ui {
    color-scheme: light only;
    background: #fff4d7;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: #d8e1dc;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--primary);
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

@media (min-width: 700px) {
    .dashboard-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .metrics-row--three {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .two-column {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid,
    .bp-session-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .span-2 {
        grid-column: span 2;
    }
}

/* ── Desktop page grid: main content + right aside ── */
.page-grid {
    display: grid;
    gap: 1.25rem;
}

@media (min-width: 900px) {
    .page-grid {
        grid-template-columns: minmax(0, 1fr) 280px;
        align-items: start;
    }

    .page-grid .page-grid__main {
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .page-grid .page-grid__aside {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    /* Tighter header on desktop — no icon button needed */
    .page-header--desktop-compact .icon-btn {
        display: none;
    }

    /* Metrics row: keep 2 columns on dashboard desktop — cards are side by side */
    .metrics-row--desktop {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ── Side navigation (desktop only) ── */
.side-nav {
    display: none;
}

@media (min-width: 900px) {
    /* Hide the mobile bottom nav */
    .bottom-nav {
        display: none;
    }

    /* Show the sidebar */
    .side-nav {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 220px;
        background: var(--surface);
        border-right: 1px solid var(--line);
        padding: 1.5rem 0.75rem;
        z-index: 200;
        gap: 0;
    }

    .side-nav__brand {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0.25rem 0.75rem 1.5rem;
        border-bottom: 1px solid var(--line);
        margin-bottom: 1rem;
    }

    .side-nav__logo {
        width: 22px;
        height: 22px;
        color: var(--primary);
        flex-shrink: 0;
    }

    .side-nav__brand-name {
        font-size: 1rem;
        font-weight: 800;
        color: var(--primary-strong);
        letter-spacing: -0.01em;
    }

    .side-nav__list {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
        flex: 1;
    }

    .side-nav__link {
        display: flex;
        align-items: center;
        gap: 0.7rem;
        padding: 0.65rem 0.75rem;
        border-radius: 8px;
        text-decoration: none;
        color: var(--muted);
        font-size: 0.88rem;
        font-weight: 600;
        transition: background 0.13s ease, color 0.13s ease;
    }

    .side-nav__link:hover {
        background: var(--surface-strong);
        color: var(--text);
    }

    .side-nav__link.active {
        background: var(--primary);
        color: #ffffff;
        font-weight: 700;
    }

    .side-nav__link.active .side-nav__icon {
        stroke-width: 2.5;
    }

    .side-nav__icon {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .side-nav__footer {
        border-top: 1px solid var(--line);
        padding-top: 0.75rem;
        margin-top: 0.5rem;
    }

}

/* ── Chat page ── */
.chat-shell {
    display: flex;
    flex-direction: column;
    /* Break out of content-shell padding */
    margin: -1rem -1.125rem 0;
    /* Mobile: fill viewport minus bottom-nav */
    height: calc(100dvh - calc(5.5rem + env(safe-area-inset-bottom, 0px)));
    background: var(--bg);
}

@media (min-width: 900px) {
    .chat-shell {
        /* Break out of content-shell desktop padding */
        margin: -2rem -2.5rem 0;
        /* Desktop: fill viewport */
        height: 100dvh;
    }
}

.chat-shell__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 28px 16px 28px;
    flex-shrink: 0;
}

.chat-shell__title-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.chat-shell__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    line-height: 1.25;
}

.chat-shell__subtitle {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted);
    margin: 0;
    line-height: 1.25;
}

.chat-badge {
    background: var(--success);
    color: var(--primary);
    font-size: 0.6875rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    border-radius: 18px;
    padding: 7px 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.chat-shell__messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 28px 16px 28px;
}

/* Individual message bubbles */
.message {
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 600px;
}

.message.assistant {
    background: var(--surface-strong);
}

.message.user {
    background: var(--warning);
}

.message__from {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--muted);
    line-height: 1.25;
}

.message p {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--text);
}

.chat-shell__input-bar {
    padding: 12px 28px 20px 28px;
    flex-shrink: 0;
    border-top: 1px solid var(--line);
}

.chat-input {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 26px;
    padding: 0 16px;
    height: 50px;
}

.chat-input input {
    flex: 1;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 0.875rem;
    color: var(--text);
    padding: 0;
    outline: none;
}

.chat-input input::placeholder {
    color: var(--muted);
}

.chat-send-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--primary);
    padding: 0.25rem;
    flex-shrink: 0;
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ── Bottom navigation pill ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    padding: 0.75rem 1.125rem calc(1rem + env(safe-area-inset-bottom, 0px));
    background: transparent;
}

.bottom-nav__pill {
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.25rem;
    height: 62px;
    max-width: 440px;
    margin: 0 auto;
    box-shadow: 0 12px 30px rgba(21, 35, 29, 0.09);
}

.bottom-nav__tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    border-radius: 26px;
    text-decoration: none;
    color: var(--muted);
    transition: background 0.15s ease, color 0.15s ease;
}

.bottom-nav__tab svg.tab-icon {
    display: block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.bottom-nav__tab .tab-label {
    display: block;
    font-size: 0.625rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
    line-height: 1;
}

.bottom-nav__tab.active {
    background: var(--primary);
    color: #ffffff;
}

.bottom-nav__tab.active svg.tab-icon {
    stroke-width: 2.5;
}

/* ── Google Health status panel ── */
.google-health-status__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.google-health-status__list,
.google-health-status__sync-types {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.google-health-status__list {
    margin-bottom: 1rem;
}

.google-health-status__row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.google-health-status__row--ok  { color: var(--text); }
.google-health-status__row--fail { color: var(--error); }

.google-health-status__scopes {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.status-dot--ok   { background: #4ade80; }
.status-dot--fail { background: var(--error); }

.google-health-status__error {
    font-size: 0.75rem;
    color: var(--muted);
    margin-left: 0.25rem;
}

.google-health-status__connect,
.google-health-status__sync {
    display: inline-block;
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 0;
}

.google-health-status__connect {
    background: var(--primary);
    color: #ffffff;
}

.google-health-status__sync {
    background: var(--surface-strong);
    color: var(--primary);
    border: 1px solid var(--line);
}

.google-health-status__sync:disabled {
    opacity: 0.5;
    cursor: default;
}

.google-health-status__sync-result {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line);
}

.google-health-status__sync-ok   { color: var(--primary); font-size: 0.875rem; margin-bottom: 0.5rem; }
.google-health-status__sync-warn { color: var(--error);   font-size: 0.875rem; margin-bottom: 0.5rem; }

.btn-icon {
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--muted);
    padding: 0.25rem;
    display: inline-flex;
    align-items: center;
}

/* ── Google Health page ─────────────────────────── */
.gh-hero { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.gh-hero__body { flex: 1 1 220px; }
.gh-hero__status { display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; }
.gh-connect-btn { margin-top: 0.75rem; display: inline-block; }

.gh-pills { display: flex; flex-wrap: wrap; gap: 0.5rem; flex: 1 1 auto; align-self: center; }
.gh-pill {
    background: var(--surface, #f5f5f3);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    min-width: 90px;
    text-align: center;
}
.gh-pill__label { display: block; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.gh-pill__value { display: block; font-size: 1.2rem; font-weight: 600; }

.gh-sync-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.gh-sync-header h2 { margin: 0; }

.gh-sync-results { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .25rem; }
.gh-sync-ok   { display: flex; align-items: center; gap: .4rem; font-size: .875rem; }
.gh-sync-fail { display: flex; align-items: center; gap: .4rem; font-size: .875rem; color: var(--error, #c0392b); }
.gh-error { color: var(--error, #c0392b); font-size: .875rem; margin: .5rem 0; }

.gh-metric-tabs { display: flex; flex-wrap: wrap; gap: .25rem; }
.gh-tab {
    background: var(--surface, #f5f5f3);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: .25rem .75rem;
    font-size: .8rem;
    cursor: pointer;
    color: var(--text);
}
.gh-tab--active {
    background: var(--primary, #2e7d56);
    color: #fff;
    border-color: var(--primary, #2e7d56);
}

.gh-table { width: 100%; border-collapse: collapse; font-size: .875rem; margin-top: .5rem; }
.gh-table th { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--border, #e0e0e0); font-weight: 600; }
.gh-table td { padding: .4rem .6rem; border-bottom: 1px solid var(--border, #e8e8e6); }

/* --- Symptom quick-add grid --- */
.symptom-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.symptom-btn {
    padding: 0.45rem 0.85rem;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.symptom-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.symptom-btn--active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.intensity-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.intensity-btn {
    flex: 1;
    min-width: 4.5rem;
    padding: 0.4rem 0.5rem;
    border: 1.5px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.intensity-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.intensity-btn--active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.gh-table tr:last-child td { border-bottom: none; }
