:root {
    /* Light theme colors */
    --bg-primary: #f5f5f5;
    --bg-secondary: white;
    --bg-tertiary: #f8f9fa;
    --text-primary: #212121;
    --text-secondary: #616161;
    --text-tertiary: #424242;
    --border-color: #d0d0d0;
    --shadow-color: rgba(0,0,0,0.12);
    --primary-color: #1976d2;
    --primary-bg: #e3f2fd;
    --header-color: #1a1a1a;
    --success-color: #388e3c;
    --warning-bg: rgba(255, 193, 7, 0.1);
    --warning-border: rgba(255, 193, 7, 0.4);
    --warning-text: #e65100;
    --privacy-bg: rgba(25, 118, 210, 0.1);
    --privacy-border: rgba(25, 118, 210, 0.3);
    --privacy-header: #1565c0;
    
    /* Day box colors */
    --day-border: #bdbdbd;
    --day-past: #757575;
    --day-current: #1976d2;
    --day-current-border: #0d47a1;
    --day-future: #e0e0e0;
    --day-checked: #388e3c;
    --day-checked-border: #1b5e20;
    --day-hover-border: #424242;
    
    /* Button colors */
    --btn-secondary-bg: #f5f5f5;
    --btn-secondary-hover: #e0e0e0;
    --btn-reset-bg: #d32f2f;
    --btn-reset-hover: #b71c1c;
    --btn-data-bg: #1976d2;
    --btn-data-hover: #0d47a1;
    --btn-help-bg: #424242;
    --btn-help-hover: #212121;
}

/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-tertiary: #cccccc;
    --border-color: #555555;
    --shadow-color: rgba(0,0,0,0.5);
    --primary-color: #4fc3f7;
    --primary-bg: #0d47a1;
    --header-color: #ffffff;
    --success-color: #66bb6a;
    --warning-bg: rgba(255, 193, 7, 0.2);
    --warning-border: rgba(255, 193, 7, 0.5);
    --warning-text: #ffc107;
    --privacy-bg: rgba(33, 150, 243, 0.2);
    --privacy-border: rgba(33, 150, 243, 0.5);
    --privacy-header: #42a5f5;
    
    /* Day box colors */
    --day-border: #555555;
    --day-past: #616161;
    --day-current: #42a5f5;
    --day-current-border: #1976d2;
    --day-future: #424242;
    --day-checked: #66bb6a;
    --day-checked-border: #388e3c;
    --day-hover-border: #757575;
    
    /* Button colors */
    --btn-secondary-bg: #424242;
    --btn-secondary-hover: #616161;
    --btn-reset-bg: #f44336;
    --btn-reset-hover: #d32f2f;
    --btn-data-bg: #42a5f5;
    --btn-data-hover: #1976d2;
    --btn-help-bg: #616161;
    --btn-help-hover: #757575;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 0;
}

h1 {
    font-size: 2.5rem;
    color: var(--header-color);
    margin-bottom: 10px;
}

.tagline {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.header-nav {
    margin-top: 15px;
}

.nav-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 5px;
    transition: all 0.3s ease;
    display: inline-block;
}

.nav-link:hover {
    background-color: var(--primary-bg);
    color: var(--primary-color);
}

.nav-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.setup-form {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--shadow-color);
    max-width: 500px;
    margin: 0 auto;
}

.setup-form h2 {
    color: var(--header-color);
    margin-bottom: 30px;
    text-align: center;
}

.setup-options {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

.option-card {
    flex: 1;
    padding: 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-tertiary);
}

.option-card:hover {
    border-color: var(--primary-color);
    background: var(--primary-bg);
}

.option-card.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.option-card:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.option-card h3 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
}

.option-card p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

.import-section {
    text-align: center;
}

.import-area {
    padding: 30px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    margin-bottom: 20px;
    background: var(--bg-tertiary);
}

.import-info h3 {
    margin: 0 0 10px 0;
    color: var(--header-color);
}

.import-info p {
    margin: 0 0 20px 0;
    color: var(--text-secondary);
}

.import-note {
    margin-top: 15px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-tertiary);
    font-weight: 500;
}

