/* Trener - mobile-first dark UI.
   No CSS framework on purpose: a handful of screens used one-thumb on a phone.
   Cards carry the identity here - each gets depth, a tinted edge and its own
   colour cue, so the eye can tell them apart without reading. */

:root {
    /* surfaces, from the page up */
    --bg: #0b0f14;
    --bg-glow: #121a24;
    --surface: #151b23;
    --surface-2: #1b232d;
    --surface-3: #222c38;
    --border: #26313f;
    --border-soft: #1e2733;

    /* text */
    --text: #e8eef5;
    --muted: #93a2b6;
    --faint: #64748b;

    /* accents */
    --accent: #f97316;
    --accent-soft: #7c3a12;
    --good: #4ade80;
    --warn: #fbbf24;
    --danger: #f87171;

    --radius: 18px;
    --radius-sm: 12px;
    --radius-pill: 999px;

    --shadow: 0 12px 28px -18px rgba(0, 0, 0, 0.9);
    /* Wycięcia ekranu: w trybie aplikacji strona rysuje się pod paskiem stanu
       i pod paskiem gestów, więc marginesy muszą je uwzględniać. */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--bg);
    background-image:
        radial-gradient(60rem 30rem at 50% -12rem, var(--bg-glow), transparent 70%);
    background-attachment: fixed;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font-family: inherit;
}

h1 {
    font-size: 1.4rem;
    font-weight: 650;
    letter-spacing: -0.015em;
    margin: 0;
    line-height: 1.15;
}

h2 {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    margin: 0;
}

.numeric {
    font-variant-numeric: tabular-nums;
}

.app-shell {
    max-width: 640px;
    margin: 0 auto;
    padding:
        calc(1.1rem + var(--safe-top))
        calc(1rem + var(--safe-right))
        calc(6rem + var(--safe-bottom))
        calc(1rem + var(--safe-left));
}

/* Mobile-first, but a desktop browser should not render a phone-width strip in
   a sea of empty space: from a tablet up the cards flow into balanced columns,
   with the wide elements (header, week bar, metric tiles) spanning across. */
@media (min-width: 700px) {
    .app-shell {
        max-width: 760px;
        /* the floating nav pill hovers over the page - leave it room */
        padding:
            calc(1.5rem + var(--safe-top))
            calc(1.5rem + var(--safe-right))
            calc(8rem + var(--safe-bottom))
            calc(1.5rem + var(--safe-left));
    }
}

@media (min-width: 1000px) {
    .app-shell {
        max-width: 1140px;
    }

    .content {
        column-count: 2;
        column-gap: 1rem;
    }

    .content > * {
        break-inside: avoid;
    }

    /* Wide elements break the column flow on purpose - a tall card left inside
       one column would push everything else out of reading order. */
    .content > .page-head,
    .content > .section-tabs,
    .content > .week-card,
    .content > .form-tiles,
    .content > .sync-note,
    .content > .calendar,
    .content > .legend,
    .content > .page-footer,
    .content > .span-all {
        column-span: all;
    }

    .form-tiles {
        grid-template-columns: repeat(4, 1fr);
    }

    h1 {
        font-size: 1.7rem;
    }
}

@media (min-width: 1400px) {
    .app-shell {
        max-width: 1320px;
    }

    .content {
        column-count: 3;
    }
}

.bare-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: calc(1.5rem + var(--safe-top)) 1.5rem calc(1.5rem + var(--safe-bottom));
}

/* --- header --------------------------------------------------------------- */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
}

.subtitle {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.month-nav {
    display: flex;
    gap: 0.35rem;
}

/* --- cards ---------------------------------------------------------------- */
.card {
    position: relative;
    background:
        linear-gradient(180deg, var(--surface) 0%, #121820 100%);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 0.85rem;
    overflow: hidden;
}

/* hairline highlight along the top edge - what makes the cards read as objects */
.card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.09), transparent);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.eyebrow {
    color: var(--faint);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.empty {
    display: grid;
    gap: 0.7rem;
    justify-items: start;
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0.15rem 0;
}

.empty p {
    margin: 0;
}

/* --- form fields ---------------------------------------------------------- */
.field {
    margin-bottom: 0.9rem;
}

.field-row {
    display: flex;
    gap: 0.6rem;
}

.field-row > .field,
.field-row > .input {
    flex: 1;
    min-width: 0;
}

label {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    padding: 0.7rem 0.75rem;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface-3);
}

