@font-face {
    font-family: 'Inter';
    src: url('./InterVariable.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

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

:root {
    --bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-secondary: rgba(255, 255, 255, 0.95);
    --text-primary: #333;
    --text-secondary: #666;
    --text-light: #999;
    --border-color: #e0e0e0;
    --card-bg: white;
    --input-bg: white;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
    --bg-primary: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    --bg-secondary: rgba(26, 32, 44, 0.95);
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --text-light: #718096;
    --border-color: #4a5568;
    --card-bg: #2d3748;
    --input-bg: #4a5568;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .cycle-value {
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    background-clip: unset;
    color: white;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: all 0.3s ease;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.container {
    max-width: 420px;
    margin: 0 auto;
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
    min-height: 100vh;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
    overscroll-behavior-y: contain;
    touch-action: pan-y pan-x;
}

.header {
    background: var(--bg-primary);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    overflow: hidden;
}

.header::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 300%;
    height: 100%;
    background: 
        linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.03), transparent),
        repeating-linear-gradient(
            90deg,
            transparent 0px,
            rgba(255, 255, 255, 0.05) 1px,
            rgba(255, 255, 255, 0.02) 2px,
            transparent 3px,
            transparent 20px
        );
    animation: wave 8s ease-in-out infinite;
    transform-origin: center;
}

@keyframes wave {
    0%, 100% { 
        transform: translateX(0%) scaleY(1) rotate(0deg);
        opacity: 0.3;
    }
    25% { 
        transform: translateX(10%) scaleY(1.2) rotate(1deg);
        opacity: 0.6;
    }
    50% { 
        transform: translateX(20%) scaleY(0.8) rotate(-1deg);
        opacity: 0.8;
    }
    75% { 
        transform: translateX(15%) scaleY(1.1) rotate(0.5deg);
        opacity: 0.5;
    }
}

.header-content {
    position: relative;
    z-index: 1;
}

.header-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 300;
}

