:root {
    color-scheme: light dark;

    /* Warmer Japanese-inspired neutral palette */
    --bg-primary: light-dark(#fffffc, #0f0f0f);
    --bg-secondary: light-dark(#f8fbf8, #1a1a1a);
    --bg-tertiary: light-dark(#f3f3f2, #2a2a2a);
    --text-primary: light-dark(#2a2a2a, #f3f3f2);
    --text-secondary: light-dark(#6a6a6a, #a8a8a8);
    --border-color: light-dark(#e7e7eb, #3a3a3a);
    --accent: light-dark(#8b5a3c, #d4a574);

    /* Texture properties - subtle for auto mode */
    --texture-opacity: light-dark(0.02, 0.04);

    /* Legacy variable mappings for compatibility */
    --text: var(--text-primary);
    --bg: var(--bg-primary);
    --gray: var(--text-secondary);
    --light-gray: var(--bg-secondary);
    --max-width: 680px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    padding: 2rem 1rem;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Auto mode texture - explicit for light and dark */
@media (prefers-color-scheme: light) {
    body {
        background-image: radial-gradient(circle at 1px 1px, rgba(0,0,0,0.04) 1px, transparent 0);
        background-size: 16px 16px;
    }
}

@media (prefers-color-scheme: dark) {
    body {
        background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.06) 1px, transparent 0);
        background-size: 16px 16px;
    }
}

header {
    max-width: var(--max-width);
    margin: 0 auto 3rem;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--light-gray);
}

.home {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--accent);
}

main {
    max-width: var(--max-width);
    margin: 0 auto;
}

section {
    margin-bottom: 3rem;
}

h1 {
    font-size: 1.8rem;
    line-height: 1.3;
    margin-bottom: 1rem;
    font-weight: 600;
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.9em;
}

p {
    margin-bottom: 1rem;
}

.intro p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.featured {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: light-dark(
        0 2px 4px rgba(0, 0, 0, 0.05),
        0 2px 4px rgba(255, 255, 255, 0.05)
    );
    position: relative;
    overflow: hidden;
}

.featured::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
}

.links {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
}

.links a {
    color: var(--accent);
    text-decoration: none;
}

.links a:hover {
    text-decoration: underline;
}

.work ul, .blog-list {
    list-style: none;
}

.work li {
    margin-bottom: 0.75rem;
}

.blog-list li {
    margin-bottom: 0.5rem;
}

.blog-list a {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.blog-list a:hover {
    border-bottom-color: var(--accent);
}

.contact a {
    color: var(--accent);
    text-decoration: none;
}

.contact a:hover {
    text-decoration: underline;
}

/* Blog page styles */
.blog-header {
    margin-bottom: 2rem;
}

.blog-header h1 {
    font-size: 2rem;
}

.post {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--light-gray);
}

.post:last-child {
    border-bottom: none;
}

.post h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.post h2 a {
    color: var(--text);
    text-decoration: none;
}

.post h2 a:hover {
    color: var(--accent);
}

.post-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Social proof section */
.proof ul {
    list-style: none;
    display: grid;
    gap: 0.75rem;
}

.proof li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.proof strong {
    color: var(--accent);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.9em;
}

/* Technical elements with monospace */
.technical {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    background: var(--bg-secondary);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9em;
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: 4px;
    position: relative;
    min-width: 2rem;
}

.theme-toggle:hover {
    color: var(--accent);
}

.theme-icon {
    display: inline-block;
    width: 1.2em;
    text-align: center;
}

/* Manual theme overrides */
[data-theme="light"] {
    color-scheme: light;
    --bg-primary: #fffffc;
    --bg-secondary: #f8fbf8;
    --bg-tertiary: #f3f3f2;
    --text-primary: #2a2a2a;
    --text-secondary: #6a6a6a;
    --border-color: #e7e7eb;
    --accent: #8b5a3c;
    --texture-opacity: 0.04;
}

[data-theme="light"] body {
    background-image: radial-gradient(circle at 1px 1px, rgba(0,0,0,0.04) 1px, transparent 0);
    background-size: 16px 16px;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #f3f3f2;
    --text-secondary: #a8a8a8;
    --border-color: #3a3a3a;
    --accent: #d4a574;
    --texture-opacity: 0.06;
}

[data-theme="dark"] body {
    background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.06) 1px, transparent 0);
    background-size: 16px 16px;
}

.post-content {
    margin-bottom: 1rem;
}

.post-content h1 {
    font-size: 2rem;
    margin: 2rem 0 1rem;
}

.post-content h2 {
    font-size: 1.5rem;
    margin: 1.5rem 0 1rem;
}

.post-content h3 {
    font-size: 1.2rem;
    margin: 1rem 0 0.5rem;
}

.post-content pre {
    background: var(--light-gray);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1rem 0;
}

.post-content code {
    background: var(--light-gray);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.9em;
}

.post-content pre code {
    background: none;
    padding: 0;
}

.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
}

/* Coming Soon posts */
.post.coming-soon {
    opacity: 0.7;
    cursor: default;
}

.post.coming-soon h2 {
    color: var(--text-secondary);
}

.post.coming-soon h2 span {
    position: relative;
}

.post-preview {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 0.5rem;
}

@media (max-width: 600px) {
    body {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .links {
        flex-direction: column;
        gap: 0.5rem;
    }
}