textarea.input {
    resize: vertical;
}

.input-unit {
    position: relative;
    flex: 1;
    min-width: 0;
}

.input-unit .input {
    padding-right: 3.2rem;
}

.unit {
    position: absolute;
    right: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--faint);
    font-size: 0.8rem;
    pointer-events: none;
}

/* --- buttons and chips ---------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    padding: 0.7rem 1rem;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(180deg, #fb8b3c, var(--accent));
    border-color: #c2570d;
    color: #1a1006;
    font-weight: 650;
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--muted);
}

.btn-danger {
    background: transparent;
    border-color: rgba(248, 113, 113, 0.4);
    color: var(--danger);
    margin-top: 0.6rem;
}

.btn-block {
    width: 100%;
}

.btn-small {
    padding: 0.42rem 0.72rem;
    font-size: 0.85rem;
    border-radius: var(--radius-pill);
}

.btn:disabled {
    opacity: 0.55;
}

.btn-icon {
    display: inline-grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.btn-icon:active {
    color: var(--text);
    border-color: var(--border);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chips-tight {
    gap: 0.3rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--muted);
    font-size: 0.85rem;
    padding: 0.5rem 0.8rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip-on {
    background: color-mix(in srgb, var(--type-color, var(--accent)) 20%, var(--surface-2));
    border-color: var(--type-color, var(--accent));
    color: var(--text);
    font-weight: 600;
}

.chip-num {
    min-width: 2.5rem;
    padding: 0.5rem 0;
    justify-content: center;
}

.chip:disabled {
    opacity: 0.4;
}

/* --- 1-5 rating ----------------------------------------------------------- */
.sliders {
    display: grid;
    gap: 0.75rem;
}

.slider-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}

.slider-value {
    color: var(--faint);
    font-size: 0.8rem;
}

.dots {
    display: flex;
    gap: 0.35rem;
}

.dot {
    flex: 1;
    height: 2.5rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--faint);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.dot-on {
    background: linear-gradient(180deg, var(--accent-soft), #5f2c0e);
    border-color: #8a4415;
    color: var(--text);
}

/* --- activity rows -------------------------------------------------------- */
.activity-list,
.plan-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

.activity-row,
.plan-list li {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.8rem 0.7rem 1rem;
    overflow: hidden;
    transition: background 0.15s ease;
}

/* the colour rail that tells disciplines apart at a glance */
.activity-row::before,
.plan-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--type-color, var(--faint));
}

.activity-row:active {
    background: var(--surface-3);
}

.activity-icon {
    display: grid;
    place-items: center;
    width: 2.3rem;
    height: 2.3rem;
    flex: none;
    border-radius: 10px;
    background: color-mix(in srgb, var(--type-color) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--type-color) 40%, transparent);
    color: var(--type-color);
}

.activity-main,
.plan-main {
    display: grid;
    gap: 0.12rem;
    flex: 1;
    min-width: 0;
}

.activity-title,
.plan-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.activity-duration {
    margin-left: auto;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
}

.activity-meta,
.plan-meta {
    color: var(--muted);
    font-size: 0.8rem;
}

.activity-notes,
.plan-desc {
    color: var(--faint);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag {
    display: inline-block;
    padding: 0.08rem 0.4rem;
    border-radius: 6px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    color: var(--faint);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.totals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border-soft);
    color: var(--muted);
    font-size: 0.82rem;
}

/* --- icons ---------------------------------------------------------------- */
.icon {
    width: 22px;
    height: 22px;
    flex: none;
    display: block;
}

.icon-sm {
    width: 17px;
    height: 17px;
}

.icon-xs {
    width: 13px;
    height: 13px;
}

