.page-header {
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    /* padding-bottom: 0.5rem;    */
    & h1{
        margin-top: 0.5rem;
    }
}

/* ── Floating bottom navigation bar ── */

.page-nav {
    position: fixed;
    left: 50%;
    /* bottom: calc(var(--nav-offset-bottom) + env(safe-area-inset-bottom)); */
    bottom: 1rem;
    transform: translateX(-50%);
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    height: var(--nav-height);
    width: max-content;
    max-width: calc(100% - 2rem);
    /* background: var(--color-surface-translucent); */
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--color-brand-dark-soft);
    border-radius: 999px;
    box-shadow: 0 8px 24px var(--shadow-black-15);
    padding: 0.45rem 0.6rem;
}

.page-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-width: 64px;
    text-decoration: none;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-brand-muted);
    transition: color 0.15s, background 0.15s;
}

.page-nav .nav-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.page-nav a:hover {
    color: var(--color-brand-dark);
}

.page-nav a.active {
    color: var(--color-brand);
    background: var(--color-brand-soft);
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 0.2rem;
    margin-bottom: 1.5rem;
    width: 100%;
    max-width: 520px;
}

/* history table */
.history-section {
    width: 100%;
    max-width: 520px;
    flex: 1;
    min-height: 0; /* let flex children shrink so .history-cards can scroll internally */
    display: flex;
    flex-direction: column;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.history-header h2 {
    font-size: 1.1rem;
}

.history-cards {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    padding: 0.2rem;
    padding-bottom: calc(var(--nav-clearance) + env(safe-area-inset-bottom)); /* lets content flow behind the floating nav while scrolling, like the chart page, but still clears it at the very end */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* legacy Edge/IE */
}

.history-cards::-webkit-scrollbar {
    display: none; /* Chrome/Safari/WebKit */
}

@media (max-width: 640px) {
    .action-grid {
        gap: 0.6rem;
    }

    .btn {
        min-height: 80px;
        font-size: 1.4rem;
    }

    .btn span.label {
        font-size: 0.65rem;
    }
}

/* ── Secondary actions (main page) ── */

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 520px;
    margin-bottom: 1rem;
}

.cal-nav button {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    transition: background 0.15s;
}

.cal-nav button:hover {
    background: var(--color-surface-tan);
}

.cal-nav h2 {
    font-size: 1.1rem;
}

.cal-nav,
.cal-grid {
    font-family: 'Datatype', monospace;
}

/* ── Chart page ── */

.chart-container {
    width: 100%;
    max-width: 480px;
}

/* ── Network error page ── */

.error-section {
    max-width: 620px;
    text-align: center;
}