/* ============================================
   right.bike Brand Style System
   Based on: docs/rightbike/brand-style.md
   ============================================ */

/* ----------------------------------------
   CSS Custom Properties (Design Tokens)
   ---------------------------------------- */
:root {
    /* Brand Colors */
    --rb-primary: #0068a6;
    --rb-secondary: #00b9f2;
    --rb-accent: #00a896;
    --rb-orange: #FF6B00;          /* Consumer brand accent - energy, differentiation */

    /* Text Colors - improved contrast */
    --rb-text-primary: #3F454D;
    --rb-text-secondary: #4B5563;  /* Darkened from #6B7280 for better contrast (~7:1) */
    --rb-text-muted: #6B7280;      /* Darkened from #9CA3AF to meet WCAG AA (~5:1) */

    /* Background Colors */
    --rb-bg-primary: #ffffff;
    --rb-bg-secondary: #fafafa;
    --rb-bg-tertiary: #f3f4f6;

    /* Semantic Colors */
    --rb-success: #00a896;
    --rb-warning: #F59E0B;
    --rb-error: #EF4444;
    --rb-info: #00b9f2;

    /* Spacing */
    --rb-space-xs: 4px;
    --rb-space-sm: 8px;
    --rb-space-md: 16px;
    --rb-space-lg: 24px;
    --rb-space-xl: 32px;
    --rb-space-2xl: 48px;

    /* Border Radius - slightly crisper for technical feel */
    --rb-radius-sm: 3px;
    --rb-radius-md: 6px;
    --rb-radius-lg: 10px;

    /* Shadows */
    --rb-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --rb-shadow-md: 0 1px 3px rgba(0, 0, 0, 0.1);
    --rb-shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);

    /* Typography */
    --rb-font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --rb-font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;

    /* Layout */
    --rb-header-height: 64px;
    --rb-sidebar-width: 240px;
    --rb-footer-height: 48px;
}

/* ----------------------------------------
   Layout Components
   ---------------------------------------- */

/* Main Layout Grid */
.rb-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.rb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--rb-header-height);
    padding: 0 var(--rb-space-lg);
    background: var(--rb-bg-primary);
    border-bottom: 1px solid var(--rb-bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 100;
}

.rb-header-left {
    display: flex;
    align-items: center;
}

.rb-logo {
    display: flex;
    align-items: center;
    gap: var(--rb-space-sm);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--rb-primary);
    text-decoration: none;
}

.rb-logo:hover {
    text-decoration: none;
    color: var(--rb-secondary);
}

.rb-logo-icon {
    height: 36px;
    width: auto;
}

@media (max-width: 480px) {
    .rb-logo-text {
        display: none;
    }
    .rb-logo-icon {
        height: 32px;
    }
}

.rb-header-nav {
    display: flex;
    gap: var(--rb-space-lg);
}

.rb-nav-link {
    color: var(--rb-text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    text-decoration: none;
    padding: var(--rb-space-sm) 0;
}

.rb-nav-link:hover {
    color: var(--rb-primary);
    text-decoration: none;
}

.rb-header-right {
    display: flex;
    align-items: center;
}

/* Body Layout (Sidebar + Main) */
.rb-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* Sidebar */
.rb-sidebar {
    width: var(--rb-sidebar-width);
    background: var(--rb-bg-primary);
    border-right: 1px solid var(--rb-bg-tertiary);
    padding: var(--rb-space-lg);
    overflow-y: auto;
    flex-shrink: 0;
}

.rb-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--rb-space-xl);
}

.rb-nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--rb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--rb-space-sm);
}

.rb-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--rb-space-xs);
}

.rb-sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--rb-space-sm);
    padding: var(--rb-space-sm) var(--rb-space-md);
    color: var(--rb-text-secondary);
    text-decoration: none;
    border-radius: var(--rb-radius-md);
    font-size: 0.875rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.rb-sidebar-link:hover {
    background: var(--rb-bg-tertiary);
    color: var(--rb-text-primary);
    text-decoration: none;
}

.rb-sidebar-link.active {
    background: rgba(0, 104, 166, 0.1);
    color: var(--rb-primary);
    font-weight: 600;
    border-left: 3px solid var(--rb-primary);
    padding-left: calc(var(--rb-space-md) - 3px);
}

/* SVG Navigation Icons */
.rb-nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: currentColor;
    transition: stroke 0.15s ease;
}

.rb-sidebar-link:hover .rb-nav-icon {
    stroke: var(--rb-text-primary);
}

.rb-sidebar-link.active .rb-nav-icon {
    stroke: var(--rb-primary);
}

/* Main Content Area */
.rb-main {
    flex: 1;
    padding: var(--rb-space-xl);
    overflow-y: auto;
    background: var(--rb-bg-secondary);
}

/* Remove focus outline on main content (skip-link target, not interactive) */
.rb-main:focus {
    outline: none;
}

.rb-content {
    max-width: 1200px;
    margin: 0 auto;
}

/* Footer */
.rb-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--rb-footer-height);
    padding: 0 var(--rb-space-lg);
    background: var(--rb-bg-primary);
    border-top: 1px solid var(--rb-bg-tertiary);
}

.rb-powered-by {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
}

/* ----------------------------------------
   Typography
   ---------------------------------------- */

.rb-hero-title {
    font-size: 3rem;
    font-weight: 300;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-md);
}

.rb-hero-subtitle {
    font-size: 1.25rem;
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-xl);
}

.rb-page-title {
    font-size: 2rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-sm);
}

.rb-page-description {
    font-size: 1rem;
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-xl);
}

/* ----------------------------------------
   Buttons
   ---------------------------------------- */

.rb-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--rb-radius-md);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.rb-button:hover {
    text-decoration: none;
}

.rb-button:active {
    transform: scale(0.98);
}

.rb-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rb-button-primary {
    background: var(--rb-primary);
    color: white;
}

.rb-button-primary:hover:not(:disabled) {
    background: #005a91;
}

.rb-button-secondary {
    background: transparent;
    color: var(--rb-primary);
    border: 2px solid var(--rb-primary);
}

.rb-button-secondary:hover:not(:disabled) {
    background: var(--rb-bg-tertiary);
}

.rb-button-large {
    padding: 16px 32px;
    font-size: 1rem;
}

.rb-button-full {
    width: 100%;
}

/* ----------------------------------------
   Cards
   ---------------------------------------- */

.rb-card {
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    box-shadow: var(--rb-shadow-md);
    padding: var(--rb-space-lg);
}

/* ----------------------------------------
   Hero Section
   ---------------------------------------- */

.rb-hero {
    text-align: center;
    padding: var(--rb-space-2xl) var(--rb-space-lg);
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    margin-bottom: var(--rb-space-xl);
}

.rb-hero-actions {
    display: flex;
    justify-content: center;
    gap: var(--rb-space-md);
}

/* ----------------------------------------
   Features Section
   ---------------------------------------- */

.rb-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--rb-space-lg);
}

.rb-feature-card {
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    box-shadow: var(--rb-shadow-md);
    padding: var(--rb-space-lg);
}

.rb-feature-title {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-sm);
}

.rb-feature-description {
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
    margin: 0;
}

/* ----------------------------------------
   Tools Page
   ---------------------------------------- */

.rb-page-header {
    margin-bottom: var(--rb-space-xl);
}

.rb-tools-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--rb-space-lg);
    margin-bottom: var(--rb-space-xl);
}

.rb-tool-card {
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    box-shadow: var(--rb-shadow-md);
    padding: var(--rb-space-xl);
    text-align: center;
}

.rb-tool-title {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-sm);
}

.rb-tool-description {
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-lg);
}

.rb-tools-info {
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-lg);
}

.rb-tools-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--rb-space-md);
}

.rb-info-list {
    color: var(--rb-text-secondary);
    font-size: 0.875rem;
}

.rb-info-list li {
    margin-bottom: var(--rb-space-sm);
}

/* ----------------------------------------
   Auth Page
   ---------------------------------------- */

.rb-auth-page {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: var(--rb-space-2xl);
}

.rb-auth-card {
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    box-shadow: var(--rb-shadow-lg);
    padding: var(--rb-space-xl);
    width: 100%;
    max-width: 400px;
}

.rb-auth-title {
    font-size: 1.5rem;
    font-weight: 500;
    text-align: center;
    margin-bottom: var(--rb-space-xl);
}

.rb-social-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--rb-space-sm);
    margin-bottom: var(--rb-space-lg);
}

.rb-social-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--rb-space-sm);
    padding: var(--rb-space-md);
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    background: var(--rb-bg-primary);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.rb-social-button:hover:not(:disabled) {
    background: var(--rb-bg-tertiary);
}

.rb-social-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Social login loading state */
.rb-social-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--rb-space-md);
    padding: var(--rb-space-xl);
    grid-column: 1 / -1; /* Span full width of grid */
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-md);
    min-height: 120px;
}

.rb-social-loading p {
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
    margin: 0;
}

.rb-social-icon {
    font-weight: 700;
    font-size: 1rem;
}

.rb-auth-divider {
    display: flex;
    align-items: center;
    gap: var(--rb-space-md);
    margin: var(--rb-space-lg) 0;
    color: var(--rb-text-muted);
    font-size: 0.875rem;
}

