:root{
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: rgba(17,24,39,0.12);
  --accent: #2563eb;
  --btn: rgba(17,24,39,0.06);
  --btnHover: rgba(17,24,39,0.10);
  --shadow: 0 6px 18px rgba(17,24,39,0.08);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiragyo, sans-serif;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
}

a{ color: var(--accent); text-decoration:none; }
a:hover{ text-decoration:underline; }

.app-header{
  position: sticky;
  top:0;
  z-index: 10;
  display:flex;
  justify-content: space-between;
  align-items:center;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand{ display:flex; align-items:baseline; gap:10px; }
.logo{ font-size: 18px; }
.title{ font-weight: 800; letter-spacing: 0.2px; }
.subtitle{ color: var(--muted); font-size: 12px; }

.top-actions{ display:flex; gap:10px; }

.btn{
  border: 1px solid var(--border);
  background: var(--btn);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 10px;
  cursor:pointer;
  transition: 120ms ease;
}
.btn:hover{ background: var(--btnHover); }
.btn:active{ transform: translateY(1px); }
.btn-ghost{ background: transparent; }

.app-shell{
  display:grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
  padding: 12px;
  width: 100%; /* フル幅 */
}

.sidebar{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  height: calc(100dvh - 78px);
  overflow: auto;
}

.sidebar-section + .sidebar-section{ margin-top: 16px; }
.sidebar-title{
  margin: 0 0 10px 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.course-meta{
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.course-meta .meta-title{
  color: var(--text);
  font-weight: 700;
  margin-bottom: 6px;
}

.chapter-list{
  list-style:none;
  padding:0;
  margin:0;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.chapter-item a{
  display:block;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  color: var(--text);
  background: rgba(17,24,39,0.03);
}
.chapter-item a:hover{
  border-color: var(--border);
  background: rgba(17,24,39,0.06);
  text-decoration:none;
}
.chapter-item.active a{
  border-color: rgba(37,99,235,0.40);
  background: rgba(37,99,235,0.08);
}

.main{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-height: calc(100dvh - 78px);
}

.breadcrumb{
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.view.hidden{ display:none; }

.page-title{ margin: 6px 0 6px 0; font-size: 22px; }
.page-desc{ margin: 0 0 16px 0; color: var(--muted); }

/* ✅ 3列表示 */
.course-cards{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.course-card{
  border: 1px solid var(--border);
  background: rgba(17,24,39,0.02);
  border-radius: 14px;
  padding: 14px;
  cursor:pointer;
  transition: 120ms ease;
}
.course-card:hover{ background: rgba(17,24,39,0.04); }
.course-card .card-title{ font-weight: 800; margin-bottom: 6px; }
.course-card .card-desc{ color: var(--muted); font-size: 13px; line-height: 1.6; }
.course-card .card-meta{ margin-top: 10px; color: var(--muted); font-size: 12px; }

.content-header{
  display:flex;
  justify-content: space-between;
  align-items:flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.content-actions{ display:flex; gap: 10px; flex-wrap: wrap; }

.content{
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

/* Markdown見栄え（シンプル） */
.markdown-body h1, .markdown-body h2, .markdown-body h3{
  margin: 18px 0 10px;
}
.markdown-body p{ line-height: 1.9; }
.markdown-body ul{ line-height: 1.9; }
.markdown-body code{
  font-family: var(--mono);
  background: rgba(17,24,39,0.06);
  padding: 2px 6px;
  border-radius: 8px;
}
.markdown-body pre{
  background: rgba(17,24,39,0.04);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 12px;
  overflow:auto;
}
.markdown-body pre code{ background: transparent; padding: 0; }

.app-footer{
  width: 100%;
  padding: 10px 14px 18px;
  color: var(--muted);
}

/* レスポンシブ（3→2→1） */
@media (max-width: 1100px){
  .course-cards{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 920px){
  .app-shell{ grid-template-columns: 1fr; }
  .sidebar{ height: auto; }
}
@media (max-width: 640px){
  .course-cards{ grid-template-columns: 1fr; }
}