/*============================================
  CSS カスタムプロパティ（カラースキーム）
============================================*/
:root {
  --primary:       #3949ab;
  --primary-dark:  #283593;
  --primary-light: #9fa8da;
  --bg:            #f5f7fa;
  --surface:       #ffffff;
  --border:        #e0e0e0;
  --text:          #212121;
  --text-muted:    #757575;
  --success:       #43a047;
  --danger:        #e53935;
}

/*============================================
  グローバルリセット
============================================*/
html {
  scroll-behavior: smooth;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

textarea {
  resize: none;
}

body {
  padding-top: 60px;
  font-family: 'Lato', sans-serif;
  background: var(--bg);
  color: var(--text);
}

/*============================================
  ナビゲーションバー
============================================*/
nav.navbar {
  background: var(--primary-dark) !important;
  box-shadow: 0 2px 8px rgba(40, 53, 147, 0.35);
}

nav#navbar {
  background: var(--primary-dark);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.5px;
}

.nav-link {
  font-weight: 500;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.nav-link:hover,
.nav-item.active .nav-link {
  opacity: 1;
}

.lang-toggle {
  display: flex;
  gap: 4px;
  margin-left: 12px;
}

.btn-lang {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: rgba(255,255,255,0.7);
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-lang:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.7);
}

.btn-lang-active {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border-color: #fff;
}

/*============================================
  メインコンテナ
============================================*/
div#main-div {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.09);
  border-radius: 0 0 10px 10px;
  min-height: calc(100vh - 60px);
}

/*============================================
  ヘッダー（ロゴ + バージョン）
============================================*/
#top {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 32px 0;
}

div#logo {
  /* position ハック除去 */
}

div#hoge {
  /* position ハック除去 — pill バッジ化 */
  position: static;
  width: auto;
  top: auto;
  left: auto;
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--primary);
  background: #e8eaf6;
  border: 1px solid var(--primary-light);
  border-radius: 20px;
  padding: 3px 11px;
  margin-bottom: 10px;
}

/*============================================
  メインコンテンツエリア
============================================*/
div#graphgraph {
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 16px 32px 24px;
}

div#about,
div#privacy,
div#contact,
div#index-content,
div#articles {
  width: auto;
  padding: 24px 40px 36px;
}

/*============================================
  メインレイアウト（エディタ + グラフ）
============================================*/
.main-layout {
  display: flex;
  gap: 16px;
}

.main-layout-editor {
  flex: 0 0 220px;
}

.main-layout-graph {
  flex: 1 1 0;
  min-width: 0;
}

@media (max-width: 768px) {
  div#graphgraph {
    padding: 12px 16px 20px;
  }
  .main-layout {
    flex-direction: column;
  }
  .main-layout-editor {
    flex: none;
    width: 100%;
  }
  .main-layout-graph {
    flex: none;
    width: 100%;
  }
  .editor-wrapper {
    height: 200px;
  }
  #network {
    height: 280px;
  }
  .settings-panel {
    padding: 8px 10px;
  }
  .preset-row {
    gap: 4px;
  }
}

/*============================================
  エディタ（行番号 + テキストエリア）
============================================*/
/* ── Editor Toolbar ───────────────────────── */
.editor-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.btn-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 3px 10px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.btn-editor:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
}
.btn-editor:disabled {
  opacity: 0.35;
  cursor: default;
}

.editor-wrapper {
  display: flex;
  height: 360px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fafafa;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.editor-wrapper:focus-within {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(92, 107, 192, 0.18);
  background: #fff;
}

.editor-wrapper.input-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.15) !important;
}

.line-numbers {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 10px 6px 10px 6px;
  background: #f1f3f4;
  color: #b0b8c1;
  font-family: 'Courier New', Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.65;
  min-width: 30px;
  user-select: none;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.line-numbers span {
  display: block;
}

textarea#input_area {
  flex: 1;
  height: 100%;
  border: none;
  border-radius: 0;
  padding: 10px 12px;
  font-family: 'Courier New', Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.65;
  background: transparent;
  color: var(--text);
  resize: none;
  outline: none;
  overflow-y: auto;
}

