/* ==========================================================================
   Workout tracker – design system
   One file, mobile-first, dark. Tokens on :root, components below.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400..700&display=swap");

:root {
    color-scheme: dark;

    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    --bg: #0b1120;
    --surface: #151d30;
    --surface-2: #1e2942;
    --surface-3: #283553;
    --border: #273450;
    --text: #e9edf6;
    --muted: #94a0b8;

    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --accent-contrast: #06202e;
    --accent-soft: rgba(56, 189, 248, .14);

    --success: #34d399;
    --success-soft: rgba(52, 211, 153, .16);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, .16);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .14);
    --gold: #fcd34d;
    --gold-soft: rgba(252, 211, 77, .18);

    --radius: 16px;
    --radius-sm: 12px;
    --radius-pill: 999px;
    --shadow: 0 16px 40px rgba(0, 0, 0, .45);
    --tap: 44px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --keyboard: 0px; /* height of the open phone keyboard, set by js/dialogs.js */
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

body.is-locked {
    overflow: hidden;
}

h1, h2, h3, p {
    margin: 0;
}

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

button {
    font: inherit;
    color: inherit;
}

[hidden] {
    display: none !important;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.app {
    max-width: 480px;
    margin: 0 auto;
    padding: var(--safe-top) 16px calc(40px + var(--safe-bottom));
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 64px;
    margin: 0 -16px 12px;
    padding: 10px 10px;
    background: var(--bg);
}

.topbar > h1 {
    flex: 1;
    min-width: 0;
    padding: 0 6px;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-text {
    flex: 1;
    min-width: 0;
    padding: 0 6px;
}

.topbar-text h1 {
    font-size: 22px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.stack-lg {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.section-title {
    margin: 24px 0 10px 4px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.hint {
    color: var(--muted);
    font-size: 14px;
}

.empty {
    padding: 32px 16px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
    font-size: 15px;
}

/* --------------------------------------------------------------------------
   Icons & buttons
   -------------------------------------------------------------------------- */

.icon {
    width: 22px;
    height: 22px;
    flex: none;
}

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

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tap);
    height: var(--tap);
    flex: none;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background .15s, color .15s;
}

.icon-btn:hover,
.icon-btn:focus-visible {
    color: var(--text);
    background: var(--surface-2);
    outline: none;
}

.icon-btn:active {
    background: var(--surface-3);
}

.icon-btn-accent {
    background: var(--accent);
    color: var(--accent-contrast);
}

.icon-btn-accent:hover,
.icon-btn-accent:focus-visible {
    background: var(--accent-strong);
    color: var(--accent-contrast);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s, color .15s, transform .08s;
}

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

.btn:focus-visible {
    outline: 3px solid var(--accent-soft);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-contrast);
}

.btn-primary:hover {
    background: var(--accent-strong);
}

.btn-ghost {
    background: var(--surface-2);
    color: var(--text);
}

.btn-ghost:hover {
    background: var(--surface-3);
}

.btn-danger {
    background: transparent;
    border-color: var(--danger-soft);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-soft);
}

.btn-block {
    width: 100%;
}

.btn-lg {
    min-height: 56px;
    font-size: 18px;
    border-radius: var(--radius);
}

.btn-sm {
    min-height: 40px;
    padding: 0 14px;
    font-size: 15px;
}

.btn[disabled],
.btn.is-busy {
    opacity: .6;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Cards & lists
   -------------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -6px -8px 10px 0;
}

.card-header h2 {
    flex: 1;
    min-width: 0;
    font-size: 18px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px 4px 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color .15s;
}

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

.list-link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 10px 6px 10px 16px;
    font-weight: 500;
}

.list-link .title {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.list-link .subtitle {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
}

.list-link .icon {
    color: var(--muted);
}

/* "Add new" row: input + round button */

.inline-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 6px;
}

.inline-form .input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border-color: transparent;
}

.inline-form .input:focus-visible {
    box-shadow: none;
    border-color: transparent;
}

