/* ===== リセット・基本スタイル ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: auto;
    scroll-padding-top: 70px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'メイリオ', sans-serif;
    line-height: 1.8;
    color: #333;
    background-color: #f6f6f6;
    font-size: 15px;
}

a {
    color: #cf7a48;
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #e08850;
}

/* ===== グローバルヘッダー ===== */
.global-header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    font-size: 1.3rem;
    font-weight: bold;
}

.site-logo a {
    color: #d4813a;
    display: flex;
    align-items: center;
    gap: 6px;
}

.site-logo a:hover {
    color: #e8944a;
    text-decoration: none;
}

/* ===== 検索ボックス ===== */
.header-search {
    position: relative;
    width: 280px;
}

.header-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #f8f8f8;
    transition: all 0.2s;
}

.header-search input:focus {
    outline: none;
    border-color: #d4813a;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(212, 129, 58, 0.1);
}

.header-search input::placeholder {
    color: #999;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-top: 4px;
    display: none;
    z-index: 200;
    max-height: 300px;
    overflow-y: auto;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #faf8f6;
}

.search-result-item .title {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.search-result-item .excerpt {
    font-size: 0.85rem;
    color: #888;
}

.search-no-result {
    padding: 16px;
    text-align: center;
    color: #888;
    font-size: 0.9rem;
}

.search-result-item mark {
    background: #fff3cd;
    color: #856404;
    padding: 0 2px;
    border-radius: 2px;
}

/* ===== メインレイアウト ===== */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 32px;
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
    min-height: calc(100vh - 56px - 80px);
}

/* ===== 左サイドバー ===== */
.sidebar-left {
    position: sticky;
    top: 80px;
    height: fit-content;
}

.sidebar-section {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.sidebar-title {
    font-size: 0.85rem;
    color: #888;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.sidebar-list {
    list-style: none;
}

.sidebar-list li {
    margin-bottom: 4px;
}

.sidebar-list a {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: #333;
    font-size: 0.9rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.sidebar-list a:hover {
    background: #fef6ee;
    color: #cf7a48;
    text-decoration: none;
}

.sidebar-list li.active a {
    background: #fff3e8;
    color: #cf7a48;
    font-weight: 600;
}

/* NEWバッジ */
.new-badge {
    background: #e74c3c;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* カテゴリ一覧 */
.category-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    max-height: calc(100vh - 200px);
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.category-list.expanded {
    max-height: none;
    overflow: visible;
}

.category-list li {
    margin-bottom: 0;
}

.category-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    font-size: 0.85rem;
}

.category-name {
    flex: 1;
}

.category-count {
    background: #f0e8e0;
    color: #888;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.sidebar-list a:hover .category-count {
    background: #ffe8d8;
    color: #cf7a48;
}

/* もっと見るボタン */
.category-more {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    background: #fef6ee;
    border: 1px solid #f0e0d0;
    border-radius: 6px;
    color: #cf7a48;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.category-more:hover {
    background: #fff3e8;
    border-color: #cf7a48;
}

.sidebar-text {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.7;
    margin-bottom: 12px;
}

.sidebar-links {
    list-style: none;
}

.sidebar-links li {
    margin-bottom: 8px;
}

.sidebar-links a {
    display: block;
    padding: 10px 12px;
    background: #fff8f0;
    border: 1px solid #f0e0d0;
    border-radius: 6px;
    color: #333;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.sidebar-links a:hover {
    background: #fff3e8;
    border-color: #e0c0a0;
    color: #cf7a48;
    text-decoration: none;
}

/* ===== メインコンテンツ ===== */
.main-content {
    min-width: 0;
}

#content {
    background: #fff;
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.loading {
    text-align: center;
    color: #888;
    padding: 40px;
}

/* ===== 記事ヘッダー ===== */
.article-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid #eee;
}

.article-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #333;
    line-height: 1.4;
    margin-bottom: 12px;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #888;
    font-size: 0.85rem;
}

.article-meta .date {
    display: flex;
    align-items: center;
    gap: 4px;
}

