/* Project Hero - base theme. Dark is the default; light is opt-in via the header toggle. */

:root {
    color-scheme: dark;
    --bg: #070b14;
    --bg-glow: #12213f;
    --surface: #0f1728;
    --surface-2: #162036;
    --border: #25324d;
    --text: #e9eef8;
    --text-muted: #9aa8c2;
    --hero-red: #e63950;
    --hero-gold: #f2c14e;
    --villain-purple: #a06cf0;
    --villain-green: #4fd08a;
    --system-blue: #4da3ff;
    --on-accent: #14080a;
    --danger-bg: rgba(230, 57, 80, 0.14);
    --success-bg: rgba(79, 208, 138, 0.14);
    --info-bg: rgba(77, 163, 255, 0.14);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --radius: 12px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", var(--font);
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #eef1f7;
    --bg-glow: #d9e2f5;
    --surface: #ffffff;
    --surface-2: #f3f5fa;
    --border: #cfd7e6;
    --text: #131a2a;
    --text-muted: #55627b;
    --hero-red: #c81e36;
    --hero-gold: #9a6a00;
    --villain-purple: #6b3fc4;
    --villain-green: #1c7d4b;
    --system-blue: #1565c0;
    --on-accent: #ffffff;
    --danger-bg: rgba(200, 30, 54, 0.1);
    --success-bg: rgba(28, 125, 75, 0.1);
    --info-bg: rgba(21, 101, 192, 0.1);
    --shadow: 0 8px 24px rgba(30, 45, 80, 0.12);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg) radial-gradient(1100px 520px at 50% -180px, var(--bg-glow), transparent 70%) no-repeat;
}

h1,
h2 {
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.15;
    margin: 0 0 0.6rem;
    text-wrap: balance;
}

h1 {
    font-size: clamp(1.7rem, 4.5vw, 2.6rem);
}

h2 {
    font-size: 1.15rem;
}

p {
    margin: 0 0 1rem;
}

a {
    color: var(--system-blue);
}

:focus-visible {
    outline: 2px solid var(--system-blue);
    outline-offset: 2px;
}

.container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 16px;
}

.skip-link {
    position: absolute;
    left: -9999px;
}

.skip-link:focus {
    left: 16px;
    top: 12px;
    z-index: 10;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 8px;
}

/* Header */

.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    padding-top: 12px;
    padding-bottom: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.brand-sub {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
}

.main-nav {
    display: flex;
    gap: 4px;
    flex: 1;
}

.main-nav a {
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
}

.main-nav a:hover {
    color: var(--text);
    background: var(--surface-2);
}

.main-nav a[aria-current="page"] {
    color: var(--text);
    box-shadow: inset 0 -2px 0 var(--hero-red);
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.header-actions form {
    margin: 0;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 220px;
    font-weight: 600;
}

.user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Buttons */

.button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button-small {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.9rem;
}

.button-block {
    width: 100%;
}

.button-primary {
    color: var(--on-accent);
    background: linear-gradient(135deg, var(--hero-gold), var(--hero-red));
}

.button-primary:hover {
    filter: brightness(1.1);
}

.button-ghost,
.icon-button {
    color: var(--text);
    background: transparent;
    border-color: var(--border);
}

.button-ghost:hover,
.icon-button:hover {
    background: var(--surface-2);
}

.icon-button {
    min-height: 36px;
    width: 36px;
    padding: 0;
}

/* Layout */

.main {
    flex: 1;
    padding-top: 28px;
    padding-bottom: 48px;
}

.site-footer {
    padding: 16px 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.eyebrow {
    margin: 0 0 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--hero-gold);
}

.lead {
    max-width: 62ch;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.page-head {
    margin-bottom: 20px;
}

.grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

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

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

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

/* Cards and stats */

.card,
.stat {
    min-width: 0;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card p:last-child {
    margin-bottom: 0;
}

.card-hero {
    border-top: 3px solid var(--hero-red);
}

.card-system {
    border-top: 3px solid var(--system-blue);
}

.card-villain {
    border-top: 3px solid var(--villain-purple);
}

.stat {
    border-left: 4px solid var(--accent, var(--border));
}

.stat-gold {
    --accent: var(--hero-gold);
}

.stat-red {
    --accent: var(--hero-red);
}

.stat-blue {
    --accent: var(--system-blue);
}

.stat-green {
    --accent: var(--villain-green);
}

.stat-label {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
}

.stat-value {
    margin: 2px 0 4px;
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.stat-note {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.level-progress {
    display: block;
    width: 100%;
    height: 8px;
    margin: 0 0 6px;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-2);
    accent-color: var(--hero-red);
    -webkit-appearance: none;
    appearance: none;
}

.level-progress::-webkit-progress-bar {
    background: var(--surface-2);
}

.level-progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--hero-gold), var(--hero-red));
}

.level-progress::-moz-progress-bar {
    background: linear-gradient(90deg, var(--hero-gold), var(--hero-red));
}

.tag {
    display: inline-block;
    padding: 1px 8px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    white-space: nowrap;
}

.tag-gold {
    color: var(--hero-gold);
}

.empty {
    color: var(--text-muted);
}

.session-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
}

