:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #eef2f7;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-2: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --shadow: 0 16px 45px rgba(15, 23, 42, 0.10);
}

html.dark {
    --bg: #090f1c;
    --surface: #111827;
    --surface-2: #1f2937;
    --text: #f9fafb;
    --muted: #9ca3af;
    --border: #263244;
    --primary: #60a5fa;
    --primary-2: #3b82f6;
    --danger: #f87171;
    --success: #22c55e;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: radial-gradient(circle at top, rgba(37,99,235,0.13), transparent 34%), var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 18px;
    line-height: 1.35;
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
}

body.has-dock {
    padding-bottom: calc(164px + env(safe-area-inset-bottom));
}

.app-shell {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 18px 14px 24px;
    transition: filter 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

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

.eyebrow {
    color: var(--primary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 800;
}

h1,
h2 {
    margin: 0;
    line-height: 1.08;
}

h1 {
    font-size: clamp(34px, 9vw, 48px);
    letter-spacing: -0.05em;
}

h2 {
    font-size: 23px;
    letter-spacing: -0.03em;
    margin-bottom: 14px;
}

button,
a,
input,
select,
textarea {
    font: inherit;
}

a {
    color: inherit;
}

button,
.button-like {
    border: 0;
    border-radius: 18px;
    min-height: 56px;
    padding: 14px 18px;
    background: var(--primary);
    color: white;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
}

button:active,
.quick-card:active,
.bottom-nav a:active {
    transform: scale(0.98);
}

button.danger {
    background: var(--danger);
    box-shadow: none;
}

.icon-button {
    width: 54px;
    height: 54px;
    min-height: 54px;
    border-radius: 18px;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card,
.exercise-card,
.hero-card {
    background: rgba(255,255,255,0.86);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

html.dark .card,
html.dark .exercise-card,
html.dark .hero-card {
    background: rgba(17, 24, 39, 0.86);
}

.compact-card {
    padding-bottom: 8px;
}

.hero-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
    border: 0;
}

.hero-label {
    opacity: 0.82;
    font-weight: 700;
    font-size: 14px;
}

.hero-number {
    font-size: 46px;
    font-weight: 900;
    letter-spacing: -0.06em;
}

.hero-number.small {
    font-size: 32px;
}

.muted,
small {
    color: var(--muted);
}

.hero-card .muted {
    color: rgba(255,255,255,0.78);
}

.quick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.quick-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 20px;
    min-height: 132px;
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.quick-card.primary {
    background: var(--text);
    color: var(--bg);
}

html.dark .quick-card.primary {
    background: #f9fafb;
    color: #111827;
}

.quick-card span {
    color: var(--muted);
    font-weight: 700;
}

.quick-card strong {
    font-size: 24px;
    letter-spacing: -0.04em;
}

.section-title-row,
.exercise-head,
.list-row,
.button-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.text-link,
.logout-link {
    color: var(--primary);
    font-weight: 800;
    text-decoration: none;
}

.logout-link {
    display: block;
    text-align: center;
    margin: 20px 0 8px;
}

.list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.list-row {
    background: var(--surface-2);
    border-radius: 20px;
    padding: 14px;
}

.pill,
.mini-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary);
    font-weight: 900;
    font-size: 14px;
}

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

.subnav {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    margin-bottom: 16px;
    padding-bottom: 4px;
}

.subnav a {
    flex: 0 0 auto;
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 12px 15px;
    color: var(--text);
    font-weight: 800;
}

label {
    display: block;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
    margin: 0 0 6px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 56px;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px 15px;
    background: var(--surface-2);
    color: var(--text);
    outline: none;
    margin-bottom: 12px;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.metric-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 14px 0;
}

.metric-tile {
    background: var(--surface-2);
    border-radius: 20px;
    padding: 14px;
}

.metric-tile span,
.metric-tile small {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric-tile strong {
    display: block;
    font-size: 22px;
    margin: 4px 0;
    letter-spacing: -0.04em;
}

.sets-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.set-row {
    display: grid;
    grid-template-columns: 42px 1fr 1fr 56px;
    gap: 10px;
    align-items: end;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 24px;
    padding: 12px;
}

.set-row.done {
    border-color: rgba(34, 197, 94, 0.55);
    background: rgba(34, 197, 94, 0.12);
}

.set-number {
    width: 42px;
    height: 42px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    color: var(--text);
    font-weight: 900;
    margin-bottom: 12px;
}

.set-row input {
    margin-bottom: 0;
    background: var(--surface);
}

.set-note {
    grid-column: 2 / -1;
}

.set-done {
    width: 56px;
    height: 56px;
    min-height: 56px;
    padding: 0;
    border-radius: 18px;
    background: var(--success);
    box-shadow: none;
}

.save-button {
    width: 100%;
    min-height: 66px;
    font-size: 20px;
    border-radius: 22px;
    margin-top: 6px;
}

.timer-dock {
    position: fixed;
    left: 50%;
    bottom: calc(76px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(calc(100% - 24px), 760px);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
    border-radius: 26px;
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,0.12);
    z-index: 2000;
    box-shadow: 0 20px 60px rgba(0,0,0,0.28);
}

.timer-dock button {
    min-height: 62px;
    border-radius: 20px;
    font-size: 19px;
}

.timer-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(8px);
    z-index: 9999;
}

.timer-overlay.hidden {
    display: none;
}

.timer-modal {
    width: min(100%, 360px);
    border-radius: 32px;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    text-align: center;
    box-shadow: 0 30px 80px rgba(0,0,0,0.38);
}

.timer-title {
    color: var(--muted);
    font-size: 18px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

#timerDisplay {
    font-size: clamp(72px, 24vw, 104px);
    font-weight: 950;
    line-height: 1;
    letter-spacing: -0.08em;
    margin: 20px 0 12px;
}

.timer-hint {
    color: var(--muted);
    margin-bottom: 18px;
}

body.timer-active .app-shell,
body.timer-active .timer-dock,
body.timer-active .bottom-nav {
    filter: blur(4px);
    opacity: 0.35;
    pointer-events: none;
}

.chart-box {
    height: 320px;
    background: var(--surface-2);
    border-radius: 24px;
    padding: 12px;
}

.weight-form,
.edit-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.exercise-edit-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.exercise-edit-card {
    background: var(--surface-2);
    border-radius: 24px;
    padding: 14px;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: env(safe-area-inset-bottom);
    transform: translateX(-50%);
    width: min(calc(100% - 24px), 760px);
    height: 66px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px;
    border-radius: 26px 26px 0 0;
    background: rgba(17, 24, 39, 0.86);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,0.12);
    z-index: 1800;
}

