:root {
    --bg: var(--tg-theme-bg-color, #ffffff);
    --bg2: var(--tg-theme-secondary-bg-color, #f5f5f7);
    --text: var(--tg-theme-text-color, #1c1c1e);
    --hint: var(--tg-theme-hint-color, #8e8e93);
    --accent: var(--tg-theme-button-color, #e8567f);
    --accent-text: var(--tg-theme-button-text-color, #ffffff);
    --link: var(--tg-theme-link-color, #e8567f);
    --border: var(--tg-theme-section-separator-color, #e5e5ea);
    --success: #34c759;
    --warning: #ff9f0a;
    --danger: #ff3b30;
    --radius: 14px;
    --radius-sm: 10px;
    --nav-h: 60px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Type scale */
    --fs-xs: 11px;
    --fs-sm: 13px;
    --fs-base: 15px;
    --fs-md: 17px;
    --fs-lg: 20px;
    --fs-xl: 24px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

a { color: var(--link); }

#app { height: 100%; }

.screen { height: 100%; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* --- Onboarding --- */

.onboarding {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
}

.onboarding:has(.step--pinned:not(.hidden)) {
    align-items: stretch;
}

.step {
    width: 100%;
    max-width: 340px;
    text-align: center;
}

.onboarding-logo {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

/* Onboarding typography — one scale for all steps */
.step h1 { font-size: var(--fs-xl); font-weight: 700; margin-bottom: 8px; }
.step h2 { font-size: var(--fs-lg); font-weight: 700; margin-bottom: 16px; }

.form-block { text-align: left; width: 100%; }
.form-block h2 { text-align: center; margin-bottom: 24px; }

.input-label {
    display: block;
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--hint);
    margin-bottom: 6px;
}

.lang-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 28px;
}

.lang-buttons button {
    padding: 14px;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: var(--fs-base);
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
}

.lang-buttons button:active {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}

#disclaimer-text {
    text-align: left;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-line;
    margin-bottom: 24px;
}

/* --- Disclaimer --- */

.disc {
    text-align: left;
    margin-bottom: 24px;
}

.disc h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}

.disc-row {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
}

.disc-row + .disc-row {
    border-top: 0.5px solid var(--border);
}

.disc-emoji {
    font-size: var(--fs-lg);
    flex-shrink: 0;
    line-height: 1.3;
}

.disc-text {
    font-size: var(--fs-base);
    line-height: 1.5;
    color: var(--text);
}

.disc-note {
    font-size: var(--fs-sm);
    line-height: 1.5;
    color: var(--hint);
    text-align: center;
    margin-top: 20px;
}

/* --- Inputs --- */

.input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: var(--fs-base);
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}

.input:focus {
    border-color: var(--accent);
}

.btn-primary {
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-text);
    font-size: var(--fs-base);
    font-weight: 600;
    font-family: var(--font);
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn-primary:active { opacity: 0.8; }
.btn-primary:disabled { opacity: 0.4; }
.btn-full { width: 100%; margin-top: 20px; }

/* --- Onboarding Chips --- */

/* Pinned bottom layout for onboarding steps */

.step--pinned {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    text-align: center;
}

.step-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.step-center {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.step-bottom {
    flex-shrink: 0;
    padding-top: 8px;
}

.step-hint {
    font-size: var(--fs-sm);
    color: var(--hint);
    text-align: center;
    margin-bottom: 10px;
    line-height: 1.4;
}

.step-hint a { color: var(--link); }

.onb-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.onb-chip {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: var(--fs-base);
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
}

.onb-chip.selected {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}

.creds-error {
    font-size: 14px;
    color: var(--danger);
    margin-top: 12px;
    text-align: center;
}

.done-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--success);
    color: #fff;
    font-size: 32px;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.done-text {
    font-size: 17px;
    font-weight: 600;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 16px;
}

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


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

main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Bottom Nav --- */

#bottom-nav {
    height: var(--nav-h);
    display: flex;
    border-top: 0.5px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--hint);
    font-size: 11px;
    font-family: var(--font);
    cursor: pointer;
    transition: color 0.2s;
}

.nav-btn.active { color: var(--accent); }
.nav-btn svg { width: 22px; height: 22px; }

/* --- Early Access Hint --- */

.early-hint {
    margin: 8px 16px;
    padding: 8px 12px;
    background: rgba(255, 159, 10, 0.08);
    border: 1px solid rgba(255, 159, 10, 0.2);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    color: var(--warning);
    text-align: center;
    line-height: 1.4;
}

/* --- Club Filter --- */

.club-filter-bar {
    display: flex;
    gap: 6px;
    padding: 4px 16px 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.club-filter-bar::-webkit-scrollbar { display: none; }

.club-chip {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--hint);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
}

.club-chip.active {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}

/* --- Week Tabs --- */

.week-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 16px 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

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

.week-tab {
    flex-shrink: 0;
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--bg2);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    border: none;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.week-tab.active {
    background: var(--accent);
    color: var(--accent-text);
}

.week-tab--early {
    border: 1.5px dashed var(--warning);
}

.week-tab--early.active {
    border: 1.5px solid var(--accent);
}

/* --- Day Pills --- */

.day-pills {
    display: flex;
    gap: 2px;
    padding: 8px 16px 12px;
}

.day-pills::-webkit-scrollbar { display: none; }

.day-pill {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 4px;
    border-radius: 12px;
    background: transparent;
    border: none;
    min-width: 0;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}

.day-pill .abbr {
    font-size: 11px;
    color: var(--hint);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.day-pill .num {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-top: 2px;
}

.day-pill.active {
    background: var(--accent);
}

.day-pill.active .abbr,
.day-pill.active .num {
    color: var(--accent-text);
}

.day-pill.today {
    border: 1.5px solid var(--accent);
}

/* --- Class Cards --- */

.class-list {
    padding: 0 16px 16px;
}

.class-card {
    background: var(--bg2);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.12s;
}

.class-card:active { transform: scale(0.98); }

.class-card__info { flex: 1; min-width: 0; }

.class-card__name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.class-card__meta {
    font-size: 13px;
    color: var(--hint);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.class-card__meta span::before {
    content: '';
}

.class-card__right {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.spots {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 600;
}

.spots--ok { background: rgba(52,199,89,0.12); color: var(--success); }
.spots--few { background: rgba(255,159,10,0.12); color: var(--warning); }
.spots--full { background: rgba(255,59,48,0.1); color: var(--danger); }

.btn-book {
    padding: 7px 14px;
    border-radius: 8px;
    background: var(--success);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
    white-space: nowrap;
}

.btn-book:disabled { opacity: 0.35; }
.btn-book.done { background: var(--success); }
.btn-autobook { background: var(--warning); color: #000; }

/* --- Bookings --- */

.bookings-list { padding: 16px; }

/* Shared section title — used in bookings, settings, anywhere */
.section-title {
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--hint);
    margin: 20px 0 10px;
}

.section-title:first-child { margin-top: 0; }

.browse-hint {
    flex-shrink: 0;
    background: var(--bg2);
    text-align: center;
    padding: 8px 16px;
    font-size: var(--fs-sm);
    color: var(--hint);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.browse-hint a {
    color: var(--link);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}

.browse-hint-x {
    color: var(--hint);
    cursor: pointer;
    padding: 4px 8px;
    font-size: var(--fs-md);
    opacity: 0.5;
}

.booking-card--mf {
    opacity: 0.7;
}

.booking-card {
    background: var(--bg2);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.booking-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.booking-dot--pending { background: var(--warning); }
.booking-dot--booked { background: var(--success); }
.booking-dot--failed { background: var(--danger); }

.booking-card__info { flex: 1; }

.booking-card__name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.booking-card__meta {
    font-size: 13px;
    color: var(--hint);
}

.btn-cancel {
    color: var(--danger);
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    padding: 8px;
}

/* --- Settings --- */

#settings-content { padding: 16px; }

.settings-section {
    margin-bottom: 24px;
}

/* settings uses shared .section-title */

.lang-chips {
    display: flex;
    gap: 8px;
}

.lang-chip {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
}

.lang-chip.active {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}

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

.settings-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.settings-row .input { flex: 1; }

.btn-sm {
    padding: 10px 16px;
    font-size: 13px;
}

.btn-outline {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    width: 100%;
}

/* --- Utilities --- */

.text-secondary { color: var(--hint); }
.text-sm { font-size: 13px; margin-top: 12px; line-height: 1.4; }
.text-hint { color: var(--hint); }
.text-center { text-align: center; }

.empty-state {
    text-align: center;
    color: var(--hint);
    padding: 48px 16px;
    font-size: 15px;
}

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--bg2) 25%, var(--bg) 50%, var(--bg2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
    height: 68px;
    margin-bottom: 8px;
}

@keyframes shimmer { to { background-position: -200% 0; } }