.inline-form .icon-btn {
    border-radius: var(--radius-pill);
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field > span {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.input {
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.textarea {
    min-height: 72px;
    resize: vertical;
    line-height: 1.4;
}

.exercise-notes,
.log-notes,
.session-exercise-notes {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
    color: var(--muted);
}

.exercise-notes span,
.log-notes span,
.session-exercise-notes span {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.exercise-notes .icon,
.log-notes .icon,
.session-exercise-notes .icon {
    flex: none;
    margin-top: 2px;
}

.exercise-notes {
    padding: 12px 0 0;
}

.log-notes {
    margin: -4px 0 12px;
}

.session-exercise-notes {
    margin: -4px 0 8px;
}

.input::placeholder {
    color: var(--muted);
}

.input:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

select.input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a0b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
}

.input-lg {
    min-height: 64px;
    font-size: 28px;
    font-weight: 600;
    text-align: center;
}

/* Minus/plus stepper around a numeric input */

.stepper {
    display: flex;
    align-items: stretch;
    min-height: 48px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}

.stepper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.stepper .input {
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding: 0 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
    text-align: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stepper .input:focus-visible {
    box-shadow: none;
}

.stepper-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 42px;
    padding: 0;
    border: 0;
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background .15s, color .15s;
}

.stepper-btn:hover {
    color: var(--text);
}

.stepper-btn:active {
    background: var(--surface-3);
    color: var(--text);
}

.stepper-lg {
    min-height: 60px;
}

.stepper-lg .input {
    font-size: 24px;
    letter-spacing: -.02em;
}

.stepper-lg .stepper-btn {
    width: 44px;
}

.stepper-lg .stepper-btn .icon {
    width: 22px;
    height: 22px;
}

/* --------------------------------------------------------------------------
   Sets table
   -------------------------------------------------------------------------- */

.sets {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.sets th {
    padding: 0 6px 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    text-align: left;
    color: var(--muted);
}

.sets td {
    padding: 8px 6px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

.sets .num {
    width: 36px;
    color: var(--muted);
}

.sets .actions {
    width: 48px;
    padding: 0;
    text-align: right;
}

.sets td.unit {
    overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Exercise cards (collapsible)
   -------------------------------------------------------------------------- */

.exercise {
    padding: 0;
}

.exercise-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 60px;
    padding: 10px 14px 10px 6px;
    list-style: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.exercise-summary::-webkit-details-marker {
    display: none;
}

.exercise-summary-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.exercise-name {
    font-size: 17px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.exercise-sets-summary {
    font-size: 14px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.exercise-chevron {
    flex: none;
    color: var(--muted);
    transition: transform .2s;
}

.exercise[open] .exercise-chevron {
    transform: rotate(90deg);
}

.exercise-body {
    padding: 0 14px 14px;
    border-top: 1px solid var(--border);
}

.exercise-body .sets {
    margin-top: 8px;
}

.exercise-body .hint {
    padding: 12px 0 0;
}

.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 36px;
    min-height: var(--tap);
    color: var(--muted);
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.is-dragging {
    position: relative;
    z-index: 20;
    box-shadow: var(--shadow);
    transition: none;
}

details.is-dragging {
    background: var(--surface-2);
}

tr.is-dragging > td {
    background: var(--surface-2);
}

.is-dragging .drag-handle {
    color: var(--accent);
    cursor: grabbing;
}

.sets td.drag-handle {
    display: table-cell;
    width: 52px;
    padding-left: 0;
    text-align: left;
    white-space: nowrap;
}

.sets td.drag-handle .icon {
    vertical-align: middle;
    margin-right: 2px;
}

.exercise-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.exercise-actions .btn-block {
    flex: 1;
}

.exercise-actions .btn:not(.btn-block) {
    padding: 0 14px;
}

/* --------------------------------------------------------------------------
   Stats, badges, disclosure
   -------------------------------------------------------------------------- */

.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat {
    padding: 12px 14px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.stat b {
    display: block;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stat span {
    font-size: 12px;
    color: var(--muted);
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 600;
}

.badge-neutral { background: var(--accent-soft); color: var(--accent); }
.badge-up      { background: var(--success-soft); color: var(--success); }
.badge-down    { background: var(--warning-soft); color: var(--warning); }
.badge-gold    { background: var(--gold-soft); color: var(--gold); }

.tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    vertical-align: middle;
}

.disclosure {
    border-top: 1px solid var(--border);
    margin-top: 14px;
    padding-top: 4px;
}

.disclosure summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--tap);
    list-style: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: var(--muted);
    -webkit-tap-highlight-color: transparent;
}

.disclosure summary::-webkit-details-marker {
    display: none;
}

.disclosure summary .icon {
    transition: transform .2s;
}

.disclosure[open] summary .icon {
    transform: rotate(90deg);
}

.disclosure-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px 0 8px;
}

.disclosure-body h3 {
    margin-bottom: 4px;
    font-size: 15px;
    font-weight: 600;
}

.disclosure-nested {
    margin-top: 6px;
    padding-top: 0;
    border-top: 0;
}

.disclosure-nested summary {
    min-height: 36px;
    font-size: 13px;
}

.sets.history td {
    font-size: 13px;
}

.sets.history .num {
    width: 64px;
    white-space: nowrap;
}

.sets.history .volume {
    width: 56px;
    text-align: right;
    color: var(--muted);
}

.sets.history tr.is-current td {
    color: var(--accent);
}

/* --------------------------------------------------------------------------
   Bottom sheet (native <dialog>)
   -------------------------------------------------------------------------- */

.sheet {
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 40px - var(--keyboard));
    max-height: calc(100dvh - 40px - var(--keyboard));
    margin: auto auto var(--keyboard); /* slides up above the phone keyboard */
    padding: 0;
    overflow-y: auto; /* only scrolls when the keyboard leaves too little room */
    transition: margin-bottom .2s ease-out, max-height .2s ease-out;
    border: 0;
    border-radius: 22px 22px 0 0;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    overscroll-behavior: contain;
}

.sheet::backdrop {
    background: rgba(2, 6, 18, .65);
    backdrop-filter: blur(3px);
}

.sheet[open] {
    animation: sheet-in .22s ease-out;
}

@keyframes sheet-in {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: none; opacity: 1; }
}

.sheet-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px 4px 22px;
    background: var(--surface);
}

.sheet-header h2 {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
}

.sheet-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px 22px 8px;
}

.sheet-footer {
    padding: 8px 22px calc(22px + var(--safe-bottom));
}

.sheet-actions {
    display: flex;
    gap: 8px;
    padding: 0 22px 8px;
}

.sheet-actions form {
    flex: 1;
}

.sheet-actions form:not(.grow) {
    flex: 0 0 auto;
}

.sheet-actions form:not(.grow) .btn {
    min-width: 52px;
    padding: 0 12px;
}

.sheet-actions form:only-child,
.sheet-actions form.grow {
    flex: 1;
}

/* --------------------------------------------------------------------------
   Training session (full-screen overlay)
   -------------------------------------------------------------------------- */

.session {
    position: fixed;
    inset: 0 0 var(--keyboard);
    z-index: 50;
    transition: bottom .2s ease-out;
    overflow-y: auto;
    background: var(--bg);
    -webkit-overflow-scrolling: touch;
}

.session-shell {
    padding-bottom: calc(120px + var(--safe-bottom));
}

.session-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 64px;
    margin: 0 -16px;
    padding: 10px 10px 6px;
    background: var(--bg);
}

.session-header .hint {
    font-variant-numeric: tabular-nums;
}

.progress-bar {
    position: sticky;
    top: 64px;
    z-index: 5;
    height: 4px;
    margin: 0 -16px 16px;
    background: var(--surface-2);
}

.progress-bar-fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width .3s;
}