.rb-auth-divider::before,
.rb-auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--rb-bg-tertiary);
}

.rb-magic-link-form {
    display: flex;
    flex-direction: column;
    gap: var(--rb-space-md);
}

.rb-form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--rb-text-primary);
}

.rb-form-input {
    padding: var(--rb-space-md);
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    font-size: 1rem;
    transition: border-color 0.15s ease;
}

.rb-form-input:focus {
    outline: none;
    border-color: var(--rb-primary);
}

.rb-form-input:disabled {
    background: var(--rb-bg-secondary);
    cursor: not-allowed;
}

.rb-auth-help {
    margin-top: var(--rb-space-lg);
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    text-align: center;
}

.rb-auth-note {
    margin-top: var(--rb-space-md);
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    text-align: center;
    padding: var(--rb-space-sm);
    background: var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-sm);
}

/* ----------------------------------------
   Auth Status Button
   ---------------------------------------- */

.rb-auth-status {
    position: relative;
}

.rb-signin-button {
    display: inline-flex;
    align-items: center;
    padding: var(--rb-space-sm) var(--rb-space-md);
    background: var(--rb-primary);
    color: white;
    border-radius: var(--rb-radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}

.rb-signin-button:hover {
    background: #005a91;
    text-decoration: none;
}

.rb-user-dropdown {
    position: relative;
}

.rb-user-button {
    display: flex;
    align-items: center;
    gap: var(--rb-space-sm);
    padding: var(--rb-space-sm) var(--rb-space-md);
    background: transparent;
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    font-size: 0.875rem;
    color: var(--rb-text-primary);
}

.rb-user-button:hover {
    background: var(--rb-bg-tertiary);
}

.rb-dropdown-arrow {
    font-size: 0.625rem;
}

.rb-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--rb-space-xs);
    background: var(--rb-bg-primary);
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    box-shadow: var(--rb-shadow-lg);
    min-width: 180px;
    z-index: 200;
}

.rb-dropdown-item {
    display: block;
    width: 100%;
    padding: var(--rb-space-sm) var(--rb-space-md);
    text-align: left;
    background: transparent;
    border: none;
    color: var(--rb-text-primary);
    font-size: 0.875rem;
    text-decoration: none;
}

.rb-dropdown-item:hover {
    background: var(--rb-bg-tertiary);
    text-decoration: none;
}

.rb-dropdown-divider {
    margin: var(--rb-space-xs) 0;
    border: none;
    border-top: 1px solid var(--rb-bg-tertiary);
}

.rb-dropdown-signout {
    color: var(--rb-error);
}

/* ----------------------------------------
   Error Page
   ---------------------------------------- */

.rb-error-page {
    text-align: center;
    padding: var(--rb-space-2xl) var(--rb-space-lg);
}

.rb-error-title {
    font-size: 2rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-md);
}

.rb-error-message {
    font-size: 1rem;
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-lg);
}

.rb-error-details {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    margin-bottom: var(--rb-space-lg);
}

.rb-error-details code {
    background: var(--rb-bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--rb-radius-sm);
}

/* ----------------------------------------
   Mobile Menu Toggle Button
   ---------------------------------------- */

/* Hidden on desktop */
.rb-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--rb-radius-md);
    transition: background-color 0.15s ease;
    margin-right: var(--rb-space-sm);
}

.rb-menu-toggle:hover {
    background: var(--rb-bg-tertiary);
}

.rb-menu-toggle:active {
    background: var(--rb-bg-secondary);
}

.rb-menu-icon {
    width: 24px;
    height: 24px;
    stroke: var(--rb-text-primary);
}

/* Toggle between menu/close icons based on state */
.rb-icon-close {
    display: none;
}

.rb-mobile-menu-open .rb-icon-menu {
    display: none;
}

.rb-mobile-menu-open .rb-icon-close {
    display: block;
}

/* Mobile menu overlay - hidden by default */
.rb-mobile-overlay {
    display: none;
    position: fixed;
    top: var(--rb-header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

/* ----------------------------------------
   Responsive Design
   ---------------------------------------- */

@media (max-width: 768px) {
    /* Show hamburger menu button on mobile */
    .rb-menu-toggle {
        display: flex;
    }

    /* Hide header nav links on mobile */
    .rb-header-nav {
        display: none;
    }

    /* Sidebar - transforms to slide-out menu on mobile */
    .rb-sidebar {
        position: fixed;
        top: var(--rb-header-height);
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: var(--rb-shadow-lg);
        overflow-y: auto;
    }

    /* Sidebar open state - triggered by class on rb-layout */
    .rb-mobile-menu-open .rb-sidebar {
        transform: translateX(0);
    }

    /* Mobile overlay - visible when menu is open */
    .rb-mobile-overlay {
        display: block;
    }

    .rb-mobile-menu-open .rb-mobile-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    /* Prevent body scroll when menu is open */
    .rb-mobile-menu-open {
        overflow: hidden;
    }

    .rb-mobile-menu-open .rb-main {
        overflow: hidden;
    }

    /* Main content area adjustments */
    .rb-main {
        padding: var(--rb-space-md);
    }

    /* Typography adjustments for mobile */
    .rb-hero-title {
        font-size: 2rem;
    }

    .rb-hero-subtitle {
        font-size: 1rem;
    }

    /* Auth buttons stack on mobile */
    .rb-social-buttons {
        grid-template-columns: 1fr;
    }

    /* Adjust header padding */
    .rb-header {
        padding: 0 var(--rb-space-md);
    }
}

/* ----------------------------------------
   Position Entry Page
   ---------------------------------------- */

.rb-position-entry {
    max-width: 800px;
}

.rb-unit-toggle {
    display: flex;
    align-items: center;
    gap: var(--rb-space-md);
    margin-bottom: var(--rb-space-xl);
    padding: var(--rb-space-md);
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-md);
}

.rb-unit-label {
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
}

.rb-unit-button {
    padding: var(--rb-space-sm) var(--rb-space-md);
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    background: var(--rb-bg-secondary);
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.rb-unit-button:hover {
    background: var(--rb-bg-tertiary);
}

.rb-unit-button.active {
    background: var(--rb-primary);
    color: white;
    border-color: var(--rb-primary);
}

/* Form Sections */
.rb-form-section {
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-xl);
    margin-bottom: var(--rb-space-lg);
    box-shadow: var(--rb-shadow-sm);
}

.rb-form-section-title {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-xs);
}

.rb-form-section-description {
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-lg);
}

.rb-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--rb-space-lg);
}

/* Position Grid */
.rb-position-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--rb-space-xl);
}

.rb-position-group {
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-md);
    padding: var(--rb-space-lg);
}

.rb-position-group-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-md);
    padding-bottom: var(--rb-space-sm);
    border-bottom: 1px solid var(--rb-bg-tertiary);
}

/* Position Diagram */
.rb-position-diagram {
    margin-bottom: var(--rb-space-xl);
}

.rb-diagram-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--rb-space-2xl);
    background: var(--rb-bg-secondary);
    border: 2px dashed var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-lg);
    text-align: center;
}

.rb-diagram-icon {
    font-size: 3rem;
    color: var(--rb-text-muted);
    margin-bottom: var(--rb-space-md);
}

.rb-diagram-placeholder p {
    color: var(--rb-text-muted);
    margin: 0;
}

.rb-diagram-hint {
    font-size: 0.75rem;
    margin-top: var(--rb-space-xs) !important;
}

/* Form Actions */
.rb-form-actions {
    display: flex;
    justify-content: space-between;
    gap: var(--rb-space-md);
    margin-top: var(--rb-space-xl);
}

/* Validation */
.rb-validation-warning {
    margin-top: var(--rb-space-md);
    padding: var(--rb-space-md);
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--rb-warning);
    border-radius: var(--rb-radius-md);
    color: var(--rb-warning);
    font-size: 0.875rem;
}

.rb-validation-summary {
    margin-top: var(--rb-space-lg);
    padding: var(--rb-space-md);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--rb-error);
    border-radius: var(--rb-radius-md);
}

.rb-validation-summary h4 {
    color: var(--rb-error);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: var(--rb-space-sm);
}

.rb-validation-summary ul {
    margin: 0;
    padding-left: var(--rb-space-lg);
    color: var(--rb-error);
    font-size: 0.875rem;
}

/* ----------------------------------------
   Measurement Input Component
   ---------------------------------------- */

.rb-measurement-input {
    margin-bottom: var(--rb-space-md);
}

.rb-measurement-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-xs);
}

.rb-required {
    color: var(--rb-error);
    margin-left: 2px;
}

.rb-measurement-help {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    margin: 0 0 var(--rb-space-sm) 0;
}

.rb-measurement-field {
    display: flex;
    align-items: center;
    gap: var(--rb-space-sm);
}

.rb-measurement-value {
    flex: 1;
    max-width: 150px;
}

.rb-measurement-unit {
    font-size: 0.875rem;
    color: var(--rb-text-muted);
    min-width: 30px;
}

.rb-measurement-error .rb-form-input {
    border-color: var(--rb-error);
}