.inline-error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 5px;
  font-weight: 500;
}

.inline-error a {
  color: var(--danger);
}

/*============================================
  グラフ可視化キャンバス
============================================*/
.network-wrapper {
  position: relative;
}

#network {
  background: #fff;
  width: 100%;
  height: 360px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

/*============================================
  ローディングスピナー
============================================*/
.spinner-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  z-index: 10;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/*============================================
  Toast 通知
============================================*/
.toast-notification {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: #323232;
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 0.87rem;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.toast-enter-active, .toast-leave-active {
  transition: opacity 0.25s, transform 0.25s;
}
.toast-enter, .toast-leave-to {
  opacity: 0;
  transform: translateY(10px);
}

/*============================================
  スムーズトグルエリア
============================================*/
.smooth-toggle-area {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  font-size: 0.82rem;
  color: var(--text-muted);
  user-select: none;
}

.smooth-toggle-area label {
  cursor: pointer;
  margin: 0;
}

.smooth-toggle-area input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--primary);
}

/*============================================
  設定パネル（ドロップダウン + ランダム生成）
============================================*/
.settings-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin-top: 12px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
}

.settings-panel-dropdowns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1;
}

/*============================================
  ドロップダウンボタン（設定系）
============================================*/
.btn.btn-secondary,
.btn-secondary.dropdown-toggle {
  background: #f1f3f4 !important;
  border: 1.5px solid var(--border) !important;
  color: var(--text) !important;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  transition: background 0.15s, border-color 0.15s;
  box-shadow: none !important;
}

.btn.btn-secondary:hover,
.btn-secondary.dropdown-toggle:hover {
  background: #e4e7ea !important;
  border-color: #bdbdbd !important;
}

.btn.btn-secondary:focus,
.btn-secondary.dropdown-toggle:focus {
  box-shadow: 0 0 0 3px rgba(57, 73, 171, 0.2) !important;
}

/*============================================
  VISUALIZE!! ボタン
============================================*/
.btn.btn-outline-primary {
  color: var(--primary) !important;
  border: 2px solid var(--primary) !important;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 5px 20px;
  border-radius: 6px;
  letter-spacing: 0.3px;
  transition: background 0.15s, color 0.15s;
}

.btn.btn-outline-primary:hover {
  background: var(--primary) !important;
  color: #fff !important;
}

/*============================================
  ランダム生成パネル
============================================*/

.random-gen-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.random-gen-field {
  display: flex;
  align-items: center;
  gap: 5px;
}

.random-gen-field-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.random-gen-input {
  width: 62px;
  padding: 4px 8px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-size: 0.84rem;
  text-align: center;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s;
}

.random-gen-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(92, 107, 192, 0.15);
}

.random-gen-input::placeholder {
  color: #bdbdbd;
  font-size: 0.78rem;
}

.random-gen-select {
  padding: 4px 8px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-size: 0.84rem;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s;
}

.random-gen-select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(92, 107, 192, 0.15);
}

.random-gen-input-w {
  width: 52px;
}