/* --- daily energy balance ------------------------------------------------- */
.balance-card {
    background:
        radial-gradient(22rem 11rem at 85% -5rem, rgba(34, 211, 238, 0.12), transparent 70%),
        linear-gradient(180deg, var(--surface) 0%, #121820 100%);
}

.balance-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.balance-cell {
    display: grid;
    gap: 0.1rem;
}

.balance-value {
    font-size: 1.5rem;
    font-weight: 660;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.balance-value.good {
    color: var(--good);
}

.balance-value.over {
    color: var(--warn);
}

/* two bars on one scale - length difference is the balance */
.balance-bars {
    display: grid;
    gap: 0.3rem;
    margin-top: 0.9rem;
}

.balance-bar {
    height: 7px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    overflow: hidden;
}

.balance-bar span {
    display: block;
    height: 100%;
    border-radius: var(--radius-pill);
    transition: width 0.4s ease;
}

/* --- sync feedback -------------------------------------------------------- */
.sync-note {
    margin: -0.4rem 0 0.9rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.sync-failed {
    color: var(--warn);
}

.spinning .icon {
    animation: spin 1.1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- week card ------------------------------------------------------------ */
.week-card {
    background:
        radial-gradient(24rem 12rem at 12% -6rem, rgba(249, 115, 22, 0.16), transparent 70%),
        linear-gradient(180deg, var(--surface) 0%, #121820 100%);
}

.week-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 0.7rem;
}

.week-total {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}

.week-total strong {
    font-size: 1.7rem;
    font-weight: 680;
    letter-spacing: -0.02em;
}

.week-target {
    color: var(--faint);
    font-size: 0.85rem;
}

.week-percent {
    color: var(--accent);
    font-size: 0.95rem;
    font-weight: 600;
}

.week-bar {
    position: relative;
    height: 9px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    overflow: hidden;
}

/* stacked by discipline: proportions speak louder than a single total */
.week-seg {
    height: 100%;
    float: left;
    transition: width 0.4s ease;
}

.week-mark {
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 2px;
    background: rgba(232, 238, 245, 0.35);
}

.week-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.6rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.week-legend span.dot-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.week-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
    margin-top: 0.85rem;
}

.week-day {
    display: grid;
    justify-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--surface-2);
}

.week-day-today {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
}

.week-day-name {
    color: var(--muted);
    font-size: 0.72rem;
}

.week-day-dots {
    display: flex;
    gap: 2px;
    height: 6px;
}

.cal-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

/* --- metric tiles --------------------------------------------------------- */
.form-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.6rem;
    margin-bottom: 0.85rem;
}

.form-tile {
    position: relative;
    display: grid;
    gap: 0.1rem;
    background: linear-gradient(180deg, var(--surface) 0%, #121820 100%);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.8rem 0.9rem;
    overflow: hidden;
}

.form-tile::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
}

.form-tile-label {
    color: var(--faint);
    font-size: 0.75rem;
    font-weight: 500;
}

.form-tile-value {
    font-size: 1.45rem;
    font-weight: 660;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.form-tile-note {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.form-tile-note.good {
    color: var(--good);
}

.spark {
    margin-top: 0.35rem;
    width: 100%;
    height: 26px;
    display: block;
    overflow: visible;
}

/* --- plan ----------------------------------------------------------------- */
.plan-check {
    display: grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    flex: none;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--faint);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.plan-check-on {
    background: color-mix(in srgb, var(--good) 18%, transparent);
    border-color: var(--good);
    color: var(--good);
}

.plan-done .plan-title {
    color: var(--muted);
    text-decoration: line-through;
}

.plan-target {
    color: var(--muted);
    font-weight: 400;
}

.type-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* --- merge proposal ------------------------------------------------------- */
.merge-card {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
    background:
        radial-gradient(20rem 10rem at 0% -4rem, rgba(249, 115, 22, 0.14), transparent 70%),
        linear-gradient(180deg, var(--surface) 0%, #121820 100%);
}

.merge-lead {
    margin: 0 0 0.8rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.merge-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.merge-col {
    display: grid;
    gap: 0.15rem;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.75rem;
}

.merge-col-garmin {
    border-color: color-mix(in srgb, var(--type-color, var(--accent)) 45%, transparent);
}

.merge-value {
    font-size: 1.15rem;
    font-weight: 640;
}

.merge-meta {
    color: var(--muted);
    font-size: 0.78rem;
}

.merge-keep {
    margin: 0.7rem 0 0;
    color: var(--faint);
    font-size: 0.8rem;
}

/* --- journal -------------------------------------------------------------- */
.journal-summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    background: transparent;
    border: 0;
    color: var(--text);
    cursor: pointer;
    padding: 0;
    text-align: left;
}

.journal-scores {
    display: flex;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.journal-score strong {
    color: var(--text);
}

.journal-edit {
    margin-left: auto;
    color: var(--accent);
    font-size: 0.85rem;
}

.quick-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.9rem;
}

.quick-row .btn {
    flex: 1;
}

/* --- wellness tiles (day view) -------------------------------------------- */
.metrics {
    display: grid;
    /* wide enough that "6 989 kcal" stays on one line */
    grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
    gap: 0.5rem;
}

.metric {
    display: grid;
    gap: 0.1rem;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.7rem;
}

.metric-value {
    font-size: 1.05rem;
    font-weight: 620;
}

.metric-label {
    color: var(--faint);
    font-size: 0.72rem;
}

.metric-note {
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.7rem;
    line-height: 1.3;
}

.week-row-side {
    width: 5.5rem;
    flex: none;
    text-align: right;
    color: var(--muted);
    font-size: 0.75rem;
}

/* --- sleep stages --------------------------------------------------------- */
.stage-bar {
    display: flex;
    height: 10px;
    border-radius: var(--radius-pill);
    overflow: hidden;
    background: var(--surface-3);
}

.stage-seg {
    height: 100%;
}

/* --- benchmarks ----------------------------------------------------------- */
.benchmark-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.6rem;
}

.benchmark {
    display: grid;
    gap: 0.2rem;
    align-content: start;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
}

.benchmark-head {
    display: grid;
    gap: 0.1rem;
}

.benchmark-value {
    font-size: 1.35rem;
    font-weight: 660;
    letter-spacing: -0.02em;
}

.benchmark-history {
    justify-self: start;
    margin-top: 0.4rem;
}

.benchmark-list {
    list-style: none;
    margin: 0.6rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.35rem;
    font-size: 0.82rem;
}

.benchmark-list li {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-soft);
}

.benchmark-list li > span:first-child {
    color: var(--muted);
    width: 5.5rem;
    flex: none;
}

.btn-link {
    margin-left: auto;
    background: none;
    border: 0;
    color: var(--faint);
    font-size: 1rem;
    cursor: pointer;
}

/* --- pasek przełączania ekranów analitycznych --- */

.section-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    scrollbar-width: none;
    /* na telefonie pasek wychodzi poza margines ekranu, żeby dało się
       przewinąć do ostatniej zakładki bez ucinania jej w połowie */
    padding-bottom: 0.2rem;
}

.section-tabs::-webkit-scrollbar {
    display: none;
}

.section-tab {
    flex: none;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.82rem;
    text-decoration: none;
    white-space: nowrap;
}

.section-tab svg {
    width: 1rem;
    height: 1rem;
}

.section-tab:hover {
    color: var(--text);
}

.section-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #0b0f14;
    font-weight: 600;
}

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

