:root {
    --bg-sand: #ebe4d1;
    --bg-sea: #b7d2cc;
    --bg-deep: #143334;
    --card: #fffaf0;
    --card-alt: #f2ebd9;
    --ink: #1e2b2f;
    --muted: #4d5f66;
    --accent: #0f6f67;
    --accent-strong: #134a45;
    --sun: #b98947;
    --ok: #1f7a4f;
    --error: #a43d2f;
    --radius-lg: 20px;
    --radius-md: 12px;
    --shadow-soft: 0 16px 36px rgba(17, 39, 42, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: "Manrope", "Segoe UI", sans-serif;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 8% -8%, rgba(185, 137, 71, 0.28), transparent 36%),
        radial-gradient(circle at 93% 2%, rgba(15, 111, 103, 0.24), transparent 39%),
        linear-gradient(165deg, var(--bg-sand), var(--bg-sea));
}

.page-shell {
    width: min(100%, 1440px);
    margin: 2rem auto 3rem;
    padding-inline: clamp(0.55rem, 2vw, 1rem);
    display: grid;
    gap: 1.15rem;
}

.hero {
    position: relative;
    background: linear-gradient(145deg, rgba(255, 253, 247, 0.95), rgba(247, 243, 232, 0.9));
    border: 1px solid rgba(16, 54, 58, 0.1);
    border-radius: var(--radius-lg);
    padding: 1.8rem 2rem;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.hero::before,
.hero::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    opacity: 0.38;
    pointer-events: none;
}

.hero::before {
    width: 260px;
    height: 260px;
    right: -85px;
    top: -145px;
    background: radial-gradient(circle, rgba(185, 137, 71, 0.42), rgba(185, 137, 71, 0));
}

.hero::after {
    width: 170px;
    height: 170px;
    right: 20px;
    bottom: -90px;
    background: radial-gradient(circle, rgba(15, 111, 103, 0.28), rgba(15, 111, 103, 0));
}

.eyebrow {
    margin: 0;
    font-size: 0.82rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent-strong);
    font-weight: 800;
}

h1,
h2,
h3 {
    margin: 0;
    font-family: "Cormorant Garamond", Georgia, serif;
    line-height: 1.1;
}

h1 {
    margin-top: 0.4rem;
    font-size: clamp(2.05rem, 4vw, 3.4rem);
}

h2 {
    font-size: clamp(1.6rem, 2.2vw, 2rem);
}

h3 {
    font-size: 1.25rem;
}

.hero-copy {
    margin: 0.9rem 0 0;
    max-width: 78ch;
    color: var(--muted);
    line-height: 1.5;
}

.auth-shell {
    width: min(1100px, 98vw);
}

.auth-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-card-wide {
    grid-column: 1 / -1;
}

.session-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.65rem;
    border: 1px solid rgba(19, 74, 69, 0.18);
    border-radius: var(--radius-md);
    background: rgba(255, 250, 240, 0.84);
    padding: 0.7rem 0.8rem;
}

.session-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.87rem;
}

.session-info strong {
    color: var(--ink);
}

.session-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(19, 74, 69, 0.2);
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    background: rgba(255, 255, 255, 0.68);
}

.logout-form {
    margin: 0;
}

.dashboard-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.48rem;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(19, 74, 69, 0.2);
    background: rgba(255, 250, 240, 0.82);
}

.nav-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.42rem 0.82rem;
    border-radius: 999px;
    border: 1px solid rgba(19, 74, 69, 0.24);
    color: var(--accent-strong);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.72);
}

.nav-pill.is-active {
    color: #f5f7f7;
    border-color: transparent;
    background: linear-gradient(120deg, var(--accent-strong), var(--accent));
    box-shadow: 0 10px 24px rgba(9, 84, 77, 0.22);
}