.facts {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 28px;
    margin: 0;
}

.facts dt {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.facts dd {
    margin: 0;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-weight: 400;
}

.table thead th {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.table tbody tr:last-child th,
.table tbody tr:last-child td {
    border-bottom: 0;
}

.table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table td.num {
    font-weight: 700;
}

/* Landing */

.hero {
    padding: 36px 0 32px;
}

.hero h1 {
    max-width: 18ch;
    font-size: clamp(2rem, 6.5vw, 3.6rem);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

/* Forms */

.auth-card {
    max-width: 440px;
    margin: 24px auto 0;
    border-top: 3px solid var(--hero-red);
}

.form {
    display: grid;
    gap: 16px;
    margin-top: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 600;
}

.field input,
.field select,
.field textarea,
.mini-field input,
.mini-field select,
.builder-item > input,
.builder-add select,
.player-inputs input {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
}

.field textarea {
    resize: vertical;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
    outline-offset: 0;
    border-color: var(--system-blue);
}

.field [aria-invalid="true"] {
    border-color: var(--hero-red);
}

.field-hint,
.field-error {
    margin: 6px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.field-error {
    color: var(--hero-red);
    font-weight: 600;
}

.auth-switch {
    margin: 20px 0 0;
    text-align: center;
    color: var(--text-muted);
}

/* Alerts */

.alert {
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid var(--alert-color);
    border-radius: 10px;
    background: var(--alert-bg);
}

.alert-error {
    --alert-color: var(--hero-red);
    --alert-bg: var(--danger-bg);
}

.alert-success {
    --alert-color: var(--villain-green);
    --alert-bg: var(--success-bg);
}

.alert-info {
    --alert-color: var(--system-blue);
    --alert-bg: var(--info-bg);
}

/* Error pages */

.error-page {
    padding: 48px 0;
    text-align: center;
}

.error-page .lead {
    margin: 0 auto 24px;
}

.error-code {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(4rem, 18vw, 8rem);
    font-weight: 700;
    line-height: 1;
    color: var(--hero-red);
}

@media (max-width: 520px) {
    .brand-sub {
        display: none;
    }

    .user-chip {
        max-width: 130px;
    }
}

/* ---------- Milestone 2: exercises, workouts, builder, player ---------- */

[hidden] {
    display: none !important;
}

h3 {
    margin: 14px 0 6px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
}

.page-head-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.page-head .facts {
    margin: 16px 0 0;
}

.meta {
    margin: 0 0 0.6rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.result-count {
    margin: 0 0 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

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

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 0.6rem;
}

.tag {
    color: var(--text-muted);
}

.tag-muted {
    border-style: dashed;
}

.tag-level-1 {
    color: var(--villain-green);
}

.tag-level-2 {
    color: var(--system-blue);
}

.tag-level-3 {
    color: var(--hero-gold);
}

.tag-level-4 {
    color: var(--hero-red);
}

.tag-level-5 {
    color: var(--villain-purple);
}

.button-danger {
    color: var(--hero-red);
    background: transparent;
    border-color: var(--hero-red);
}

.button-danger:hover {
    background: var(--danger-bg);
}

.button-large {
    min-height: 56px;
    padding: 0 28px;
    font-size: 1.1rem;
}

.button:disabled,
.icon-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.icon-danger {
    color: var(--hero-red);
}

.card-actions,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

.card-actions form,
.hero-actions form {
    margin: 0;
}

.link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.empty-state {
    display: grid;
    justify-items: start;
    gap: 12px;
    color: var(--text-muted);
}

/* Filters */

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    align-items: end;
    gap: 12px;
    margin-bottom: 16px;
}

.filters-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
}

/* Forms */

.form-page {
    max-width: 640px;
    margin: 0 auto;
    border-top: 3px solid var(--system-blue);
}

.field-row {
    display: grid;
    gap: 16px;
}

@media (min-width: 560px) {
    .field-row {
        grid-template-columns: 1fr 1fr;
    }
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}

.check input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--hero-red);
}

/* Workout cards and detail */

.workout-card {
    display: flex;
    flex-direction: column;
    border-top: 3px solid var(--hero-red);
}

.workout-card.theme-villain {
    border-top-color: var(--villain-purple);
}

.workout-card h2 a {
    color: var(--text);
    text-decoration: none;
}

.workout-card h2 a:hover {
    text-decoration: underline;
}

.workout-desc {
    flex: 1;
    color: var(--text-muted);
}

.workout-card .card-actions {
    margin-top: 4px;
}

.page-head.theme-villain .eyebrow {
    color: var(--villain-purple);
}

.block {
    margin-bottom: 16px;
    border-left: 4px solid var(--hero-red);
}

.block-warmup {
    border-left-color: var(--hero-gold);
}

.block-cooldown {
    border-left-color: var(--system-blue);
}

.item-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: item;
}

