*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Km markers on route */
.km-marker {
    background: #92400e;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.km-marker span {
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

/* Toast notification */
.ryp-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(1rem);
    background: #92400e;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 9999;
    pointer-events: none;
}
.ryp-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: #fffbf5;
    color: #2d1b0e;
}

.ryp-app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

.ryp-header {
    background: linear-gradient(135deg, #92400e 0%, #d97706 50%, #f59e0b 100%);
    color: white;
    padding: 0.6rem 1rem;
    text-align: center;
    box-shadow: 0 2px 12px rgba(146, 64, 14, 0.3);
    position: relative;
    z-index: 10000;
}

.ryp-header-actions {
    position: absolute;
    top: 0.6rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ryp-lang-picker {
    position: relative;
}
.ryp-lang-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(4px);
}
.ryp-lang-btn:hover { background: rgba(255,255,255,0.25); }
.ryp-lang-btn img { width: 20px; height: 14px; border-radius: 2px; }
.ryp-lang-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.3rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    overflow: hidden;
    min-width: 140px;
    z-index: 10000;
}
.ryp-lang-menu button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: none;
    font-size: 0.85rem;
    color: #2d1b0e;
    cursor: pointer;
    text-align: left;
}
.ryp-lang-menu button:hover { background: #fef3c7; }
.ryp-lang-menu button img { width: 22px; height: 15px; border-radius: 2px; }

.ryp-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}
.ryp-brand img {
    width: 38px;
    height: 38px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}
.ryp-brand h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
    outline: none;
}
.ryp-tagline {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 0.1rem;
    font-style: italic;
}

.ryp-main { flex: 1; position: relative; overflow: hidden; }

.map-container, #map { width: 100%; height: 100%; }

/* Side panel */
.ryp-panel {
    position: absolute;
    top: 0; right: 0;
    width: 380px; max-width: 100%;
    height: 100%;
    background: #fffbf5;
    box-shadow: -4px 0 24px rgba(146, 64, 14, 0.12);
    overflow-y: auto;
    padding: 1.5rem;
    z-index: 1000;
    animation: slideIn 0.25s ease-out;
    border-left: 3px solid #f59e0b;
}