.rb-measurement-error-text {
    color: var(--rb-error);
    font-size: 0.75rem;
    margin: var(--rb-space-xs) 0 0 0;
}

/* ----------------------------------------
   From Bike Page
   ---------------------------------------- */

.rb-bike-search {
    max-width: 800px;
}

.rb-search-input-wrapper {
    display: flex;
    gap: var(--rb-space-md);
    margin-bottom: var(--rb-space-lg);
}

.rb-search-input {
    flex: 1;
}

.rb-search-results {
    margin-top: var(--rb-space-lg);
}

.rb-bike-result {
    display: flex;
    align-items: center;
    gap: var(--rb-space-md);
    padding: var(--rb-space-md);
    background: var(--rb-bg-primary);
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    margin-bottom: var(--rb-space-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.rb-bike-result:hover {
    border-color: var(--rb-primary);
    background: var(--rb-bg-secondary);
}

.rb-bike-result.selected {
    border-color: var(--rb-primary);
    background: rgba(0, 104, 166, 0.05);
}

.rb-bike-image {
    width: 60px;
    height: 40px;
    object-fit: contain;
    background: var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-sm);
}

.rb-bike-info {
    flex: 1;
}

.rb-bike-name {
    font-weight: 500;
    color: var(--rb-text-primary);
}

.rb-bike-details {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
}

/* ----------------------------------------
   Results Page
   ---------------------------------------- */

.rb-results-page {
    max-width: 1000px;
}

.rb-results-summary {
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-xl);
    margin-bottom: var(--rb-space-xl);
    text-align: center;
}

.rb-results-headline {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-sm);
}

.rb-results-subtext {
    font-size: 1rem;
    color: var(--rb-text-secondary);
}

.rb-frame-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--rb-space-lg);
}

.rb-frame-card {
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    overflow: hidden;
    box-shadow: var(--rb-shadow-md);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rb-frame-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--rb-shadow-lg);
}

.rb-frame-image {
    width: 100%;
    height: 160px;
    object-fit: contain;
    background: var(--rb-bg-tertiary);
}

.rb-frame-content {
    padding: var(--rb-space-lg);
}

.rb-frame-brand {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rb-frame-model {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin: var(--rb-space-xs) 0;
}

.rb-frame-size {
    display: inline-block;
    padding: var(--rb-space-xs) var(--rb-space-sm);
    background: var(--rb-primary);
    color: white;
    border-radius: var(--rb-radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: var(--rb-space-md);
}

.rb-frame-fit-score {
    display: flex;
    align-items: center;
    gap: var(--rb-space-sm);
    font-size: 0.875rem;
}

.rb-fit-score-bar {
    flex: 1;
    height: 6px;
    background: var(--rb-bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.rb-fit-score-fill {
    height: 100%;
    background: var(--rb-success);
    border-radius: 3px;
}

.rb-fit-score-label {
    color: var(--rb-text-secondary);
    min-width: 40px;
    text-align: right;
}

/* ----------------------------------------
   Loading States
   ---------------------------------------- */

.rb-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--rb-space-2xl);
    text-align: center;
}

.rb-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--rb-bg-tertiary);
    border-top-color: var(--rb-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--rb-space-md);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.rb-loading p {
    color: var(--rb-text-secondary);
}

/* ----------------------------------------
   Empty States
   ---------------------------------------- */

.rb-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--rb-space-2xl);
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
}

.rb-empty-icon {
    font-size: 4rem;
    color: var(--rb-text-muted);
    margin-bottom: var(--rb-space-lg);
}

.rb-empty-state h3 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-sm);
}

.rb-empty-state p {
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-lg);
}

/* ----------------------------------------
   Error Card
   ---------------------------------------- */

.rb-error-card {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid var(--rb-error);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-xl);
    text-align: center;
}

.rb-error-card h3 {
    color: var(--rb-error);
    font-size: 1.25rem;
    margin-bottom: var(--rb-space-sm);
}

.rb-error-card p {
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-lg);
}

/* ----------------------------------------
   Results Page Additions
   ---------------------------------------- */

.rb-position-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--rb-space-lg);
    margin-top: var(--rb-space-lg);
}

.rb-position-value {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rb-value-label {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rb-value-number {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--rb-primary);
    font-family: var(--rb-font-mono);
    font-variant-numeric: tabular-nums;
}

.rb-results-section {
    margin-bottom: var(--rb-space-xl);
}

.rb-section-title {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-lg);
}

.rb-no-results {
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-xl);
    text-align: center;
}

.rb-no-results p {
    color: var(--rb-text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

.rb-frame-image-placeholder {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rb-bg-tertiary);
    font-size: 4rem;
    color: var(--rb-text-muted);
}

.rb-fit-label {
    color: var(--rb-text-muted);
    font-size: 0.75rem;
}

/* Save Prompt */
.rb-save-prompt {
    background: linear-gradient(135deg, var(--rb-primary) 0%, #005a91 100%);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-xl);
    text-align: center;
    color: white;
}

.rb-save-prompt h3 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: var(--rb-space-sm);
}

.rb-save-prompt p {
    opacity: 0.9;
    margin-bottom: var(--rb-space-lg);
}

.rb-save-actions {
    display: flex;
    justify-content: center;
    gap: var(--rb-space-md);
}

.rb-save-prompt .rb-button-primary {
    background: white;
    color: var(--rb-primary);
}

.rb-save-prompt .rb-button-primary:hover {
    background: var(--rb-bg-secondary);
}

.rb-save-prompt .rb-button-secondary {
    background: transparent;
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
}

.rb-save-prompt .rb-button-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}

/* Search Box */
.rb-search-box {
    display: flex;
    gap: var(--rb-space-md);
    margin-bottom: var(--rb-space-md);
}

.rb-search-input {
    flex: 1;
    padding: var(--rb-space-md);
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    font-size: 1rem;
    font-family: var(--rb-font-family);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rb-search-input:focus {
    outline: none;
    border-color: var(--rb-primary);
    box-shadow: 0 0 0 3px rgba(0, 104, 166, 0.1);
}

.rb-search-button {
    flex-shrink: 0;
}

.rb-search-hint {
    font-size: 0.875rem;
    color: var(--rb-text-muted);
    margin-top: var(--rb-space-xs);
}

.rb-search-prompt {
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-xl);
    text-align: center;
}

.rb-search-prompt p {
    color: var(--rb-text-secondary);
    max-width: 500px;
    margin: 0 auto;
}

.rb-section-description {
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-lg);
}

/* Frame Image Styles */
.rb-frame-image {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rb-bg-tertiary);
    overflow: hidden;
}

.rb-frame-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.rb-frame-year {
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
    display: block;
    margin-top: var(--rb-space-xs);
}

.rb-frame-type {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-top: var(--rb-space-xs);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .rb-position-grid {
        grid-template-columns: 1fr;
    }

    .rb-form-grid {
        grid-template-columns: 1fr;
    }

    .rb-form-actions {
        flex-direction: column;
    }

    .rb-form-actions .rb-button {
        width: 100%;
    }

    .rb-unit-toggle {
        flex-wrap: wrap;
    }

    .rb-position-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .rb-save-actions {
        flex-direction: column;
    }

    .rb-save-actions .rb-button {
        width: 100%;
    }
}

/* ----------------------------------------
   From Bike Page Additions
   ---------------------------------------- */

.rb-bike-image-placeholder {
    width: 60px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-sm);
    font-size: 1.5rem;
    color: var(--rb-text-muted);
    flex-shrink: 0;
}

.rb-hint {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    margin-top: var(--rb-space-xs);
}

.rb-hint a {
    color: var(--rb-primary);
}

.rb-selected-bike {
    background: var(--rb-bg-secondary);
    border: 2px solid var(--rb-primary);
    border-radius: var(--rb-radius-md);
    padding: var(--rb-space-md);
    margin-bottom: var(--rb-space-lg);
}

.rb-selected-bike h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--rb-primary);
    margin: 0;
}

.rb-config-field {
    margin-bottom: var(--rb-space-md);
}

.rb-saddle-measurement {
    margin-top: var(--rb-space-xl);
    padding-top: var(--rb-space-xl);
    border-top: 1px solid var(--rb-bg-tertiary);
}

.rb-saddle-measurement h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-sm);
}

.rb-measurement-guide {
    margin-bottom: var(--rb-space-lg);
}

.rb-guide-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--rb-space-xl);
    background: var(--rb-bg-secondary);
    border: 2px dashed var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    text-align: center;
}

.rb-guide-icon {
    font-size: 2rem;
    color: var(--rb-text-muted);
    margin-bottom: var(--rb-space-sm);
}

.rb-guide-placeholder p {
    color: var(--rb-text-muted);
    font-size: 0.875rem;
    margin: 0;
}

.rb-alternative-option {
    margin-top: var(--rb-space-xl);
    padding: var(--rb-space-lg);
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    text-align: center;
}

.rb-alternative-option p {
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-md);
}

/* ----------------------------------------
   From Bike Page - Additional Styles
   ---------------------------------------- */

.rb-bike-image {
    width: 60px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-sm);
    flex-shrink: 0;
    overflow: hidden;
}

