/* ============================================================
 *  リョヒコンパス Docs — v3
 *  Claude docs 調のクリーンなダークテーマ
 *  AppBar / 折りたたみサイドバー / 検索 / TOC / prev-next
 * ============================================================ */

:root {
  --brand: #1E40AF;
  --brand-light: #60A5FA;
  --ink: #E7EAF0;
  --ink-muted: #B3BAC9;
  --ink-dim: #8B93A3;
  --bg: #0E1117;
  --bg-raised: #161B22;
  --panel: #1C232E;
  --panel-2: #242C39;
  --border: #2D3542;
  --border-strong: #3A4352;
  --accent-bg: rgba(96,165,250,.10);
  --nav-hover: rgba(255,255,255,.04);
  --sidebar-width: 280px;
  --toc-width: 220px;
  --appbar-height: 56px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding-top: var(--appbar-height);
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand-light); }
a:hover { color: #93BCFA; }
::selection { background: var(--brand); color: #fff; }

/* === Skip link === */
.skip-link {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}
.skip-link:focus {
  left: 12px;
  top: calc(var(--appbar-height) + 8px);
  width: auto;
  height: auto;
  padding: 10px 18px;
  background: var(--brand);
  color: #fff !important;
  border-radius: 8px;
  z-index: 300;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  text-decoration: none;
  font-size: 14px;
}

:focus-visible {
  outline: 2px solid var(--brand-light);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ============================================================
 *  AppBar
 * ============================================================ */
.docs-appbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--appbar-height);
  z-index: 150;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  display: flex !important;
  flex-direction: row;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  margin: 0;
}

.appbar-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  padding: 0;
}
.appbar-menu-btn:hover { background: var(--panel); }

.appbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  min-width: 0;
  height: 40px;
}
.appbar-brand:hover { color: var(--ink); text-decoration: none; }
.appbar-brand img {
  height: 26px !important;
  width: 26px !important;
  flex-shrink: 0;
  display: block;
}
.appbar-brand strong {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--ink);
}
.appbar-brand .sub {
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  margin-left: 2px;
}

.appbar-spacer { flex: 1 1 auto; }

.appbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.appbar-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.appbar-link:hover {
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
}
.appbar-link i { font-size: 14px; }

/* ============================================================
 *  Layout
 * ============================================================ */
.doc-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: calc(100vh - var(--appbar-height));
  position: relative;
}

/* ============================================================
 *  Sidebar
 * ============================================================ */
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--appbar-height);
  height: calc(100vh - var(--appbar-height));
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0 40px;
  display: flex;
  flex-direction: column;
}

/* Search */
.sidebar-search {
  padding: 6px 16px 10px;
  position: relative;
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 13.5px;
  padding: 8px 12px 8px 34px;
  border-radius: 8px;
  font-family: inherit;
  outline: none;
}
.sidebar-search input::placeholder { color: var(--ink-dim); }
.sidebar-search input:focus {
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(96,165,250,.22);
}
.sidebar-search-icon {
  position: absolute;
  left: 26px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-dim);
  pointer-events: none;
  font-size: 14px;
}

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 0 20px;
}

/* Section */
.nav-section {}
.nav-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 14px 20px 6px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.nav-section-title:hover { color: var(--ink); }
.nav-section-title .chev {
  transition: transform .2s ease;
  font-size: 10px;
  color: var(--ink-dim);
}
.nav-section.collapsed .nav-section-title .chev { transform: rotate(-90deg); }
.nav-section-items {
  overflow: hidden;
  transition: max-height .28s ease;
  max-height: 2000px;
}
.nav-section.collapsed .nav-section-items { max-height: 0; }

/* Nav item */
.sidebar a.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 20px 7px 17px;
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.4;
  border-left: 3px solid transparent;
  min-height: 32px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .12s ease, color .12s ease;
}
.sidebar a.nav-item:hover {
  background: var(--nav-hover);
  color: var(--ink);
  text-decoration: none;
}
.sidebar a.nav-item[aria-current="page"] {
  color: var(--brand-light);
  background: var(--accent-bg);
  border-left-color: var(--brand-light);
  font-weight: 600;
}
.sidebar a.nav-item i.bi {
  font-size: 14px;
  color: var(--ink-dim);
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}
.sidebar a.nav-item[aria-current="page"] i.bi { color: var(--brand-light); }
.sidebar a.nav-item.hidden-by-search { display: none !important; }

.no-search-results {
  padding: 14px 20px;
  color: var(--ink-dim);
  font-size: 12.5px;
  font-style: italic;
  display: none;
}
.no-search-results.visible { display: block; }

/* Sidebar resize handle (desktop) */
.sidebar-resize {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
  transition: background .15s ease;
}
.sidebar-resize:hover,
.sidebar-resize.dragging { background: rgba(96,165,250,.25); }
body.resizing { cursor: col-resize; user-select: none; }

