/* Cabin Restore PWA - Matching App Design */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500;600&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #1A1A1A;
    --secondary: #6B7280;
    --tertiary: #9CA3AF;
    --accent: #7ABFDC;
    --accent-light: #E8F4FC;
    --surface: #FFFFFF;
    --background: #F5F7FA;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --orange: #5B8A9A;
    --orange-light: #EDF5F7;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--primary);
    -webkit-font-smoothing: antialiased;
}

#app {
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ============================================
   SPLASH SCREEN
   ============================================ */
#splash-screen {
    background: #FAFCFE;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.splash-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    overflow: hidden;
}

.splash-gradient {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to top,
        rgba(122, 191, 220, 0.08) 0%,
        rgba(232, 244, 252, 0.04) 30%,
        transparent 60%
    );
}

.splash-cloud {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.4;
}

.splash-cloud.cloud-1 {
    width: 300px;
    height: 120px;
    background: linear-gradient(90deg, rgba(122, 191, 220, 0.15), transparent);
    bottom: 10%;
    left: -10%;
    animation: splash-drift 25s ease-in-out infinite;
}

.splash-cloud.cloud-2 {
    width: 200px;
    height: 80px;
    background: linear-gradient(90deg, transparent, rgba(122, 191, 220, 0.12));
    bottom: 25%;
    right: -10%;
    animation: splash-drift 30s ease-in-out infinite reverse;
}

.splash-cloud.cloud-3 {
    width: 180px;
    height: 60px;
    background: rgba(122, 191, 220, 0.08);
    top: 15%;
    left: 10%;
    animation: splash-float 20s ease-in-out infinite;
}

@keyframes splash-drift {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(20px); }
}

@keyframes splash-float {
    0%, 100% { transform: translateY(0) scale(1); opacity: 0.4; }
    50% { transform: translateY(-10px) scale(1.05); opacity: 0.5; }
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 24px;
}

.splash-logo {
    width: 85vw;
    max-width: 400px;
    height: auto;
    margin-bottom: 24px;
    filter: drop-shadow(0 15px 30px rgba(122, 191, 220, 0.3));
}

.splash-subheadline {
    font-size: 14px;
    font-weight: 400;
    color: #5A6A7A;
    line-height: 1.8;
    margin-top: 8px;
}

.splash-tagline {
    margin-top: 4px;
    font-size: 14px;
    color: #7ABFDC;
    font-weight: 500;
}

.splash-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px;
    text-align: center;
    padding-bottom: calc(24px + var(--safe-bottom));
}

.splash-version {
    font-size: 12px;
    font-weight: 400;
    color: #A0AEC0;
    letter-spacing: 1px;
}

/* Splash fade out animation */
#splash-screen.fade-out {
    animation: splash-fade-out 0.5s ease-out forwards;
}

@keyframes splash-fade-out {
    from { opacity: 1; }
    to { opacity: 0; visibility: hidden; }
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    background: var(--background);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px;
}

.screen.active {
    display: flex;
}

/* Header */
.header {
    padding: calc(var(--safe-top) + 16px) 20px 16px;
    background: var(--background);
    position: sticky;
    top: 0;
    z-index: 10;
    position: relative;
}

.header-logo {
    position: fixed;
    top: calc(var(--safe-top) + 8px);
    right: 12px;
    width: 80px;
    height: auto;
    z-index: 100;
}

.header h1 {
    font-size: 26px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 6px;
}

.header.with-back {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 16px;
}

.header.with-back h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 0;
}

.subtitle {
    font-size: 15px;
    font-weight: 500;
    color: var(--secondary);
    margin-bottom: 2px;
}

.tagline {
    font-size: 13px;
    font-weight: 500;
    color: var(--tertiary);
}

.back-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: -8px;
}

/* Content */
.content {
    flex: 1;
    padding-bottom: 20px;
}

.section {
    padding: 0 20px;
    margin-top: 24px;
}

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

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 6px;
}

