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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.8;
    color: #333;
    background: #f8f9fa;
}

header {
    background: #1a1a2e;
    padding: 1rem 2rem;
}

header nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

header nav a {
    color: #fff;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: bold;
    white-space: nowrap;
}

.header-search {
    margin-left: auto;
    max-width: 320px;
}

.header-search input {
    width: 100%;
    padding: 0.4rem 0.8rem;
    border: 1px solid #e8e8f0;
    border-radius: 6px;
    font-size: 0.85rem;
    background: #fff;
    color: #333;
    outline: none;
    transition: border-color 0.2s;
}

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

.header-search input:focus {
    border-color: #e94560;
}

/* 2カラムレイアウト */
.layout {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

main {
    flex: 1;
    min-width: 0;
    padding: 2rem 3rem;
    overflow-y: auto;
}

/* サイドバー */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e8e8f0;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.sidebar-nav h3 {
    font-size: 1rem;
    margin-bottom: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e94560;
    color: #1a1a2e;
}

.sidebar-item {
    margin-bottom: 2px;
}

.sidebar-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
}

.sidebar-label:hover {
    background: #e8e8f0;
}

.sidebar-label .toggle {
    font-size: 0.7rem;
    color: #888;
    cursor: pointer;
    user-select: none;
    width: 1rem;
    text-align: center;
}

.sidebar-label a,
.sidebar-label .folder-name {
    color: #333;
    text-decoration: none;
    font-size: 0.9rem;
}

.sidebar-label a:hover,
.sidebar-label .folder-name:hover {
    color: #e94560;
}

.sidebar-children {
    padding-left: 1.2rem;
}

.sidebar-article a {
    color: #555;
    text-decoration: none;
    font-size: 0.85rem;
    display: block;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
}

.sidebar-article a:hover {
    background: #e8e8f0;
    color: #e94560;
}

.sidebar-admin-link {
    display: block;
    color: #555;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
}

.sidebar-admin-link:hover {
    background: #e8e8f0;
    color: #e94560;
}

footer {
    text-align: center;
    padding: 2rem;
    color: #888;
    font-size: 0.85rem;
}

h1 { font-size: 1.8rem; margin-bottom: 1rem; }

/* パンくず */
.breadcrumb {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 1.5rem;
}

.breadcrumb a {
    color: #e94560;
    text-decoration: none;
}

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

/* 記事一覧 */
.article-list { display: flex; flex-direction: column; gap: 1.5rem; }

.article-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.article-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.article-card-body { padding: 1.2rem; }

.article-card h2 {
    font-size: 1.2rem;
    margin: 0.5rem 0;
}

.article-card h2 a {
    color: #1a1a2e;
    text-decoration: none;
}