.random-gen-sep {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.btn-random-gen {
  padding: 5px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn-random-gen:hover {
  background: var(--primary-dark);
}

.btn-random-gen:active {
  transform: scale(0.97);
}

/*============================================
  解析ツール トグル + セクション
============================================*/
.btn-advanced-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px 0;
  margin: 14px 0 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.btn-advanced-toggle:hover {
  background: #eef0f8;
  border-color: var(--primary-light);
  color: var(--primary);
}

.btn-advanced-toggle.is-open {
  background: var(--surface);
  border-color: var(--border);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  color: var(--primary);
}

.advanced-section {
  margin-top: -1px;
  padding: 16px;
  border: 1.5px solid var(--border);
  border-top: none;
  background: var(--surface);
  border-radius: 0 0 10px 10px;
  box-shadow: 0 4px 12px rgba(57, 73, 171, 0.06);
}

.advanced-empty {
  text-align: center;
  color: #b0b8c8;
  font-size: 0.84rem;
  padding: 28px 16px;
  line-height: 1.7;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  background: #fafbfd;
}

/*============================================
  URL Export ボタン
============================================*/
.btn.btn-outline-success {
  color: var(--success) !important;
  border: 2px solid var(--success) !important;
  font-weight: 600;
  font-size: 0.84rem;
  padding: 5px 14px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.btn.btn-outline-success:hover {
  background: var(--success) !important;
  color: #fff !important;
}

/*============================================
  エラーアラート
============================================*/
.alert.alert-danger {
  border-radius: 6px;
  border: 1px solid #ffcdd2;
  border-left: 4px solid var(--danger);
  background: #fff5f5;
  margin-bottom: 16px;
  margin-top: 4px;
}

.alert.alert-danger a.alert-link {
  color: var(--danger);
}

/*============================================
  トップページ コンテンツエリア
============================================*/
div#index-content {
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/*============================================
  広告エリア
============================================*/
#ad-area {
  max-width: 728px;
  margin: 0 auto;
  padding: 12px 16px;
  text-align: center;
}

/*============================================
  ページラッパー（メイン + サイドバー広告）
============================================*/
#page-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
}

#ad-sidebar-spacer {
  width: 160px;
  flex-shrink: 0;
}

#ad-sidebar {
  position: sticky;
  top: 76px;
  width: 160px;
  flex-shrink: 0;
  padding-top: 16px;
}

@media (max-width: 1350px) {
  #ad-sidebar,
  #ad-sidebar-spacer {
    display: none;
  }
}

/*============================================
  使い方・このページについて 共通
============================================*/
.about-section {
  margin-bottom: 36px;
}

.about-h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  border-left: 4px solid var(--primary);
  padding-left: 10px;
  margin-bottom: 14px;
}

.about-h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 16px 0 8px;
}

.about-p {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 10px;
}

.about-p a, .about-section a {
  color: var(--primary);
}