.rb-bike-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.rb-no-sizes {
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-md);
    padding: var(--rb-space-lg);
    text-align: center;
}

.rb-no-sizes p {
    color: var(--rb-text-secondary);
    margin: 0;
}

.rb-input-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    margin-top: var(--rb-space-xs);
}

/* Calculated Position Display */
.rb-calculated-position {
    margin-top: var(--rb-space-xl);
    padding: var(--rb-space-lg);
    background: linear-gradient(135deg, rgba(0, 104, 166, 0.05) 0%, rgba(0, 185, 242, 0.05) 100%);
    border: 1px solid var(--rb-primary);
    border-radius: var(--rb-radius-lg);
}

.rb-calculated-position h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--rb-primary);
    margin-bottom: var(--rb-space-md);
    text-align: center;
}

.rb-position-values {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--rb-space-lg);
    text-align: center;
}

.rb-calculation-notes {
    margin-top: var(--rb-space-md);
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    text-align: center;
}

/* Error Message */
.rb-error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--rb-error);
    border-radius: var(--rb-radius-md);
    padding: var(--rb-space-lg);
    text-align: center;
    margin-top: var(--rb-space-md);
}

.rb-error-message p {
    color: var(--rb-error);
    margin-bottom: var(--rb-space-md);
}

/* Form Select Styling */
.rb-form-input[type="number"] {
    -moz-appearance: textfield;
}

.rb-form-input[type="number"]::-webkit-outer-spin-button,
.rb-form-input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

select.rb-form-input {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    appearance: none;
}

/* ----------------------------------------
   Frame Selection and Recommendations
   ---------------------------------------- */

.rb-frame-card {
    cursor: pointer;
    transition: all 0.15s ease;
}

.rb-frame-card.selected {
    border: 2px solid var(--rb-primary);
    box-shadow: 0 0 0 3px rgba(0, 104, 166, 0.15);
}

.rb-frame-selected-badge {
    display: inline-block;
    margin-top: var(--rb-space-sm);
    padding: var(--rb-space-xs) var(--rb-space-sm);
    background: var(--rb-primary);
    color: white;
    border-radius: var(--rb-radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

/* Frame Recommendation Panel */
.rb-frame-recommendation {
    margin-top: var(--rb-space-xl);
    padding: var(--rb-space-xl);
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    border: 1px solid var(--rb-bg-tertiary);
}

.rb-recommendation-title {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-xs);
}

.rb-recommendation-subtitle {
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-lg);
}

.rb-recommendation-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--rb-space-lg);
}

.rb-recommendation-card {
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-md);
    padding: var(--rb-space-lg);
    border: 1px solid var(--rb-bg-tertiary);
}

.rb-recommendation-card.fit-excellent {
    border-color: var(--rb-success);
    background: rgba(0, 168, 150, 0.05);
}

.rb-recommendation-card.fit-good {
    border-color: var(--rb-secondary);
    background: rgba(0, 185, 242, 0.05);
}

.rb-recommendation-card.fit-acceptable {
    border-color: var(--rb-warning);
    background: rgba(245, 158, 11, 0.05);
}

.rb-recommendation-card.fit-compromise {
    border-color: var(--rb-text-muted);
    background: var(--rb-bg-secondary);
}

.rb-recommendation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--rb-space-md);
    padding-bottom: var(--rb-space-md);
    border-bottom: 1px solid var(--rb-bg-tertiary);
}

.rb-recommendation-size {
    display: flex;
    flex-direction: column;
}

.rb-size-label {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rb-size-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--rb-primary);
    font-family: var(--rb-font-mono);
    font-variant-numeric: tabular-nums;
}

.rb-fit-badge {
    display: inline-block;
    padding: var(--rb-space-xs) var(--rb-space-sm);
    border-radius: var(--rb-radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.rb-fit-badge.fit-excellent {
    background: var(--rb-success);
    color: white;
}

.rb-fit-badge.fit-good {
    background: var(--rb-secondary);
    color: white;
}

.rb-fit-badge.fit-acceptable {
    background: var(--rb-warning);
    color: white;
}

.rb-fit-badge.fit-compromise {
    background: var(--rb-text-muted);
    color: white;
}

.rb-stem-config {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--rb-space-sm);
    margin-bottom: var(--rb-space-md);
}

.rb-config-item {
    display: flex;
    flex-direction: column;
}

.rb-config-label {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rb-config-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--rb-text-primary);
    font-family: var(--rb-font-mono);
    font-variant-numeric: tabular-nums;
}

.rb-position-accuracy {
    font-size: 0.75rem;
    color: var(--rb-text-secondary);
    padding-top: var(--rb-space-sm);
    border-top: 1px dashed var(--rb-bg-tertiary);
}

.rb-accuracy-label {
    margin-right: var(--rb-space-xs);
}

.rb-accuracy-value {
    font-family: var(--rb-font-mono);
    font-variant-numeric: tabular-nums;
}

.rb-no-recommendation {
    text-align: center;
    padding: var(--rb-space-lg);
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-md);
}

.rb-no-recommendation p {
    color: var(--rb-text-secondary);
    margin: 0;
}

.rb-recommendation-error {
    text-align: center;
    padding: var(--rb-space-lg);
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid var(--rb-error);
    border-radius: var(--rb-radius-md);
}

.rb-recommendation-error p {
    color: var(--rb-error);
    margin-bottom: var(--rb-space-md);
}

.rb-loading-inline {
    padding: var(--rb-space-lg);
}

.rb-loading-inline .rb-loading-spinner {
    width: 32px;
    height: 32px;
}

/* ----------------------------------------
   Position Diagram Component
   ---------------------------------------- */

.rb-position-diagram-container {
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-lg);
    margin-bottom: var(--rb-space-lg);
}

.rb-position-svg {
    width: 100%;
    max-width: 500px;
    height: auto;
    margin: 0 auto;
    display: block;
}

.rb-diagram-label {
    font-size: 12px;
    font-family: var(--rb-font-family);
    fill: var(--rb-text-secondary);
}

.rb-diagram-bar {
    fill: var(--rb-secondary);
    font-weight: 500;
}

.rb-diagram-saddle {
    fill: var(--rb-accent);
    font-weight: 500;
}

.rb-diagram-scale {
    font-size: 10px;
    font-family: var(--rb-font-family);
    fill: var(--rb-text-muted);
}

.rb-diagram-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--rb-space-lg);
    margin-top: var(--rb-space-lg);
    padding-top: var(--rb-space-md);
    border-top: 1px solid var(--rb-bg-tertiary);
}

.rb-legend-item {
    display: flex;
    align-items: center;
    gap: var(--rb-space-sm);
    font-size: 0.75rem;
    color: var(--rb-text-secondary);
}

.rb-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.rb-legend-bb {
    background: var(--rb-primary);
}

.rb-legend-bar {
    background: var(--rb-secondary);
}

.rb-legend-saddle {
    background: var(--rb-accent);
}

/* Responsive */
@media (max-width: 768px) {
    .rb-recommendation-list {
        grid-template-columns: 1fr;
    }

    .rb-stem-config {
        grid-template-columns: repeat(2, 1fr);
    }

    .rb-diagram-legend {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--rb-space-sm);
    }
}

/* ----------------------------------------
   Compare Page Styles
   ---------------------------------------- */

.rb-compare-page {
    max-width: 1200px;
}

.rb-compare-position-summary {
    background: var(--rb-bg-secondary);
    padding: var(--rb-space-md);
    border-radius: var(--rb-radius-md);
    margin-bottom: var(--rb-space-lg);
}

.rb-position-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--rb-space-sm);
}

.rb-position-title {
    font-weight: 600;
    color: var(--rb-text-primary);
}

.rb-position-values {
    color: var(--rb-text-secondary);
    font-size: 0.875rem;
}

.rb-link-small {
    font-size: 0.75rem;
    color: var(--rb-secondary);
    text-decoration: none;
    margin-left: auto;
}

.rb-link-small:hover {
    text-decoration: underline;
}

.rb-compare-section {
    margin-bottom: var(--rb-space-xl);
}

.rb-compare-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--rb-space-md);
}

.rb-compare-empty {
    text-align: center;
    padding: var(--rb-space-2xl);
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-lg);
}

.rb-compare-empty h3 {
    margin: var(--rb-space-md) 0 var(--rb-space-sm);
    color: var(--rb-text-primary);
}

.rb-compare-empty p {
    color: var(--rb-text-secondary);
    margin: 0;
}

/* Search Results List */
.rb-search-results {
    margin-top: var(--rb-space-lg);
}

.rb-search-results h3 {
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-sm);
}

.rb-frame-list {
    display: flex;
    flex-direction: column;
    gap: var(--rb-space-sm);
    max-height: 400px;
    overflow-y: auto;
}