.item-list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.item-list li:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.item-main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 16px;
}

.item-name {
    font-weight: 700;
}

.item-target {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--hero-gold);
}

.item-list .meta,
.item-notes {
    margin: 2px 0 0;
}

.item-notes {
    font-size: 0.9rem;
    font-style: italic;
}

/* Builder */

.builder {
    display: grid;
    gap: 16px;
    align-items: start;
}

.builder-main {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.builder-main .block {
    margin-bottom: 0;
}

.builder-side {
    min-width: 0;
}

@media (min-width: 960px) {
    .builder {
        grid-template-columns: minmax(0, 1fr) 320px;
    }

    .builder-preview {
        position: sticky;
        top: 16px;
    }
}

.builder-items {
    display: grid;
    gap: 12px;
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
}

.builder-item {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
}

.builder-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.builder-item-buttons {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.builder-item-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.mini-field {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.mini-field span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.mini-field input,
.mini-field select,
.builder-item > input,
.builder-add select {
    background: var(--surface);
}

.builder-add {
    display: flex;
    gap: 8px;
}

.builder-add select {
    flex: 1;
    min-width: 0;
}

.builder-add .button {
    min-height: 44px;
    flex-shrink: 0;
}

.preview-items li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    font-size: 0.9rem;
}

.preview-items .meta {
    margin: 0;
    white-space: nowrap;
}

/* Session player: covers the whole viewport */

.player {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg) radial-gradient(900px 480px at 50% -120px, var(--bg-glow), transparent 70%) no-repeat;
}

.player.is-rest {
    --bg-glow: rgba(77, 163, 255, 0.35);
}

.player-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.player-title {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    line-height: 1.2;
}

.player-title strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-title .eyebrow {
    margin: 0;
}

.player-clock {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.player-progress {
    display: block;
    width: 100%;
    height: 6px;
    border: 0;
    background: var(--surface-2);
    -webkit-appearance: none;
    appearance: none;
}

.player-progress::-webkit-progress-bar {
    background: var(--surface-2);
}

.player-progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--hero-gold), var(--hero-red));
}