/* 機能カード */
.about-features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.about-feature-item {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.about-feature-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.about-feature-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* 技術バッジ */
.about-tech-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.about-tech-badge {
  background: #e8eaf6;
  border: 1px solid var(--primary-light);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.83rem;
  color: var(--primary);
}

.about-tech-role {
  color: var(--text-muted);
  font-weight: 400;
}

/* 更新履歴 */
.about-changelog {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.about-changelog-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 0.87rem;
}

.about-version-badge {
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.about-changelog-desc {
  color: var(--text);
}

/*============================================
  使い方ページ固有
============================================*/
.howto-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.howto-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}

.howto-step-num {
  flex: 0 0 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.howto-step-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.howto-step-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.howto-step-desc code {
  background: #e8eaf6;
  color: var(--primary);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.82rem;
}

/* 入力例 */
.howto-example-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.howto-example-block {
  flex: 1 1 160px;
}

.howto-example-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.howto-code {
  background: #f5f5f5;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: 'Courier New', Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
  margin: 0;
  color: var(--text);
}

/* 機能説明 */
.howto-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.howto-feature-item {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  align-items: baseline;
}

.howto-feature-title {
  flex: 0 0 130px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}

.howto-feature-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* FAQ */
.howto-faq {
  border-left: 3px solid var(--primary-light);
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--bg);
  border-radius: 0 6px 6px 0;
}

.howto-faq-q {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.howto-faq-a {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/*============================================
  記事一覧（AtCoder 解説）
============================================*/
.articles-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.article-card {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.article-card:hover {
  background: var(--bg);
  text-decoration: none;
  color: inherit;
}

.article-date {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 72px;
}

.article-contest {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 58px;
}

.article-body {
  flex: 1;
  min-width: 0;
}

.article-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.article-title a {
  color: var(--text);
  text-decoration: none;
}

.article-title a:hover {
  color: var(--primary);
}

.article-tags {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
}

.article-tag {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 3px;
  padding: 1px 5px;
  vertical-align: middle;
}

/*── 記事ページ ──*/
.article-back {
  margin-bottom: 12px;
  font-size: 0.82rem;
}

.article-back a {
  color: var(--text-muted);
  text-decoration: none;
}

.article-back a:hover {
  color: var(--primary);
}

.article-detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.82rem;
}

.article-detail-meta a {
  color: var(--primary);
  font-weight: 600;
}

.article-section {
  margin-bottom: 16px;
}

.article-section-h {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 8px;
}

.article-detail-p {
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 6px;
}

.article-detail-p code {
  background: #e8eaf6;
  color: var(--primary);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.82rem;
}

.article-detail-p strong {
  color: var(--text);
  font-weight: 700;
}

.article-detail-code {
  background: #f5f5f5;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: 'Courier New', Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text);
  margin: 8px 0;
  overflow-x: auto;
}

/*============================================
  フッター
============================================*/
#foot {
  padding: 14px 40px 16px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

#footer {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.footer-links {
  margin-bottom: 8px;
  font-size: 0.8rem;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

.footer-sep {
  color: var(--text-muted);
  margin: 0 8px;
}

/* お問い合わせページ カード */
.contact-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 16px;
}

.contact-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.contact-card-body {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 12px;
}

.contact-link {
  display: inline-block;
  padding: 8px 20px;
  background: var(--primary);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

.contact-link:hover {
  background: var(--primary-dark);
  color: #fff;
  text-decoration: none;
}

.contact-link:active {
  transform: scale(0.97);
}

/* プライバシーポリシー セクションカード */
.privacy-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 18px 22px;
  margin-bottom: 20px;
}

.privacy-card .about-h2 {
  margin-bottom: 10px;
}

.privacy-card .about-p {
  margin-bottom: 0;
}

/*============================================
  ユーティリティ
============================================*/
.space {
  margin-right: 6px;
}

/* howtouse.html の vis.js プレビューカード */
.smooth {
  position: relative;
  top: 3px;
}

.bd-example {
  position: relative;
  padding: 1rem;
  margin: 1rem -15px 0;
  border: solid #f8f9fa;
  border-width: 0.2rem 0 0;
}

li#menu {
  list-style-type: none;
  display: inline;
}

/*============================================
  プリセットエリア
============================================*/
.preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
}

.preset-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 2px;
}

.btn-preset {
  font-size: 0.78rem;
  padding: 3px 11px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: #f8f9fa;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.6;
}

.btn-preset:hover {
  background: #e8eaf6;
  border-color: var(--primary-light);
  color: var(--primary);
}

.btn-preset-fun {
  background: #fff8e1;
  border-color: #ffe082;
  color: #e65100;
}

.btn-preset-fun:hover {
  background: #fff3c4;
  border-color: #ffb300;
  color: #bf360c;
}

/*============================================
  グラフ情報パネル
============================================*/
.graph-info-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f8f9ff 0%, #f0f2fb 100%);
  border: 1px solid #dde1f0;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.info-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
}

.info-value {
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.tree-badge, .forest-badge, .dag-badge, .scc-badge, .complete-badge, .bipartite-badge {
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
  text-transform: uppercase;
}

.tree-badge {
  background: #e8f5e9;
  color: var(--success);
  border: 1px solid #a5d6a7;
}

.forest-badge {
  background: #e3f2fd;
  color: #1565c0;
  border: 1px solid #90caf9;
}

.dag-badge {
  background: #f3e5f5;
  color: #6a1b9a;
  border: 1px solid #ce93d8;
}

.scc-badge {
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffcc80;
}

.complete-badge {
  background: #fce4ec;
  color: #880e4f;
  border: 1px solid #f48fb1;
}

.bipartite-badge {
  background: #e0f7fa;
  color: #006064;
  border: 1px solid #80deea;
}

/*============================================
  最短経路 / 探索アニメ
============================================*/
.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.feature-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #fafbfd;
  border: 1px solid #dde1f0;
  border-radius: 10px;
  font-size: 0.84rem;
  flex-wrap: wrap;
}

