:root {
    --primary: #2c3e50;
    --accent: #e74c3c;
    --accent-hover: #c0392b;
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #95a5a6;
    --border-color: #ecf0f1;
    --shadow-sm: 0 2px 5px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 30px rgba(0,0,0,0.12);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.15);
    --font-sans: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    --font-serif: "Merriweather", "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", serif;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    overflow-x: hidden;
}

/* 繧｢繝九Γ繝ｼ繧ｷ繝ｧ繝ｳ螳夂ｾｩ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translate3d(0, 30px, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* 繧ｯ繝ｩ繧ｹ驕ｩ逕ｨ */
.animate-fade-in-up { animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; opacity: 0; }
.animate-fade-in { animation: fadeIn 0.8s ease forwards; }
.animate-slide-in { animation: slideInRight 0.5s ease forwards; opacity: 0; }

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }

/* 蜈ｱ騾壹Ξ繧､繧｢繧ｦ繝� */
.novel-container {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
}

.novel-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.nav-bar {
    max-width: 1000px;
    margin: 0 auto;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-logo {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: -0.5px;
    transition: color 0.3s;
}
.brand-logo:hover { color: var(--accent); }

.nav-links a {
    color: var(--text-main);
    text-decoration: none;
    margin-left: 25px;
    font-weight: 500;
    font-size: 0.95rem;
    position: relative;
    transition: color 0.3s;
}
.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: var(--accent);
    transition: width 0.3s;
}
.nav-links a:hover::after { width: 100%; }
.nav-links a:hover { color: var(--accent); }

/* 繧ｫ繝ｼ繝峨ョ繧ｶ繧､繝ｳ */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    padding: 30px;
    margin-bottom: 30px;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease;
    border: 1px solid rgba(0,0,0,0.02);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

/* 繝懊ち繝ｳ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: 50px;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
}

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 15px rgba(44, 62, 80, 0.3); }
.btn-primary:hover { background: #34495e; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(44, 62, 80, 0.4); }

.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3); }
.btn-accent:hover { background: var(--accent-hover); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4); }

.btn-secondary { background: #ecf0f1; color: var(--text-main); }
.btn-secondary:hover { background: #dfe6e9; transform: translateY(-2px); }

.btn-danger { background: #fff; color: #e74c3c; border: 1px solid #e74c3c; }
.btn-danger:hover { background: #e74c3c; color: #fff; }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

/* 小説本文 */
.novel-viewer {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    line-height: 2.8;
    color: #2c3e50;
    text-align: justify;
    word-wrap: break-word; /* 長い単語を折り返し */
}

/* Catchphrase styling */
.novel-catchphrase {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    color: var(--text-main);
    text-align: center;
    margin-bottom: 10px;
    font-weight: bold;
    letter-spacing: 0.5px;
    display: inline-block;
    position: relative;
    padding: 0 10px;
}
/* Optional: Decorative lines for catchphrase */
.novel-catchphrase::before,
.novel-catchphrase::after {
    content: "━━";
    color: var(--accent);
    margin: 0 10px;
    font-weight: normal;
    opacity: 0.6;
}

/* 繝ｪ繝ｳ繧ｯ */
.author-link {
    font-weight: bold;
    color: var(--text-main);
    text-decoration: none;
    transition: color 0.2s;
    border-bottom: 1px dotted transparent;
}
.author-link:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* 繧ｨ繝�ぅ繧ｿ */
.editor-toolbar {
    background: #fff;
    border: 1px solid var(--border-color);
    border-bottom: none;
    padding: 10px;
    border-radius: 12px 12px 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.05);
}
.toolbar-btn {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    color: #555;
    transition: all 0.2s;
}
.toolbar-btn:hover {
    background: #f8f9fa;
    border-color: #bdc3c7;
    color: var(--primary);
    transform: translateY(-1px);
}

textarea.editor-content {
    border-radius: 0 0 12px 12px;
    border-color: var(--border-color);
    padding: 20px;
    font-size: 1.1rem;
    transition: border 0.3s;
}
textarea.editor-content:focus {
    box-shadow: none;
    border-color: var(--primary);
}