.section-desc {
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

/* Quick Start Cards */
.quick-start-card {
    background: var(--orange);
    border-radius: 16px;
    padding: 16px 18px;
    margin-bottom: 10px;
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: #FFFFFF;
}

.card-subtitle {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.category-card {
    background: var(--accent);
    border-radius: 14px;
    padding: 14px;
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.category-card:active {
    transform: scale(0.97);
}

.category-icon {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    color: var(--accent);
}

.category-icon svg {
    width: 20px;
    height: 20px;
}

.category-name {
    font-size: 13px;
    font-weight: 600;
    color: #FFFFFF;
}

/* Browse List */
.browse-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.browse-card {
    background: var(--surface);
    border-radius: 14px;
    padding: 16px;
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: transform 0.15s ease;
    display: flex;
    align-items: center;
    gap: 14px;
}

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

.browse-icon {
    width: 44px;
    height: 44px;
    border-radius: 22px;
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent);
}

.browse-icon svg {
    width: 22px;
    height: 22px;
}

.browse-info {
    flex: 1;
    min-width: 0;
}

.browse-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 2px;
}

.browse-desc {
    font-size: 12px;
    font-weight: 500;
    color: var(--secondary);
    line-height: 1.4;
}

.browse-arrow {
    color: var(--tertiary);
    flex-shrink: 0;
}

/* Preferences */
.preferences-card {
    background: var(--orange);
    border-radius: 14px;
    border: none;
    overflow: hidden;
}

.preference-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
}

.preference-label {
    font-size: 14px;
    font-weight: 500;
    color: #FFFFFF;
}

.preference-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 16px;
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 51px;
    height: 31px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border);
    border-radius: 31px;
    transition: background 0.2s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 27px;
    height: 27px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Segmented Control */
.segmented-control {
    display: flex;
    background: var(--border-light);
    border-radius: 10px;
    padding: 3px;
    gap: 4px;
}

.segment {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.segment.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

/* Settings Sections */
.settings-section {
    margin-bottom: 24px;
}

.settings-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
    padding: 0 20px;
}

.settings-card {
    background: var(--orange);
    border-radius: 14px;
    margin: 0 20px;
    border: none;
    overflow: hidden;
}

.settings-card .preference-label {
    color: #FFFFFF;
}

.settings-card .preference-divider {
    background: rgba(255, 255, 255, 0.2);
}

.about-section {
    background: var(--surface);
    border-radius: 14px;
    margin: 0 20px;
    padding: 16px;
    border: 1px solid var(--border-light);
}

.about-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}

.about-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.version-text {
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--tertiary);
    margin-top: 20px;
    padding: 0 20px;
}

/* Routine Detail Screen */
.routine-hero {
    width: 100%;
    height: 200px;
    object-fit: cover;
    object-position: center top;
    border-radius: 16px;
    margin: 0 20px 20px;
    width: calc(100% - 40px);
}

.routine-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--primary);
    padding: 0 20px;
    margin-bottom: 6px;
}

.routine-desc {
    font-size: 14px;
    font-weight: 500;
    color: var(--secondary);
    padding: 0 20px;
    margin-bottom: 12px;
}

.routine-time {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 20px;
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary);
}

.routine-time svg {
    width: 16px;
    height: 16px;
}

.level-description {
    background: var(--accent-light);
    border-radius: 12px;
    padding: 14px 16px;
    margin: 12px 20px 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    line-height: 1.4;
}

.session-settings {
    margin-top: 20px;
}

.session-settings-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    padding: 0 20px;
    margin-bottom: 12px;
}

/* Primary Button */
.primary-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: calc(100% - 40px);
    margin: 20px;
}

.primary-btn:active {
    transform: scale(0.97);
}

.primary-btn svg {
    width: 18px;
    height: 18px;
}

/* Bottom Tab Bar */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(70px + var(--safe-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: 10px;
    padding-bottom: var(--safe-bottom);
    z-index: 100;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 4px 20px;
    color: var(--tertiary);
    transition: color 0.2s ease;
}

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

.tab-item svg {
    width: 24px;
    height: 24px;
}

.tab-label {
    font-size: 11px;
    font-weight: 500;
    font-family: inherit;
}

/* Player Screen */
#player-screen {
    background: #000;
    padding-bottom: 0;
}

#player-screen .tab-bar {
    display: none;
}

.player-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#player-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 24px);
    background: linear-gradient(
        to bottom,
        rgba(0,0,0,0.6) 0%,
        transparent 20%,
        transparent 80%,
        rgba(0,0,0,0.4) 100%
    );
    pointer-events: none;
}

.player-overlay > * {
    pointer-events: auto;
}

.player-header {
    text-align: center;
}