.rb-frame-list-item {
    display: flex;
    align-items: center;
    gap: var(--rb-space-md);
    padding: var(--rb-space-sm) var(--rb-space-md);
    background: var(--rb-bg-primary);
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.rb-frame-list-item:hover {
    border-color: var(--rb-secondary);
    background: var(--rb-bg-secondary);
}

.rb-frame-list-item.selected {
    border-color: var(--rb-success);
    background: rgba(0, 168, 150, 0.05);
}

.rb-frame-list-image {
    width: 60px;
    height: 40px;
    object-fit: contain;
    border-radius: var(--rb-radius-sm);
    flex-shrink: 0;
}

.rb-frame-list-image-placeholder {
    width: 60px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-sm);
    font-size: 1.5rem;
    flex-shrink: 0;
}

.rb-frame-list-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.rb-frame-list-info .rb-frame-brand {
    font-size: 0.75rem;
    color: var(--rb-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rb-frame-list-info .rb-frame-model {
    font-weight: 500;
    color: var(--rb-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-frame-list-action {
    flex-shrink: 0;
}

.rb-badge {
    display: inline-block;
    padding: var(--rb-space-xs) var(--rb-space-sm);
    border-radius: var(--rb-radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.rb-badge-add {
    background: var(--rb-secondary);
    color: white;
}

.rb-badge-selected {
    background: var(--rb-success);
    color: white;
}

.rb-badge-disabled {
    background: var(--rb-bg-tertiary);
    color: var(--rb-text-muted);
}

/* Comparison Grid */
.rb-comparison-grid {
    display: grid;
    grid-template-columns: repeat(var(--compare-count, 1), 1fr);
    gap: var(--rb-space-lg);
}

@media (max-width: 768px) {
    .rb-comparison-grid {
        grid-template-columns: 1fr;
    }
}

.rb-comparison-card {
    background: var(--rb-bg-primary);
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-lg);
    overflow: hidden;
}

.rb-comparison-card-header {
    position: relative;
    padding: var(--rb-space-md);
    background: var(--rb-bg-secondary);
    text-align: center;
    border-bottom: 1px solid var(--rb-bg-tertiary);
}

.rb-comparison-remove {
    position: absolute;
    top: var(--rb-space-sm);
    right: var(--rb-space-sm);
    width: 24px;
    height: 24px;
    border: none;
    background: var(--rb-bg-tertiary);
    color: var(--rb-text-secondary);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.rb-comparison-remove:hover {
    background: var(--rb-error);
    color: white;
}

.rb-comparison-image {
    width: 120px;
    height: 80px;
    object-fit: contain;
    margin: 0 auto var(--rb-space-sm);
}

.rb-comparison-image-placeholder {
    width: 120px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    font-size: 2.5rem;
    margin: 0 auto var(--rb-space-sm);
}

.rb-comparison-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--rb-text-primary);
    margin: 0;
}

.rb-comparison-subtitle {
    font-size: 1rem;
    color: var(--rb-text-primary);
    margin: var(--rb-space-xs) 0;
}

.rb-comparison-type {
    font-size: 0.75rem;
    color: var(--rb-text-secondary);
}

.rb-comparison-card-body {
    padding: var(--rb-space-md);
}

.rb-comparison-loading,
.rb-comparison-error,
.rb-comparison-no-fit {
    text-align: center;
    padding: var(--rb-space-lg);
    color: var(--rb-text-secondary);
}

.rb-comparison-error {
    color: var(--rb-error);
}

.rb-spinner-small {
    width: 20px;
    height: 20px;
}

/* Comparison Suggestion Cards */
.rb-comparison-suggestion {
    padding: var(--rb-space-md);
    margin-bottom: var(--rb-space-sm);
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-md);
    border-left: 4px solid var(--rb-text-muted);
}

.rb-comparison-suggestion.fit-excellent {
    border-left-color: var(--rb-success);
}

.rb-comparison-suggestion.fit-good {
    border-left-color: var(--rb-secondary);
}

.rb-comparison-suggestion.fit-acceptable {
    border-left-color: var(--rb-warning);
}

.rb-comparison-suggestion.fit-compromise {
    border-left-color: var(--rb-error);
}

.rb-suggestion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--rb-space-sm);
}

.rb-suggestion-size {
    font-weight: 600;
    color: var(--rb-text-primary);
}

.rb-suggestion-config {
    display: flex;
    flex-direction: column;
    gap: var(--rb-space-xs);
    margin-bottom: var(--rb-space-sm);
}

.rb-config-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.rb-config-row .rb-config-label {
    color: var(--rb-text-secondary);
}

.rb-config-row .rb-config-value {
    font-weight: 500;
    color: var(--rb-text-primary);
}

.rb-suggestion-accuracy {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    text-align: right;
}

/* Compare Help Section */
.rb-compare-help {
    background: var(--rb-bg-secondary);
    padding: var(--rb-space-lg);
    border-radius: var(--rb-radius-lg);
    margin-top: var(--rb-space-2xl);
}

.rb-compare-help h3 {
    font-size: 1rem;
    color: var(--rb-text-primary);
    margin: 0 0 var(--rb-space-md);
}

.rb-compare-help ol {
    margin: 0;
    padding-left: var(--rb-space-lg);
    color: var(--rb-text-secondary);
}

.rb-compare-help li {
    margin-bottom: var(--rb-space-sm);
}

.rb-compare-help li:last-child {
    margin-bottom: 0;
}

.rb-button-small {
    padding: var(--rb-space-xs) var(--rb-space-md);
    font-size: 0.875rem;
}

/* ----------------------------------------
   Positions Page Styles
   ---------------------------------------- */

.rb-positions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--rb-space-lg);
}

.rb-positions-count {
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
}

.rb-positions-list {
    display: flex;
    flex-direction: column;
    gap: var(--rb-space-md);
}

.rb-position-card {
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-lg);
    box-shadow: var(--rb-shadow-sm);
    transition: box-shadow 0.15s ease;
}

.rb-position-card:hover {
    box-shadow: var(--rb-shadow-md);
}

.rb-position-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--rb-space-md);
}

.rb-position-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--rb-text-primary);
    margin: 0;
}

.rb-position-discipline {
    display: inline-block;
    padding: var(--rb-space-xs) var(--rb-space-sm);
    background: var(--rb-bg-tertiary);
    color: var(--rb-text-secondary);
    border-radius: var(--rb-radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.rb-position-values {
    display: flex;
    flex-wrap: wrap;
    gap: var(--rb-space-lg);
    margin-bottom: var(--rb-space-md);
    padding: var(--rb-space-md);
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-md);
}

.rb-position-value {
    display: flex;
    flex-direction: column;
    min-width: 80px;
}

.rb-position-value .rb-value-label {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    text-transform: uppercase;
}

.rb-position-value .rb-value-data {
    font-size: 1rem;
    font-weight: 500;
    color: var(--rb-primary);
    font-family: var(--rb-font-mono);
    font-variant-numeric: tabular-nums;
}

.rb-position-meta {
    display: flex;
    gap: var(--rb-space-md);
    margin-bottom: var(--rb-space-md);
}

.rb-position-source,
.rb-position-date {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
}

.rb-position-source::before {
    content: "Source: ";
    color: var(--rb-text-secondary);
}

.rb-position-date::before {
    content: "Fit date: ";
    color: var(--rb-text-secondary);
}

.rb-position-actions {
    display: flex;
    gap: var(--rb-space-sm);
    flex-wrap: wrap;
}

/* Auth Required State */
.rb-auth-required {
    text-align: center;
    padding: var(--rb-space-2xl);
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
}

.rb-auth-required h2 {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-sm);
}

.rb-auth-required p {
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-lg);
}

/* Alert Styles */
.rb-alert {
    padding: var(--rb-space-md);
    border-radius: var(--rb-radius-md);
    margin-bottom: var(--rb-space-lg);
}

.rb-alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--rb-error);
    color: var(--rb-error);
}

.rb-alert-success {
    background: rgba(0, 168, 150, 0.1);
    border: 1px solid var(--rb-success);
    color: var(--rb-success);
}

.rb-alert-info {
    background: rgba(0, 185, 242, 0.1);
    border: 1px solid var(--rb-info);
    color: var(--rb-info);
}

/* Spinner */
.rb-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--rb-bg-tertiary);
    border-top-color: var(--rb-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--rb-space-md);
}

/* Modal Styles */
.rb-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.rb-modal {
    background: var(--rb-bg-primary);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-xl);
    max-width: 400px;
    width: 100%;
    margin: var(--rb-space-md);
    box-shadow: var(--rb-shadow-lg);
}

.rb-modal h3 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin: 0 0 var(--rb-space-md);
}

.rb-modal p {
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-lg);
}

.rb-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--rb-space-md);
}

/* Button Text Variant */
.rb-button-text {
    background: transparent;
    color: var(--rb-primary);
    padding: var(--rb-space-sm) var(--rb-space-md);
}

.rb-button-text:hover:not(:disabled) {
    background: var(--rb-bg-tertiary);
}

/* Button Danger Variant */
.rb-button-danger {
    background: var(--rb-error);
    color: white;
}

.rb-button-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* Form Group */
.rb-form-group {
    margin-bottom: var(--rb-space-lg);
}

.rb-form-help {
    display: block;
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    margin-top: var(--rb-space-xs);
}

/* Form Section Title */
.rb-form-section h2 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin: 0 0 var(--rb-space-xs);
}

.rb-form-section-help {
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
    margin: 0 0 var(--rb-space-lg);
}