/* 陬�｣ｾ */
.txt-tilt { display: inline-block; transform: rotate(15deg); transform-origin: center bottom; margin: 0 2px; }
.txt-under { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.txt-strike { text-decoration: line-through; color: var(--text-muted); }
.txt-marker { background: linear-gradient(transparent 60%, rgba(255, 234, 167, 0.8) 60%); padding: 0 2px; }
.novel-box { border: 1px solid var(--primary); background: #fff; padding: 20px; margin: 20px 0; border-radius: 8px; position: relative; }
.novel-box::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--primary); border-radius: 8px 0 0 8px; }
.txt-blur { filter: blur(6px); transition: filter 0.4s ease; cursor: pointer; user-select: none; }
.txt-blur:hover { filter: blur(0); }
.txt-code { font-family: 'Consolas', monospace; background: #f1f2f6; padding: 2px 6px; border-radius: 4px; color: #e74c3c; font-size: 0.9em; }
.novel-hr { border: 0; height: 1px; background: linear-gradient(to right, transparent, #ccc, transparent); margin: 40px 0; }

ruby { display: inline-flex; flex-direction: column-reverse; vertical-align: bottom; align-items: center; line-height: 1; }
rt { font-size: 0.5em; line-height: 1.2; margin-bottom: 2px; color: var(--primary); }

/* 蜈･蜉帙ヵ繧ｩ繝ｼ繝� */
input[type="text"], select, textarea {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 15px;
    transition: all 0.3s;
}
input[type="text"]:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(44, 62, 80, 0.1);
    outline: none;
}
/* Editor height fix */
.editor-wrapper { height: 70vh; min-height: 500px; }

/* Missing Style Definitions */
.txt-bold { font-weight: bold; }
.txt-italic { font-style: italic; }
.txt-large { font-size: 1.4em; }
.txt-small { font-size: 0.8em; }
.txt-center { text-align: center; display: block; }
.txt-right { text-align: right; display: block; }


/* Mobile Responsiveness */
@media (max-width: 768px) {
    .nav-bar {
        padding: 10px 15px;
    }
    .brand-logo {
        font-size: 1.3rem;
    }
    .nav-links a {
        margin-left: 15px;
        font-size: 0.85rem;
    }
    .novel-container {
        margin: 20px auto;
        padding: 0 15px;
    }
    .card {
        padding: 20px;
    }
    .novel-header {
        position: sticky; /* Keep sticky but ensure it doesn't take too much space */
    }
    
    /* Grid Layouts to Single Column */
    div[style*='grid-template-columns'] {
        grid-template-columns: 1fr !important;
    }
    
    /* Editor adjustments */
    .editor-wrapper {
        flex-direction: column;
        height: auto;
    }
    .editor-main, .editor-preview {
        height: 50vh;
        width: 100%;
    }
    .editor-toolbar {
        overflow-x: auto;
        padding-bottom: 5px;
    }
    .toolbar-group {
        flex-shrink: 0;
    }
    
    /* Font sizes */
    .novel-viewer {
        font-size: 1.1rem;
        line-height: 2.4;
    }
    h1 { font-size: 1.8rem !important; }
    h2 { font-size: 1.5rem !important; }
}

@media (max-width: 480px) {
    .nav-links a {
        margin-left: 10px;
        font-size: 0.8rem;
    }
    .btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}


/* 色・装飾の修正 */
.txt-red { color: #e74c3c !important; }
.txt-blue { color: #3498db !important; }

/* プレビューエリアの修正 */
.preview-box {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal; /* nl2brしているのでnormalでOK */
    max-width: 100%;
    overflow-x: hidden;
}

/* テキストエリアの自動調整用 */
textarea.editor-content {
    min-height: 400px; /* デフォルトを大きく */
    overflow-y: hidden; /* 自動調整時はスクロールバーを隠す */
    resize: none; /* 手動リサイズ無効（自動調整と競合するため） */
}


/* Nickname truncation */
.nickname-truncate {
    max-width: 120px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.nickname-truncate-sm {
    max-width: 80px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.nickname-truncate-lg {
    max-width: 200px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* Editor Layout Fixes */
.editor-wrapper {
    display: flex;
    flex-direction: row;
    gap: 0;
    overflow: hidden;
}

.editor-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.editor-preview {
    flex: 1;
    min-width: 0;
    border-left: 1px solid #eee;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-box {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

textarea.editor-content {
    width: 100% !important;
    box-sizing: border-box;
    flex: 1;
}

@media (max-width: 900px) {
    .editor-wrapper {
        flex-direction: column;
        height: auto;
        min-height: auto;
    }
    .editor-main, .editor-preview {
        width: 100%;
        flex: none;
    }
    .editor-preview {
        border-left: none;
        border-top: 1px solid #eee;
        max-height: 400px;
    }
}

/* Desktop Editor Height Fix */
@media (min-width: 1024px) {
    .editor-wrapper {
        height: 70vh;
        max-height: 800px;
    }
}

/* Force scrollable textarea fixes */
.editor-main {
    overflow: hidden !important;
    height: 100%;
}

textarea.editor-content {
    resize: none !important;
    overflow-y: auto !important;
    height: 100% !important; /* Fallback/Ensure fill */
    flex: 1;
}

/* Fix Ruby Alignment - Native & Robust */
ruby {
    display: ruby;
    ruby-position: over;
    vertical-align: baseline;
    line-height: 1;
}

rt {
    display: ruby-text;
    font-size: 0.5em;
    text-align: center;
    line-height: 1;
}

/* ============================================
   ENHANCED ANIMATIONS (控えめ・上品)
   ============================================ */

/* スクロール連動アニメーション */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* カードのスタッガードアニメーション */
.work-card:nth-child(1) { --card-delay: 0s; }
.work-card:nth-child(2) { --card-delay: 0.05s; }
.work-card:nth-child(3) { --card-delay: 0.1s; }
.work-card:nth-child(4) { --card-delay: 0.15s; }
.work-card:nth-child(5) { --card-delay: 0.2s; }
.work-card:nth-child(6) { --card-delay: 0.25s; }
.work-card:nth-child(7) { --card-delay: 0.3s; }
.work-card:nth-child(8) { --card-delay: 0.35s; }
.work-card:nth-child(9) { --card-delay: 0.4s; }
.work-card:nth-child(10) { --card-delay: 0.45s; }
.work-card:nth-child(11) { --card-delay: 0.5s; }
.work-card:nth-child(12) { --card-delay: 0.55s; }

.work-card.animate-on-scroll {
    transition-delay: var(--card-delay, 0s);
}

/* ボタンクリックフィードバック（控えめ） */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.25s ease;
}

.btn:active {
    transform: scale(0.97);
}

/* ボタンフォーカス状態の改善 */
.btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* ハートアニメーション（いいねボタン） */
@keyframes heartPulse {
    0% { transform: scale(1); }
    25% { transform: scale(1.15); }
    50% { transform: scale(0.95); }
    75% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.btn-like.liked .heart-icon,
.btn-like.btn-accent .heart-icon {
    animation: heartPulse 0.4s ease;
}

.heart-icon {
    display: inline-block;
    transition: transform 0.2s ease;
}

.btn-like:hover .heart-icon {
    transform: scale(1.1);
}

/* ローディングスピナー */
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ページ遷移（控えめフェード） */
.page-enter {
    animation: pageEnter 0.3s ease;
}

@keyframes pageEnter {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 読了時間表示 */
.reading-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 3px 10px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 20px;
}

/* カードホバー効果の強化 */
.card.hover-card:hover,
.work-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

/* フォーカス状態の強化 */
input[type="text"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(44, 62, 80, 0.12);
    outline: none;
}

/* モーション軽減設定への対応 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .animate-on-scroll {
        opacity: 1;
        transform: none;
    }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

/* ダークモード用変数 - 視認性を重視した配色 */
[data-theme="dark"] {
    --primary: #7eb8ff;
    --accent: #ff8080;
    --accent-hover: #ff6666;
    --bg-body: #121218;
    --bg-card: #1c1c28;
    --text-main: #f0f0f5;
    --text-muted: #b0b0c0;
    --border-color: #3a3a50;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] body {
    background-color: var(--bg-body);
    color: var(--text-main);
}

[data-theme="dark"] .novel-header {
    background: rgba(28, 28, 40, 0.98);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .card {
    background: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .btn-secondary {
    background: #2d2d40;
    color: #e8e8f0;
}

[data-theme="dark"] .btn-secondary:hover {
    background: #3d3d55;
}

[data-theme="dark"] .btn-primary {
    background: #4a7cc9;
    color: #fff;
}

[data-theme="dark"] .btn-primary:hover {
    background: #5a8cd9;
}

[data-theme="dark"] input[type="text"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #1c1c28;
    border-color: var(--border-color);
    color: #f0f0f5;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #808090;
}

/* 小説本文 - 読みやすさを重視 */
[data-theme="dark"] .novel-viewer {
    color: #e8e8f0;
    line-height: 2.8;
}

/* リンク色 */
[data-theme="dark"] a {
    color: #7eb8ff;
}

[data-theme="dark"] a:hover {
    color: #9ec8ff;
}

[data-theme="dark"] .author-link {
    color: #c0c0d0;
}

[data-theme="dark"] .author-link:hover {
    color: #ff8080;
}

/* タイトルやヘッダー */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4 {
    color: #f5f5fa;
}

/* カード内の説明文 */
[data-theme="dark"] .card div[style*="color: #555"] {
    color: #c0c0d0 !important;
}

/* マーカー・装飾 */
[data-theme="dark"] .txt-marker {
    background: linear-gradient(transparent 60%, rgba(255, 200, 100, 0.35) 60%);
}

[data-theme="dark"] .novel-box {
    background: #22222e;
    border-color: var(--primary);
}

[data-theme="dark"] .txt-code {
    background: #2a2a3a;
    color: #ff9090;
}

[data-theme="dark"] .txt-red {
    color: #ff9090 !important;
}

[data-theme="dark"] .txt-blue {
    color: #7eb8ff !important;
}

/* ローディング */
[data-theme="dark"] .loading-overlay {
    background: rgba(18, 18, 24, 0.95);
}

[data-theme="dark"] .spinner {
    border-color: #3a3a50;
    border-top-color: #7eb8ff;
}

/* エディタ */
[data-theme="dark"] .editor-toolbar {
    background: #1c1c28;
    border-color: var(--border-color);
}

[data-theme="dark"] .toolbar-btn {
    background: #2a2a3a;
    border-color: #3a3a50;
    color: #d0d0e0;
}

[data-theme="dark"] .toolbar-btn:hover {
    background: #3a3a4a;
    border-color: #4a4a60;
    color: #fff;
}

[data-theme="dark"] textarea.editor-content {
    background: #1c1c28;
    color: #f0f0f5;
    border-color: var(--border-color);
}

[data-theme="dark"] .preview-box {
    background: #1c1c28;
    color: #e8e8f0;
}

/* バッジ・ステータス表示 */
[data-theme="dark"] span[style*="background: #f8f9fa"],
[data-theme="dark"] div[style*="background: #f8f9fa"] {
    background: #2a2a3a !important;
}

[data-theme="dark"] span[style*="color: var(--text-muted)"] {
    color: #b0b0c0 !important;
}

/* 目次リスト */
[data-theme="dark"] ul[style*="border: 1px solid #f0f0f0"] {
    border-color: #3a3a50 !important;
}

[data-theme="dark"] li[style*="border-bottom: 1px solid #f0f0f0"] {
    border-color: #3a3a50 !important;
}

/* コメント欄 */
[data-theme="dark"] div[style*="background: #fdfdfd"],
[data-theme="dark"] div[style*="background: #f9f9f9"],
[data-theme="dark"] div[style*="background: #f8f9fa"] {
    background: #22222e !important;
}

[data-theme="dark"] div[style*="border: 1px solid #f0f0f0"],
[data-theme="dark"] div[style*="border-bottom: 1px solid #f0f0f0"] {
    border-color: #3a3a50 !important;
}

[data-theme="dark"] div[style*="color: #444"] {
    color: #d0d0e0 !important;
}

/* 説明文エリア */
[data-theme="dark"] div[style*="background: linear-gradient(to bottom right, #ffffff, #f9f9f9)"] {
    background: linear-gradient(to bottom right, #22222e, #1c1c28) !important;
    border-color: #3a3a50 !important;
}

/* フッター */
[data-theme="dark"] footer {
    background: #1c1c28 !important;
    border-color: #3a3a50 !important;
}

/* システム設定によるダークモード自動適用 - 視認性を重視 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary: #7eb8ff;
        --accent: #ff8080;
        --accent-hover: #ff6666;
        --bg-body: #121218;
        --bg-card: #1c1c28;
        --text-main: #f0f0f5;
        --text-muted: #b0b0c0;
        --border-color: #3a3a50;
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
    }

    :root:not([data-theme="light"]) body {
        background-color: var(--bg-body);
        color: var(--text-main);
    }

    :root:not([data-theme="light"]) .novel-header {
        background: rgba(28, 28, 40, 0.98);
    }

    :root:not([data-theme="light"]) .card {
        background: var(--bg-card);
        border-color: var(--border-color);
    }

    :root:not([data-theme="light"]) .btn-secondary {
        background: #2d2d40;
        color: #e8e8f0;
    }

    :root:not([data-theme="light"]) .btn-primary {
        background: #4a7cc9;
        color: #fff;
    }

    :root:not([data-theme="light"]) input[type="text"],
    :root:not([data-theme="light"]) select,
    :root:not([data-theme="light"]) textarea {
        background: #1c1c28;
        border-color: var(--border-color);
        color: #f0f0f5;
    }

    :root:not([data-theme="light"]) .novel-viewer {
        color: #e8e8f0;
    }

    :root:not([data-theme="light"]) a {
        color: #7eb8ff;
    }

    :root:not([data-theme="light"]) h1,
    :root:not([data-theme="light"]) h2,
    :root:not([data-theme="light"]) h3,
    :root:not([data-theme="light"]) h4 {
        color: #f5f5fa;
    }

    :root:not([data-theme="light"]) .loading-overlay {
        background: rgba(18, 18, 24, 0.95);
    }

    :root:not([data-theme="light"]) .spinner {
        border-color: #3a3a50;
        border-top-color: #7eb8ff;
    }

    :root:not([data-theme="light"]) footer {
        background: #1c1c28 !important;
        border-color: #3a3a50 !important;
    }
}

/* テーマ切替ボタン */
.theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.theme-toggle .icon-sun {
    display: none;
}

.theme-toggle .icon-moon {
    display: inline;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: inline;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun {
        display: inline;
    }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon {
        display: none;
    }
}
