/* ============================================
   TERASU Manual — scale-morning準拠リニューアル v1.2
   ============================================ */
:root {
  /* Yellow (Modern Amber) — scale-morning のオレンジ位置を全部これに */
  --y:       #FACC15;
  --y-soft:  #FDE047;
  --y-dim:   #EAB308;
  --y-deep:  #CA8A04;

  /* Black/Dark — scale-morning と同じ濃度感 */
  --bg:       #0A0A0A;       /* メイン背景（純黒よりわずかに明るく） */
  --bg-card:  #161616;       /* カード（少し浮く） */
  --bg-card-2:#1F1F1F;       /* テーブルヘッダ等 */
  --bg-soft:  #262626;
  --border:   #1F1F1F;       /* ほぼ見えない境界 */
  --border-2: #2D2D2D;

  /* Text */
  --text:     #FFFFFF;
  --text-2:   #D4D4D4;
  --text-3:   #A3A3A3;
  --text-4:   #737373;

  /* Layout */
  --topbar-h: 64px;
  --sidebar-w: 240px;

  --font: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --font-mono: "Noto Sans JP", "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   TOP HEADER
   ============================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}
.topbar-brand a {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}
.topbar-logo {
  height: 32px;
  width: auto;
  display: block;
  margin: -10px 0;
}
.topbar-subtitle {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  padding-left: 14px;
  border-left: 1px solid var(--border-2);
  line-height: 1.4;
}
.topbar-brand a:hover .topbar-subtitle { color: var(--y); }
.topbar-meta {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 500;
}
@media (max-width: 600px) {
  .topbar-subtitle { display: none; }
  .topbar { padding: 0 16px; }
}

/* ============================================
   LAYOUT
   ============================================ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--topbar-h));
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-left: 16px;
}

.sidebar-search {
  padding: 8px 8px 16px;
}
.sidebar-search input {
  width: 100%;
  padding: 9px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: all .15s;
}
.sidebar-search input::placeholder { color: var(--text-4); }
.sidebar-search input:focus { border-color: var(--y); }

.sidebar-section-label {
  padding: 4px 12px 12px;
  font-size: 11px;
  color: var(--text-4);
  letter-spacing: 0.15em;
  font-weight: 700;
}

.sidebar-nav {
  flex: 1;
  padding: 0 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.nav-item {
  display: block;
  padding: 10px 14px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 6px;
  transition: all .12s;
  line-height: 1.5;
}
.nav-item:hover {
  background: var(--bg-card);
  color: var(--text);
}
.nav-item.active {
  background: var(--y);
  color: #0A0A0A;
  font-weight: 700;
}

.sidebar-footer {
  padding: 14px 20px 16px;
  font-size: 11px;
  color: var(--text-4);
}
.sidebar-version { color: var(--y); font-weight: 600; margin-bottom: 3px; }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main {
  padding: 40px 56px 80px;
  background: var(--bg);
  min-width: 0;
}
.content {
  max-width: 880px;
  margin: 0 auto;
}

/* ============================================
   HOME / TOC
   ============================================ */
.home-section {
  margin-bottom: 48px;
}
.home-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--y);
  display: inline-block;
  letter-spacing: 0.01em;
}
.home-lead {
  color: var(--text-3);
  font-size: 14px;
  margin: 16px 0 28px;
  line-height: 1.95;
}

.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.phase-card {
  display: block;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 22px 24px;
  text-decoration: none;
  color: var(--text);
  transition: all .18s ease;
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
}
.phase-card:hover {
  background: var(--bg-card-2);
  border-color: var(--y-dim);
  transform: translateY(-2px);
}
.phase-card-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--y);
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}
.phase-card-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.4;
  color: var(--text);
}
.phase-card-desc {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.75;
}

.home-meta {
  display: flex;
  gap: 56px;
  margin: 24px 0 40px;
  padding: 28px 32px;
  background: var(--bg-card);
  border-radius: 12px;
}
.home-meta-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.home-meta-num {
  font-size: 34px;
  font-weight: 900;
  color: var(--y);
  line-height: 1;
}
.home-meta-label {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.18em;
  font-weight: 600;
}

/* ============================================
   PAGE HEADER (各Phase上部)
   ============================================ */
.page-header {
  margin-bottom: 32px;
}
.page-phase-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--y);
  letter-spacing: 0.2em;
  margin-bottom: 12px;
}
.page-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 6px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--y);
  display: inline-block;
}
.page-lead {
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.95;
  margin-top: 18px;
}

/* ============================================
   MARKDOWN BODY (カード調)
   ============================================ */
.md-body { color: var(--text-2); }