.field-note {
    display: block;
    margin-top: 0.25rem;
    color: var(--faint);
    font-size: 0.72rem;
    min-height: 1rem;
}

.field-note.good {
    color: var(--good);
}

/* Podpowiedź, która jest zarazem przyciskiem - wygląda jak notka pod polem. */
.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    font: inherit;
    font-size: 0.72rem;
    cursor: pointer;
    text-decoration: underline dotted;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1rem;
}

.hint {
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.hint + .hint {
    margin-top: 0.6rem;
}

.hint.warn {
    color: var(--warn);
}

.hint strong {
    color: var(--text);
    font-weight: 600;
}

/* --- strefy tętna --- */

.zone-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0;
}

.zone-row + .zone-row {
    border-top: 1px solid var(--border-soft);
}

.zone-badge {
    flex: none;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #0b0f14;
    font-weight: 700;
    font-size: 0.85rem;
}

.zone-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.zone-name {
    color: var(--text);
    font-size: 0.9rem;
}

.zone-meaning {
    color: var(--faint);
    font-size: 0.74rem;
}

.zone-range {
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

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

.kind-group {
    margin-bottom: 0.7rem;
}

.kind-group .eyebrow {
    display: block;
    margin-bottom: 0.3rem;
}

/* --- mobility ------------------------------------------------------------- */
.exercise {
    padding: 0.8rem 0.9rem;
}

.exercise-picked {
    border-color: color-mix(in srgb, #f472b6 45%, var(--border));
}

.exercise-head {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.exercise-title {
    display: grid;
    gap: 0.1rem;
    flex: 1;
    min-width: 0;
    background: none;
    border: 0;
    color: inherit;
    text-align: left;
    cursor: pointer;
    padding: 0;
}

.exercise-body {
    margin-top: 0.7rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--border-soft);
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.55;
}

.exercise-body p {
    margin: 0 0 0.5rem;
}

.exercise-cue strong,
.exercise-why strong {
    color: var(--text);
}

.session-bar {
    border-color: color-mix(in srgb, #f472b6 40%, var(--border));
}

/* --- add menu ------------------------------------------------------------- */
.add-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.7rem;
}

.add-tile {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin: 0;
}

.add-main {
    display: grid;
    gap: 0.15rem;
}

/* --- calendar ------------------------------------------------------------- */
.calendar {
    background: linear-gradient(180deg, var(--surface) 0%, #121820 100%);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.8rem;
}

.cal-weekdays,
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.3rem;
}

.cal-weekdays {
    color: var(--faint);
    font-size: 0.7rem;
    text-align: center;
    margin-bottom: 0.4rem;
}

.cal-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.85rem;
}

.cal-out {
    opacity: 0.3;
}

.cal-today {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
}

.cal-journal .cal-num {
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-underline-offset: 3px;
}

.cal-dots {
    display: flex;
    gap: 2px;
    height: 6px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.9rem;
    color: var(--faint);
    font-size: 0.75rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.legend-ring {
    width: 10px;
    height: 2px;
    background: var(--accent);
    display: inline-block;
}

/* --- week / progress views ------------------------------------------------ */
.week-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.5rem;
    border-bottom: 1px solid var(--border-soft);
}

.week-row:last-child {
    border-bottom: 0;
}

.week-row-label {
    width: 5.5rem;
    flex: none;
    color: var(--muted);
    font-size: 0.8rem;
}

.week-row-bar {
    flex: 1;
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    overflow: hidden;
}

/* a day with nothing on it should read as a gap, not as a full bar */
.week-row-empty {
    background: repeating-linear-gradient(90deg,
        var(--border-soft) 0 6px, transparent 6px 12px);
    opacity: 0.5;
    height: 2px;
    align-self: center;
}

.week-row-total {
    width: 3.6rem;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 600;
}

.chart {
    width: 100%;
    height: 150px;
    display: block;
    overflow: visible;
}

.chart-tall {
    height: 190px;
}

/* Podpisy osi leżą na wykresie, nie zabierają mu wysokości. */
.chart-axis {
    position: relative;
    height: 0;
    color: var(--faint);
    font-size: 0.68rem;
}

.chart-axis span {
    position: absolute;
    right: 0;
    transform: translateY(50%);
    padding-left: 0.3rem;
}

.chart-days {
    display: flex;
    justify-content: space-between;
    color: var(--faint);
    font-size: 0.66rem;
    margin-top: 0.35rem;
}

/* --- makroskładniki --- */

.macro-row + .macro-row {
    margin-top: 0.85rem;
}

.macro-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.macro-name {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text);
    font-size: 0.9rem;
}

