/* ============================================
   猫の育て方アカデミー - Style Sheet
   ============================================ */

:root {
    --primary: #ea580c;
    --primary-dark: #c2410c;
    --primary-light: #fff7ed;
    --accent: #f59e0b;
    --accent-light: #fef3c7;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --bg: #fffbf5;
    --bg-card: #ffffff;
    --bg-sidebar: #1c1917;
    --bg-code: #1e1e1e;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-sidebar: #e2e8f0;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 15px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-width: 280px;
    --header-height: 60px;
}

[data-theme="dark"] {
    --bg: #171412;
    --bg-card: #1c1917;
    --bg-sidebar: #171412;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --border: #3d3225;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 15px rgba(0,0,0,0.3);
    --primary-light: #431407;
    --success-light: #064e3b;
    --danger-light: #7f1d1d;
    --accent-light: #78350f;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    overflow: hidden;
    height: 100vh;
}

.header {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--bg-sidebar);
    color: white;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-center { flex: 1; max-width: 400px; margin: 0 24px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.5px; }
.logo-accent { color: var(--accent); }
.sidebar-toggle { background: none; border: none; color: white; font-size: 1.4rem; cursor: pointer; padding: 4px 8px; border-radius: 4px; display: none; }
.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }
.btn-icon { background: none; border: none; font-size: 1.2rem; cursor: pointer; padding: 6px 10px; border-radius: 6px; transition: background 0.2s; }
.btn-icon:hover { background: rgba(255,255,255,0.15); }

.global-progress { display: flex; align-items: center; gap: 12px; }
.global-progress-bar { flex: 1; height: 8px; background: rgba(255,255,255,0.2); border-radius: 4px; overflow: hidden; }
.global-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--success)); border-radius: 4px; transition: width 0.5s ease; width: 0%; }
.global-progress-text { font-size: 0.8rem; white-space: nowrap; opacity: 0.9; }

.main-layout { display: flex; margin-top: var(--header-height); height: calc(100vh - var(--header-height)); }

.sidebar { width: var(--sidebar-width); min-width: var(--sidebar-width); background: var(--bg-sidebar); color: var(--text-sidebar); overflow-y: auto; padding: 12px 0; border-right: 1px solid rgba(255,255,255,0.05); transition: transform 0.3s ease; }
.sidebar-section { padding: 4px 12px; }
.sidebar-level { margin-bottom: 4px; }
.sidebar-level-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); cursor: pointer; border-radius: 6px; transition: background 0.2s; }
.sidebar-level-header:hover { background: rgba(255,255,255,0.05); }
.sidebar-level-header .chevron { font-size: 0.65rem; transition: transform 0.2s; }
.sidebar-level-header.expanded .chevron { transform: rotate(90deg); }
.sidebar-modules { overflow: hidden; max-height: 0; transition: max-height 0.3s ease; }
.sidebar-modules.expanded { max-height: 2000px; }
.sidebar-item { display: flex; align-items: center; gap: 10px; padding: 8px 16px 8px 28px; font-size: 0.85rem; cursor: pointer; border-radius: 6px; margin: 1px 8px; transition: all 0.2s; position: relative; }
.sidebar-item:hover { background: rgba(255,255,255,0.08); }
.sidebar-item.active { background: var(--primary); color: white; }
.sidebar-item.completed { opacity: 0.85; }
.sidebar-item .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-secondary); flex-shrink: 0; }
.sidebar-item.completed .status-dot { background: var(--success); }
.sidebar-item.active .status-dot { background: white; }
.sidebar-icon { font-size: 1rem; }
.dashboard-link { padding: 10px 16px; margin: 0 8px 8px; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,0.1); }

.content { flex: 1; overflow-y: auto; padding: 32px; max-width: 100%; }

.dashboard-hero { background: linear-gradient(135deg, #ea580c, #f59e0b); color: white; padding: 40px; border-radius: var(--radius-lg); margin-bottom: 32px; }
.dashboard-hero h2 { font-size: 1.8rem; margin-bottom: 8px; }
.dashboard-hero p { opacity: 0.9; font-size: 1.05rem; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; margin-bottom: 32px; }

.stat-card { background: var(--bg-card); padding: 24px; border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--border); }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-secondary); margin-top: 4px; }