.md-body h2 {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  margin: 28px 0 0;
  padding: 22px 28px 12px;
  background: var(--bg-card);
  border-radius: 12px 12px 0 0;
  letter-spacing: 0.01em;
}
.md-body h2 + * {
  margin-top: 0;
  border-radius: 0;
}
/* h2の直後から次のh2/hrまでをカード扱い */
.md-section {
  background: var(--bg-card);
  border-radius: 0 0 12px 12px;
  padding: 4px 28px 24px;
  margin-bottom: 20px;
}
.md-section > *:first-child { margin-top: 12px; }
.md-section > *:last-child { margin-bottom: 0; }

.md-body h3 {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--y);
  margin: 28px 0 12px;
}
.md-body h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 10px;
}

.md-body p {
  font-size: 14px;
  line-height: 1.95;
  margin-bottom: 14px;
  color: var(--text-2);
}
.md-body ul, .md-body ol {
  margin: 12px 0;
  padding-left: 22px;
}
.md-body li {
  font-size: 14px;
  line-height: 1.95;
  margin-bottom: 6px;
  color: var(--text-2);
}
.md-body li::marker { color: var(--y); }

.md-body a {
  color: var(--y);
  text-decoration: underline;
  text-decoration-color: var(--y-deep);
  text-underline-offset: 3px;
  transition: all .15s;
}
.md-body a:hover {
  color: var(--y-soft);
  text-decoration-color: var(--y);
}
.md-body strong {
  font-weight: 700;
  color: var(--text);
}
.md-body em {
  color: var(--y);
  font-style: normal;
  font-weight: 600;
}

.md-body code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-soft);
  color: var(--y);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.md-body pre {
  background: #050505;
  border: 1px solid var(--border-2);
  color: var(--text-2);
  padding: 16px 20px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 16px 0;
  font-size: 12.5px;
  line-height: 1.7;
  font-family: var(--font-mono);
}
.md-body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
}
.md-body pre::-webkit-scrollbar { height: 6px; }
.md-body pre::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.md-body blockquote {
  border-left: 3px solid var(--y);
  background: rgba(250,204,21,.05);
  padding: 14px 20px;
  margin: 16px 0;
  border-radius: 0 8px 8px 0;
  color: var(--text-2);
}
.md-body blockquote p { margin-bottom: 6px; }
.md-body blockquote p:last-child { margin-bottom: 0; }
.md-body blockquote strong { color: var(--y); }

.md-body hr {
  border: 0;
  border-top: 1px solid var(--border-2);
  margin: 36px 0;
}

.md-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 16px 0;
  font-size: 13px;
  background: var(--bg-card-2);
  border-radius: 10px;
  overflow: hidden;
}
.md-body th, .md-body td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-2);
  color: var(--text-2);
}
.md-body th {
  background: var(--bg-soft);
  font-weight: 700;
  color: var(--y);
  font-size: 12.5px;
  letter-spacing: 0.02em;
}
.md-body tr:last-child td { border-bottom: 0; }

.md-body img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 16px 0;
  border: 1px solid var(--border-2);
}

.md-body input[type="checkbox"] {
  margin-right: 8px;
  width: 14px;
  height: 14px;
  accent-color: var(--y);
  vertical-align: middle;
}
.md-body li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -22px;
  padding: 2px 0;
}

/* ============================================
   PAGE NAVIGATION (前後・scale-morning準拠)
   ============================================ */
.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--border-2);
}
.page-nav-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px 28px;
  background: var(--bg-card);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  transition: all .15s;
  border: 1px solid transparent;
}
.page-nav-item:hover {
  background: var(--bg-card-2);
  border-color: var(--y-dim);
}
.page-nav-item.next { text-align: right; align-items: flex-end; }
.page-nav-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--y);
  letter-spacing: 0.08em;
}
.page-nav-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.page-nav-item.empty { visibility: hidden; }

/* ============================================
   MOBILE
   ============================================ */
.menu-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  background: var(--y);
  border: 0;
  border-radius: 50%;
  color: var(--bg);
  box-shadow: 0 8px 24px rgba(250,204,21,.3);
  cursor: pointer;
  z-index: 100;
  align-items: center;
  justify-content: center;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 85vw;
    max-width: 320px;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s ease;
    background: var(--bg);
    padding-left: 0;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0,0,0,.6);
  }
  .menu-toggle { display: flex; }
  .main { padding: 28px 20px 60px; }
  .topbar-meta { display: none; }
  .home-meta { gap: 32px; padding: 22px 24px; }
  .home-meta-num { font-size: 26px; }
  .phase-grid { grid-template-columns: 1fr; }
  .page-nav { grid-template-columns: 1fr; }
  .page-nav-item.next { text-align: left; align-items: flex-start; }
}
