:root {
    --bg: #090b10;
    --bg-elev: #12151c;
    --card: #171b24;
    --card-2: #1e2430;
    --line: rgba(255, 255, 255, 0.08);
    --text: #f4f1ea;
    --muted: #9aa3b2;
    --lime: #d6ff4a;
    --lime-dim: #b6db2e;
    --orange: #ff6a3d;
    --blue: #7dd3fc;
    --good: #4ade80;
    --danger: #fb7185;
    --shadow: none;
    --radius: 12px;
    --btn-gap: 12px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Figtree", "Segoe UI", sans-serif;
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    background:
        radial-gradient(900px 380px at 80% -12%, rgba(214, 255, 74, 0.07), transparent 50%),
        radial-gradient(640px 320px at -10% 18%, rgba(255, 106, 61, 0.06), transparent 45%),
        var(--bg);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.app-shell {
    width: min(520px, 100%);
    margin: 0 auto;
    min-height: 100vh;
    padding: 12px 14px calc(76px + var(--safe-bottom));
}

.app-shell.live-mode {
    padding-bottom: 16px;
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: "Outfit", sans-serif;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-size: 1.05rem;
}

.logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--lime);
    display: block;
    flex: none;
}
.logo img {
    width: 100%;
    height: 100%;
    display: block;
}

h1, h2, h3 {
    font-family: "Outfit", sans-serif;
    letter-spacing: -0.03em;
    margin: 0 0 5px;
}

h1 { font-size: 1.35rem; line-height: 1.15; }
h2 { font-size: 1.05rem; }
p { color: var(--muted); line-height: 1.4; margin: 0 0 8px; font-size: 0.9rem; }

