/* ============================================
   TERASU 制作部署マニュアル — SPA stylesheet
   FSトンマナ（オレンジ #ff6b2b / ダーク）に統一
   ============================================ */
:root {
  /* Orange (TERASU / FS) */
  --y:       #ff6b2b;
  --y-soft:  #ff8f5e;
  --y-dim:   #ff8f5e;
  --y-deep:  #e85d20;

  /* Black/Dark */
  --bg:       #0a0a0a;
  --bg-card:  #111111;
  --bg-card-2:#1a1a1a;
  --bg-soft:  #1a1a1a;
  --border:   #222222;
  --border-2: #2a2a2a;

  /* Text */
  --text:     #ffffff;
  --text-2:   #e0e0e0;
  --text-3:   #999999;
  --text-4:   #666666;

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

  --font: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, 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（FSマニュアルと同一トンマナ）
   ============================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: rgba(10,10,10,.92);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.topbar-brand a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}
.topbar-logo {
  height: 17px;
  width: auto;
  display: block;
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--text);
}
.topbar-meta {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-mono);
}
@media (max-width: 600px) {
  .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);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-search {
  padding: 16px 14px 10px;
}
.sidebar-search input {
  width: 100%;
  padding: 9px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  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: 18px 14px 6px;
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
  opacity: .55;
}

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

.nav-item {
  display: block;
  padding: 9px 14px;
  color: var(--text-3);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  transition: all .2s;
  line-height: 1.5;
}
.nav-item:hover {
  background: rgba(255,107,43,.08);
  color: var(--y);
}
.nav-item.active {
  background: var(--y);
  color: #fff;
  font-weight: 700;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main {
  padding: 48px 48px 120px;
  background: var(--bg);
  min-width: 0;
  display: flex;
  justify-content: center;
}
.content {
  max-width: 820px;
  width: 100%;
}

/* ============================================
   HOME / TOC
   ============================================ */
.home-section {
  margin-bottom: 44px;
}
.home-title {
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 4px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--y);
  display: inline-block;
  letter-spacing: 1px;
}
.home-lead {
  color: var(--text-3);
  font-size: 14px;
  margin: 16px 0 26px;
  line-height: 1.9;
}

.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.phase-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  text-decoration: none;
  color: var(--text);
  transition: all .2s ease;
  position: relative;
  overflow: hidden;
}
.phase-card:hover {
  border-color: var(--y);
  background: rgba(255,107,43,.05);
  transform: translateY(-2px);
}
.phase-card-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--y-soft);
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}
.phase-card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 7px;
  line-height: 1.4;
  color: var(--text);
}
.phase-card-desc {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.7;
}

/* ============================================
   PAGE HEADER（各章上部）
   ============================================ */
.page-header {
  margin-bottom: 30px;
}
.page-phase-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--y-soft);
  letter-spacing: 0.18em;
  margin-bottom: 12px;
}
.page-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.5px;
  line-height: 1.3;
  margin-bottom: 6px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--y);
  display: inline-block;
}
.page-lead {
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.9;
  margin-top: 16px;
}

/* ============================================
   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;
  border: 1px solid var(--border);
  border-bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.md-body h2 + * { margin-top: 0; border-radius: 0; }
/* h2の直後から次のh2/hrまでをカード扱い */
.md-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 0;
  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-soft);
  margin: 26px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.md-body h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 18px 0 10px;
}

.md-body p {
  font-size: 14px;
  line-height: 1.9;
  margin-bottom: 13px;
  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.9;
  margin-bottom: 6px;
  color: var(--text-2);
}
.md-body li::marker { color: var(--y); }

.md-body a {
  color: var(--y-soft);
  text-decoration: underline;
  text-decoration-color: var(--y-deep);
  text-underline-offset: 3px;
  transition: all .15s;
}
.md-body a:hover { color: var(--y); text-decoration-color: var(--y); }
.md-body strong { font-weight: 700; color: var(--text); }
.md-body em { color: var(--y-soft); 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-soft);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.md-body pre {
  background: #0d0d0d;
  border: 1px solid var(--border-2);
  color: var(--text-2);
  padding: 16px 18px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 16px 0;
  font-size: 12.5px;
  line-height: 1.75;
  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(255,107,43,.05);
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 0 8px 8px 0;
  color: var(--text-2);
  font-weight: 500;
}
.md-body blockquote p { margin-bottom: 6px; }
.md-body blockquote p:last-child { margin-bottom: 0; }
.md-body blockquote strong { color: var(--y-soft); }

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

.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13px;
}
.md-body th {
  background: rgba(255,107,43,.15);
  color: var(--y-soft);
  font-weight: 700;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--y);
}
.md-body td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: top;
}
.md-body tr:hover td { background: rgba(255,107,43,.05); }

.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;
}

/* インラインアイコン（:Li〇〇: 変換） */
.ic {
  width: 1.04em; height: 1.04em;
  display: inline-block; vertical-align: -2px; flex-shrink: 0;
}
.md-body .ic { color: var(--y); }
.md-body h3 .ic, .md-body h4 .ic { color: var(--y-soft); }
/* :Li1〜:Li9: の数字バッジ */
.md-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--y); color: #fff;
  font-family: var(--font-mono); font-weight: 800; font-size: 12px;
  border-radius: 6px; vertical-align: -3px; margin-right: 4px;
}

/* ============================================
   PAGE NAVIGATION（前後）
   ============================================ */
.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.page-nav-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  transition: all .2s;
}
.page-nav-item:hover { border-color: var(--y); background: rgba(255,107,43,.05); }
.page-nav-item.next { text-align: right; align-items: flex-end; }
.page-nav-label {
  font-size: 12px; font-weight: 600; color: var(--text-3);
  letter-spacing: 1px; text-transform: uppercase;
}
.page-nav-title { font-size: 15px; font-weight: 700; color: var(--y-soft); }
.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: #fff;
  box-shadow: 0 8px 24px rgba(255,107,43,.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);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .menu-toggle { display: flex; }
  .main { padding: 28px 18px 90px; }
  .topbar-meta { display: none; }
  .phase-grid { grid-template-columns: 1fr; }
  .page-nav { grid-template-columns: 1fr; }
  .page-nav-item.next { text-align: left; align-items: flex-start; }
}