.settings-btn {
    position: absolute;
    top: 1rem;
    left: 1rem; /* moved to left side */
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.settings-btn:focus, .settings-btn:focus-visible {
    outline: none;
    box-shadow: none;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.install-btn {
    position: absolute;
    top: 1rem;
    right: 3.5rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .3s ease;
    backdrop-filter: blur(10px);
}

.install-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.help-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.18);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.help-btn:focus, .help-btn:focus-visible {
    outline: none;
    box-shadow: none;
}

.help-btn:hover { 
    background: rgba(255,255,255,0.32); 
    transform: translateY(-2px); 
}

.help-modal { max-width:520px; padding:0; }
.help-intro .lead { font-size:1.05rem; margin-bottom:0.25rem; color:var(--text-primary); }
.help-list { display:flex; flex-direction:column; gap:0.75rem; margin-top:0.5rem; }
.help-item { display:flex; gap:0.75rem; align-items:flex-start; padding:0.75rem; background:var(--input-bg); border-radius:12px; border:1px solid var(--border-color); }
.help-item i { font-size:1.6rem; color:var(--bg-primary); flex:0 0 40px; display:flex; align-items:center; justify-content:center; }
.help-item div { display:flex; flex-direction:column; }
.help-item div strong { font-size:1rem; color:var(--text-primary); margin-bottom:0.15rem; }
.help-item div span { font-size:0.9rem; color:var(--text-secondary); line-height:1.3; }
.help-modal .muted { margin-top:0.75rem; color:var(--text-light); font-size:0.85rem; }

.main-content {
    padding: 1.5rem;
}

.input-section {
    margin-bottom: 2rem;
}

.input-section .form-grid { display: grid; grid-template-columns: 1fr 30px 1fr; gap: 0.75rem; align-items: end; border-bottom: 1px solid var(--border-color); padding-bottom: 0.75rem; margin-bottom: 1rem; }
.form-grid .input-group { margin-bottom: 0; }
.form-grid label { font-size: 0.9rem; }

.form-grid .input-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    justify-content: center; /* center icon + text */
    text-align: center;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group input,
.input-group select {
    height: 56px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
}

.input-group input {
    width: 100%;
    padding: 0 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    background: var(--input-bg);
    transition: all 0.3s ease;
    color: var(--text-primary);
    caret-color: var(--text-primary);
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
}

.input-group select {
    width: 100%;
    padding: 0 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: all 0.3s ease;
    cursor: pointer;
}

.input-group select:focus {
    outline: none;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
}

.form-grid .middle-action {
    display: flex;
    align-items: end;
    justify-content: center;
}

.calculate-btn {
    flex: 1;
    width: 100%;
    padding: 1.2rem;
    background: var(--bg-primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    transform: translateY(0);
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.3);
}

.calculate-btn:active {
    transform: translateY(0);
}

.results-section {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.results-section.show {
    opacity: 1;
    transform: translateY(0);
}

.cycles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.cycle-card {
    background: var(--card-bg);
    color: var(--text-primary);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px var(--shadow-light);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.cycle-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px var(--shadow-medium);
}

.cycle-card.physical {
    border-image: linear-gradient(135deg, #ff6b6b, #ff8e53) 1;
}

.cycle-card.emotional {
    border-image: linear-gradient(135deg, #4ecdc4, #44a08d) 1;
}

.cycle-card.intellectual {
    border-image: linear-gradient(135deg, #45b7d1, #96c93d) 1;
}

.cycle-card.intuitive {
    border-image: linear-gradient(135deg, #f093fb, #f5576c) 1;
}

.cycle-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.cycle-header i {
    font-size: 1.2rem;
}

.physical .cycle-header i { color: #ff6b6b; }
.emotional .cycle-header i { color: #4ecdc4; }
.intellectual .cycle-header i { color: #45b7d1; }
.intuitive .cycle-header i { color: #f093fb; }

.cycle-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.cycle-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: var(--bg-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-theme="dark"] .cycle-value {
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    background-clip: unset;
    color: white;
}

.cycle-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.cycle-progress {
    height: 100%;
    border-radius: 3px;
    transition: all 0.8s ease;
    background: var(--bg-primary);
}

.physical .cycle-progress { background: linear-gradient(90deg, #ff6b6b, #ff8e53); }
.emotional .cycle-progress { background: linear-gradient(90deg, #4ecdc4, #44a08d); }
.intellectual .cycle-progress { background: linear-gradient(90deg, #45b7d1, #96c93d); }
.intuitive .cycle-progress { background: linear-gradient(90deg, #f093fb, #f5576c); }

.cycle-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.3;
}

.chart-container {
    background: var(--card-bg);
    color: var(--text-primary);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 1rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px var(--shadow-light);
}

.summary-card {
    background: var(--card-bg);
    color: var(--text-primary);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px var(--shadow-light);
}

.summary-card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    justify-content: space-between;
}

.summary-card h3 i {
    color: #667eea;
}

.summary-content {
    color: var(--text-secondary);
    line-height: 1.6;
}

.summary-content p {
    margin-bottom: 0.5rem;
}

.positive { color: #4ecdc4; font-weight: 600; }
.negative { color: #ff6b6b; font-weight: 600; }
.neutral { color: #ffa726; font-weight: 600; }

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 9999; /* increased so modals appear above header/animations */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding-top: 2rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.modal-overlay::-webkit-scrollbar,
.modal-content::-webkit-scrollbar { width: 0; height: 0; display: none; }

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 20px;
    width: 90%;
    max-width: 450px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px var(--shadow-medium);
    transform: translateY(30px) scale(0.9);
    transition: all 0.3s ease;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.show .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 1.3rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.settings-section {
    margin-bottom: 2rem;
}

.settings-section h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--input-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    border-radius: 30px;
    transition: 0.3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: var(--card-bg);
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background: var(--bg-primary);
}

input:checked + .slider:before {
    transform: translateX(30px);
}

.profiles-list {
    margin-bottom: 1rem;
}

.profile-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 0.5rem;
}

.profile-info h4 {
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.profile-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.profile-actions {
    display: flex;
    gap: 0.5rem;
}

.profile-actions button {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.edit-btn:hover {
    background: #4ecdc4;
    color: white;
}

.delete-btn:hover {
    background: #ff6b6b;
    color: white;
}

.add-profile-btn {
    width: 100%;
    padding: 1rem;
    background: var(--bg-primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.add-profile-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.save-profile-btn {
    flex: 1;
    padding: 1rem;
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.save-profile-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(78, 205, 196, 0.3);
}

.cancel-btn {
    flex: 1;
    padding: 1rem;
    background: var(--input-bg);
    color: var(--text-primary);
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cancel-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.navigation-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-btn {
    padding: 1rem;
    background: rgba(102, 126, 234, 0.1);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    transition: all 0.3s ease;
    flex: 0 0 auto;
    min-width: 80px;
}

.nav-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: #667eea;
    transform: translateY(-1px);
}

.nav-btn:active {
    transform: translateY(0);
}

.app-footer {
    text-align: center;
    padding: 1rem 0.5rem;
    color: #ffffff;
    background: #1f2937; /* dark grey */
    font-size: 0.9rem;
}

.app-footer a { color: inherit; text-decoration: underline; }

/* Ensure footer is readable in light mode */
:root .app-footer {
    color: #ffffff; /* enforce white text in both themes */
    background: #1f2937; /* enforce dark grey background in root scope as fallback */
}

@media (max-width: 480px) {
    .container {
        max-width: 100%;
    }
    
    .header {
        padding: 1.5rem 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .cycles-grid {
        gap: 0.8rem;
    }
    
    .cycle-card {
        padding: 1.2rem;
    }
}

.actions-row { display:flex; gap:0.5rem; margin-top:0.5rem; }
.share-btn, .compare-btn { flex:1; padding:1rem; border:none; border-radius:12px; font-weight:600; cursor:pointer; display:flex; align-items:center; justify-content:center; gap:0.5rem; transition:transform .2s ease, box-shadow .2s ease; }
.share-btn { background: linear-gradient(135deg,#667eea,#764ba2); color:#fff; }
.compare-btn { background: linear-gradient(135deg,#4ecdc4,#44a08d); color:#fff; }

.share-btn:hover, .compare-btn:hover { transform: translateY(-2px); box-shadow:0 8px 24px rgba(0,0,0,.15); }
.compare-results { margin-top:1rem; background: var(--card-bg); border:1px solid var(--border-color); border-radius:12px; padding:1rem; }
.compare-results .row { display:grid; grid-template-columns: 1fr auto 1fr; gap:.5rem; align-items:center; margin:.35rem 0; }
.compare-results .label { font-size:.85rem; color:var(--text-secondary); text-align:center; }
.compare-results .val { font-weight:700; text-align:center; }
.compare-score { margin-top:.8rem; text-align:center; font-weight:700; }

.compare-icon-btn {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    border: 2px solid #f5576c;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: #fff;
    box-shadow: 0 2px 10px rgba(245, 87, 108, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s ease;
}

.compare-icon-btn:hover {
    border-color: #f093fb;
    transform: translateY(-1px);
}

.compare-icon-btn i { font-size: 26px; }

.share-compare-btn { background: linear-gradient(135deg,#667eea,#764ba2); color:#fff; }

#cycleDetailModal .modal-body ul {
    margin-top: .75rem;
    padding-left: 1.25rem;
}
#cycleDetailModal .modal-body li {
    margin: .55rem 0;
    color: var(--text-secondary);
    line-height: 1.55;
}

#cycleDetailModal .modal-body p {
    margin: .5rem 0 .8rem !important;
    line-height: 1.6 !important;
}

#compareModal .modal-actions { gap: 0.5rem; flex-wrap: wrap; }
#compareModal .modal-actions .save-profile-btn,
#compareModal .modal-actions .cancel-btn { padding: 0.75rem; font-size: 0.95rem; flex: 1 1 0; min-width: 0; }

.settings-btn i,
.help-btn i {
    font-size: 1.3rem;
}