body {
    max-width: 800px;
    margin: 50px auto;
    padding: 0 20px;
    font-family: system-ui;
    line-height: 1.6;
}
img { max-width: 100%; }
code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
}
pre code {
    display: block;
    padding: 12px;
}

body {
    margin: 0;
    display: flex;
}

#outline {
    width: 250px;
    height: 100vh;
    position: fixed;
    left: -250px;
    top: 0;
    background: #f8f8f8;
    border-right: 1px solid #ddd;
    padding: 20px;
    overflow-y: auto;
    transition: left 0.3s;
    z-index: 999;
}

#outline.active {
    left: 0;
}

#outline-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    z-index: 1000;
}

#outline h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #666;
}

#outline a {
    display: block;
    padding: 4px 0;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
}

#outline a:hover {
    color: #0066cc;
}

#outline .h2 { padding-left: 12px; }
#outline .h3 { padding-left: 24px; }
#outline .h4 { padding-left: 36px; }
#outline .h5 { padding-left: 48px; }
#outline .h6 { padding-left: 60px; }

#content {
    max-width: 800px;
    margin: 50px auto;
    padding: 0 20px;
    flex: 1;
}

#custom-search {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    display: none;
    z-index: 1000;
}

#custom-search.active {
    display: flex;
    gap: 8px;
    align-items: center;
}

#search-input {
    border: 1px solid #ccc;
    padding: 6px 10px;
    border-radius: 4px;
    outline: none;
}

#search-input:focus {
    border-color: #0066cc;
}

.search-count {
    color: #666;
    font-size: 14px;
}

mark.highlight {
    background-color: yellow;
    padding: 0;
}

mark.current-highlight {
    background-color: orange;
}

button {
    border: none;
    background: #f0f0f0;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
}

button:hover {
    background: #e0e0e0;
}

/* Dark Mode with Native CSS */
:root {
    --bg: #ffffff;
    --text: #000000;
    --border: #ddd;
    --surface: #f8f8f8;
    --surface-hover: #e0e0e0;
    --input-bg: #ffffff;
    --link: #0066cc;
    --highlight: yellow;
    --highlight-current: orange;
    --code-bg: #f4f4f4;
    --secondary-text: #666;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a1a;
        --text: #e0e0e0;
        --border: #444;
        --surface: #2d2d2d;
        --surface-hover: #3d3d3d;
        --input-bg: #1a1a1a;
        --link: #4da6ff;
        --highlight: #665500;
        --highlight-current: #cc6600;
        --code-bg: #2d2d2d;
        --secondary-text: #999;
    }
}

/* Manual override with data attribute */
[data-theme="light"] {
    --bg: #ffffff;
    --text: #000000;
    --border: #ddd;
    --surface: #f8f8f8;
    --surface-hover: #e0e0e0;
    --input-bg: #ffffff;
    --link: #0066cc;
    --highlight: yellow;
    --highlight-current: orange;
    --code-bg: #f4f4f4;
    --secondary-text: #666;
}

[data-theme="dark"] {
    --bg: #1a1a1a;
    --text: #e0e0e0;
    --border: #444;
    --surface: #2d2d2d;
    --surface-hover: #3d3d3d;
    --input-bg: #1a1a1a;
    --link: #4da6ff;
    --highlight: #665500;
    --highlight-current: #cc6600;
    --code-bg: #2d2d2d;
    --secondary-text: #999;
}

body {
    background: var(--bg);
    color: var(--text);
    color-scheme: light dark;
}

#content {
    color: var(--text);
}

#outline {
    background: var(--surface);
    border-right-color: var(--border);
}

#outline h3 {
    color: var(--secondary-text);
}

#outline a {
    color: var(--text);
}

#outline a:hover {
    color: var(--link);
}

#outline-toggle,
#reading-time,
#custom-search,
#dark-mode-toggle {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

#search-input {
    background: var(--input-bg);
    border-color: var(--border);
    color: var(--text);
}

#search-input:focus {
    border-color: var(--link);
}

button {
    background: var(--surface);
    color: var(--text);
}

button:hover {
    background: var(--surface-hover);
}

mark.highlight {
    background-color: var(--highlight);
}

mark.current-highlight {
    background-color: var(--highlight-current);
}

code {
    background: var(--code-bg);
    color: var(--text);
}

pre {
    background: var(--code-bg);
    border-color: var(--border);
}

a {
    color: var(--link);
}

.heading-anchor {
    color: var(--secondary-text);
}

.heading-anchor:hover {
    color: var(--link);
}

.search-count {
    color: var(--secondary-text);
}

#dark-mode-toggle span {
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    transition: background 0.3s, color 0.3s;
}

[data-theme="light"] #dark-mode-toggle .light,
:root:not([data-theme]) #dark-mode-toggle .light {
    background: var(--surface-hover);
}

[data-theme="dark"] #dark-mode-toggle .dark {
    background: var(--surface-hover);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) #dark-mode-toggle .dark {
        background: var(--surface-hover);
    }
    :root:not([data-theme]) #dark-mode-toggle .light {
        background: transparent;
    }
}

/* Reading Progress Bar */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: #0066cc;
    z-index: 9999;
    transition: width 0.1s ease;
}

/* Reading Time Estimate */
#reading-time {
    position: fixed;
    top: 80px;
    left: 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    color: #666;
    z-index: 998;
}
