/* Minimal Design System - Unified Styles */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Essential Monochrome Palette */
    --black: #000000;
    --white: #ffffff;
    --gray-light: #f8f8f8;
    --gray-medium: #999999;
    --gray-dark: #333333;
    
    /* Minimal Accent System */
    --accent: #555555;
    --accent-dim: rgba(85, 85, 85, 0.06);
    
    /* Typography Scale */
    --font-small: clamp(0.6875rem, 0.5vw + 0.65rem, 0.875rem);
    --font-base: clamp(0.75rem, 0.6vw + 0.7rem, 1rem);
    
    /* Unified Spacing System */
    --space-small: 0.25em;
    --space-base: 0.5em;
    --space-large: 3em;
    --space-article-gap: 1em;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --black: #ffffff; 
        --white: #0a0a0a;
        --gray-light: #111111;
        --gray-medium: #666666;
        --gray-dark: #cccccc;
        --accent: #888888;
        --accent-dim: rgba(136, 136, 136, 0.08);
    }
}

html { 
    font-size: 100%; 
    scroll-behavior: smooth; 
    text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
    font-size: var(--font-small); 
    font-weight: 400; 
    line-height: 1.3;
    color: var(--black); 
    background-color: var(--white);
    text-rendering: optimizeLegibility; 
    -webkit-font-smoothing: antialiased; 
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: 0.005em;
    word-spacing: 0.015em;
    font-feature-settings: "liga" 1;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: var(--space-base) var(--space-base);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-large);
}

@media (min-width: 641px) {
    .container {
        max-width: 1200px;
        padding: var(--space-large) var(--space-base);
    }
    
    .content-wrapper {
        gap: var(--space-large);
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1400px;
        padding: var(--space-large) var(--space-base);
    }
    
    .content-wrapper {
        display: grid;
        grid-template-columns: 1fr 80px;
        grid-template-rows: auto 1fr auto;
        gap: var(--space-large) var(--space-large);
        align-items: start;
    }
    
    header {
        grid-column: 1 / -1;
        grid-row: 1;
    }
    
    main {
        grid-column: 1;
        grid-row: 2;
        max-width: 100ch;
    }
    
    nav {
        grid-column: 2;
        grid-row: 2;
        position: sticky;
        top: var(--space-large);
        align-self: start;
    }
    
    footer {
        grid-column: 1 / -1;
        grid-row: 3;
        text-align: center;
    }
}

header {
    margin-bottom: var(--space-base);
    padding-bottom: var(--space-small);
}

@media (min-width: 641px) {
    header {
        padding-bottom: var(--space-base);
    }
}

.site-title {
    font-size: var(--font-small);
    font-weight: 400;
    letter-spacing: 0.005em;
    display: inline;
    text-transform: lowercase;
}

.site-title a {
    color: var(--black);
    text-decoration: none;
    transition: color 0.2s ease;
}

.site-title a:hover {
    color: var(--accent);
}

.site-meta {
    font-size: var(--font-small);
    color: var(--gray-medium);
    font-weight: 400;
    margin-left: var(--space-small);
    opacity: 0.7;
}

@media (min-width: 641px) {
    .site-meta {
        margin-left: var(--space-base);
    }
}

nav {
    margin-top: var(--space-large);
}

@media (min-width: 1024px) {
    nav {
        margin-top: 0;
    }
}

.nav-list {
    list-style: none;
    display: flex;
    gap: var(--space-base);
    justify-content: flex-start;
}

@media (min-width: 1024px) {
    .nav-list {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-base);
    }
}

.nav-link {
    color: var(--gray-dark);
    text-decoration: none;
    font-size: var(--font-small);
    font-weight: 400;
    padding: var(--space-small) 0;
    position: relative;
    transition: color 0.15s ease;
}

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

.nav-link.active {
    color: var(--black);
    font-weight: 400;
}

main {
    margin-bottom: var(--space-base);
}

/* Posts styles */
.posts {
    list-style: none;
}

.post {
    margin-bottom: var(--space-base);
    position: relative;
}

.post:last-child {
    margin-bottom: 0;
}

.post-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: color 0.15s ease;
}

.post-link:hover .post-title {
    color: var(--accent);
}