.rb-form-section-readonly {
    background: var(--rb-bg-secondary);
}

.rb-form-section-readonly h3 {
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
    margin: 0 0 var(--rb-space-xs);
}

.rb-form-section-readonly p {
    margin: 0;
    color: var(--rb-text-primary);
}

/* Form Row */
.rb-form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--rb-space-lg);
}

@media (max-width: 768px) {
    .rb-form-row {
        grid-template-columns: 1fr;
    }

    .rb-positions-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--rb-space-md);
    }

    .rb-position-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--rb-space-sm);
    }

    .rb-position-values {
        flex-direction: column;
        gap: var(--rb-space-sm);
    }

    .rb-position-actions {
        justify-content: flex-start;
    }
}

/* Form Select */
.rb-form-select {
    padding: var(--rb-space-md);
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    font-size: 1rem;
    background-color: var(--rb-bg-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.rb-form-select:focus {
    outline: none;
    border-color: var(--rb-primary);
}

/* Empty State with h2 */
.rb-empty-state h2 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin: 0 0 var(--rb-space-sm);
}

/* ----------------------------------------
   Bike Category Selector (Phase 4)
   ---------------------------------------- */

.rb-category-selector {
    display: flex;
    flex-wrap: wrap;
    gap: var(--rb-space-sm);
    margin-bottom: var(--rb-space-md);
}

.rb-category-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--rb-space-md) var(--rb-space-lg);
    min-width: 100px;
    background: var(--rb-bg-secondary);
    border: 2px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
}

.rb-category-button:hover {
    border-color: var(--rb-secondary);
    background: var(--rb-bg-tertiary);
}

.rb-category-button.active {
    border-color: var(--rb-primary);
    background: rgba(0, 104, 166, 0.1);
}

.rb-category-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--rb-text-primary);
}

.rb-category-button.active .rb-category-name {
    color: var(--rb-primary);
}

.rb-category-hint {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    margin-top: var(--rb-space-xs);
}

/* Results page header with share button */
.rb-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--rb-space-md);
}

.rb-header-text {
    flex: 1;
}

.rb-share-actions {
    flex-shrink: 0;
}

/* Category badge on results page */
.rb-category-badge {
    margin-top: var(--rb-space-sm);
}

.rb-badge-category {
    background: var(--rb-secondary);
    color: white;
}

@media (max-width: 768px) {
    .rb-header-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .rb-category-selector {
        justify-content: center;
    }

    .rb-category-button {
        flex: 1 1 calc(33% - var(--rb-space-sm));
        min-width: 80px;
    }
}

/* ----------------------------------------
   Garage Bike Comparison Styles (Phase 4)
   ---------------------------------------- */

.rb-garage-section {
    background: linear-gradient(135deg, rgba(0, 104, 166, 0.02) 0%, rgba(0, 185, 242, 0.02) 100%);
    border: 1px solid rgba(0, 104, 166, 0.1);
}

.rb-section-description {
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-lg);
    font-size: 0.875rem;
}

.rb-garage-bikes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--rb-space-md);
}

.rb-garage-bike-card {
    background: var(--rb-bg-primary);
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    padding: var(--rb-space-md);
    display: flex;
    flex-direction: column;
    gap: var(--rb-space-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rb-garage-bike-card:hover {
    border-color: var(--rb-secondary);
}

.rb-garage-bike-card.added {
    border-color: var(--rb-primary);
    background: rgba(0, 104, 166, 0.03);
}

.rb-garage-bike-card.no-frame {
    opacity: 0.6;
}

.rb-garage-bike-header {
    display: flex;
    align-items: flex-start;
    gap: var(--rb-space-sm);
}

.rb-garage-bike-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.rb-garage-bike-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.rb-garage-bike-name {
    font-weight: 500;
    color: var(--rb-text-primary);
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rb-garage-bike-size {
    font-size: 0.75rem;
    color: var(--rb-text-muted);
}

.rb-garage-bike-config {
    padding: var(--rb-space-xs) 0;
}

.rb-garage-bike-config-text {
    font-size: 0.75rem;
    color: var(--rb-text-secondary);
}

.rb-garage-bike-action {
    margin-top: auto;
    display: flex;
    justify-content: center;
}

.rb-garage-bike-no-frame {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--rb-space-xs);
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    padding: var(--rb-space-sm) 0;
}

/* Comparison card garage bike badge */
.rb-garage-badge {
    position: absolute;
    top: var(--rb-space-sm);
    left: var(--rb-space-sm);
    background: var(--rb-primary);
    color: white;
    font-size: 0.625rem;
    font-weight: 600;
    padding: var(--rb-space-xs) var(--rb-space-sm);
    border-radius: var(--rb-radius-sm);
    text-transform: uppercase;
    z-index: 1;
}

.rb-comparison-card-garage {
    border: 2px solid var(--rb-primary);
}

.rb-comparison-card-garage .rb-comparison-card-header {
    position: relative;
}

.rb-comparison-nickname {
    font-size: 0.75rem;
    color: var(--rb-text-secondary);
    font-style: italic;
    margin: 0;
}

/* Responsive adjustments for garage grid */
@media (max-width: 480px) {
    .rb-garage-bikes-grid {
        grid-template-columns: 1fr;
    }
}

/* ----------------------------------------
   Enhanced Error Boundary Styles
   ---------------------------------------- */

.rb-error-actions {
    display: flex;
    justify-content: center;
    gap: var(--rb-space-md);
    margin-top: var(--rb-space-lg);
}

.rb-error-details-expand {
    margin-top: var(--rb-space-lg);
    text-align: left;
}

.rb-error-details-expand summary {
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--rb-text-muted);
    padding: var(--rb-space-sm);
}

.rb-error-details-expand summary:hover {
    color: var(--rb-text-secondary);
}

.rb-error-stack {
    margin-top: var(--rb-space-sm);
    padding: var(--rb-space-md);
    background: var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-sm);
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--rb-text-secondary);
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ----------------------------------------
   404 Not Found Page Styles
   ---------------------------------------- */

.rb-not-found {
    text-align: center;
    padding: var(--rb-space-2xl);
}

.rb-not-found-code {
    font-size: 6rem;
    font-weight: 700;
    color: var(--rb-text-muted);
    line-height: 1;
    margin-bottom: var(--rb-space-md);
}

.rb-not-found h1 {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-sm);
}

.rb-not-found p {
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-xl);
}

.rb-not-found-actions {
    display: flex;
    justify-content: center;
    gap: var(--rb-space-md);
}

/* ----------------------------------------
   Accessibility
   ---------------------------------------- */

/* Skip Link - visually hidden until focused */
.rb-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    padding: var(--rb-space-sm) var(--rb-space-md);
    background: var(--rb-primary);
    color: white;
    text-decoration: none;
    font-weight: 500;
    z-index: 1000;
    transition: top 0.2s ease;
}

.rb-skip-link:focus {
    top: 0;
    outline: 2px solid var(--rb-secondary);
    outline-offset: 2px;
}

/* Screen Reader Only - visually hidden but accessible */
.rb-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles - enhanced visibility for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--rb-primary);
    outline-offset: 2px;
}

.rb-button:focus-visible {
    outline: 2px solid var(--rb-secondary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0, 104, 166, 0.2);
}

.rb-form-input:focus-visible,
.rb-form-select:focus-visible {
    outline: none;
    border-color: var(--rb-primary);
    box-shadow: 0 0 0 3px rgba(0, 104, 166, 0.15);
}

.rb-sidebar-link:focus-visible {
    outline: 2px solid var(--rb-primary);
    outline-offset: -2px;
}

.rb-nav-link:focus-visible {
    outline: 2px solid var(--rb-primary);
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .rb-loading-spinner {
        animation: none;
        border-top-color: var(--rb-primary);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --rb-primary: #0056b3;
        --rb-secondary: #0099cc;
        --rb-accent: #008b7a;
        --rb-text-primary: #000000;
        --rb-text-secondary: #333333;
        --rb-text-muted: #555555;
        --rb-bg-tertiary: #cccccc;
    }

    .rb-button {
        border: 2px solid currentColor;
    }

    .rb-form-input,
    .rb-form-select {
        border-width: 2px;
    }
}

/* Focus within for form groups */
.rb-measurement-input:focus-within {
    border-radius: var(--rb-radius-md);
    outline: 2px solid rgba(0, 104, 166, 0.3);
    outline-offset: 2px;
}

/* ----------------------------------------
   Saved Position Selector (Results Page)
   ---------------------------------------- */

.rb-position-selector {
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-xl);
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.rb-position-selector h2 {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin: 0 0 var(--rb-space-sm);
}

.rb-position-selector p {
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-lg);
}

.rb-saved-positions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--rb-space-md);
    margin-bottom: var(--rb-space-lg);
}

.rb-saved-position-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--rb-space-xs);
    padding: var(--rb-space-md);
    background: var(--rb-bg-primary);
    border: 2px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    width: 100%;
    font-family: inherit;
    font-size: 1rem;
}

.rb-saved-position-card:hover {
    border-color: var(--rb-primary);
    box-shadow: var(--rb-shadow-md);
    transform: translateY(-2px);
}