.player-title {
    font-size: 20px;
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.player-instruction {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.player-stats {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stat-item {
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 10px 14px;
    min-width: 70px;
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    margin-bottom: 2px;
}

.stat-value {
    font-size: 20px;
    font-weight: 600;
    color: white;
}

.player-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
}

.close-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255,255,255,0.15);
    border-radius: 22px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.play-pause-btn {
    width: 64px;
    height: 64px;
    border: none;
    background: var(--orange);
    border-radius: 32px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.play-pause-btn svg {
    width: 28px;
    height: 28px;
}

.play-pause-btn .pause-icon {
    display: none;
}

.play-pause-btn.playing .play-icon {
    display: none;
}

.play-pause-btn.playing .pause-icon {
    display: block;
}

/* Complete Screen */
#complete-screen {
    background: var(--background);
}

.complete-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.complete-icon {
    width: 80px;
    height: 80px;
    border-radius: 40px;
    background: #10B981;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.complete-icon svg {
    width: 40px;
    height: 40px;
}

.complete-content h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
}

.complete-content p {
    font-size: 15px;
    font-weight: 500;
    color: var(--secondary);
    margin-bottom: 32px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.screen.active {
    animation: fadeIn 0.2s ease;
}

/* Disclaimer Link */
.disclaimer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
}

.disclaimer-row svg {
    color: var(--tertiary);
}

/* Onboarding */
.onboarding-header {
    padding: calc(var(--safe-top) + 20px) 20px 12px;
}

.onboarding-title {
    font-size: 26px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}

.onboarding-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--secondary);
    line-height: 1.45;
    margin-bottom: 6px;
}

.onboarding-text.small {
    font-size: 13px;
    opacity: 0.8;
}

.warning-card {
    background: #FEE2E2;
    border-radius: 16px;
    padding: 16px;
    margin: 12px 20px 0;
}

.warning-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 6px;
}

.warning-body {
    font-size: 12px;
    font-weight: 500;
    color: var(--secondary);
    line-height: 1.5;
    margin-bottom: 10px;
}

.level-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 16px;
    border: 2px solid var(--border-light);
    cursor: pointer;
    margin: 0 20px 12px;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.level-card:active { transform: scale(0.99); }

.level-card.selected {
    background: var(--accent);
    border-color: var(--accent);
}

.level-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.level-card.selected .level-card-title { color: #FFFFFF; }

.level-card-desc {
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary);
    line-height: 1.4;
}

.level-card.selected .level-card-desc { color: rgba(255,255,255,0.75); }

.onboarding-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background);
    border-top: 1px solid var(--border-light);
    padding: 16px 20px calc(var(--safe-bottom) + 16px);
}

.onboarding-footer .primary-btn { margin: 0; width: 100%; }

#onboarding-screen .tab-bar { display: none; }

/* Player Loading Overlay */
.player-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.player-loading.visible {
    display: flex;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Player Error Overlay */
.player-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 15;
}

.player-error.visible {
    display: flex;
}

.error-content {
    text-align: center;
    color: #FFFFFF;
    padding: 20px;
}

.error-content svg {
    margin-bottom: 16px;
    opacity: 0.8;
}

.error-content p {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 20px;
}

.retry-btn {
    background: var(--accent);
    color: #FFFFFF;
    border: none;
    border-radius: 12px;
    padding: 12px 32px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.retry-btn:active {
    transform: scale(0.97);
    opacity: 0.9;
}

/* Double-buffered video elements */
.player-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.player-video.active {
    opacity: 1;
    z-index: 1;
}

/* Preparing session UI */
.progress-bar {
    width: 100%;
    height: 10px;
    background: var(--border-light);
    border-radius: 999px;
    overflow: hidden;
}

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

.prep-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 13px;
    color: var(--secondary);
    font-weight: 500;
}

/* Preparing screen - use neutral colors, not JetBlue branded */
#preparing-screen .settings-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
}

#preparing-screen .settings-card .preference-label,
#preparing-screen .settings-card .section-desc,
#preparing-screen .settings-card .settings-label {
    color: var(--primary);
}

#preparing-screen .progress-bar .progress-fill {
    background: var(--secondary);
}

.secondary-btn {
    width: calc(100% - 40px);
    margin: 0 20px;
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.secondary-btn:active { transform: scale(0.99); }