.post-date {
    font-size: var(--font-small);
    color: var(--gray-medium);
    font-weight: 400;
    margin-bottom: var(--space-small);
    opacity: 0.9;
    font-variant-numeric: tabular-nums;
}

.post-title {
    font-size: var(--font-small);
    font-weight: 400;
    color: var(--black);
    letter-spacing: 0.005em;
    max-width: none;
}

@media (min-width: 641px) {
    .post-title {
        max-width: 28ch;
    }
}


/* About page styles */
.tagline {
    margin-bottom: var(--space-large);
}

.cv {
    margin-bottom: var(--space-base);
}

.contact {
    margin-bottom: var(--space-large);
}

.contact p {
    font-size: var(--font-small);
    color: var(--black);
    margin-bottom: var(--space-small);
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.contact p:last-child {
    margin-bottom: var(--space-small);
}

.cv-title {
    font-size: var(--font-small);
    font-weight: 500;
    color: var(--black);
    margin-bottom: var(--space-base);
    margin-top: var(--space-large);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.cv-title:first-child {
    margin-top: 0;
}

.cv-item {
    display: grid;
    grid-template-columns: 2.7rem 1fr;
    gap: var(--space-small);
    margin-bottom: var(--space-small);
    align-items: baseline;
    line-height: 1.3;
}

.cv-year {
    font-size: var(--font-small);
    color: var(--black);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    opacity: 0.9;
}

.cv-description {
    font-size: var(--font-small);
    color: var(--black);
    font-weight: 400;
}

/* Article page styles */
.back-link {
    color: var(--black);
    text-decoration: none;
    font-size: var(--font-small);
    margin-bottom: var(--space-article-gap);
    display: inline-block;
    transition: color 0.15s ease;
}

.back-link:hover {
    color: var(--accent);
}


.article-header {
    margin-bottom: var(--space-article-gap);
    max-width: 65ch;
}

.article-date {
    font-size: var(--font-small);
    color: var(--gray-medium);
    font-weight: 400;
    opacity: 0.8;
}

.article-title {
    font-size: var(--font-small);
    font-weight: 400;
    margin-bottom: 0;
    color: var(--black);
    letter-spacing: 0.005em;
    max-width: 25ch;
}

.article-content p {
    margin-bottom: var(--space-base);
    font-size: var(--font-small);
    max-width: 80ch;
    color: var(--black);
    font-weight: 400;
    white-space: pre-line;
    line-height: 1.3;
}

.article-content a {
    color: var(--black);
    text-decoration: underline;
    text-decoration-color: var(--accent);
}

.article-content a:hover {
    color: var(--accent);
}

.footnotes {
    margin-top: var(--space-large);
    padding-top: var(--space-large);
    font-size: var(--font-small);
    color: var(--gray-dark);
}

.footnotes p {
    max-width: 65ch;
    border-top: 1px solid var(--gray-medium);
    padding-top: var(--space-large);
    margin-top: calc(-1 * var(--space-large));
}


footer {
    font-size: var(--font-small);
    color: var(--gray-medium);
    text-align: right;
    margin-top: var(--space-large);
    padding-top: var(--space-base);
    opacity: 0.7;
}

@media (min-width: 1024px) {
    footer {
        text-align: center;
    }
}

/* Accessibility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

::selection {
    background-color: var(--accent);
    color: var(--white);
}

/* Transitions */
* {
    transition: color 0.15s ease, 
               border-color 0.15s ease, 
               opacity 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* Mobile specific spacing and scroll control */
@media (max-width: 640px) {
    body {
        overflow: hidden;
        height: 100vh;
    }
    
    html {
        overflow: hidden;
        height: 100vh;
    }
    
    .container {
        height: 100vh;
        overflow: hidden;
    }
    
    .content-wrapper {
        gap: 2.5em;
        position: relative;
        height: 100vh;
        overflow: hidden;
    }
    
    header {
        margin-bottom: 2.5em;
    }
    
    /* Nav positioning - all pages */
    nav {
        position: absolute;
        top: 0;
        right: 0;
        margin-top: 0;
    }
}

@media (max-width: 640px) {
    html.allow-scroll,
    html.allow-scroll body,
    html.allow-scroll .container,
    html.allow-scroll .content-wrapper {
      overflow: auto;  /* 既存の overflow: hidden を打ち消す */
      height: auto;    /* 既存の height: 100vh を打ち消す */
    }
  }