.level-card { background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; }
.level-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.level-card-header { padding: 20px 24px; display: flex; align-items: center; gap: 16px; }
.level-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0; }
.level-card-header h3 { font-size: 1.05rem; margin-bottom: 2px; }
.level-card-header .level-desc { font-size: 0.82rem; color: var(--text-secondary); }
.level-progress { padding: 0 24px 16px; }
.level-progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.level-progress-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.level-progress-text { font-size: 0.75rem; color: var(--text-secondary); margin-top: 6px; text-align: right; }

.level-1 .level-icon { background: #fff7ed; color: #ea580c; }
.level-2 .level-icon { background: #fef3c7; color: #d97706; }
.level-3 .level-icon { background: #e0e7ff; color: #4f46e5; }
.level-4 .level-icon { background: #fce7f3; color: #be185d; }
.level-5 .level-icon { background: #d1fae5; color: #059669; }
.level-6 .level-icon { background: #fee2e2; color: #dc2626; }
.level-7 .level-icon { background: #e0f2fe; color: #0284c7; }
.level-8 .level-icon { background: #f3e8ff; color: #7c3aed; }
.level-9 .level-icon { background: #ccfbf1; color: #0d9488; }
.level-10 .level-icon { background: #fde68a; color: #92400e; }
.level-11 .level-icon { background: #dcfce7; color: #16a34a; }
.level-12 .level-icon { background: #f1f5f9; color: #475569; }

.level-1 .level-progress-fill { background: #ea580c; }
.level-2 .level-progress-fill { background: #d97706; }
.level-3 .level-progress-fill { background: #4f46e5; }
.level-4 .level-progress-fill { background: #be185d; }
.level-5 .level-progress-fill { background: #059669; }
.level-6 .level-progress-fill { background: #dc2626; }
.level-7 .level-progress-fill { background: #0284c7; }
.level-8 .level-progress-fill { background: #7c3aed; }
.level-9 .level-progress-fill { background: #0d9488; }
.level-10 .level-progress-fill { background: #92400e; }
.level-11 .level-progress-fill { background: #16a34a; }
.level-12 .level-progress-fill { background: #475569; }

.module-header { margin-bottom: 32px; }
.module-breadcrumb { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 8px; }
.module-breadcrumb a { color: var(--primary); text-decoration: none; cursor: pointer; }
.module-breadcrumb a:hover { text-decoration: underline; }
.module-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 8px; }
.module-meta { display: flex; align-items: center; gap: 16px; font-size: 0.85rem; color: var(--text-secondary); }
.module-body { max-width: 860px; }
.module-body h2 { font-size: 1.4rem; font-weight: 700; margin: 32px 0 16px; padding-bottom: 8px; border-bottom: 2px solid var(--primary); color: var(--primary); }
.module-body h3 { font-size: 1.15rem; font-weight: 600; margin: 24px 0 12px; }
.module-body p { margin-bottom: 16px; line-height: 1.8; }
.module-body ul, .module-body ol { margin: 0 0 16px 24px; }
.module-body li { margin-bottom: 6px; line-height: 1.7; }
.module-body strong { color: var(--primary); }

.info-box { padding: 16px 20px; border-radius: var(--radius); margin: 16px 0; border-left: 4px solid; }
.info-box.tip { background: var(--primary-light); border-color: var(--primary); }
.info-box.success { background: var(--success-light); border-color: var(--success); }
.info-box.warning { background: var(--accent-light); border-color: var(--accent); }
.info-box.danger { background: var(--danger-light); border-color: var(--danger); }
.info-box-title { font-weight: 700; margin-bottom: 4px; }

.module-body table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.9rem; background: var(--bg-card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.module-body thead { background: var(--primary); color: white; }
.module-body th { padding: 12px 16px; text-align: left; font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
.module-body td { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.module-body tbody tr:hover { background: var(--primary-light); }
.module-body code { background: var(--bg); border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px; font-size: 0.88em; font-family: 'Consolas', 'Monaco', monospace; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 24px; font-size: 0.95rem; font-weight: 600; border: none; border-radius: var(--radius); cursor: pointer; transition: all 0.2s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-lg { padding: 14px 32px; font-size: 1.05rem; }

.module-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 40px; padding-top: 24px; border-top: 2px solid var(--border); }

.quiz-container { max-width: 760px; }
.quiz-header { margin-bottom: 32px; }
.quiz-header h2 { font-size: 1.5rem; margin-bottom: 8px; }
.quiz-progress { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; color: var(--text-secondary); }
.quiz-progress-bar { flex: 1; max-width: 300px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.quiz-progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; }
.quiz-question { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; margin-bottom: 24px; box-shadow: var(--shadow); }
.quiz-question-num { font-size: 0.78rem; font-weight: 700; color: var(--primary); text-transform: uppercase; margin-bottom: 8px; }
.quiz-question-text { font-size: 1.1rem; font-weight: 600; margin-bottom: 20px; line-height: 1.6; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all 0.2s; line-height: 1.5; }
.quiz-option:hover { border-color: var(--primary); background: var(--primary-light); }
.quiz-option.selected { border-color: var(--primary); background: var(--primary-light); }
.quiz-option.correct { border-color: var(--success); background: var(--success-light); }
.quiz-option.incorrect { border-color: var(--danger); background: var(--danger-light); }
.quiz-option-marker { width: 24px; height: 24px; border: 2px solid var(--border); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.quiz-option.selected .quiz-option-marker { border-color: var(--primary); background: var(--primary); color: white; }
.quiz-option.correct .quiz-option-marker { border-color: var(--success); background: var(--success); color: white; }
.quiz-option.incorrect .quiz-option-marker { border-color: var(--danger); background: var(--danger); color: white; }
.quiz-explanation { margin-top: 16px; padding: 14px 18px; background: var(--primary-light); border-radius: var(--radius); font-size: 0.9rem; line-height: 1.6; display: none; }
.quiz-explanation.show { display: block; }
.quiz-fill-blank { margin: 12px 0; }
.quiz-fill-blank input { padding: 10px 16px; border: 2px solid var(--border); border-radius: var(--radius); font-size: 1rem; width: 100%; max-width: 400px; font-family: 'Consolas', monospace; background: var(--bg-card); color: var(--text); }
.quiz-fill-blank input:focus { outline: none; border-color: var(--primary); }
.quiz-actions { display: flex; gap: 12px; margin-top: 24px; }

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(4px); }
.modal { background: var(--bg-card); border-radius: var(--radius-lg); padding: 40px; max-width: 480px; width: 90%; text-align: center; box-shadow: var(--shadow-lg); }
.modal h2 { font-size: 1.5rem; margin-bottom: 16px; }
.modal .score-circle { width: 120px; height: 120px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 800; margin: 20px auto; color: white; }
.modal .score-circle.pass { background: linear-gradient(135deg, var(--success), #059669); }
.modal .score-circle.fail { background: linear-gradient(135deg, var(--danger), #dc2626); }
.modal p { color: var(--text-secondary); margin-bottom: 24px; line-height: 1.6; }
.modal .modal-actions { display: flex; gap: 12px; justify-content: center; }

.collapsible { border: 1px solid var(--border); border-radius: var(--radius); margin: 12px 0; overflow: hidden; }
.collapsible-header { padding: 12px 18px; background: var(--bg); cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.collapsible-header:hover { background: var(--primary-light); }
.collapsible-body { padding: 18px; display: none; border-top: 1px solid var(--border); }
.collapsible.open .collapsible-body { display: block; }

@media (max-width: 768px) {
    html { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
    body { height: 100dvh !important; }
    .main-layout { height: calc(100dvh - var(--header-height)) !important; }
    .sidebar-toggle { display: block; }
    .sidebar { position: fixed !important; top: var(--header-height) !important; left: 0 !important; bottom: 0 !important; z-index: 50 !important; transform: translateX(-100%) !important; transition: transform 0.3s ease !important; width: var(--sidebar-width) !important; }
    .sidebar.open { transform: translateX(0) !important; }
    .content { width: 100% !important; max-width: 100vw !important; padding: 16px !important; -webkit-overflow-scrolling: touch; }
    .header { padding: 0 12px !important; }
    .header-center { display: none !important; }
    .dashboard-hero { padding: 24px 16px !important; }
    .dashboard-hero h2 { font-size: 1.3rem !important; }
    .module-title { font-size: 1.4rem; }
    .module-body table { display: block; overflow-x: auto; max-width: 100%; }
    .module-nav { flex-direction: column !important; gap: 12px; }
    .dashboard-grid { grid-template-columns: 1fr !important; }
    .modal { width: 92% !important; padding: 24px 16px !important; }
    .quiz-actions { flex-direction: column; }
}

.sidebar::-webkit-scrollbar, .content::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track, .content::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

@media print { .header, .sidebar { display: none; } .content { margin: 0; padding: 20px; } }