.rb-saved-position-card:focus {
    outline: none;
    border-color: var(--rb-primary);
    box-shadow: 0 0 0 3px rgba(0, 104, 166, 0.2);
}

.rb-saved-position-card .rb-position-name {
    font-weight: 600;
    color: var(--rb-text-primary);
    font-size: 1rem;
}

.rb-saved-position-card .rb-position-discipline {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--rb-primary);
    background: rgba(0, 104, 166, 0.1);
    padding: 2px 8px;
    border-radius: var(--rb-radius-sm);
}

.rb-saved-position-card .rb-position-coords {
    font-size: 0.8125rem;
    color: var(--rb-text-secondary);
    font-family: var(--rb-font-mono);
}

/* Divider with "or" text */
.rb-divider {
    display: flex;
    align-items: center;
    gap: var(--rb-space-md);
    margin: var(--rb-space-lg) 0;
}

.rb-divider::before,
.rb-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--rb-bg-tertiary);
}

.rb-divider span {
    color: var(--rb-text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

@media (max-width: 640px) {
    .rb-position-selector {
        padding: var(--rb-space-lg);
    }

    .rb-saved-positions-grid {
        grid-template-columns: 1fr;
    }
}

/* ----------------------------------------
   Save Position Form (Results page)
   ---------------------------------------- */

/* Inline form for saving position */
.rb-save-position-form {
    text-align: center;
}

.rb-inline-form {
    display: flex;
    gap: var(--rb-space-md);
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.rb-form-group-inline {
    margin: 0;
}

.rb-save-position-form .rb-form-input,
.rb-save-position-form .rb-form-select {
    background: rgba(255, 255, 255, 0.95);
    color: var(--rb-text-primary);
    border: 1px solid rgba(255, 255, 255, 0.5);
    min-width: 180px;
}

.rb-save-position-form .rb-form-input:focus,
.rb-save-position-form .rb-form-select:focus {
    background: white;
    border-color: white;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.rb-save-position-form .rb-form-input::placeholder {
    color: var(--rb-text-muted);
}

/* Save success state */
.rb-save-success {
    text-align: center;
}

.rb-success-icon {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: var(--rb-space-md);
    color: var(--rb-accent);
    background: rgba(255, 255, 255, 0.2);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.rb-success-message {
    opacity: 0.95;
    margin-bottom: var(--rb-space-lg);
}

.rb-success-actions {
    display: flex;
    justify-content: center;
    gap: var(--rb-space-md);
    flex-wrap: wrap;
}

/* Small alert for inline errors */
.rb-alert-small {
    padding: var(--rb-space-sm) var(--rb-space-md);
    margin-bottom: var(--rb-space-md);
    font-size: 0.875rem;
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
    .rb-inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .rb-save-position-form .rb-form-input,
    .rb-save-position-form .rb-form-select {
        min-width: 100%;
    }

    .rb-success-actions {
        flex-direction: column;
    }
}

/* ----------------------------------------
   Saved Positions Section (Tools page)
   ---------------------------------------- */

.rb-saved-positions-section {
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-xl);
    margin-bottom: var(--rb-space-xl);
}

.rb-saved-positions-section .rb-section-title {
    margin-bottom: var(--rb-space-sm);
}

.rb-saved-positions-section .rb-section-description {
    margin-bottom: var(--rb-space-lg);
}

/* ----------------------------------------
   Save Frame Button (on frame cards)
   ---------------------------------------- */

.rb-save-frame-btn {
    position: absolute;
    top: var(--rb-space-sm);
    right: var(--rb-space-sm);
    display: flex;
    align-items: center;
    gap: var(--rb-space-xs);
    padding: var(--rb-space-xs) var(--rb-space-sm);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    font-size: 0.75rem;
    color: var(--rb-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 10;
}

.rb-save-frame-btn:hover {
    background: white;
    border-color: var(--rb-primary);
    color: var(--rb-primary);
}

.rb-save-frame-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.rb-save-frame-btn.saved {
    background: var(--rb-primary);
    border-color: var(--rb-primary);
    color: white;
}

.rb-save-frame-btn.saved:hover {
    background: var(--rb-accent);
    border-color: var(--rb-accent);
}

.rb-save-icon {
    font-size: 1rem;
    line-height: 1;
}

.rb-save-text {
    font-weight: 500;
}

/* Frame card needs position:relative for the save button */
.rb-frame-card {
    position: relative;
}

/* ----------------------------------------
   Saved Frames Page
   ---------------------------------------- */

.rb-saved-frame-actions {
    display: flex;
    gap: var(--rb-space-sm);
    padding: 0 var(--rb-space-lg) var(--rb-space-md);
    border-top: 1px solid var(--rb-bg-tertiary);
    padding-top: var(--rb-space-md);
}

.rb-saved-date {
    display: block;
    padding: 0 var(--rb-space-lg) var(--rb-space-md);
    font-size: 0.75rem;
    color: var(--rb-text-muted);
}

.rb-frame-notes {
    font-size: 0.875rem;
    color: var(--rb-text-secondary);
    margin-top: var(--rb-space-sm);
    font-style: italic;
}

/* ============================================
   Dark Theme Support
   ============================================
   Automatic dark theme based on system preference.
   No manual toggle - follows prefers-color-scheme.
   ============================================ */

@media (prefers-color-scheme: dark) {
    :root {
        /* Background Colors - inverted hierarchy */
        --rb-bg-primary: #1a1a1a;
        --rb-bg-secondary: #0d0d0d;
        --rb-bg-tertiary: #2a2a2a;

        /* Text Colors - light on dark with good contrast */
        --rb-text-primary: #f0f0f0;
        --rb-text-secondary: #c0c0c0;
        --rb-text-muted: #8a8a8a;

        /* Shadows - more subtle in dark mode */
        --rb-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
        --rb-shadow-md: 0 1px 3px rgba(0, 0, 0, 0.3);
        --rb-shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.3);

        /* Brand colors stay the same - they provide contrast */
        /* --rb-primary: #0068a6; */
        /* --rb-secondary: #00b9f2; */
        /* --rb-accent: #00a896; */
        /* --rb-orange: #FF6B00; */
    }

    /* Global text color for dark mode */
    body {
        color: var(--rb-text-primary);
    }

    /* Header adjustments */
    .rb-header {
        background: var(--rb-bg-primary);
        border-bottom-color: var(--rb-bg-tertiary);
    }

    /* Sidebar adjustments */
    .rb-sidebar {
        background: var(--rb-bg-primary);
        border-right-color: var(--rb-bg-tertiary);
    }

    /* Footer adjustments */
    .rb-footer {
        background: var(--rb-bg-primary);
        border-top-color: var(--rb-bg-tertiary);
    }

    /* Cards and elevated surfaces */
    .rb-card,
    .rb-feature-card,
    .rb-tool-card,
    .rb-hero,
    .rb-form-section,
    .rb-auth-card,
    .rb-tools-info {
        background: var(--rb-bg-primary);
        border: 1px solid var(--rb-bg-tertiary);
    }

    /* Form inputs */
    .rb-form-input,
    .rb-form-select,
    .rb-form-textarea {
        background: var(--rb-bg-secondary);
        border-color: var(--rb-bg-tertiary);
        color: var(--rb-text-primary);
    }

    .rb-form-input:focus,
    .rb-form-select:focus,
    .rb-form-textarea:focus {
        background: var(--rb-bg-primary);
        border-color: var(--rb-secondary);
    }

    .rb-form-input::placeholder {
        color: var(--rb-text-muted);
    }

    /* Unit toggle buttons */
    .rb-unit-button {
        background: var(--rb-bg-secondary);
        border-color: var(--rb-bg-tertiary);
        color: var(--rb-text-secondary);
    }

    .rb-unit-button:hover {
        background: var(--rb-bg-tertiary);
    }

    /* Tables */
    .rb-table {
        background: var(--rb-bg-primary);
    }

    .rb-table th {
        background: var(--rb-bg-secondary);
        border-color: var(--rb-bg-tertiary);
    }

    .rb-table td {
        border-color: var(--rb-bg-tertiary);
    }

    .rb-table tr:hover {
        background: var(--rb-bg-tertiary);
    }

    /* Frame cards */
    .rb-frame-card {
        background: var(--rb-bg-primary);
        border: 1px solid var(--rb-bg-tertiary);
    }

    /* Save frame button */
    .rb-save-frame-btn {
        background: rgba(26, 26, 26, 0.95);
        border-color: var(--rb-bg-tertiary);
        color: var(--rb-text-secondary);
    }

    .rb-save-frame-btn:hover {
        background: var(--rb-bg-primary);
        border-color: var(--rb-secondary);
        color: var(--rb-secondary);
    }

    /* Code blocks */
    code {
        background: var(--rb-bg-tertiary);
    }

    /* Alerts and notifications */
    .rb-alert {
        background: var(--rb-bg-tertiary);
        border-color: var(--rb-bg-tertiary);
    }

    .rb-alert-error {
        background: rgba(239, 68, 68, 0.15);
        border-color: var(--rb-error);
    }

    .rb-alert-success {
        background: rgba(0, 168, 150, 0.15);
        border-color: var(--rb-success);
    }

    /* Social login buttons */
    .rb-social-button {
        background: var(--rb-bg-secondary);
        border-color: var(--rb-bg-tertiary);
        color: var(--rb-text-primary);
    }

    .rb-social-button:hover {
        background: var(--rb-bg-tertiary);
    }

    /* Divider */
    .rb-divider {
        background: var(--rb-bg-tertiary);
    }

    .rb-divider-text {
        background: var(--rb-bg-primary);
        color: var(--rb-text-muted);
    }

    /* Modal overlay */
    .rb-modal-overlay {
        background: rgba(0, 0, 0, 0.8);
    }

    .rb-modal {
        background: var(--rb-bg-primary);
        border: 1px solid var(--rb-bg-tertiary);
    }

    /* Position diagram */
    .rb-position-diagram {
        background: var(--rb-bg-secondary);
        border-color: var(--rb-bg-tertiary);
    }

    /* Error page */
    .rb-error-card {
        background: var(--rb-bg-primary);
        border: 1px solid var(--rb-bg-tertiary);
    }

    .rb-error-details code {
        background: var(--rb-bg-tertiary);
    }

    /* Saved positions section */
    .rb-saved-positions-section {
        background: var(--rb-bg-secondary);
        border: 1px solid var(--rb-bg-tertiary);
    }

    /* Comparison table */
    .rb-comparison-table th,
    .rb-comparison-table td {
        background: var(--rb-bg-primary);
        border-color: var(--rb-bg-tertiary);
    }

    .rb-comparison-table th {
        background: var(--rb-bg-secondary);
    }

    /* Result header gradient adjustment */
    .rb-result-header {
        background: linear-gradient(135deg, #004d7a 0%, #003c5f 100%);
    }

    /* Spinner */
    .rb-spinner {
        border-color: var(--rb-bg-tertiary);
        border-top-color: var(--rb-secondary);
    }

    /* Accordion */
    .rb-accordion-header {
        background: var(--rb-bg-secondary);
        border-color: var(--rb-bg-tertiary);
    }

    .rb-accordion-header:hover {
        background: var(--rb-bg-tertiary);
    }

    .rb-accordion-body {
        background: var(--rb-bg-primary);
        border-color: var(--rb-bg-tertiary);
    }

    /* Garage card */
    .rb-garage-card {
        background: var(--rb-bg-primary);
        border: 1px solid var(--rb-bg-tertiary);
    }

    /* Position card */
    .rb-position-card {
        background: var(--rb-bg-primary);
        border: 1px solid var(--rb-bg-tertiary);
    }

    /* Empty state */
    .rb-empty-state {
        background: var(--rb-bg-primary);
        border: 1px solid var(--rb-bg-tertiary);
    }

    /* Skip link */
    .rb-skip-link:focus {
        background: var(--rb-primary);
        color: white;
    }

    /* Logo text - ensure visibility in dark mode */
    .rb-logo {
        color: var(--rb-secondary);
    }

    .rb-logo:hover {
        color: var(--rb-primary);
    }

    /* Mobile menu toggle button */
    .rb-menu-toggle:hover {
        background: var(--rb-bg-tertiary);
    }

    .rb-menu-toggle:active {
        background: var(--rb-bg-secondary);
    }

    .rb-menu-icon {
        stroke: var(--rb-text-primary);
    }

    /* Mobile overlay */
    .rb-mobile-overlay {
        background: rgba(0, 0, 0, 0.7);
    }

    /* Scrollbar styling for dark mode (WebKit browsers) */
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    ::-webkit-scrollbar-track {
        background: var(--rb-bg-secondary);
    }

    ::-webkit-scrollbar-thumb {
        background: var(--rb-bg-tertiary);
        border-radius: 4px;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: var(--rb-text-muted);
    }
}

/* ============================================
   Content Pages (About, How It Works, Help)
   ============================================ */

/* Content Sections */
.rb-content-section {
    margin-bottom: var(--rb-space-2xl);
}

.rb-content-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-md);
}

.rb-content-section p {
    line-height: 1.7;
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-md);
}

.rb-content-section ul {
    margin-left: var(--rb-space-lg);
    margin-bottom: var(--rb-space-md);
}

.rb-content-section li {
    line-height: 1.7;
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-sm);
}

/* CTA Group */
.rb-cta-group {
    display: flex;
    gap: var(--rb-space-md);
    flex-wrap: wrap;
    margin-top: var(--rb-space-lg);
}

.rb-cta-section {
    text-align: center;
    padding: var(--rb-space-2xl);
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-lg);
}