/* ============================================================
 *  Main
 * ============================================================ */
.main {
  padding: 40px 48px 60px;
  min-width: 0;
}
.main-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 48px;
  max-width: 1080px;
  margin: 0 auto;
}
.content-area { min-width: 0; }

/* Breadcrumb */
.breadcrumb {
  color: var(--ink-dim);
  font-size: 12.5px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--ink-muted);
  text-decoration: none;
  padding: 2px 6px;
  margin: -2px -6px;
  border-radius: 4px;
}
.breadcrumb a:hover {
  color: var(--brand-light);
  background: rgba(96,165,250,.08);
}
.breadcrumb .sep { color: var(--ink-dim); font-size: 10px; }
.breadcrumb .current { color: var(--ink); font-weight: 500; }

/* Content */
.content { max-width: 780px; }
.content h1 {
  font-size: 32px;
  margin: 0 0 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--appbar-height) + 24px);
  line-height: 1.25;
  color: var(--ink);
}
.content h2 {
  font-size: 22px;
  margin-top: 44px;
  margin-bottom: 14px;
  font-weight: 700;
  color: var(--ink);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: calc(var(--appbar-height) + 24px);
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.content h3 {
  font-size: 17px;
  margin-top: 28px;
  margin-bottom: 10px;
  font-weight: 700;
  color: var(--ink);
  scroll-margin-top: calc(var(--appbar-height) + 24px);
  line-height: 1.4;
}
.content h4 {
  font-size: 15px;
  margin-top: 20px;
  margin-bottom: 8px;
  color: var(--ink-muted);
  font-weight: 600;
}
.content p, .content li {
  font-size: 15px;
  color: #C7CFDB;
  line-height: 1.75;
}
.content strong { color: var(--ink); font-weight: 600; }
.content ul, .content ol { padding-left: 22px; }
.content li { margin-bottom: 6px; }

.content a {
  color: var(--brand-light);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.content a:hover { color: #93BCFA; text-decoration-thickness: 2px; }

.content code {
  background: var(--panel);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--brand-light);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.content pre {
  background: var(--panel);
  padding: 16px 18px;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
  line-height: 1.55;
  font-size: 13px;
}
.content pre code { background: transparent; padding: 0; color: var(--ink); }

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 13.5px;
}
.content th, .content td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
}
.content th { background: var(--panel); color: var(--ink); font-weight: 600; }
.content td { color: #C7CFDB; }
.content tbody tr:nth-child(even) td { background: rgba(255,255,255,.018); }

.content hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}
.content blockquote {
  border-left: 3px solid var(--brand-light);
  padding: 12px 16px;
  color: var(--ink-muted);
  margin: 20px 0;
  background: rgba(96,165,250,.04);
  border-radius: 0 6px 6px 0;
}

/* Heading anchor */
.content h2 .anchor, .content h3 .anchor {
  opacity: 0;
  margin-left: 8px;
  color: var(--brand-light);
  text-decoration: none;
  font-size: .85em;
  transition: opacity .15s ease;
}
.content h2:hover .anchor,
.content h3:hover .anchor,
.content h2 .anchor:focus-visible,
.content h3 .anchor:focus-visible { opacity: 1; }

/* ============================================================
 *  TOC (wide desktop only)
 * ============================================================ */
.toc { display: none; }

@media (min-width: 1280px) {
  .main-inner {
    grid-template-columns: 1fr var(--toc-width);
    max-width: 1280px;
  }
  .toc {
    display: block;
    position: sticky;
    top: calc(var(--appbar-height) + 32px);
    align-self: start;
    max-height: calc(100vh - var(--appbar-height) - 64px);
    overflow-y: auto;
    padding: 0 0 0 20px;
    border-left: 1px solid var(--border);
  }
  .toc-title {
    color: var(--ink-dim);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 12px;
  }
  .toc-list { list-style: none; padding: 0; margin: 0; }
  .toc-list li { margin: 0; }
  .toc-list a {
    color: var(--ink-muted);
    text-decoration: none;
    font-size: 13px;
    line-height: 1.5;
    display: block;
    padding: 4px 10px;
    border-left: 2px solid transparent;
    margin-left: -2px;
  }
  .toc-list a:hover { color: var(--ink); background: rgba(255,255,255,.02); }
  .toc-list a.active {
    color: var(--brand-light);
    border-left-color: var(--brand-light);
  }
  .toc-list .toc-h3 { padding-left: 24px; font-size: 12.5px; }
}

@media (min-width: 1600px) {
  .main-inner { max-width: 1400px; }
  .main { padding: 48px 64px 64px; }
}

/* ============================================================
 *  Prev/Next
 * ============================================================ */
.prev-next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 56px 0 24px;
}
.prev-next a {
  display: block;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink-muted);
  transition: border-color .15s ease, background .15s ease;
}
.prev-next a:hover {
  border-color: var(--brand-light);
  background: var(--panel-2);
  color: var(--ink);
  text-decoration: none;
}
.prev-next .pn-label {
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 4px;
  display: block;
}
.prev-next .pn-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  display: block;
  line-height: 1.4;
}
.prev-next .pn-prev { text-align: left; }
.prev-next .pn-next { text-align: right; }
.prev-next .pn-empty { visibility: hidden; }