.player-progress::-moz-progress-bar {
    background: linear-gradient(90deg, var(--hero-gold), var(--hero-red));
}

.player-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 16px 32px;
    text-align: center;
}

.player-screen h1 {
    font-size: clamp(1.9rem, 7vw, 3.2rem);
    margin: 0;
}

.player-screen .lead {
    margin-bottom: 16px;
}

.player-round {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--hero-gold);
}

.is-rest .player-round {
    color: var(--system-blue);
}

.player-target {
    margin: 0;
    min-height: 1.6em;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-muted);
}

.player-timer {
    margin: 4px 0;
    font-family: var(--font-display);
    font-size: clamp(4.5rem, 24vw, 9rem);
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.is-paused .player-timer {
    opacity: 0.4;
}

.player-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    max-width: 360px;
    text-align: left;
}

.player-inputs label {
    display: grid;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.player-inputs input {
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
}

.player-hint {
    max-width: 52ch;
    margin: 8px 0 0;
    color: var(--text-muted);
}

.player-next {
    margin: 4px 0 12px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.player-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.player-controls .button-large {
    flex: 1 1 100%;
    max-width: 360px;
}

.player-controls .button-ghost {
    min-height: 48px;
}

.facts-center {
    justify-content: center;
    margin: 12px 0 20px;
    text-align: center;
}

.player-form {
    width: 100%;
    max-width: 400px;
    text-align: left;
}

/* ---------- Circuits ---------- */

.circuit-info {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: 10px;
}

.circuit-info p {
    margin: 0 0 8px;
}

.round-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.round-steps li {
    min-width: 40px;
    padding: 4px 8px;
    border-radius: 8px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
    color: var(--hero-gold);
    background: var(--surface-2);
}

.circuit-total {
    margin: 0 0 8px;
}

.table-scroll {
    overflow-x: auto;
}

.table-splits th,
.table-splits td {
    padding: 8px 6px;
    font-size: 0.9rem;
}

.table-splits thead th {
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    vertical-align: bottom;
}

.table-splits tbody th {
    white-space: nowrap;
}

.table-splits .meta {
    margin: 0;
}

.builder-mode {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: 10px;
}

.builder-mode .button {
    justify-self: start;
}

.player-split {
    min-height: 1.4em;
    margin: 0;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    color: var(--hero-gold);
}

/* Mobile first: status tiles sit two abreast even on small phones. */
.grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 519px) {
    .grid-4 {
        gap: 10px;
    }

    .stat {
        padding: 14px;
    }

    .stat-value {
        font-size: 2rem;
    }
}

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

/* Player: both clocks are labelled - whole workout (top) and current exercise (centre). */
.player-clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.player-clock-label,
.player-timer-label {
    margin: 0;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
}

.player-timer-label {
    margin-top: 8px;
}

.table td.num + td.num,
.table th.num + th.num {
    padding-left: 14px;
}

/* ---------- Weekly plan ---------- */

.week-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.week-range {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.week-range a {
    font-size: 0.85rem;
}

.plan-days {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.plan-day {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    border-left: 4px solid var(--border);
}

.plan-day.is-today {
    border-left-color: var(--hero-gold);
}

.plan-day.is-done {
    border-left-color: var(--villain-green);
}

.plan-date {
    display: flex;
    flex-direction: column;
}

.plan-weekday {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.plan-date .meta,
.plan-body .meta {
    margin: 0;
}

.plan-workout {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 700;
}

.plan-workout a {
    color: var(--text);
}

.plan-day .card-actions {
    margin-top: 10px;
}

.plan-add,
.plan-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

.plan-add select,
.plan-inline input {
    flex: 1 1 160px;
    min-width: 0;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
}

.plan-add .button {
    min-height: 44px;
}

.plan-extra {
    margin-top: 8px;
}

.week-dots {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.week-dots li {
    padding: 6px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-muted);
}

.week-dots .is-planned {
    border-color: var(--hero-gold);
    color: var(--hero-gold);
}

.week-dots .is-done {
    border-color: var(--villain-green);
    color: var(--on-accent);
    background: var(--villain-green);
}

.week-dots .is-today {
    outline: 2px solid var(--system-blue);
    outline-offset: 1px;
}

/* Mobile first: on narrow screens the navigation gets its own row below brand and
   account, and scrolls sideways instead of widening the page. */
.main-nav a {
    white-space: nowrap;
}

@media (max-width: 759px) {
    .main-nav {
        order: 3;
        flex: 1 0 100%;
        overflow-x: auto;
        margin: 0 -16px;
        padding: 0 12px;
        scrollbar-width: none;
    }

    .main-nav::-webkit-scrollbar {
        display: none;
    }

    .main-nav a {
        padding: 8px 10px;
    }
}

/* Equipment checkboxes in the exercise form */
.check-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px 16px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.check-group legend {
    padding: 0 6px;
    font-size: 0.9rem;
    font-weight: 600;
}

.check-group .field-hint {
    grid-column: 1 / -1;
    margin: 0;
}

/* ---------- Admin ---------- */

.member-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (min-width: 760px) {
    .member-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.member-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.member-name {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text);
}

.member-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.assign-form {
    margin-bottom: 16px;
}

.assign-form input[type="date"] {
    flex: 0 1 170px;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
}

.assign-form .button {
    min-height: 44px;
}

.plan-days-compact .plan-day {
    grid-template-columns: 56px minmax(0, 1fr);
    padding: 10px 0 10px 12px;
    border-bottom: 1px solid var(--border);
}

.plan-days-compact {
    gap: 0;
}

.plan-days-compact .plan-day:last-child {
    border-bottom: 0;
}

.plan-days-compact form {
    margin: 6px 0 0;
}

.manage-row {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 14px 0;
    border-top: 1px solid var(--border);
}

.manage-row .button {
    justify-self: start;
}

.page-head .eyebrow a {
    color: inherit;
    text-decoration: none;
}

/* Filter buttons get their own row, so "Filtern" plus "Zurücksetzen" never widen the page. */
.filters .field {
    min-width: 0;
}

.filters-actions {
    grid-column: 1 / -1;
    flex-wrap: wrap;
}

/* Stacked cards keep their distance; button labels never break into two lines. */
main > section.card {
    margin-bottom: 16px;
}

.button {
    white-space: nowrap;
}

/* ---------- Milestone 3: profile, badges, progress, friends, leaderboard ---------- */

.avatar {
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
}

.avatar-28 { width: 28px; height: 28px; font-size: 0.8rem; }
.avatar-40 { width: 40px; height: 40px; font-size: 1.1rem; }
.avatar-96 { width: 96px; height: 96px; font-size: 2.6rem; }

.avatar-initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--on-accent);
    background: linear-gradient(135deg, var(--hero-gold), var(--hero-red));
}

a.user-chip {
    color: var(--text);
    text-decoration: none;
}

.profile-head {
    display: flex;
    align-items: center;
    gap: 16px;
}

.profile-head .meta {
    margin: 0;
    overflow-wrap: anywhere;
}

.field input[type="file"] {
    padding: 8px;
}

.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.badge {
    display: grid;
    gap: 2px;
    padding: 12px;
    border: 1px solid var(--hero-gold);
    border-radius: 10px;
    text-align: center;
    background: var(--surface-2);
}

.badge.is-locked {
    border-color: var(--border);
    opacity: 0.55;
}

.badge.is-locked .badge-icon {
    filter: grayscale(1);
}

.badge-icon {
    font-size: 1.9rem;
    line-height: 1.2;
}

.badge-name {
    font-weight: 700;
}

.badge .meta {
    margin: 0;
    font-size: 0.78rem;
}

.chart-box {
    position: relative;
    height: 240px;
}

.chart-box-small {
    height: 180px;
}

.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.calendar-head {
    padding-bottom: 2px;
    font-size: 0.7rem;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    color: var(--text-muted);
}

.calendar-day {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    background: var(--surface-2);
}

.calendar-day a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    min-height: 40px;
    border-radius: 8px;
    font-weight: 700;
    color: var(--on-accent);
    text-decoration: none;
    background: var(--villain-green);
}

.calendar-day.is-today {
    outline: 2px solid var(--system-blue);
    outline-offset: 1px;
}

.calendar-count {
    font-size: 0.65rem;
}

.subnav,
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.subnav a,
.chips a {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
}

.subnav a[aria-current],
.chips a[aria-current] {
    border-color: var(--hero-red);
    color: var(--text);
    background: var(--surface-2);
}

.people,
.ranking {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.people li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.people li:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.people-name {
    flex: 1 1 140px;
    min-width: 0;
    font-weight: 700;
}

.people-name .meta {
    display: block;
    margin: 0;
    font-weight: 400;
}

.people-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.people-actions form {
    margin: 0;
}

.ranking {
    gap: 8px;
}

.ranking li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
}

.ranking li.is-me {
    border-color: var(--hero-gold);
}

.rank {
    min-width: 1.6em;
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    color: var(--hero-gold);
}

.rank-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.rank-value .meta {
    margin: 0;
    font-weight: 400;
}

/* On small phones the account chip shows the picture only; it still leads to the profile. */
@media (max-width: 519px) {
    .user-chip .user-name {
        display: none;
    }
}

.request-message {
    font-style: italic;
}

/* ---------- Exercise pictures ---------- */

/* The pictures are photos on a white background; a white frame keeps them clean in both themes. */
.exercise-image,
.exercise-thumb,
.player-image {
    display: block;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
}

.exercise-image {
    width: 100%;
    max-width: 320px;
    height: auto;
    max-height: 220px;
    margin: 0 0 12px;
}

.item-list li.has-image {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    column-gap: 12px;
    align-items: start;
}

.item-list li.has-image > :not(.exercise-thumb) {
    grid-column: 2;
}

.exercise-thumb {
    grid-row: 1 / span 3;
    width: 72px;
    height: 72px;
}

.player-image {
    width: auto;
    max-width: min(100%, 320px);
    height: clamp(120px, 24vh, 220px);
    margin: 4px auto;
}

/* ---------- Points ---------- */

.item-points {
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.player-points {
    margin: 0;
    font-size: 0.95rem;
    color: var(--hero-gold);
}

/* ---------- Training locations ---------- */

.location-card .facts {
    margin: 10px 0;
}

.player-location {
    margin: 0 auto 16px;
}

.player-location .field-hint {
    min-height: 1.4em;
    margin: 6px 0 0;
}

.friends-switch {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 12px;
}

.friends-switch p {
    margin: 0;
    flex: 1 1 260px;
}

.plan-location {
    margin-top: 8px;
}

.plan-friends {
    margin: 10px 0 0;
    padding: 10px 0 0;
    border-top: 1px dashed var(--border);
    list-style: none;
}

.plan-friends li {
    padding: 4px 0 4px 10px;
    border-left: 3px solid var(--system-blue);
    margin-bottom: 6px;
    overflow-wrap: anywhere;
}

.plan-friends li:last-child {
    margin-bottom: 0;
}

.plan-friends .meta {
    display: block;
    margin: 0;
}

fieldset[data-geo-form] {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}
