/* ============================================================
   Claude Design の教科書 — 共通スタイル
   配色: Plex Indigo（白〜生成り + 藍紫 #4338ca）／ライト・ダーク両対応
   フォント: IBM Plex Sans JP（読み込めない環境ではシステムフォント）
   ============================================================ */

:root {
  --bg: #faf9f5;
  --bg-card: #ffffff;
  --text: #22252e;
  --text-sub: #5a6072;
  --accent: #4338ca;
  --accent-strong: #3730a3;
  --accent-soft: #eef0fb;
  --border: #e5e3da;
  --warn-bg: #fdf4e7;
  --warn-border: #d9a35c;
  --ok-bg: #eef7ef;
  --ok-border: #79b381;
  --code-bg: #f2f1ec;
  --code-text: #30333e;
  --shadow: 0 1px 4px rgba(40, 40, 80, 0.08);
}

:root[data-theme="dark"] {
  --bg: #16171d;
  --bg-card: #1f212b;
  --text: #e9e9ef;
  --text-sub: #a8adbf;
  --accent: #9297f7;
  --accent-strong: #aeb2fa;
  --accent-soft: #272b48;
  --border: #363a4d;
  --warn-bg: #3a2f1c;
  --warn-border: #b08341;
  --ok-bg: #203527;
  --ok-border: #56895e;
  --code-bg: #262832;
  --code-text: #dcdde6;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "IBM Plex Sans JP", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.95;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- ヘッダー ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.55rem 1.2rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.site-header .book-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-sub);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-header .book-title:hover { color: var(--accent); }
.site-header .spacer { flex: 1; }
#theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 0.25rem 0.85rem;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}
#theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 本文レイアウト ---------- */
main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.5rem 1.2rem 4rem;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.5;
  margin: 1.2rem 0 0.4rem;
  letter-spacing: 0.01em;
}
h2 {
  font-size: 1.35rem;
  line-height: 1.55;
  margin: 3rem 0 0.8rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--accent-soft);
}
h2::before { content: "■ "; color: var(--accent); font-size: 0.9em; }
h3 {
  font-size: 1.12rem;
  margin: 2.2rem 0 0.6rem;
  color: var(--accent-strong);
}
p { margin: 0.9rem 0; }
ul, ol { padding-left: 1.5em; }
li { margin: 0.35rem 0; }
a { color: var(--accent); text-underline-offset: 3px; }
strong { font-weight: 700; }
mark {
  background: var(--accent-soft);
  color: var(--text);
  padding: 0 0.25em;
  border-radius: 3px;
}

.chapter-label {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.15rem 0.9rem;
  border-radius: 999px;
  margin-top: 1.5rem;
}
.lede { color: var(--text-sub); font-size: 1.02rem; }

/* ---------- コード・プロンプト ---------- */
code, kbd, pre {
  font-family: "IBM Plex Mono", ui-monospace, "Consolas", monospace;
}
code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  word-break: break-all;
}
kbd {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.05em 0.5em;
  font-size: 0.85em;
}
pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1rem 1.1rem;
  border-radius: 10px;
  overflow-x: auto;
  line-height: 1.75;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* コピーして使うプロンプト枠 */
