:root {
    color-scheme: light;
    --bg: #ffffff;
    --text: #333333;
    --heading: #2c3e50;
    --heading-muted: #34495e;
    --link: #3498db;
    --link-hover: #2980b9;
    --nav-border: #eeeeee;
    --border: #dddddd;
    --input-bg: #ffffff;
    --snippet: #555555;
    --notice-bg: #d4edda;
    --notice-border: #c3e6cb;
    --notice-text: #155724;
    --table-header: #f8f9fa;
    --table-row: #f8f9fa;
    --code-bg: #f8f9fa;
    --blockquote-bg: #f8f9fa;
    --blockquote-border: #3498db;
    --button-bg: #3498db;
    --button-hover: #2980b9;
    --button-text: #ffffff;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #0f1115;
        --text: #e3e6ea;
        --heading: #e6edf3;
        --heading-muted: #c7d0d9;
        --link: #7fb9ff;
        --link-hover: #a7cfff;
        --nav-border: #2a2f36;
        --border: #2a2f36;
        --input-bg: #151a1f;
        --snippet: #a9b1ba;
        --notice-bg: #1e2a21;
        --notice-border: #2f5038;
        --notice-text: #b8f2c2;
        --table-header: #1a1f24;
        --table-row: #151a1f;
        --code-bg: #1a1f24;
        --blockquote-bg: #1a1f24;
        --blockquote-border: #7fb9ff;
        --button-bg: #2d6cdf;
        --button-hover: #2559b8;
        --button-text: #f5f8ff;
    }
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #ffffff;
    --text: #333333;
    --heading: #2c3e50;
    --heading-muted: #34495e;
    --link: #3498db;
    --link-hover: #2980b9;
    --nav-border: #eeeeee;
    --border: #dddddd;
    --input-bg: #ffffff;
    --snippet: #555555;
    --notice-bg: #d4edda;
    --notice-border: #c3e6cb;
    --notice-text: #155724;
    --table-header: #f8f9fa;
    --table-row: #f8f9fa;
    --code-bg: #f8f9fa;
    --blockquote-bg: #f8f9fa;
    --blockquote-border: #3498db;
    --button-bg: #3498db;
    --button-hover: #2980b9;
    --button-text: #ffffff;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1115;
    --text: #e3e6ea;
    --heading: #e6edf3;
    --heading-muted: #c7d0d9;
    --link: #7fb9ff;
    --link-hover: #a7cfff;
    --nav-border: #2a2f36;
    --border: #2a2f36;
    --input-bg: #151a1f;
    --snippet: #a9b1ba;
    --notice-bg: #1e2a21;
    --notice-border: #2f5038;
    --notice-text: #b8f2c2;
    --table-header: #1a1f24;
    --table-row: #151a1f;
    --code-bg: #1a1f24;
    --blockquote-bg: #1a1f24;
    --blockquote-border: #7fb9ff;
    --button-bg: #2d6cdf;
    --button-hover: #2559b8;
    --button-text: #f5f8ff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text);
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    background-color: var(--bg);
}

h1 {
    color: var(--heading);
    border-bottom: 2px solid var(--link);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

h2, h3, h4, h5, h6 {
    color: var(--heading-muted);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.nav {
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--nav-border);
}

.nav a,
.nav button {
    margin-right: 1rem;
    font-weight: 500;
}

.theme-toggle {
    background: none;
    border: none;
    padding: 0;
    margin-top: 0;
    color: var(--link);
    font: inherit;
    cursor: pointer;
}

.theme-toggle:hover {
    text-decoration: underline;
}

ul {
    padding-left: 1.5rem;
}

textarea {
    width: 100%;
    max-width: 100%;
    min-height: 400px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.4;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    resize: vertical;
    background-color: var(--input-bg);
    color: var(--text);
}

input[type="text"],
input[type="search"] {
    width: 100%;
    max-width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background-color: var(--input-bg);
    color: var(--text);
}

label {
    display: block;
    margin-top: 0.75rem;
    font-weight: 500;
}

button {
    background-color: var(--button-bg);
    color: var(--button-text);
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 1rem;
}

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

.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.search-form input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
    background-color: var(--input-bg);
    color: var(--text);
}

.snippet {
    color: var(--snippet);
    font-size: 0.95em;
    margin-top: 0.25rem;
}

.notice {
    background-color: var(--notice-bg);
    border: 1px solid var(--notice-border);
    color: var(--notice-text);
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
}

th, td {
    border: 1px solid var(--border);
    padding: 0.75rem;
    text-align: left;
}

th {
    background-color: var(--table-header);
    font-weight: 600;
}

tr:nth-child(even) {
    background-color: var(--table-row);
}

code {
    background-color: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

pre {
    background-color: var(--code-bg);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
}

pre code {
    background-color: transparent;
    padding: 0;
}

blockquote {
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    border-left: 4px solid var(--blockquote-border);
    background-color: var(--blockquote-bg);
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    body {
        padding: 0.5rem;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    h1 {
        font-size: 1.5rem;
    }

    textarea {
        min-height: 300px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    button {
        width: 100%;
        padding: 1rem;
    }

    table {
        font-size: 14px;
    }

    th, td {
        padding: 0.5rem;
    }
}