.macro-grams {
    font-size: 1.25rem;
    font-weight: 600;
}

.macro-grams small {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 400;
}

.macro-track {
    display: flex;
    height: 9px;
    margin-top: 0.4rem;
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-3);
}

.macro-track.slim {
    height: 5px;
    margin-top: 0.5rem;
}

.macro-fill {
    height: 100%;
}

.macro-note {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.3rem;
    color: var(--muted);
    font-size: 0.76rem;
}

.macro-note .good {
    color: var(--good);
}

.macro-note .warn {
    color: var(--warn);
}

/* --- lista dni --- */

.day-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.day-list li + li {
    margin-top: 0.5rem;
}

.day-row {
    display: block;
    padding: 0.7rem 0.8rem;
    border-radius: 12px;
    background: var(--surface-2);
    text-decoration: none;
    color: inherit;
}

.day-row:hover {
    background: var(--surface-3);
}

.day-row-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.day-row-date {
    color: var(--text);
    font-size: 0.92rem;
}

.day-row-kcal {
    font-weight: 600;
}

.day-row-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.45rem;
    font-size: 0.76rem;
    color: var(--muted);
}

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

.macro-chip {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.balance-badge {
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.74rem;
    white-space: nowrap;
}

.balance-badge.deficit {
    background: rgba(34, 211, 238, 0.12);
    color: #22d3ee;
}

.balance-badge.surplus {
    background: rgba(251, 191, 36, 0.12);
    color: #fbbf24;
}

.chart-legend {
    display: flex;
    justify-content: space-between;
    color: var(--faint);
    font-size: 0.72rem;
    margin-top: 0.3rem;
}

.analysis {
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.6;
}

.analysis > :first-child {
    margin-top: 0;
}

/* A full weekly analysis runs for pages; show the opening and let the reader
   ask for the rest. */
.analysis-collapsed {
    max-height: 20rem;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 70%, transparent 100%);
}

.analysis-toggle {
    margin-top: 0.7rem;
}