.quest-steps {
    display: grid;
    gap: 0.7rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.quest-step {
    border-radius: var(--radius-md);
    border: 1px solid rgba(20, 74, 69, 0.18);
    background: linear-gradient(150deg, rgba(255, 250, 240, 0.92), rgba(242, 235, 217, 0.88));
    padding: 0.78rem;
    display: grid;
    gap: 0.36rem;
}

.quest-step h3 {
    font-size: 1.05rem;
}

.quest-step p {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.35;
}

.quest-index {
    display: inline-grid;
    place-items: center;
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 999px;
    border: 1px solid rgba(20, 74, 69, 0.3);
    color: var(--accent-strong);
    background: rgba(255, 255, 255, 0.7);
    font-weight: 800;
    font-size: 0.78rem;
}

.flash {
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
    font-weight: 700;
}

.flash-ok {
    border: 1px solid color-mix(in srgb, var(--ok) 40%, white);
    background: color-mix(in srgb, var(--ok) 10%, white);
    color: #104f30;
}

.flash-error {
    border: 1px solid color-mix(in srgb, var(--error) 46%, white);
    background: color-mix(in srgb, var(--error) 12%, white);
    color: #76251b;
}

.top-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1.35fr 1fr;
}

.panel {
    background: linear-gradient(160deg, rgba(255, 253, 247, 0.95), rgba(248, 245, 236, 0.9));
    border: 1px solid rgba(16, 54, 58, 0.12);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 1.35rem;
    display: grid;
    gap: 1rem;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.metric-block {
    background: color-mix(in srgb, var(--card) 82%, var(--bg-sea));
    border: 1px solid rgba(16, 54, 58, 0.08);
    border-radius: var(--radius-md);
    padding: 0.7rem 0.8rem;
}

.metric-label {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
}

.metric-value {
    margin-top: 0.35rem;
    display: block;
    font-size: 1.18rem;
}

.progress-wrap {
    display: grid;
    gap: 0.42rem;
}

.progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.88rem;
    color: var(--muted);
    font-weight: 700;
}

.progress-track {
    position: relative;
    height: 0.95rem;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(10, 123, 113, 0.15);
    border: 1px solid rgba(10, 123, 113, 0.2);
}

.progress-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background:
        linear-gradient(100deg, rgba(9, 84, 77, 0.95), rgba(10, 123, 113, 0.95) 58%, rgba(192, 138, 69, 0.9));
    box-shadow: inset -8px 0 12px rgba(255, 255, 255, 0.2);
    transition: width 280ms ease;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.9rem;
}

.stack-form,
.add-member-form {
    display: grid;
    gap: 0.75rem;
}

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

input {
    font: inherit;
    border-radius: 10px;
    border: 1px solid rgba(16, 54, 58, 0.2);
    padding: 0.54rem 0.62rem;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.95);
}

input:focus {
    outline: 2px solid rgba(10, 123, 113, 0.35);
    border-color: rgba(10, 123, 113, 0.6);
}

.date-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font: inherit;
    font-weight: 800;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    padding: 0.52rem 1rem;
    transition: transform 160ms ease, box-shadow 180ms ease, background 180ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    color: #f4f7f7;
    background: linear-gradient(120deg, var(--accent-strong), var(--accent));
    box-shadow: 0 12px 28px rgba(9, 84, 77, 0.26);
}

.button-ghost {
    color: var(--accent-strong);
    border-color: rgba(9, 84, 77, 0.28);
    background: rgba(255, 255, 255, 0.72);
}

.button-link {
    text-decoration: none;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(19, 74, 69, 0.14);
    padding-bottom: 0.5rem;
}

.section-heading p {
    margin: 0;
    color: var(--muted);
}

.section-heading-inline {
    align-items: center;
}

.member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.7rem;
}

.member-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(16, 54, 58, 0.11);
    background: color-mix(in srgb, var(--card-alt) 78%, white);
}

.member-card p {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.helper-note {
    margin: 0;
    color: var(--muted);
    font-style: italic;
}

code {
    font-size: 0.78rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background: rgba(16, 54, 58, 0.08);
    border-radius: 6px;
    padding: 0.1rem 0.35rem;
    overflow-wrap: anywhere;
}

.strava-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 1rem;
    color: var(--muted);
    font-size: 0.84rem;
}

.strava-meta span {
    min-width: 0;
}

.strava-sync-all-form {
    width: fit-content;
}

.strava-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.7rem;
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.overview-card {
    border: 1px solid rgba(16, 54, 58, 0.14);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--card) 86%, white);
    padding: 0.75rem;
    display: grid;
    gap: 0.44rem;
}

.overview-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.strava-card {
    border: 1px solid rgba(16, 54, 58, 0.12);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--card) 88%, white);
    padding: 0.75rem;
    display: grid;
    gap: 0.5rem;
}