.article-meta .players {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 棋譜記事の追加情報 */
.kifu-info {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 16px;
    background: #faf8f6;
    border-radius: 6px;
    margin-bottom: 24px;
    font-size: 0.9rem;
    color: #666;
}

.kifu-info-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.kifu-article .shogi-container {
    margin: 0;
}

/* ===== 記事本文 ===== */
.article-content {
    font-size: 1rem;
    line-height: 1.9;
}

.article-content h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #333;
    margin: 40px 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0e6dc;
}

.article-content h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #333;
    margin: 32px 0 12px;
}

.article-content p {
    margin: 16px 0;
}

.article-content ul,
.article-content ol {
    margin: 16px 0;
    padding-left: 24px;
}

.article-content li {
    margin: 8px 0;
}

.article-content blockquote {
    margin: 24px 0;
    padding: 16px 20px;
    background: #faf8f6;
    border-left: 4px solid #d4813a;
    color: #555;
    border-radius: 0 4px 4px 0;
}

.article-content code {
    background: #f6f6f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SFMono-Regular', 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: #d4813a;
}

.article-content pre {
    margin: 24px 0;
    padding: 20px;
    background: #282c34;
    color: #abb2bf;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.6;
}

.article-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.article-content strong {
    font-weight: 700;
    color: #333;
}

.article-content img {
    max-width: 100%;
    border-radius: 4px;
}

/* ===== 記事一覧（トップページ） ===== */
.post-list-page {
    list-style: none;
}

.post-card {
    padding: 24px;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

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

.post-card:hover {
    background: #fdfbf9;
}

.post-card {
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}

.post-card h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.post-card h2 a {
    color: #333;
}

.post-card h2 a:hover {
    color: #cf7a48;
}

.post-card .meta {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.post-card .excerpt {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* 表示切替 */
.view-toggle {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 16px;
}

.view-toggle button {
    padding: 6px 12px;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #666;
    transition: all 0.2s;
}

.view-toggle button:hover {
    border-color: #cf7a48;
    color: #cf7a48;
}

.view-toggle button.active {
    background: #cf7a48;
    border-color: #cf7a48;
    color: #fff;
}

/* タイル表示 */
.post-list-page.tile-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.post-list-page.tile-view .post-card {
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.post-list-page.tile-view .post-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #ddd;
}

/* ===== タグ ===== */
.tags {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: 8px;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: #fff3e8;
    color: #cf7a48;
    font-size: 0.75rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.tag:hover {
    background: #cf7a48;
    color: #fff;
}

.tag.active {
    background: #cf7a48;
    color: #fff;
}

.filter-info {
    padding: 12px 16px;
    background: #fff8f0;
    border: 1px solid #f0e0d0;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    color: #666;
}

.clear-filter {
    margin-left: 12px;
    color: #cf7a48;
    font-size: 0.85rem;
}

.clear-filter:hover {
    color: #e08850;
}

/* ===== フッター ===== */
.global-footer {
    background: #fff;
    border-top: 1px solid #e0e0e0;
    text-align: center;
    padding: 24px;
    color: #888;
    font-size: 0.85rem;
}

/* ===== レスポンシブ ===== */
@media (max-width: 900px) {
    .main-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar-left {
        position: static;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 16px;
    }
    
    .sidebar-section {
        margin-bottom: 0;
    }
}

@media (max-width: 600px) {
    .header-inner {
        padding: 0 16px;
        flex-direction: column;
        height: auto;
        padding: 12px 16px;
        gap: 10px;
    }
    
    .header-search {
        width: 100%;
    }
    
    .main-container {
        padding: 16px;
    }
    
    #content {
        padding: 20px;
    }
    
    .article-header h1 {
        font-size: 1.4rem;
    }
    
    .sidebar-left {
        grid-template-columns: 1fr;
    }
    
    .category-list {
        grid-template-columns: 1fr;
    }
    
    .post-list-page.tile-view {
        grid-template-columns: 1fr;
    }
}