.session-list {
    display: flex;
    flex-direction: column;
    gap: 22px;
    margin-bottom: 20px;
}

.session-exercise-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    padding: 0 4px;
}

.session-exercise-header h2 {
    font-size: 18px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.set-row {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 6px 12px 6px 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.set-row + .set-row {
    margin-top: 2px;
}

.set-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.set-plan {
    font-weight: 500;
}

.set-last {
    font-size: 13px;
    color: var(--muted);
}

.set-row.is-done .set-num {
    background: var(--success-soft);
    color: var(--success);
}

.set-row.is-done .set-plan {
    color: var(--muted);
}

.set-row.is-current {
    background: var(--surface);
    border-color: var(--accent);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.set-row.is-current .set-num {
    background: var(--accent);
    color: var(--accent-contrast);
}

.set-current {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 8px;
    padding: 14px 12px 12px;
    background: var(--surface);
    border: 1px solid var(--accent);
    border-top: 0;
    border-radius: 0 0 var(--radius) var(--radius);
}

.rest-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--keyboard);
    z-index: 60;
    transition: bottom .2s ease-out;
    overflow: hidden;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
}

.rest-bar-fill {
    position: absolute;
    inset: 0;
    width: 0;
    background: var(--accent-soft);
    transition: width .25s linear;
}

.rest-bar-content {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 480px;
    margin: 0 auto;
    padding: 10px 16px;
}

.rest-bar-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.rest-bar-content b {
    flex: 1;
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.rest-bar-content .btn {
    min-height: 40px;
    padding: 0 12px;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.switch-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.summary-plan {
    padding: 4px 0;
}

.session-exercise-record {
    margin: -4px 0 8px;
    font-size: 13px;
    color: var(--gold);
}

.set-pr {
    margin-left: 6px;
    padding: 1px 8px;
    font-size: 11px;
    vertical-align: 2px;
}

/* --------------------------------------------------------------------------
   Progress charts (js/charts.js renders the SVG)
   -------------------------------------------------------------------------- */

.chart {
    position: relative;
    margin: 8px 0 12px;
}

.chart-title {
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}

.chart svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    touch-action: pan-y;
}

.chart .grid {
    stroke: var(--border);
    stroke-width: 1;
}

.chart .axis-text {
    fill: var(--muted);
    font-size: 11px;
    font-family: var(--font);
}

.chart .area {
    fill: var(--accent-soft);
}

.chart .line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.chart .marker {
    fill: var(--accent);
    stroke: var(--surface);
    stroke-width: 2;
}

.chart .end-label {
    fill: var(--text);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
}

.chart .crosshair {
    stroke: var(--muted);
    stroke-width: 1;
}

.chart .marker.is-active {
    r: 6;
}

.chart-tooltip {
    position: absolute;
    top: 22px;
    z-index: 3;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    pointer-events: none;
}

.chart-tooltip b {
    display: block;
    font-size: 14px;
    color: var(--text);
}

/* --------------------------------------------------------------------------
   Training calendar
   -------------------------------------------------------------------------- */

.stats-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.stats-3 .stat {
    padding: 10px 8px;
    text-align: center;
}

.cal {
    margin-top: 14px;
}

.cal-months {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 3px;
    margin-left: 26px;
    height: 16px;
    font-size: 11px;
    color: var(--muted);
}

.cal-months span {
    white-space: nowrap;
}

.cal-body {
    display: flex;
    gap: 6px;
}

.cal-weekdays {
    display: grid;
    grid-template-rows: repeat(7, 1fr);
    gap: 3px;
    width: 20px;
    font-size: 10px;
    color: var(--muted);
}

.cal-weekdays span {
    display: flex;
    align-items: center;
}

.cal-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    grid-template-rows: repeat(7, 1fr);
    grid-auto-flow: column;
    gap: 3px;
}

.cal-day {
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: var(--surface-2);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cal-day.cal-1 {
    background: color-mix(in oklab, var(--accent) 55%, var(--surface-2));
}

.cal-day.cal-2 {
    background: var(--accent);
}

.cal-day.is-future {
    background: transparent;
    border: 1px dashed var(--border);
    cursor: default;
}

.cal-day.is-today {
    box-shadow: 0 0 0 2px var(--text);
}

.cal-day.is-selected {
    box-shadow: 0 0 0 2px var(--accent);
}

.cal-caption {
    margin-top: 10px;
    min-height: 20px;
}

/* --------------------------------------------------------------------------
   Plate calculator
   -------------------------------------------------------------------------- */

.set-tools {
    display: flex;
    justify-content: flex-end;
    margin-top: -6px;
}

.link-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.plates {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 56px;
}

.plate {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 56px;
    padding: 0 8px;
    border-radius: 8px;
    background: var(--surface-3);
    border: 2px solid var(--border);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.plate-25 { height: 56px; background: var(--danger-soft); border-color: var(--danger); }
.plate-20 { height: 52px; background: var(--accent-soft); border-color: var(--accent); }
.plate-15 { height: 48px; background: var(--gold-soft); border-color: var(--gold); }
.plate-10 { height: 44px; background: var(--success-soft); border-color: var(--success); }
.plate-5 { height: 38px; }
.plate-2-5 { height: 32px; font-size: 13px; }
.plate-1-25 { height: 28px; font-size: 12px; }
.plate-0-5 { height: 24px; font-size: 11px; }

/* --------------------------------------------------------------------------
   Log edit sheet
   -------------------------------------------------------------------------- */

.card-header-text {
    flex: 1;
    min-width: 0;
}

.log-edit-exercise h3 {
    margin-bottom: 6px;
    font-size: 15px;
    font-weight: 600;
}

.log-edit-set {
    display: grid;
    grid-template-columns: 28px 1fr 1fr 36px;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.log-edit-set .num {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.log-edit-set .input {
    min-height: 44px;
    padding: 8px 12px;
    font-variant-numeric: tabular-nums;
}

.log-edit-set .log-edit-unit {
    grid-column: 3 / span 2;
}

/* --------------------------------------------------------------------------
   Timed-set countdown inside the current set
   -------------------------------------------------------------------------- */

.set-timer {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.set-timer-fill {
    position: absolute;
    inset: 0;
    width: 0;
    background: var(--accent-soft);
    transition: width .25s linear;
}

.set-timer > * {
    position: relative;
}

.set-timer b {
    flex: 1;
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.set-timer .hint {
    flex: 1;
}

.set-timer .btn {
    min-height: 40px;
    padding: 0 14px;
    font-size: 14px;
}

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */

.login-card {
    margin-top: clamp(24px, 12vh, 96px);
    padding: 28px 20px 24px;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    text-align: center;
}

.login-brand img {
    width: 72px;
    height: 72px;
    border-radius: 20px;
}

.login-brand h1 {
    font-size: 24px;
    font-weight: 600;
}

.login-brand p {
    color: var(--muted);
    font-size: 15px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--danger-soft);
    color: var(--danger);
}

.alert .icon {
    flex: none;
    margin-top: 2px;
}

.input-group {
    position: relative;
}

.input-group > .icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.input-group .input {
    padding-left: 44px;
}

.input-group.has-action .input {
    padding-right: 52px;
}

.input-group-action {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.input-group-action .icon-hide,
.input-group-action[aria-pressed="true"] .icon-show {
    display: none;
}

.input-group-action[aria-pressed="true"] .icon-hide {
    display: block;
}

.switch {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--tap);
    font-size: 15px;
    cursor: pointer;
    user-select: none;
}

.switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.switch-track {
    flex: none;
    position: relative;
    width: 44px;
    height: 26px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    transition: background .15s;
}

.switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--text);
    transition: transform .15s;
}

.switch input:checked + .switch-track {
    background: var(--accent);
}

.switch input:checked + .switch-track::after {
    transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* --------------------------------------------------------------------------
   Installable app: install card (front page) and offline banner
   -------------------------------------------------------------------------- */

.install-card {
    position: relative;
    display: grid;
    grid-template-columns: 40px 1fr;
    align-items: start;
    gap: 10px 12px;
    padding: 14px 44px 14px 14px;
    background: var(--accent-soft);
    border: 1px solid color-mix(in oklab, var(--accent) 35%, transparent);
    border-radius: var(--radius);
}

.install-card-icon {
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-contrast);
}

.install-card-text {
    flex: 1;
    min-width: 0;
    font-size: 15px;
}

.install-card-text strong {
    display: block;
    margin-bottom: 2px;
}

.install-card-text p {
    color: var(--muted);
}

.install-card-hint {
    margin-top: 8px;
    color: var(--text) !important;
}

.install-card-hint .icon {
    vertical-align: -3px;
}

.install-card > .btn {
    grid-column: 2;
    justify-self: start;
}

.install-card-close {
    position: absolute;
    top: 4px;
    right: 4px;
    color: var(--muted);
}

.offline-banner {
    position: sticky;
    top: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(8px + var(--safe-top)) 16px 8px;
    background: var(--warning-soft);
    color: var(--text);
    font-size: 14px;
    border-bottom: 1px solid color-mix(in oklab, var(--warning) 40%, transparent);
}

.offline-banner .icon {
    flex: none;
    color: var(--warning);
}

/* --------------------------------------------------------------------------
   Error page
   -------------------------------------------------------------------------- */

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