/* ============================================================
 *  Page footer
 * ============================================================ */
.page-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--ink-dim);
  font-size: 13px;
  text-align: center;
}
.page-footer a { text-decoration: none; color: var(--ink-muted); }
.page-footer a:hover { color: var(--brand-light); text-decoration: underline; }

/* ============================================================
 *  Hero
 * ============================================================ */
.doc-hero {
  background: linear-gradient(135deg, rgba(30,64,175,.16) 0%, rgba(96,165,250,.06) 100%);
  border: 1px solid rgba(96,165,250,.22);
  border-radius: 14px;
  padding: 28px 32px;
  margin: 0 0 32px;
}
.doc-hero h1 {
  margin: 0 0 10px;
  font-size: 28px;
  border: none;
  padding: 0;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.doc-hero p {
  color: var(--ink-muted);
  font-size: 15px;
  margin: 0;
  line-height: 1.75;
}

/* ============================================================
 *  Hub cards
 * ============================================================ */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 24px 0 48px;
}
.hub-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  text-decoration: none;
  color: var(--ink);
  display: block;
  transition: border-color .15s ease, transform .15s ease, background .15s ease;
}
.hub-card:hover {
  border-color: var(--brand-light);
  background: var(--panel-2);
  transform: translateY(-2px);
  color: var(--ink);
  text-decoration: none;
}
.hub-card .hub-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent-bg);
  color: var(--brand-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
}
.hub-card h3 {
  font-size: 16px;
  margin: 0 0 6px;
  color: var(--ink);
  font-weight: 700;
}
.hub-card p {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 0;
  line-height: 1.6;
}

/* ============================================================
 *  Sidebar backdrop
 * ============================================================ */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: var(--appbar-height) 0 0 0;
  background: rgba(0,0,0,.55);
  z-index: 140;
}
.sidebar-backdrop.open { display: block; }

/* ============================================================
 *  Responsive: Tablet ≤ 991
 * ============================================================ */
@media (max-width: 991.98px) {
  .doc-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -340px;
    top: var(--appbar-height);
    width: 300px;
    z-index: 160;
    transition: left .25s ease;
    height: calc(100vh - var(--appbar-height));
    background: var(--bg-raised);
  }
  .sidebar.open { left: 0; }
  .sidebar-resize { display: none; }
  .appbar-menu-btn { display: inline-flex; }
  .appbar-brand .sub { display: none; }
  .main { padding: 28px 28px 48px; }
  .main-inner { gap: 28px; }
  .content h1 { font-size: 26px; }
  .content h2 { font-size: 20px; }
  .prev-next { grid-template-columns: 1fr; }
  .prev-next .pn-empty { display: none; }
  .doc-hero { padding: 22px 22px; margin-bottom: 24px; }
  .doc-hero h1 { font-size: 23px; }
  .doc-hero p { font-size: 14.5px; }
  .hub-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
}

/* ============================================================
 *  Responsive: Phone ≤ 576
 * ============================================================ */
@media (max-width: 576px) {
  .main { padding: 20px 18px 48px; }
  .content h1 { font-size: 24px; }
  .content h2 { font-size: 19px; }
  .content h3 { font-size: 16px; }
  .content p, .content li { font-size: 15.5px; line-height: 1.78; }
  .content { max-width: 100%; }
  .sidebar { width: 88%; max-width: 320px; }
  .prev-next a { padding: 14px 16px; }
  .breadcrumb { font-size: 12.5px; }
  .docs-appbar { padding: 0 12px; gap: 10px; }
  .appbar-brand strong { font-size: 14.5px; }
  .appbar-brand img { height: 24px !important; width: 24px !important; }
  .appbar-links { gap: 2px; }
  .appbar-link {
    padding: 8px 10px;
    font-size: 12.5px;
  }
  .appbar-link span { display: none; }
  .appbar-link i { font-size: 18px; }
  .hub-grid { grid-template-columns: 1fr; }
  .doc-hero { padding: 20px 18px; }
  .doc-hero h1 { font-size: 22px; }
  .doc-hero p { font-size: 14px; }
}

/* ============================================================
 *  Reduced motion
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