input[type="date"],
input[type="number"] {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

input[type="date"]:focus,
input[type="number"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-color: var(--primary-color);
}

.helper-text {
    display: block;
    margin-top: 5px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-primary:hover {
    background-color: var(--primary-color);
    opacity: 0.9;
}

.btn-primary:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn-secondary {
    padding: 10px 20px;
    background-color: var(--btn-secondary-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

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

.btn-secondary:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn-help {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 12px 16px;
    background-color: var(--btn-help-bg);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow-color);
    z-index: 999;
}

.btn-help:hover {
    background-color: var(--btn-help-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.btn-help:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.hidden {
    display: none;
}

.app-view {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--shadow-color);
    margin-bottom: 40px;
}

.stats-bar {
    display: flex;
    justify-content: space-around;
    margin-bottom: 40px;
    padding: 20px;
    background-color: #ecf0f1;
    border-radius: 8px;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

.time-display {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px;
    background: linear-gradient(135deg, var(--header-color) 0%, var(--day-hover-border) 100%);
    border-radius: 10px;
    color: white;
}

.current-time {
    margin-bottom: 15px;
}

#clock-time {
    font-size: 3rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    display: block;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.time-label {
    font-size: 0.9rem;
    opacity: 0.8;
    font-style: italic;
}

.today-info {
    font-size: 1.2rem;
    opacity: 0.9;
}

.btn-secondary {
    padding: 12px 24px;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s;
}

.btn-secondary:hover {
    background-color: #229954;
}

.life-grid-container {
    margin-top: 40px;
}

.life-grid-container h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
}

.view-toggle {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.view-btn {
    padding: 8px 16px;
    background-color: #ecf0f1;
    border: 2px solid #bdc3c7;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.view-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.view-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.life-grid {
    display: grid;
    gap: 1px;
    max-width: 100%;
    overflow-x: auto;
    padding: 10px;
}

.life-grid.year-view {
    grid-template-columns: repeat(31, 1fr);
}

.life-grid.life-view {
    grid-template-columns: repeat(365, 1fr);
}

.day-box {
    width: 20px;
    height: 20px;
    border: 1px solid var(--day-border);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.day-box.past {
    background-color: var(--day-past);
}

.day-box.current {
    background-color: var(--day-current);
    border-color: var(--day-current-border);
}

.day-box.future {
    background-color: var(--day-future);
}

.day-box.checked {
    background-color: var(--day-checked);
    border-color: var(--day-checked-border);
}

.day-box.has-note::after {
    content: '•';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
}

.day-box:hover {
    transform: scale(1.2);
    border-color: var(--day-hover-border);
    z-index: 10;
}

.day-box.pressing {
    animation: pulse 0.5s ease-in-out;
    transform: scale(1.1);
}

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

.month-header {
    grid-column: 1 / -1;
    text-align: center;
    padding: 10px;
    background-color: var(--btn-help-bg);
    color: white;
    font-weight: bold;
    margin: 5px 0;
}

.data-controls {
    margin-top: 40px;
    padding: 20px;
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.data-controls h4 {
    margin: 0 0 15px 0;
    color: var(--header-color);
    font-size: 1.1rem;
}

.data-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.btn-data {
    padding: 10px 20px;
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s;
}

.btn-data:hover {
    background-color: var(--success-color);
    opacity: 0.9;
}

.btn-data:focus {
    outline: 2px solid var(--success-color);
    outline-offset: 2px;
}

.data-info {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.btn-reset {
    margin-top: 20px;
    padding: 10px 20px;
    background-color: var(--btn-reset-bg);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn-reset:hover {
    background-color: var(--btn-reset-hover);
}

.btn-reset:focus {
    outline: 2px solid var(--btn-reset-bg);
    outline-offset: 2px;
}

/* Modal styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 15% auto;
    padding: 30px;
    border: 1px solid var(--border-color);
    width: 80%;
    max-width: 500px;
    border-radius: 10px;
    position: relative;
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 15px;
}

.close:hover,
.close:focus {
    color: var(--text-primary);
}

#modal-note {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 16px;
    resize: vertical;
    min-height: 100px;
    margin: 20px 0;
    font-family: inherit;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

#modal-note:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-color: var(--primary-color);
}

.mobile-hint {
    text-align: center;
    font-size: 0.85rem;
    color: #7f8c8d;
    margin-bottom: 15px;
    font-style: italic;
}

@media (max-width: 768px) {
    .stats-bar {
        flex-direction: column;
        gap: 20px;
    }
    
    .btn-secondary {
        width: 100%;
    }
    
    .setup-options {
        flex-direction: column;
    }
    
    /* Year view on mobile - show as weeks */
    .life-grid.year-view {
        grid-template-columns: repeat(7, 1fr);
        gap: 2px;
    }
    
    /* Life view on mobile - show decades that expand */
    .life-grid.life-view {
        display: flex;
        flex-direction: column;
        gap: 10px;
        overflow-x: visible;
    }
    
    .day-box {
        width: 100%;
        height: 40px;
        min-width: 40px;
        font-size: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Decade groups for life view on mobile */
    .decade-group {
        background: var(--bg-secondary);
        border-radius: 8px;
        padding: 10px;
        box-shadow: 0 2px 5px var(--shadow-color);
    }
    
    .decade-header {
        font-weight: bold;
        padding: 10px;
        background: var(--btn-help-bg);
        color: white;
        border-radius: 5px;
        margin-bottom: 10px;
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .decade-header::after {
        content: '▼';
        font-size: 0.8rem;
        transition: transform 0.3s;
    }
    
    .decade-group.collapsed .decade-header::after {
        transform: rotate(-90deg);
    }
    
    .decade-content {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 2px;
    }
    
    .decade-group.collapsed .decade-content {
        display: none;
    }
    
    .time-display {
        padding: 20px;
    }
    
    #clock-time {
        font-size: 2rem;
    }
    
    .data-buttons {
        flex-direction: column;
    }
    
    .btn-data {
        width: 100%;
    }
}

/* Floating scroll buttons - primarily for mobile */
.scroll-buttons {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: 10px;
}

.scroll-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-btn:hover {
    background: var(--primary-color);
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

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

/* Privacy notice styles */
.privacy-notice {
    background: var(--privacy-bg);
    border: 1px solid var(--privacy-border);
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.privacy-notice h4 {
    color: var(--privacy-header);
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.privacy-notice ul {
    list-style: none;
    padding-left: 0;
}

.privacy-notice li {
    position: relative;
    padding-left: 24px;
    margin-bottom: 8px;
    color: var(--text-tertiary);
}

.privacy-notice li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: bold;
}

.privacy-notice .warning-text {
    margin-top: 15px;
    padding: 10px;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: 5px;
    color: var(--warning-text);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Philosophy section styles */
.philosophy-section {
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--bg-secondary) 100%);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 30px;
    margin-top: 30px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    box-shadow: 0 4px 12px var(--shadow-color);
}

.philosophy-section h3 {
    color: var(--primary-color);
    font-size: 1.3rem;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.philosophy-quote {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--header-color);
    margin: 20px 0;
    padding: 20px;
    border-left: 4px solid var(--primary-color);
    border-right: 4px solid var(--primary-color);
    font-style: italic;
}

.philosophy-section p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 15px;
}

.philosophy-section p:last-child {
    margin-bottom: 0;
    font-weight: 500;
    color: var(--text-primary);
}

/* Blog preview section */
.blog-preview {
    margin-top: 30px;
    padding: 0 20px;
}

.blog-preview h3 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.view-all-link {
    display: block;
    text-align: center;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 20px;
    transition: opacity 0.3s ease;
}

.view-all-link:hover {
    opacity: 0.7;
    text-decoration: underline;
}

.blog-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.blog-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-decoration: none;
    transition: all 0.3s ease;
    display: block;
}

.blog-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
    border-color: var(--primary-color);
}

.blog-card h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.blog-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.blog-card .read-more {
    color: var(--primary-color);
    font-weight: 500;
    font-size: 0.9rem;
}

/* Theme toggle styles */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 2px 8px var(--shadow-color);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.theme-icon {
    display: block;
    transition: transform 0.3s ease;
}

.theme-toggle:active .theme-icon {
    transform: rotate(30deg);
}

.theme-toggle:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.language-switcher {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
}

.language-switcher select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.language-switcher select:hover {
    border-color: var(--primary-color);
}

.language-switcher select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-color: var(--primary-color);
}

/* RTL adjustments */
[dir="rtl"] .theme-toggle {
    left: 20px;
    right: auto;
}

[dir="rtl"] .language-switcher {
    left: auto;
    right: 20px;
}

[dir="rtl"] .header-nav {
    direction: rtl;
}

[dir="rtl"] .container {
    direction: rtl;
}

/* Show on mobile when app is loaded */
@media (max-width: 768px) {
    .app-view .scroll-buttons {
        display: flex;
    }
}