.article-card h2 a:hover { color: #e94560; }

.article-card p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.article-card time {
    color: #999;
    font-size: 0.8rem;
}

.category {
    display: inline-block;
    background: #e94560;
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* 記事詳細 */
.article-detail {
    background: #fff;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.article-detail header { background: none; padding: 0 0 1.5rem 0; border-bottom: 1px solid #eee; margin-bottom: 1.5rem; }
.article-detail header h1 { color: #1a1a2e; margin-top: 0.5rem; }
.article-detail header time { color: #999; font-size: 0.85rem; }

.article-content p { margin-bottom: 16px; }
.article-content h2 { font-size: 1.25rem; margin: 56px 0 18px; padding-bottom: 8px; border-bottom: 2px solid #e8eaf0; color: #1a1a1a; }
.article-content h3 { font-size: 1rem; margin: 24px 0 10px; color: #2a2a2a; font-weight: 600; }
.article-content ul, .article-content ol { margin: 1rem 0; padding-left: 1.5rem; }
.article-content code { font-family: "SF Mono", "Fira Code", "Consolas", monospace; background: #f0f1f6; padding: 2px 7px; border-radius: 4px; font-size: 0.87em; color: #c7254e; }
.article-content pre { background: #1e2029; color: #e4e6eb; padding: 18px 20px; border-radius: 6px; overflow-x: auto; font-size: 0.87rem; line-height: 1.7; margin-bottom: 18px; white-space: pre-wrap; word-wrap: break-word; }
.article-content pre code { background: none; color: inherit; padding: 0; }
.article-content strong { color: #1a1a1a; }

/* 記事内: コードブロック */
.article-content .code-block { position: relative; margin-bottom: 18px; }
.article-content .code-block .where { display: inline-block; font-size: 0.72rem; font-weight: 600; color: #888; background: #2a2d3a; padding: 4px 12px; border-radius: 6px 6px 0 0; }
.article-content .code-block pre { border-radius: 0 6px 6px 6px; margin-top: 0; }
.article-content .code-block .copy-btn { position: absolute; top: 30px; right: 8px; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2); color: #aaa; font-size: 0.72rem; padding: 3px 10px; border-radius: 4px; cursor: pointer; transition: all 0.15s; }
.article-content .code-block .copy-btn:hover { background: rgba(255,255,255,0.2); color: #ddd; }
.article-content .cm { color: #6a737d; }

/* 記事内: 出力ブロック */
.article-content .output { background: #fef2f2; color: #991b1b; border-left: 4px solid #ef4444; padding: 12px 16px; border-radius: 0 4px 4px 0; margin-bottom: 18px; font-family: "SF Mono", "Fira Code", "Consolas", monospace; font-size: 0.87rem; line-height: 1.6; }
.article-content .output.success { background: #f0fdf4; color: #166534; border-left-color: #22c55e; }
.article-content .output.danger { background: #fef2f2; color: #991b1b; border-left-color: #ef4444; }

/* 記事内: ボックス */
.article-content .info-box { background: #f0f7ff; border: 1px solid #bfdbfe; border-radius: 6px; padding: 16px 20px; margin-bottom: 18px; font-size: 0.93rem; }
.article-content .info-box .info-title { font-weight: 700; color: #1e40af; margin-bottom: 6px; font-size: 0.88rem; }
.article-content .warn-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 16px 20px; margin-bottom: 18px; font-size: 0.93rem; }
.article-content .warn-box .warn-title { font-weight: 700; color: #92400e; margin-bottom: 6px; font-size: 0.88rem; }
.article-content .caution-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 16px 20px; margin-bottom: 18px; font-size: 0.93rem; }
.article-content .caution-box .caution-title { font-weight: 700; color: #92400e; margin-bottom: 6px; font-size: 0.88rem; }

/* 記事内: 対象読者・目次 */
.article-content .target-box { background: #f7f8fb; border: 1px solid #e8eaf0; border-radius: 6px; padding: 20px 24px; margin: 32px 0; }
.article-content .target-box h2 { font-size: 0.9rem; color: #555; margin: 0 0 10px; border: none; padding: 0; }
.article-content .toc { border: 1px solid #e0e0e0; border-radius: 6px; padding: 20px 24px; margin-bottom: 40px; }
.article-content .toc h2 { font-size: 0.9rem; color: #555; margin: 0 0 10px; border: none; padding: 0; }
.article-content .toc a { color: #3366cc; text-decoration: none; }
.article-content .toc a:hover { text-decoration: underline; }

/* 記事内: ステップラベル */
.article-content .step-label { display: inline-block; background: #3366cc; color: #fff; font-size: 0.75rem; font-weight: 700; padding: 2px 10px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }

/* 記事内: フロー図（小さなステップ表示用） */
.article-content .flow:not(:has(.flow-item)) { display: flex; align-items: stretch; gap: 0; margin: 32px 0 40px; overflow-x: auto; }
.article-content .flow-step { flex: 1; text-align: center; padding: 16px 8px; background: #f7f8fb; border: 1px solid #e0e4ea; border-radius: 6px; font-size: 0.8rem; line-height: 1.5; color: #444; }
.article-content .flow-step.error { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.article-content .flow-step.success { background: #f0fdf4; border-color: #86efac; color: #166534; }
.article-content .flow-arrow { display: flex; align-items: center; padding: 0 4px; color: #aaa; font-size: 1.1rem; flex-shrink: 0; }

/* 記事内: フローアイテム（コードブロック付きセクション用） */
.article-content .flow-item { flex: none; width: 100%; background: #f7f8fb; border: 1px solid #e0e4ea; border-radius: 8px; padding: 20px; }
.article-content .flow-item h3 { font-size: 1rem; margin: 0 0 12px; color: #2a2a2a; font-weight: 600; }
.article-content .flow-item .code-block { margin-bottom: 0; }
.article-content .flow-item pre { margin-bottom: 0; }
.article-content .flow:has(.flow-item) { flex-direction: column; gap: 24px; margin: 24px 0; }

/* 記事内: テーブル */
.article-content .table-wrap { overflow-x: auto; margin-bottom: 24px; }
.article-content table { width: 100%; border-collapse: collapse; margin-bottom: 24px; font-size: 0.9rem; }
.article-content th { background: #edf2f7; color: #2d3748; text-align: left; padding: 10px 14px; font-weight: 600; font-size: 0.85rem; border-bottom: 2px solid #cbd5e0; }
.article-content td { padding: 10px 14px; border-bottom: 1px solid #edf2f7; vertical-align: top; }

/* 記事内: チェックリスト・まとめ */
.article-content .checklist, .article-content .summary-box { background: #f7f8fb; border: 1px solid #e0e4ea; border-radius: 6px; padding: 20px 24px; margin: 16px 0; }

/* 記事内: タグ */
.article-content .tag { display: inline-block; background: #eef2ff; color: #4f5fad; font-size: 0.78rem; font-weight: 600; padding: 3px 10px; border-radius: 4px; }
.article-content .meta { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; font-size: 0.85rem; color: #888; }
.article-content .lead { font-size: 0.98rem; color: #555; line-height: 1.9; }
.article-content .hero { margin-bottom: 40px; }

/* 記事内: コードタブ */
.article-content .code-tabs { margin-bottom: 24px; border-radius: 8px; overflow: hidden; border: 1px solid #e0e4ea; }
.article-content .tab-buttons { display: flex; background: #f0f1f6; border-bottom: 2px solid #e0e4ea; overflow-x: auto; }
.article-content .tab-btn { padding: 10px 20px; border: none; background: none; cursor: pointer; font-size: 0.85rem; font-weight: 600; color: #64748b; white-space: nowrap; transition: all 0.2s; position: relative; }
.article-content .tab-btn:hover { color: #3b82f6; background: rgba(59,130,246,0.05); }
.article-content .tab-btn.active { color: #3b82f6; background: #fff; }
.article-content .tab-btn.active::after { content: ""; position: absolute; bottom: -2px; left: 0; right: 0; height: 3px; background: #3b82f6; border-radius: 3px 3px 0 0; }
.article-content .tab-panel { display: none; padding: 0; background: #fff; }
.article-content .tab-panel.active { display: block; }
.article-content .tab-panel .tab-display { padding: 20px; line-height: 1.8; }
.article-content .tab-panel pre { margin: 0; border-radius: 0; }
.article-content .tab-panel .code-block { margin-bottom: 0; }
.article-content .tab-panel .code-block pre { border-radius: 0; }
.article-content .tab-panel .code-block .where { border-radius: 0; }

/* 記事内: ステップセクション（旧サイトからの移行用） */
.article-content .step { margin-bottom: 24px; }
.article-content .step h2 { font-size: 1.15rem; }
.article-content .step-number { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: #3b82f6; color: #fff; font-size: 0.8rem; font-weight: 700; border-radius: 50%; margin-right: 10px; vertical-align: middle; }
.article-content .step .command-block { background: #1e2029; color: #e4e6eb; padding: 14px 18px; border-radius: 6px; margin: 10px 0; font-family: "SF Mono", "Fira Code", "Consolas", monospace; font-size: 0.87rem; line-height: 1.6; overflow-x: auto; }
.article-content .step .output-block { background: #f7f8fb; border-left: 3px solid #22c55e; padding: 12px 16px; border-radius: 0 4px 4px 0; margin: 10px 0; font-family: "SF Mono", "Fira Code", "Consolas", monospace; font-size: 0.85rem; line-height: 1.5; color: #444; }
.article-content .step .note { background: #f0f7ff; border: 1px solid #bfdbfe; border-radius: 6px; padding: 12px 16px; margin: 10px 0; font-size: 0.9rem; }
.article-content .step .warning { background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 12px 16px; margin: 10px 0; font-size: 0.9rem; }

/* 管理ヘッダー */
.manage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* ボタン */
.btn {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }

.btn-primary { background: #e94560; color: #fff; }
.btn-secondary { background: #ccc; color: #333; }
.btn-danger { background: #dc3545; color: #fff; }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.8rem; }

/* テーブル */
.table-wrapper {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow-x: auto;
}

.manage-table {
    width: 100%;
    border-collapse: collapse;
}

.manage-table th {
    background: #f0f1f3;
    color: #333;
    padding: 0.8rem 1rem;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid #ddd;
}

.manage-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.manage-table tbody tr:hover { background: #f0f0f5; }

.manage-table code {
    background: #f4f4f4;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85rem;
}

.manage-table .actions {
    display: flex;
    gap: 0.5rem;
    white-space: nowrap;
}

.manage-table .indent {
    color: #aaa;
    margin-right: 0.2rem;
}

.empty-row {
    text-align: center;
    color: #999;
    padding: 2rem !important;
}

/* フォーム */
.form-page {
    background: #fff;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.manage-form {
    margin-top: 1.5rem;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    color: #333;
}

.form-error {
    color: #dc3545;
    font-size: 0.85rem;
    margin-top: 0.3rem;
}

.form-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

/* モバイルメニューボタン */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* サイドバーオーバーレイ（モバイル用） */
.sidebar-overlay {
    display: none;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .sidebar-toggle { display: block; }

    .header-search { max-width: 160px; }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 260px;
        height: 100vh;
        z-index: 1000;
        background: #fff;
        border-right: 1px solid #e8e8f0;
        padding: 1.5rem 1rem;
        overflow-y: auto;
        transition: left 0.3s ease;
        box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.4);
        z-index: 999;
    }

    .sidebar-overlay.open {
        display: block;
    }

    main {
        padding: 1.5rem 1rem;
    }

    .article-detail { padding: 1.2rem; }

    .article-content .flow { flex-direction: column; align-items: center; }
    .article-content .flow-arrow { transform: rotate(90deg); padding: 4px 0; }
    .article-content .flow-step { min-width: 200px; }

    .manage-header { flex-wrap: wrap; gap: 0.5rem; }
}
