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

:root {
    --paragraph-font-size-multiplier: 1;
}

body {
    font-family: 'Amiri', serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    display: grid;
    grid-template-columns: 300px 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: 
        "header header"
        "sidebar main"
        "footer footer";
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Theme Variables */
body[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #1a1a1a;
    --bg-accent: #252525;
    --text-primary: #e3e3e3;
    --text-secondary: #888;
    --border-color: #333;
    --scrollbar-track: #1a1a1a;
    --scrollbar-thumb: #444;
    --scrollbar-thumb-hover: #555;
}

body[data-theme="sunset"] {
    --bg-primary: #2a1a3e;
    --bg-secondary: #3d2b52;
    --bg-tertiary: #4f3566;
    --bg-accent: #6b4b7a;
    --text-primary: #f5d7e8;
    --text-secondary: #c49db8;
    --border-color: #8a5c9c;
    --scrollbar-track: #3d2b52;
    --scrollbar-thumb: #8a5c9c;
    --scrollbar-thumb-hover: #a066b7;
}

body[data-theme="ocean"] {
    --bg-primary: #0a1828;
    --bg-secondary: #1a3b4d;
    --bg-tertiary: #2a5971;
    --bg-accent: #3a7896;
    --text-primary: #c7e9f1;
    --text-secondary: #7db3c9;
    --border-color: #4a97bb;
    --scrollbar-track: #1a3b4d;
    --scrollbar-thumb: #4a97bb;
    --scrollbar-thumb-hover: #5bb6df;
}

body[data-theme="forest"] {
    --bg-primary: #1a2b1a;
    --bg-secondary: #2d4a2d;
    --bg-tertiary: #3f683f;
    --bg-accent: #528752;
    --text-primary: #e8f5e8;
    --text-secondary: #a8d4a8;
    --border-color: #65a665;
    --scrollbar-track: #2d4a2d;
    --scrollbar-thumb: #65a665;
    --scrollbar-thumb-hover: #7bc47b;
}

body[data-theme="cream"] {
    --bg-primary: #f7f3e9;
    --bg-secondary: #e8dcc0;
    --bg-tertiary: #d4c5a0;
    --bg-accent: #c7b299;
    --text-primary: #3c2e26;
    --text-secondary: #8b7355;
    --border-color: #c7b299;
    --scrollbar-track: #e8dcc0;
    --scrollbar-thumb: #c7b299;
    --scrollbar-thumb-hover: #b5a085;
}

body[data-theme="warm"] {
    --bg-primary: #2c2416;
    --bg-secondary: #3d3424;
    --bg-tertiary: #4a3f2a;
    --bg-accent: #5c4f35;
    --text-primary: #e8dcc0;
    --text-secondary: #b5a085;
    --border-color: #5c4f35;
    --scrollbar-track: #3d3424;
    --scrollbar-thumb: #5c4f35;
    --scrollbar-thumb-hover: #6b5940;
}

body[data-theme="matrix"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-accent: #30363d;
    --text-primary: #00ff41;
    --text-secondary: #39ff14;
    --border-color: #00b33c;
    --scrollbar-track: #161b22;
    --scrollbar-thumb: #00b33c;
    --scrollbar-thumb-hover: #00ff41;
}

header {
    grid-area: header;
    background-color: var(--bg-secondary);
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    transition: transform 0.3s ease;
}

header h1 {
    font-size: 2.5rem;
    margin: 0;
    color: var(--text-primary);
}

aside {
    grid-area: sidebar;
    background-color: var(--bg-tertiary);
    padding: 20px 0;
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
}

.sidebar-controls {
    padding: 15px 20px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 10px;
}

.font-controls, .theme-controls {
    margin-bottom: 15px;
}

.font-controls:last-child, .theme-controls:last-child {
    margin-bottom: 0;
}

.sidebar-controls label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: bold;
}

.font-controls button {
    background-color: var(--bg-accent);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 35px;
    height: 35px;
    margin: 0 5px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.2s ease;
}

.font-controls button:hover {
    background-color: var(--bg-secondary);
    transform: scale(1.1);
}

.theme-buttons {
    display: flex;
    gap: 8px;
}

.theme-btn {
    width: 30px;
    height: 30px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.theme-btn:hover {
    transform: scale(1.1);
    border-width: 3px;
}

.theme-btn.active {
    border-width: 3px;
    box-shadow: 0 0 0 2px var(--text-primary);
}

.theme-btn[data-theme="dark"] {
    background: linear-gradient(45deg, #121212, #1e1e1e);
}

.theme-btn[data-theme="sunset"] {
    background: linear-gradient(45deg, #8a5c9c, #c49db8);
}

.theme-btn[data-theme="ocean"] {
    background: linear-gradient(45deg, #1a3b4d, #4a97bb);
}

.theme-btn[data-theme="forest"] {
    background: linear-gradient(45deg, #2d4a2d, #65a665);
}

.theme-btn[data-theme="cream"] {
    background: linear-gradient(45deg, #f7f3e9, #e8dcc0);
}

.theme-btn[data-theme="warm"] {
    background: linear-gradient(45deg, #2c2416, #3d3424);
}

.theme-btn[data-theme="matrix"] {
    background: linear-gradient(45deg, #0d1117, #161b22);
    border-color: #00b33c;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li {
    border-bottom: 1px solid var(--border-color);
}

.sidebar-nav li a {
    display: block;
    padding: 15px 20px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.2rem;
    transition: background-color 0.3s;
}

.sidebar-nav li a:hover, .sidebar-nav li a.active {
    background-color: var(--bg-accent);
    color: var(--text-primary);
}

main {
    grid-area: main;
    padding: 30px;
    overflow-y: auto;
    max-height: calc(100vh - 80px - 40px);
}

.content-section {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.content-section.active {
    display: block;
}

.content-section h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.content-section p {
    font-size: calc(1.4rem * var(--paragraph-font-size-multiplier));
    line-height: 2.2;
    margin-bottom: 20px;
    text-align: right;
    letter-spacing: 0.01em;
}

footer {
    grid-area: footer;
    background-color: var(--bg-secondary);
    padding: 10px 20px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Mobile menu toggle button */
.menu-toggle {
    display: none;
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-accent);
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    z-index: 100;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

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

/* Responsive design */
@media (max-width: 768px) {
    header.hidden {
        transform: translateY(-100%);
    }
    
    body {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr auto;
        grid-template-areas: 
            "header"
            "sidebar"
            "main"
            "footer";
        overflow: auto;
    }
    
    aside {
        border-left: none;
        border-bottom: 1px solid #333;
        display: block;
        max-height: unset;
        transition: max-height 0.3s ease;
    }
    
    main {
        max-height: none;
        padding: 20px;
    }
    
    .menu-toggle {
        display: block;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .content-section h2 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }
    
    .content-section p {
        font-size: calc(1.1rem * var(--paragraph-font-size-multiplier));
        line-height: 1.8;
    }
    
    .sidebar-nav li a {
        padding: 12px 15px;
        font-size: 1rem;
    }
}

/* Mobile phone specific */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
        padding: 0 40px;
    }
    
    main {
        padding: 15px;
    }
    
    .content-section h2 {
        font-size: 1.3rem;
        padding-bottom: 10px;
        margin-bottom: 10px;
    }
    
    .content-section p {
        font-size: calc(0.95rem * var(--paragraph-font-size-multiplier));
        line-height: 1.7;
    }
    
    .sidebar-nav li a {
        padding: 10px;
        font-size: 0.9rem;
    }
    
    .menu-toggle {
        font-size: 1.2rem;
        padding: 4px 8px;
    }
}