.prompt {
  position: relative;
  margin: 1.4rem 0;
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.prompt .prompt-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.45rem 1rem;
}
.prompt .prompt-head::before { content: "📋"; }
.prompt pre {
  margin: 0;
  border-radius: 0;
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.98rem;
}
.copy-btn {
  position: absolute;
  top: 0.35rem;
  right: 0.6rem;
  border: 1px solid var(--accent);
  background: var(--bg-card);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.8rem;
  font-family: inherit;
  padding: 0.15rem 0.8rem;
  cursor: pointer;
}
.copy-btn:hover { background: var(--accent); color: #fff; }

/* ---------- 情報ボックス ---------- */
.goal, .note, .warning, .example, .exercise, .check-section {
  margin: 1.6rem 0;
  padding: 1.1rem 1.3rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.box-title {
  display: block;
  font-weight: 700;
  font-size: 1.02rem;
  margin-bottom: 0.5rem;
}

.goal { background: var(--accent-soft); border-left: 5px solid var(--accent); }
.goal .box-title::before { content: "🎯 "; }

.note { background: var(--bg-card); border-left: 5px solid var(--ok-border); }
.note .box-title::before { content: "💡 "; }

.warning { background: var(--warn-bg); border-left: 5px solid var(--warn-border); }
.warning .box-title::before { content: "⚠️ "; }

.example { background: var(--bg-card); border: 1.5px solid var(--border); border-top: 5px solid var(--accent); }
.example .box-title::before { content: "✍️ "; }
.example .box-title { color: var(--accent-strong); }

.exercise { background: var(--bg-card); border: 1.5px solid var(--border); border-top: 5px solid var(--warn-border); }
.exercise .box-title::before { content: "💪 "; }

.check-section { background: var(--ok-bg); border-left: 5px solid var(--ok-border); }
.check-section .box-title::before { content: "✅ "; }

/* ヒント・模範解答（折りたたみ） */
details {
  margin: 0.8rem 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 0;
}
details summary {
  cursor: pointer;
  font-weight: 700;
  padding: 0.6rem 1rem;
  color: var(--accent-strong);
  user-select: none;
}
details summary:hover { color: var(--accent); }
details[open] summary { border-bottom: 1px dashed var(--border); }
details .details-body { padding: 0.4rem 1.1rem 0.9rem; }
details.hint summary::before { content: "💡 "; }
details.answer summary::before { content: "🔑 "; }

/* ---------- チェックボックス ---------- */
.check-list { list-style: none; padding-left: 0; }
.check-list li { margin: 0.5rem 0; }
.check-list label {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  cursor: pointer;
}
.check-list input[type="checkbox"],
.done-check input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.35rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.done-check {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  justify-content: center;
  margin: 2.5rem 0 1rem;
  padding: 1rem;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  background: var(--bg-card);
}

/* ---------- 表 ---------- */
.table-wrap { overflow-x: auto; margin: 1.4rem 0; }
table {
  border-collapse: collapse;
  width: 100%;
  background: var(--bg-card);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 0.95rem;
}
th, td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.8rem;
  text-align: left;
  vertical-align: top;
}
th { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }

/* ---------- 画面の図解（スクリーンショットの代わり） ---------- */
.screen {
  margin: 1.6rem 0;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
}
.screen .screen-bar {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.45rem 0.9rem;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  color: var(--text-sub);
  font-weight: 600;
}
.screen .screen-bar::before { content: "● ● ●"; letter-spacing: 2px; color: var(--border); font-size: 0.7rem; }
.screen .screen-body { display: flex; min-height: 180px; }
.screen .pane { padding: 0.9rem; }
.screen .pane-chat {
  flex: 1;
  border-right: 1px solid var(--border);
  background: var(--bg);
  min-width: 130px;
}
.screen .pane-canvas { flex: 2; background: var(--bg-card); }
.screen .pane-label {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.05rem 0.7rem;
  margin-bottom: 0.6rem;
}
.screen .bubble {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  margin: 0.5rem 0;
  line-height: 1.6;
}
.screen .canvas-block {
  border: 1.5px dashed var(--accent);
  border-radius: 8px;
  padding: 0.6rem;
  margin: 0.5rem 0;
  text-align: center;
  color: var(--text-sub);
}
.screen .ui-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 7px;
  padding: 0.15rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0.15rem;
}
.screen .ui-btn.ghost {
  background: var(--bg-card);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.screen-caption {
  text-align: center;
  color: var(--text-sub);
  font-size: 0.88rem;
  margin: 0.5rem 0 1.5rem;
}

/* ---------- 手順ステップ ---------- */
.steps { counter-reset: step; list-style: none; padding-left: 0; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0.2rem 0 0.9rem 3rem;
  border-left: 2px solid var(--accent-soft);
  margin-left: 1.1rem;
}
.steps > li:last-child { border-left-color: transparent; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: -1.15rem;
  top: 0;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 目次（index 用） ---------- */
.hero {
  text-align: center;
  padding: 2.5rem 0 1rem;
}
.hero h1 { font-size: 2.1rem; margin-bottom: 0.3rem; }
.hero .sub { color: var(--text-sub); font-size: 1.05rem; }
.toc-list { list-style: none; padding: 0; }
.toc-list li { margin: 0.7rem 0; }
.toc-card {
  display: flex;
  gap: 1rem;
  align-items: center;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}
.toc-card:hover { border-color: var(--accent); }
.toc-num {
  flex-shrink: 0;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}
.toc-body { flex: 1; }
.toc-title { font-weight: 700; font-size: 1.05rem; }
.toc-desc { color: var(--text-sub); font-size: 0.9rem; line-height: 1.7; }
.toc-done {
  flex-shrink: 0;
  font-size: 1.4rem;
  opacity: 0.15;
}
.toc-done.is-done { opacity: 1; }

/* ---------- 前後ナビ・フッター ---------- */
.nav-buttons {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin: 3rem 0 1rem;
}
.nav-buttons a {
  flex: 1;
  display: block;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
}
.nav-buttons a:hover { border-color: var(--accent); }
.nav-buttons .nav-dir { display: block; font-size: 0.8rem; color: var(--text-sub); }
.nav-buttons .nav-next { text-align: right; }

.sources {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-sub);
}
.sources ul { padding-left: 1.3em; }

footer.site-footer {
  text-align: center;
  color: var(--text-sub);
  font-size: 0.82rem;
  padding: 1.5rem 1rem 2.5rem;
  border-top: 1px solid var(--border);
}

/* ---------- 画面下部の固定ナビ（戻る・目次・次へ） ---------- */
body.has-pagenav { padding-bottom: 4.6rem; }
.page-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
  padding: 0.55rem 0.9rem;
  padding-bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(30, 30, 60, 0.08);
}
.page-nav a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.35rem 0.9rem;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
  min-width: 6.5rem;
}
.page-nav a:hover { border-color: var(--accent); color: var(--accent); }
.page-nav a.is-disabled {
  visibility: hidden;
}
.page-nav .page-nav-target {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-sub);
}
.page-nav .page-nav-toc {
  flex: 1;
  border-style: dashed;
  font-weight: 600;
  color: var(--text-sub);
}
@media (max-width: 640px) {
  .page-nav a { min-width: 5.2rem; padding: 0.3rem 0.6rem; }
  .page-nav .page-nav-target { display: none; }
}

/* ---------- スマホ対応 ---------- */
@media (max-width: 640px) {
  body { font-size: 17px; }
  .screen .screen-body { flex-direction: column; }
  .screen .pane-chat { border-right: none; border-bottom: 1px solid var(--border); }
  .nav-buttons { flex-direction: column; }
  .hero h1 { font-size: 1.7rem; }
}