.feature-label {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.76rem;
  margin-right: 2px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.feature-arrow {
  color: var(--primary-light);
  font-weight: 600;
}

.node-input {
  width: 58px;
  padding: 5px 8px;
  border: 1.5px solid #dde1f0;
  border-radius: 6px;
  font-size: 0.84rem;
  text-align: center;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.node-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(57, 73, 171, 0.08);
}

.btn-feature {
  padding: 5px 14px;
  border: 1.5px solid var(--primary-light);
  border-radius: 6px;
  background: #e8eaf6;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-feature:hover { background: #c5cae9; }
.btn-feature-active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
  box-shadow: 0 2px 6px rgba(57, 73, 171, 0.25);
}

.btn-feature-reset {
  padding: 3px 9px;
  border: 1px solid #dde1f0;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-feature-reset:hover {
  background: #f1f3f4;
  color: var(--danger);
  border-color: var(--danger);
}

.feature-result {
  color: var(--text);
  font-size: 0.84rem;
}
.feature-noresult {
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
}

/*============================================
  最短経路パネル
============================================*/
.sp-path-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #fffde7 0%, #fff8e1 100%);
  border: 1px solid #ffe082;
  border-radius: 10px;
  font-size: 0.83rem;
}

/*============================================
  距離配列パネル
============================================*/
.sp-all-dists-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #f5f7ff 0%, #eef0fb 100%);
  border: 1px solid #c5cae9;
  border-radius: 10px;
  font-size: 0.83rem;
}

.dist-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid #c5cae9;
  border-radius: 8px;
  padding: 4px 8px;
  min-width: 36px;
  line-height: 1.3;
  transition: transform 0.1s;
}
.dist-item:hover {
  transform: translateY(-1px);
}

.dist-item.dist-from {
  border-color: #0288d1;
  background: #e1f5fe;
}

.dist-item.dist-unreachable {
  border-color: #bdbdbd;
  background: #f5f5f5;
  color: #9e9e9e;
}

.dist-vertex {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
}