.analysis h1,
.analysis h2 {
    font-size: 1.02rem;
    font-weight: 650;
    margin: 1.2rem 0 0.4rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border-soft);
}

.analysis h3,
.analysis h4 {
    font-size: 0.92rem;
    font-weight: 650;
    color: var(--accent);
    margin: 1rem 0 0.3rem;
}

.analysis p {
    margin: 0 0 0.6rem;
}

.analysis ul,
.analysis ol {
    margin: 0 0 0.7rem;
    padding-left: 1.1rem;
}

.analysis li {
    margin-bottom: 0.25rem;
}

.analysis strong {
    color: #fff;
}

.analysis hr {
    border: 0;
    border-top: 1px solid var(--border-soft);
    margin: 1rem 0;
}

.analysis blockquote {
    margin: 0 0 0.7rem;
    padding-left: 0.8rem;
    border-left: 2px solid var(--accent);
    color: var(--muted);
}

.analysis code {
    background: var(--surface-2);
    border-radius: 5px;
    padding: 0.05rem 0.3rem;
    font-size: 0.85em;
}

/* tables need to scroll rather than squeeze the page on a phone */
.analysis table {
    display: block;
    width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    margin: 0 0 0.8rem;
    font-size: 0.84rem;
    font-variant-numeric: tabular-nums;
}

.analysis th,
.analysis td {
    border-bottom: 1px solid var(--border-soft);
    padding: 0.4rem 0.6rem 0.4rem 0;
    text-align: left;
    vertical-align: top;
}

.analysis th {
    color: var(--faint);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* --- bottom navigation ---------------------------------------------------- */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: color-mix(in srgb, #0d131a 88%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border-soft);
    padding:
        0.35rem
        calc(0.4rem + var(--safe-right))
        calc(0.35rem + var(--safe-bottom))
        calc(0.4rem + var(--safe-left));
}

.nav-item {
    display: grid;
    justify-items: center;
    gap: 0.15rem;
    padding: 0.3rem 0;
    color: var(--faint);
    font-size: 0.68rem;
    text-align: center;
    /* równa wysokość wszystkich komórek — inaczej środkowa z okrągłym
       przyciskiem rozpychałaby pasek */
    min-height: 2.9rem;
    align-content: center;
    transition: color 0.15s ease;
}

/* komórka z plusem nie ma podpisu, więc sama się wyśrodkuje w pionie */
.nav-center {
    align-content: center;
}

.nav-item.active {
    color: var(--accent);
}

.nav-fab {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    margin: -1.1rem auto 0;
    border-radius: 50%;
    background: linear-gradient(180deg, #fb8b3c, var(--accent));
    color: #1a1006;
    box-shadow: 0 10px 20px -8px rgba(249, 115, 22, 0.7);
}

/* On a desktop a full-width bar pinned to the bottom looks like a phone UI
   stretched; a floating pill reads as a deliberate control. */
@media (min-width: 700px) {
    .bottom-nav {
        left: 50%;
        right: auto;
        bottom: 1.1rem;
        transform: translateX(-50%);
        width: min(540px, calc(100% - 3rem));
        border: 1px solid var(--border);
        border-radius: var(--radius-pill);
        box-shadow: var(--shadow);
        padding: 0.35rem 0.6rem;
    }

    .nav-fab {
        margin-top: -1.4rem;
    }
}

/* --- toast ---------------------------------------------------------------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(5.2rem + var(--safe-bottom));
    transform: translate(-50%, 1rem);
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow);
    color: var(--text);
    font-size: 0.85rem;
    padding: 0.5rem 0.9rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-on {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast-good {
    color: var(--good);
}

/* --- login ---------------------------------------------------------------- */
.login-card {
    width: 100%;
    max-width: 360px;
    text-align: center;
    background: linear-gradient(180deg, var(--surface) 0%, #121820 100%);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem 1.5rem;
}

.login-logo {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
}

.login-form {
    display: grid;
    gap: 0.6rem;
    margin-top: 1.25rem;
}

.login-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin: 0.75rem 0 0;
}

.link {
    color: var(--accent);
    font-size: 0.85rem;
}

.page-footer {
    text-align: center;
    padding: 0.4rem 0 1rem;
}

/* --- blazor error toast --------------------------------------------------- */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: #b3261e;
    color: #fff;
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
}

#blazor-error-ui .reload {
    text-decoration: underline;
    margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
    float: right;
    cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