@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.ryp-panel h2 { font-size: 1.3rem; margin-bottom: 0.5rem; color: #92400e; }

.ryp-avg { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.ryp-avg .stars { color: #d97706; font-size: 1.4rem; }

.no-ratings { color: #78716c; font-style: italic; margin-bottom: 1rem; }

/* Rating form */
.ryp-form {
    background: linear-gradient(135deg, #fef3c7, #fff7ed);
    border: 1px solid #fde68a;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.ryp-form h3 { font-size: 1.05rem; margin-bottom: 0.75rem; color: #92400e; }

.star-input { display: flex; gap: 0.3rem; margin-bottom: 0.75rem; cursor: pointer; font-size: 2rem; }
.star-filled { color: #d97706; transition: transform 0.1s; }
.star-filled:hover { transform: scale(1.2); }
.star-empty { color: #d6d3d1; }

.ryp-input {
    display: block; width: 100%;
    padding: 0.6rem 0.85rem; margin-bottom: 0.6rem;
    border: 1px solid #d6d3d1; border-radius: 8px;
    font-size: 0.9rem; font-family: inherit;
    resize: vertical;
    background: white;
    transition: border-color 0.15s;
}
.ryp-input:focus { border-color: #d97706; outline: none; box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.1); }

.ryp-btn {
    width: 100%; padding: 0.7rem;
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
    border: none; border-radius: 8px;
    font-size: 1rem; font-weight: 700;
    cursor: pointer; transition: all 0.15s;
    box-shadow: 0 2px 8px rgba(180, 83, 9, 0.3);
}
.ryp-btn:hover { background: linear-gradient(135deg, #b45309, #92400e); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(180, 83, 9, 0.4); }
.ryp-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.ryp-error { color: #dc2626; font-size: 0.85rem; margin-top: 0.5rem; }

/* Reviews */
.ryp-reviews { margin-top: 1rem; }
.ryp-reviews h3 { font-size: 1.05rem; margin-bottom: 0.5rem; color: #92400e; }

.review {
    border-bottom: 1px solid #e7e5e4;
    padding: 0.75rem 0;
}
.review:last-child { border-bottom: none; }
.review-header { display: flex; justify-content: space-between; align-items: center; }
.stars-sm { color: #d97706; font-size: 0.9rem; }
.review p { margin: 0.3rem 0; font-size: 0.9rem; color: #44403c; }
.review small { color: #a8a29e; font-size: 0.8rem; }

.ryp-btn-close {
    display: block; width: 100%; margin-top: 1rem;
    padding: 0.6rem; background: #f5f5f4; color: #57534e;
    border: 1px solid #d6d3d1; border-radius: 8px; font-size: 0.9rem;
    cursor: pointer; transition: background 0.15s;
}
.ryp-btn-close:hover { background: #e7e5e4; }

.pie-group { margin-bottom: 1.25rem; }
.pie-group h4 { font-size: 0.95rem; margin-bottom: 0.5rem; border-bottom: 2px solid #fde68a; padding-bottom: 0.4rem; color: #78350f; }

/* Mobile */
@media (max-width: 480px) {
    .ryp-panel { width: 100%; border-left: none; border-top: 3px solid #f59e0b; }
    .ryp-header { padding: 0.5rem; }
    .ryp-brand h1 { font-size: 1.1rem; margin-right: 2.5rem; }
    .ryp-brand img { width: 28px; height: 28px; }
    .ryp-header-actions { top: 0.4rem; right: 0.5rem; gap: 0.3rem; }
    .ryp-info-btn { width: 1.6rem; height: 1.6rem; font-size: 0.85rem; }
    .ryp-lang-btn { padding: 0.2rem 0.4rem; font-size: 0.7rem; }
    .ryp-strava-panel { top: 0.5rem; right: 0.5rem; }
}

/* Strava panel overlay */
.ryp-strava-panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    background: rgba(255, 251, 245, 0.95);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 2px 12px rgba(146, 64, 14, 0.15);
    border: 1px solid #fde68a;
}
.ryp-btn-strava {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #fc4c02, #d94400);
    color: white;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.15s;
}
.ryp-btn-strava:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(252, 76, 2, 0.4); }
.ryp-gpx-divider { text-align: center; margin: 0.4rem 0; }
.ryp-gpx-or { font-size: 0.75rem; color: #78716c; }
.ryp-btn-gpx {
    display: inline-block; width: 100%; padding: 0.5rem 1rem; background: linear-gradient(135deg, #6d9e37, #4a7c1e);
    color: white; border-radius: 8px; font-weight: 700; font-size: 0.85rem; cursor: pointer; transition: all 0.15s;
    text-align: center; box-sizing: border-box;
}
.ryp-btn-gpx:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74, 124, 30, 0.4); }
.ryp-strava-controls { display: flex; gap: 0.5rem; align-items: center; }
.ryp-strava-controls .ryp-input { margin-bottom: 0; min-width: 180px; font-size: 0.85rem; }
.ryp-btn-sm {
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
    color: #78716c;
    background: #f5f5f4;
    border: 1px solid #d6d3d1;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s;
}
.ryp-btn-sm:hover { background: #e7e5e4; }

/* Info button */
.ryp-info-btn {
    background: rgba(255,255,255,0.15);
    border: 1.5px solid rgba(255,255,255,0.4);
    color: white;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.ryp-info-btn:hover { background: rgba(255,255,255,0.3); }

/* About modal */
.ryp-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ryp-modal {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.ryp-modal h2 {
    color: #92400e;
    margin-bottom: 1rem;
    font-size: 1.4rem;
}
.ryp-modal p {
    color: #44403c;
    line-height: 1.7;
    font-size: 0.95rem;
}
.ryp-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #78716c;
    cursor: pointer;
}
.ryp-modal-close:hover { color: #292524; }

.ryp-modal h3 {
    color: #92400e;
    margin: 1.5rem 0 0.5rem;
    font-size: 1.1rem;
}
.ryp-beta-notice {
    margin-top: 1.5rem;
    padding: 0.75rem 1rem;
    background: #fef3c7;
    border-radius: 8px;
    border-left: 4px solid #f59e0b;
}
.ryp-beta-notice p {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    color: #78350f;
}
.ryp-beta-badge {
    display: inline-block;
    background: #f59e0b;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.05em;
}