/* Option Cards (for How It Works) */
.rb-option-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--rb-space-lg);
    margin-top: var(--rb-space-lg);
}

.rb-option-card {
    background: var(--rb-bg-primary);
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-lg);
}

.rb-option-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-sm);
}

.rb-option-card p {
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-md);
}

/* Feature List */
.rb-feature-list {
    list-style: none;
    padding: 0;
    margin: var(--rb-space-lg) 0;
}

.rb-feature-list li {
    padding: var(--rb-space-sm) 0;
    padding-left: var(--rb-space-lg);
    position: relative;
}

.rb-feature-list li::before {
    content: '\2713';  /* Checkmark */
    position: absolute;
    left: 0;
    color: var(--rb-success);
    font-weight: bold;
}

/* FAQ Section */
.rb-faq-list {
    margin-top: var(--rb-space-lg);
}

.rb-faq-item {
    border: 1px solid var(--rb-bg-tertiary);
    border-radius: var(--rb-radius-md);
    margin-bottom: var(--rb-space-md);
    overflow: hidden;
}

.rb-faq-item summary {
    padding: var(--rb-space-md);
    font-weight: 500;
    color: var(--rb-text-primary);
    cursor: pointer;
    background: var(--rb-bg-secondary);
    list-style: none;
}

.rb-faq-item summary::-webkit-details-marker {
    display: none;
}

.rb-faq-item summary::before {
    content: '+';
    float: right;
    font-weight: 600;
    color: var(--rb-primary);
    font-size: 1.25rem;
}

.rb-faq-item[open] summary::before {
    content: '-';
}

.rb-faq-item summary:hover {
    background: var(--rb-bg-tertiary);
}

.rb-faq-answer {
    padding: var(--rb-space-md);
    background: var(--rb-bg-primary);
    border-top: 1px solid var(--rb-bg-tertiary);
}

.rb-faq-answer p {
    margin-bottom: var(--rb-space-sm);
}

.rb-faq-answer p:last-child {
    margin-bottom: 0;
}

.rb-faq-answer ul {
    margin-left: var(--rb-space-lg);
    margin-top: var(--rb-space-sm);
}

/* ============================================
   Settings Page
   ============================================ */

.rb-settings-section {
    margin-bottom: var(--rb-space-2xl);
}

.rb-settings-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-md);
    padding-bottom: var(--rb-space-sm);
    border-bottom: 1px solid var(--rb-bg-tertiary);
}

.rb-settings-description {
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-lg);
}

.rb-settings-card {
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-md);
    padding: var(--rb-space-lg);
}

.rb-settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--rb-space-sm) 0;
}

.rb-settings-item:not(:last-child) {
    border-bottom: 1px solid var(--rb-bg-tertiary);
}

.rb-settings-label {
    font-weight: 500;
    color: var(--rb-text-secondary);
}

.rb-settings-value {
    color: var(--rb-text-primary);
}

.rb-settings-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--rb-space-lg);
}

.rb-settings-action-card {
    background: var(--rb-bg-secondary);
    border-radius: var(--rb-radius-md);
    padding: var(--rb-space-lg);
}

.rb-settings-action-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--rb-text-primary);
    margin-bottom: var(--rb-space-sm);
}

.rb-settings-action-card p {
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-md);
    font-size: 0.9375rem;
}

.rb-settings-danger {
    border: 1px solid var(--rb-error);
    border-left-width: 4px;
}

.rb-settings-danger h3 {
    color: var(--rb-error);
}

/* Modal warning and confirm styles */
.rb-modal-warning {
    color: var(--rb-error);
    margin-top: var(--rb-space-md);
}

.rb-modal-confirm {
    margin: var(--rb-space-md) 0;
}

.rb-modal-confirm label {
    display: flex;
    align-items: center;
    gap: var(--rb-space-sm);
    cursor: pointer;
}

.rb-modal-confirm input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Dark Mode overrides for new pages */
@media (prefers-color-scheme: dark) {
    .rb-content-section h2,
    .rb-option-card h3,
    .rb-settings-action-card h3 {
        color: var(--rb-text-primary);
    }

    .rb-option-card {
        background: var(--rb-bg-secondary);
        border-color: var(--rb-bg-tertiary);
    }

    .rb-faq-item {
        border-color: var(--rb-bg-tertiary);
    }

    .rb-faq-item summary {
        background: var(--rb-bg-tertiary);
    }

    .rb-faq-item summary:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .rb-faq-answer {
        background: var(--rb-bg-secondary);
    }

    .rb-settings-card,
    .rb-settings-action-card {
        background: var(--rb-bg-tertiary);
    }

    .rb-settings-danger {
        border-color: var(--rb-error);
    }
}