.dist-value {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.dist-item.dist-from .dist-value {
  color: #0288d1;
}

.dist-item.dist-unreachable .dist-value {
  color: #9e9e9e;
}

/*============================================
  トポロジカル順序
============================================*/
.topo-order {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  border: 1px solid #ce93d8;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 0.83rem;
}

.topo-label {
  color: #6a1b9a;
  font-weight: 600;
  margin-right: 6px;
  white-space: nowrap;
}

.topo-node {
  color: var(--text);
  font-weight: 600;
}

.topo-arrow {
  color: #9c27b0;
  font-weight: 400;
}

/* ── History Panel ─────────────────────────────── */
.history-panel {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.history-label {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}

.btn-history-clear {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 2px 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-history-clear:hover {
  background: var(--bg);
  color: var(--text);
}

.history-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 4px 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.84rem;
  transition: background 0.12s;
}
.history-item:hover {
  background: var(--bg);
}

.history-time {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  min-width: 38px;
}

.history-meta {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

.history-flags {
  display: flex;
  gap: 4px;
}

.history-flag {
  background: #e3f2fd;
  color: #1565c0;
  font-size: 0.72rem;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 500;
}

.history-preview {
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

/* ── BST Visualizer ────────────────────────────── */

.bst-container {
  padding: 0 16px 32px;
}

.bst-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.bst-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.bst-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.bst-panel {
  width: 300px;
  min-width: 260px;
  flex-shrink: 0;
}

.bst-section {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.bst-label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 8px;
}

.bst-small-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 6px;
  white-space: nowrap;
}

.bst-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bst-input-small {
  width: 70px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  text-align: center;
}

.bst-input-small:focus {
  outline: none;
  border-color: var(--primary);
}

.bst-btn {
  padding: 5px 14px;
  border: none;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.bst-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bst-btn-primary {
  background: var(--primary);
  color: #fff;
}

.bst-btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.bst-btn-accent {
  background: #43a047;
  color: #fff;
}

.bst-btn-accent:hover:not(:disabled) {
  background: #2e7d32;
}

.bst-btn-danger {
  background: #ef5350;
  color: #fff;
  width: 100%;
}

.bst-btn-danger:hover:not(:disabled) {
  background: #c62828;
}

.bst-btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
}

.bst-btn-text:hover {
  text-decoration: underline;
}

.bst-radio-group {
  display: flex;
  gap: 12px;
}

.bst-radio {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  cursor: pointer;
}

.bst-radio input {
  margin: 0;
}

/* Speed slider */
.bst-speed-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bst-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  direction: rtl; /* 左が速い、右が遅い → 反転して左が遅い、右が速い */
}

.bst-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

.bst-speed-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.bst-speed-value {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Operation log */
.bst-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.bst-log-header .bst-label {
  margin-bottom: 0;
}

.bst-log {
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.82rem;
  font-family: 'Lato', monospace;
}

.bst-log-empty {
  color: var(--text-muted);
  text-align: center;
}

.bst-log-entry {
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}

.bst-log-success {
  color: #2e7d32;
}

.bst-log-error {
  color: #c62828;
}

.bst-log-info {
  color: var(--text);
}

/* Network display */
.bst-network-wrapper {
  flex: 1;
  position: relative;
  min-height: 500px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafafa;
}

#bst-network {
  width: 100%;
  height: 500px;
}

.bst-empty-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* ── B-Tree Visualizer ────────────────────────────── */

.btree-container {
  padding: 0 16px 32px;
}

.btree-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.btree-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.btree-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.btree-panel {
  width: 300px;
  min-width: 260px;
  flex-shrink: 0;
}

.btree-section {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.btree-label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 8px;
}

.btree-small-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 6px;
  white-space: nowrap;
}

.btree-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btree-input-small {
  width: 70px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  text-align: center;
}

.btree-input-small:focus {
  outline: none;
  border-color: var(--primary);
}

.btree-btn {
  padding: 5px 14px;
  border: none;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btree-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btree-btn-primary {
  background: var(--primary);
  color: #fff;
}

.btree-btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btree-btn-accent {
  background: #43a047;
  color: #fff;
}

.btree-btn-accent:hover:not(:disabled) {
  background: #2e7d32;
}

.btree-btn-danger {
  background: #ef5350;
  color: #fff;
  width: 100%;
}

.btree-btn-danger:hover:not(:disabled) {
  background: #c62828;
}

.btree-btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
}

.btree-btn-text:hover {
  text-decoration: underline;
}

/* Order selector */
.btree-order-group {
  display: flex;
  gap: 10px;
}

.btree-order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s;
}

.btree-order-badge.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.btree-order-badge:hover:not(.active):not(:disabled) {
  border-color: var(--primary-light);
}

.btree-order-badge:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btree-radio-group {
  display: flex;
  gap: 12px;
}

.btree-radio {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  cursor: pointer;
}

.btree-radio input {
  margin: 0;
}

/* Speed slider */
.btree-speed-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btree-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  direction: rtl;
}

.btree-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

.btree-speed-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.btree-speed-value {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Operation log */
.btree-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.btree-log-header .btree-label {
  margin-bottom: 0;
}

.btree-log {
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.82rem;
  font-family: 'Lato', monospace;
}

.btree-log-empty {
  color: var(--text-muted);
  text-align: center;
}

.btree-log-entry {
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}

.btree-log-success {
  color: #2e7d32;
}

.btree-log-error {
  color: #c62828;
}

.btree-log-info {
  color: var(--text);
}

/* Network display */
.btree-network-wrapper {
  flex: 1;
  position: relative;
  min-height: 600px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafafa;
}

#btree-network {
  width: 100%;
  height: 600px;
}

.btree-empty-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 1.1rem;
}
