/* Define theme variables */
:root {
    --bg: #f5f7fa;
    --text: #222;
    --card-bg: #ffffff;
    --accent: #3a7bd5;
    --accent-dark: #1e4e91;
    --hover: #2f68b3;
    --border: #e0e0e0;
}

body.dark {
    --bg: #121212;
    --text: #e0e0e0;
    --card-bg: #1e1e1e;
    --accent: #90caf9;
    --accent-dark: #42a5f5;
    --hover: #1976d2;
    --border: #333;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: background 0.3s, color 0.3s;
}

/* Top nav (tabs + toggle) */
#topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--accent);
    color: white;
    padding: 10px;
}

#tabs {
    display: flex;
    flex-wrap: wrap;
}

#tabs div {
    margin-right: 20px;
    padding: 8px 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.3s;
}

#tabs div:hover {
    background: var(--hover);
}

#tabs .active {
    background: var(--accent-dark);
}

/* Toggle button */
#mode-toggle {
    cursor: pointer;
    background: transparent;
    border: 1px solid white;
    border-radius: 20px;
    padding: 6px 12px;
    color: white;
    font-size: 0.9rem;
    transition: background 0.3s;
}

#mode-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Main layout */
#main {
    flex: 1;
    display: flex;
    padding: 20px;
    gap: 20px;
    overflow: hidden;
}

/* Notes area */
#notes-container {
    flex: 3;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    padding: 20px;
    overflow-y: auto;
    transition: background 0.3s;
}

#notes h2 {
    color: var(--accent);
}

#notes h2,
#notes h3 {
    scroll-margin-top: 15px;
    /* adjust height (px) */
}

#notes a {
    text-decoration: none;
    color: var(--accent);
}

#notes a:hover {
    text-decoration: underline;
}

/* TOC area */
#toc {
    flex: 1;
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    max-width: 250px;
    transition: background 0.3s;
}

#toc h3 {
    margin-top: 0;
    font-size: 1rem;
    color: var(--text);
}

#toc ul {
    list-style: none;
    padding-left: 0;
}

#toc li {
    margin: 6px 0;
}

#toc a {
    text-decoration: none;
    color: var(--accent);
}

#toc a:hover {
    text-decoration: underline;
}

@media screen and (max-width:680px) {
    #main {
        flex-direction: column;
    }
}