.eyebrow {
    color: var(--lime);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.card + .card { margin-top: 8px; }
.card + .btn { margin-top: var(--btn-gap); }
.stack {
    display: flex;
    flex-direction: column;
    gap: var(--btn-gap);
    margin-bottom: var(--btn-gap);
}

.hero {
    background:
        linear-gradient(180deg, rgba(214, 255, 74, 0.1), transparent 70%),
        var(--card);
    border: 1px solid rgba(214, 255, 74, 0.16);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 14px;
    border: 0;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.92rem;
    width: 100%;
    margin: 0 0 var(--btn-gap);
}

.btn-lime { background: var(--lime); color: #111; }
.btn-orange { background: var(--orange); color: white; }
.btn-ghost {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
}
.btn-danger { background: rgba(251, 113, 133, 0.12); color: var(--danger); }
.btn-sm {
    min-height: 36px;
    width: auto;
    padding: 0 12px;
    font-size: 0.82rem;
    margin-bottom: 0;
}
.btn:disabled { opacity: 0.45; }

.card > .btn:last-child,
.card > form:last-child > .btn:last-child,
.stack .btn {
    margin-bottom: 0;
}

.row {
    display: flex;
    gap: var(--btn-gap);
}
.row .btn {
    width: auto;
    flex: 1;
    margin-bottom: 0;
}
.row:has(> .btn) {
    margin-bottom: var(--btn-gap);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.grid-2:has(> .btn) {
    gap: var(--btn-gap);
    margin-bottom: var(--btn-gap);
}
.grid-2 > .btn { margin-bottom: 0; }
.builder-reps .btn { margin-bottom: 0; }

.kpi {
    background: var(--card-2);
    border-radius: 10px;
    padding: 10px 12px;
}
.kpi b { display: block; font-size: 1.2rem; font-family: "Outfit", sans-serif; line-height: 1.1; }
.kpi span { color: var(--muted); font-size: 0.75rem; }

.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 0.78rem; color: var(--muted); font-weight: 700; }
.field input, .field select, .field textarea {
    width: 100%;
    background: #0e1117;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
}
.field textarea { min-height: 68px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: rgba(214, 255, 74, 0.5);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(214, 255, 74, 0.1);
    color: var(--lime);
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-weight: 800;
}

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.small a { color: var(--lime); text-decoration: underline; text-underline-offset: 2px; }
.center { text-align: center; }
.mb-0 { margin-bottom: 0; }
.mt-8 { margin-top: 6px; }
.mt-16 { margin-top: 10px; }

.nav {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: min(520px, 100%);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(12, 14, 18, 0.94);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(8px + var(--safe-bottom));
    z-index: 20;
}

.nav a {
    display: grid;
    place-items: center;
    gap: 1px;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 800;
    padding: 6px 0;
}
.nav a.active { color: var(--lime); }
.nav svg { width: 20px; height: 20px; }

.alert {
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 0.8rem;
}
.alert-ok { background: rgba(74, 222, 128, 0.12); color: var(--good); }
.alert-err { background: rgba(251, 113, 133, 0.12); color: var(--danger); }

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item strong { font-size: 0.95rem; }

.stepper {
    display: grid;
    grid-template-columns: 44px minmax(3.4em, 1fr) 44px;
    gap: 6px;
    align-items: center;
}
.stepper button {
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: var(--card-2);
    font-size: 1.3rem;
    font-weight: 800;
}
.stepper input {
    width: 100%;
    min-width: 0;
    height: 44px;
    text-align: center;
    background: #0e1117;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 800;
    padding: 0 8px;
    font-variant-numeric: tabular-nums;
    appearance: textfield;
    -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.live-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.exercise-card.done {
    outline: 1px solid rgba(214, 255, 74, 0.4);
}

.timer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 7, 10, 0.94);
    display: grid;
    place-items: start center;
    padding: 20px 16px calc(20px + var(--safe-bottom));
    overflow: auto;
    z-index: 50;
}
.timer-panel {
    width: min(420px, 100%);
    text-align: center;
    padding-top: 12px;
}
.timer-ring {
    width: min(200px, 58vw);
    height: min(200px, 58vw);
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin: 8px auto 14px;
    background: conic-gradient(var(--lime) calc(var(--p) * 1%), #222 0);
}
.timer-inner {
    width: 82%;
    height: 82%;
    border-radius: 50%;
    background: #0b0d12;
    display: grid;
    place-items: center;
    text-align: center;
}
.timer-inner strong {
    font-family: "Outfit", sans-serif;
    font-size: 2.4rem;
    letter-spacing: -0.05em;
}

.timer-next {
    text-align: left;
    margin-top: 4px;
}
.timer-next-ex {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}
.timer-next-ex:last-child { border-bottom: 0; }
.timer-next-ex strong {
    font-size: 0.95rem;
}

.spotify-bar {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    text-align: left;
    margin-top: 10px;
    max-width: 100%;
    overflow: hidden;
}
.spotify-now {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 8px 10px;
    align-items: center;
}
.spotify-art {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    background: #0e1117;
}
.spotify-meta {
    min-width: 0;
}
.spotify-meta .small {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.spotify-controls {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.spotify-controls button,
.spotify-hit {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: var(--card-2);
    color: var(--text);
    font-size: 1rem;
    transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.spotify-hit.is-playing {
    background: #161c10;
    color: var(--lime);
}
.spotify-hit.is-playing::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -45%;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(214, 255, 74, 0.5), transparent);
    animation: spotify-flow 1.5s ease-in-out infinite;
    pointer-events: none;
}
@keyframes spotify-flow {
    0% { transform: translateX(0); }
    100% { transform: translateX(380%); }
}
.spotify-hit:active,
.spotify-hit.is-hit {
    background: var(--lime);
    color: #111;
    transform: scale(0.94);
}
.spotify-hit.is-hit.is-playing::before {
    display: none;
}
.spotify-icon {
    position: relative;
    z-index: 1;
    display: block;
}
.spotify-icon.is-play {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 7px 0 7px 12px;
    border-color: transparent transparent transparent currentColor;
    margin-left: 2px;
}
.spotify-icon.is-pause {
    width: 12px;
    height: 14px;
    background:
        linear-gradient(currentColor, currentColor) 0 0 / 4px 100% no-repeat,
        linear-gradient(currentColor, currentColor) 100% 0 / 4px 100% no-repeat;
}

.progress {
    height: 4px;
    background: #222;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 6px;
}
.progress > span {
    display: block;
    height: 100%;
    background: var(--lime);
}

.guest {
    min-height: 100vh;
    width: min(440px, 100%);
    margin: 0 auto;
    padding: 24px 16px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.empty {
    text-align: center;
    padding: 18px 8px;
    color: var(--muted);
    font-size: 0.8rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    font-size: 0.72rem;
    font-weight: 800;
    border-radius: 999px;
    padding: 4px 8px;
    background: var(--card-2);
    color: var(--muted);
    line-height: 1;
    white-space: nowrap;
}

.history-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: none;
}

[x-cloak] { display: none !important; }

.install-banner {
    background: var(--card);
    border: 1px solid rgba(214, 255, 74, 0.22);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin: 0 0 12px;
}

.linkish {
    display: inline-block;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.sheet {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    z-index: 40;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.sheet-card {
    width: min(520px, 100%);
    max-height: 78vh;
    overflow: auto;
    background: #141821;
    border-radius: 16px 16px 0 0;
    padding: 12px 12px calc(16px + var(--safe-bottom));
}
.picker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    padding: 11px 4px;
}
.picker-item:active { background: var(--card-2); }

.session-block {
    margin-top: 8px;
}
.session-exos {
    margin: 3px 0 0;
    padding-left: 16px;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.45;
}
.session-exos li { margin: 0; }

.path {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 10px 0 12px;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--muted);
}
.path a { color: inherit; text-decoration: none; }
.path .is-on { color: var(--lime); }

.section-head {
    margin: 22px 0 10px;
}
.section-head h2 { margin-bottom: 4px; }

.builder-block, .builder-exo {
    scroll-margin-top: 12px;
}
.builder-exo {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 0 4px;
    border-top: 1px solid var(--line);
    margin-top: 8px;
}
.builder-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: none;
}
.builder-actions .btn {
    min-width: 36px;
    margin-bottom: 0;
}
.builder-reps {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}
.builder-reps input {
    width: 100%;
    background: #0e1117;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    font-weight: 700;
}
.builder-reps input[name="alternative_name"] {
    grid-column: 1 / -1;
}
.picker-item.is-picked { color: var(--lime); }

.week-card { padding-bottom: 8px; }
.week-row {
    display: grid;
    grid-template-columns: 2.4rem 1fr;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-top: 1px solid var(--line);
}
.week-row:first-of-type { border-top: 0; padding-top: 0; }
.week-row-name {
    font-weight: 800;
    font-size: 0.78rem;
    color: var(--muted);
    letter-spacing: 0.02em;
}
.week-row.is-today .week-row-name { color: var(--lime); }
.week-picks {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.week-pick {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 10px;
    flex: none;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #0e1117;
    font-weight: 800;
    font-size: 0.8rem;
    cursor: pointer;
}
.week-pick input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.week-pick:has(input:checked) {
    background: var(--lime);
    color: #111;
    border-color: var(--lime);
}
.week-pick.is-rest:has(input:checked) {
    background: var(--card-2);
    color: var(--muted);
    border-color: var(--line);
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 14px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}
.check input {
    width: 18px;
    height: 18px;
    accent-color: var(--lime);
    flex: none;
}
.field-code input {
    letter-spacing: 0.35em;
    text-align: center;
    font-size: 1.35rem;
    font-family: "Outfit", sans-serif;
    font-weight: 800;
}
.link-btn {
    background: none;
    border: 0;
    color: var(--lime);
    font-weight: 800;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 0;
}