.bottom-nav a {
    text-decoration: none;
    color: rgba(255,255,255,0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    font-weight: 900;
    font-size: 15px;
}

.bottom-nav a.active {
    background: white;
    color: #111827;
}

.login-page {
    min-height: 100vh;
    padding: 0;
    background:
        radial-gradient(circle at top left, rgba(96,165,250,0.35), transparent 32%),
        radial-gradient(circle at bottom right, rgba(34,197,94,0.18), transparent 34%),
        var(--bg);
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
}

.login-card {
    width: min(100%, 420px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 32px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.login-badge {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.14);
    color: var(--primary);
    font-weight: 900;
    font-size: 14px;
    margin-bottom: 18px;
}

.login-card h1 {
    font-size: 42px;
    margin-bottom: 10px;
}

.login-card p {
    color: var(--muted);
    margin-bottom: 24px;
}

.login-card button {
    width: 100%;
    min-height: 64px;
    margin-top: 8px;
    font-size: 19px;
}

.login-error {
    background: rgba(220, 38, 38, 0.12);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.35);
    padding: 12px 14px;
    border-radius: 18px;
    margin-bottom: 16px;
    font-weight: 800;
}

@media (min-width: 720px) {
    .app-shell {
        padding-top: 28px;
    }

    .weight-form {
        grid-template-columns: 1fr 1fr auto;
        align-items: end;
    }

    .edit-grid {
        grid-template-columns: 100px 1fr 100px 130px;
        align-items: end;
    }
}

@media (max-width: 430px) {
    body {
        font-size: 17px;
    }

    .hero-card {
        grid-template-columns: 1fr;
    }

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

    .exercise-card,
    .card,
    .hero-card {
        border-radius: 24px;
        padding: 16px;
    }

    .set-row {
        grid-template-columns: 38px 1fr 1fr 52px;
        gap: 8px;
        padding: 10px;
    }

    .set-number {
        width: 38px;
        height: 38px;
    }

    .set-done {
        width: 52px;
        height: 56px;
    }

    input,
    select,
    textarea,
    button {
        min-height: 58px;
    }
}