.strava-card p {
    margin: 0;
}

.strava-connected {
    color: var(--ok);
    font-weight: 700;
}

.strava-status {
    color: var(--muted);
    font-size: 0.83rem;
}

.strava-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.strava-actions form {
    margin: 0;
}

.steps-table-wrap {
    border: 1px solid rgba(16, 54, 58, 0.15);
    border-radius: var(--radius-md);
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    background: rgba(255, 255, 255, 0.75);
}

.steps-table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
}

.steps-table th,
.steps-table td {
    border-bottom: 1px solid rgba(16, 54, 58, 0.1);
    padding: 0.34rem 0.24rem;
    text-align: center;
    font-size: 0.75rem;
    white-space: nowrap;
}

.steps-table thead th {
    font-size: 0.67rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    background: color-mix(in srgb, var(--card-alt) 70%, white);
}

.steps-table th:not(.sticky-col),
.steps-table td:not(.sticky-col) {
    min-width: 48px;
}

.sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: color-mix(in srgb, var(--card) 88%, white);
}

.member-name-cell {
    min-width: 142px;
    text-align: left;
}

.member-name-cell span {
    display: block;
    font-weight: 700;
}

.member-name-cell small {
    color: var(--muted);
    font-size: 0.72rem;
}

.step-input {
    width: 3.2rem;
    min-width: 0;
    padding: 0.28rem 0.3rem;
    text-align: right;
    border-radius: 8px;
    border-color: rgba(16, 54, 58, 0.22);
}

.total-cell {
    font-weight: 800;
    color: var(--accent-strong);
}

.steps-table tfoot th,
.steps-table tfoot td {
    border-bottom: none;
    background: color-mix(in srgb, var(--bg-sea) 58%, white);
}

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

.realm-card {
    border: 1px solid rgba(16, 54, 58, 0.14);
    border-radius: var(--radius-md);
    padding: 0.8rem;
    display: grid;
    gap: 0.32rem;
    background: rgba(255, 255, 255, 0.75);
}

.realm-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.realm-card strong {
    font-size: 0.82rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.realm-index {
    display: inline-block;
    width: fit-content;
    padding: 0.12rem 0.46rem;
    border-radius: 999px;
    border: 1px solid rgba(16, 54, 58, 0.2);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.realm-met {
    background: color-mix(in srgb, var(--ok) 14%, white);
}

.realm-met strong {
    color: #1f7a4f;
}

.realm-current {
    background: linear-gradient(140deg, rgba(192, 138, 69, 0.18), rgba(10, 123, 113, 0.12));
    border-color: rgba(192, 138, 69, 0.58);
}

.realm-current strong {
    color: #7f531a;
}

.realm-locked {
    opacity: 0.85;
}

.reveal {
    opacity: 0;
    transform: translateY(12px);
    animation: reveal-up 560ms ease forwards;
    animation-delay: var(--delay, 0ms);
}

@keyframes reveal-up {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1040px) {
    .auth-grid {
        grid-template-columns: 1fr;
    }

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

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

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

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

    .member-name-cell {
        min-width: 138px;
    }

    .step-input {
        width: 3.35rem;
    }
}

@media (max-width: 860px) {
    .sticky-col {
        position: static;
    }

    .steps-table-wrap {
        margin-inline: -0.2rem;
        width: calc(100% + 0.4rem);
    }

    .steps-table th,
    .steps-table td {
        font-size: 0.71rem;
    }

    .step-input {
        width: 3rem;
    }
}

@media (max-width: 720px) {
    .quest-steps {
        grid-template-columns: 1fr;
    }

    .auth-shell {
        width: 100%;
    }

    .page-shell {
        width: 100%;
        margin: 1rem auto 2rem;
    }

    .hero,
    .panel {
        padding: 1rem;
    }

    .metric-grid,
    .date-grid {
        grid-template-columns: 1fr;
    }

    .meta-row,
    .section-heading {
        flex-direction: column;
        align-items: flex-start;
    }

    .button {
        width: 100%;
    }

    .dashboard-nav {
        gap: 0.35rem;
    }

    .session-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .session-info {
        width: 100%;
    }

    .nav-pill {
        flex: 1 1 calc(50% - 0.35rem);
    }

    .strava-sync-all-form {
        width: 100%;
    }

    .strava-actions {
        flex-direction: column;
    }
}
