/* ==========================================================================
   「やって覚える！」シリーズ共通 ＆ 「やって覚える！支援士」メインスタイル
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. デザイン トークン ＆ 基本定義
   -------------------------------------------------------------------------- */
:root {
  --bg-main: #090d16;
  --bg-card: rgba(15, 23, 42, 0.85);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --bg-slot: rgba(15, 23, 42, 0.6);
  --border-color: rgba(51, 65, 85, 0.7);
  --border-active: #0284c7;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #cbd5e1;

  --accent-sky: #0284c7;
  --accent-sky-light: #38bdf8;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #a855f7;

  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.25);
  
  --radius-lg: 1rem;
  --radius-md: 0.75rem;
  --radius-sm: 0.5rem;

  --font-sans: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
}

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

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(14, 165, 233, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 5rem;
  -webkit-tap-highlight-color: transparent;
}

/* --------------------------------------------------------------------------
   2. ヘッダー ＆ トップ ナビゲーション
   -------------------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-icon {
  width: 2.25rem;
  height: 2.25rem;
  background: linear-gradient(135deg, var(--accent-sky), var(--accent-purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.4);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  background: linear-gradient(90deg, #ffffff, #7dd3fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.series-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 9999px;
  text-transform: uppercase;
}

/* 問題選択セレクター */
.question-selector-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(30, 41, 59, 0.8);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-sub);
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.question-select {
  background: rgba(15, 23, 42, 0.9);
  color: var(--accent-sky-light);
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  max-width: 280px;
}

/* --------------------------------------------------------------------------
   3. メイン コンテンツ ＆ 問題概要カード
   -------------------------------------------------------------------------- */
.main-container {
  max-width: 1200px;
  margin: 1.5rem auto 0;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.problem-overview-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.problem-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.category-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  background: rgba(2, 132, 199, 0.15);
  color: var(--accent-sky-light);
  border: 1px solid rgba(2, 132, 199, 0.3);
  border-radius: var(--radius-sm);
}

.problem-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}

.problem-description {
  font-size: 0.9rem;
  color: var(--text-sub);
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   4. インタラクティブ ワークスペース
   -------------------------------------------------------------------------- */
.interactive-workspace {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);

}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
}

.section-title i {
  color: var(--accent-sky-light);
}

.helper-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- カード倉庫 (Warehouse) --- */
.tokens-warehouse {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  min-height: 60px;
  padding: 0.5rem;
  background: rgba(15, 23, 42, 0.4);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
}

.token-card {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  cursor: grab;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 44px; /* タッチ操作に最適化 */
}

.token-card:hover {
  border-color: var(--accent-sky-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.token-card:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.token-card.selected {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.2);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

.drag-handle {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* --- ドロップ スロット (Slots) --- */
.slots-container {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 1rem;
}

.slot-row {
  background: var(--bg-slot);
  border: 1.5px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s;
  min-height: 64px;
}

.slot-row.active-target {
  border-color: var(--accent-sky-light);
  background: rgba(2, 132, 199, 0.1);
  box-shadow: inset 0 0 12px rgba(2, 132, 199, 0.2);
}

.slot-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.slot-label-wrapper {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.slot-label {
  font-family: 'Outfit', 'Inter', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-sky-light);
  letter-spacing: 0.03em;
}

/* ヒントボタン（スマホ・PC両対応） */
.slot-hint-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 50%;
  position: relative;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 1;
}

.slot-hint-btn:hover,
.slot-hint-btn.is-active {
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.15);
}

/* ツールチップ吹き出し */
.slot-hint-tooltip {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: #0f172a;
  border: 1px solid var(--accent-amber);
  color: #f8fafc;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 0 10px rgba(245, 158, 11, 0.2);
  z-index: 100;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(4px);
}

.slot-hint-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 12px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--accent-amber) transparent transparent transparent;
}

/* PCホバー または スマホタップ(アクティブ)で表示 */
.slot-hint-btn:hover .slot-hint-tooltip,
.slot-hint-btn.is-active .slot-hint-tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.slot-placeholder {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.slot-target-zone {
  min-width: 240px;
  flex-grow: 1;
  min-height: 48px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  gap: 0.5rem;
}

/* 正誤状態のフィードバック */
.slot-row.correct {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
}

.slot-row.incorrect {
  border-color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
}

/* --------------------------------------------------------------------------
   5. シーケンス並べ替え ＆ ログ解析エンジン固有スタイル
   -------------------------------------------------------------------------- */
/* シーケンス並べ替え */
.sequence-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sequence-item {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: grab;
  transition: all 0.2s;
}

.sequence-item:hover {
  border-color: var(--accent-sky);
}

.sequence-content {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sequence-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

.sequence-desc {
  font-size: 0.8rem;
  color: var(--text-sub);
}

.sequence-controls {
  display: flex;
  gap: 0.35rem;
}

.seq-btn {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-sub);
  width: 2.2rem;
  height: 2.2rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.seq-btn:hover {
  background: var(--accent-sky);
  color: #fff;
}

/* ログ解析 */
.log-viewer {
  background: #020617;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-x: auto;
}

.log-line {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(30, 41, 59, 0.4);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-sub);
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line:hover {
  background: rgba(30, 41, 59, 0.8);
}

.log-line.selected {
  border-left-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.15);
}

.log-line.suspicious {
  border-left-color: var(--accent-rose);
}

.log-quiz-box {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.log-q-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.log-q-text {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--accent-sky-light);
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem;
}

.option-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

.option-btn:hover {
  border-color: var(--accent-sky);
  background: rgba(2, 132, 199, 0.2);
}

.option-btn.selected {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.25);
  font-weight: 700;
}

.option-btn.correct {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.3);
  color: #fff;
}

.option-btn.incorrect {
  border-color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.3);
}

/* --------------------------------------------------------------------------
   6. アクション フッター ＆ モーダル
   -------------------------------------------------------------------------- */
.action-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  z-index: 40;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.9);
  color: var(--text-sub);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #fff;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-sky), #0369a1);
  color: #fff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #38bdf8, var(--accent-sky));
  transform: translateY(-1px);
}

.btn-amber {
  background: linear-gradient(135deg, var(--accent-amber), #d97706);
  color: #fff;
}

/* モーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-amber);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-sub);
}

.modal-body ul {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-body strong {
  color: #fff;
  font-weight: 700;
}

code,
.inline-code {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-sky-light);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-family: 'Outfit', monospace;
  font-size: 0.88em;
}

/* --------------------------------------------------------------------------
   7. レスポンシブ スタイル
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .header-inner {
    padding: 0.5rem 0.75rem;
  }
  .brand-title {
    font-size: 1rem;
  }
  .question-select {
    max-width: 180px;
  }
  /* スマホ表示時は縦スクロール削減のためパーツ倉庫を非表示（ボトムシートで選択） */
  #warehouseSection {
    display: none;
  }
  .slots-container {
    grid-template-columns: 1fr;
  }
  .slot-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 0.75rem;
  }
  .slot-target-zone {
    min-width: 100%;
    min-height: 52px;
    cursor: pointer;
  }
  .footer-inner {
    justify-content: space-between;
  }
  .btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
  }
}

/* --------------------------------------------------------------------------
   8. ボトムシート（スマホ向けパーツ選択シート）
   -------------------------------------------------------------------------- */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.bottom-sheet-overlay.active {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet-card {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border-top: 1px solid var(--border-color);
  border-radius: 20px 20px 0 0;
  padding: 0.75rem 1.25rem 2rem;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.6);
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.bottom-sheet-overlay.active .bottom-sheet-card {
  transform: translateY(0);
}

.bottom-sheet-handle-bar {
  width: 40px;
  height: 4px;
  background: rgba(148, 163, 184, 0.4);
  border-radius: 2px;
  margin: 0.25rem auto 0.5rem;
}

.bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
  padding-bottom: 0.75rem;
}

.bottom-sheet-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.bottom-sheet-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.bottom-sheet-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 1rem;
}

.bottom-sheet-clear-btn {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fda4af;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.bottom-sheet-clear-btn:active {
  background: rgba(244, 63, 94, 0.3);
}

.bottom-sheet-tokens-grid {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bottom-sheet-token-card {
  background: rgba(30, 41, 59, 0.8);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  text-align: left;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.bottom-sheet-token-card:active {
  transform: scale(0.98);
  border-color: var(--accent-sky-light);
  background: rgba(2, 132, 199, 0.15);
}

.bottom-sheet-token-card.is-selected {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.15);
}

.sheet-token-status.selected-icon {
  color: var(--accent-emerald);
  font-size: 1.1rem;
}

.sheet-token-badge {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(51, 65, 85, 0.6);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* スロット空欄の案内表示（タップを促す） */
.slot-target-zone:empty::before {
  content: '+ タップしてカードを選択';
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  pointer-events: none;
  font-style: italic;
}

/* ==========================================================================
   9. シーケンス図ビルダー (Sequence Diagram Builder) スタイル
   ========================================================================== */
.sequence-diagram-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-lg);
  overflow-x: auto;
}

.sequence-diagram-container {
  min-width: 680px;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* アクターヘッダー（VD, SaaS-X, IDaaS-Yグループ） */
.seq-actors-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 2;
}

.seq-actor-op-col {
  width: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.seq-actors-grid {
  flex-grow: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}

.seq-actor-box {
  background: #1e293b;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.4rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.82rem;
  color: #fff;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* IDaaS-Y グループ枠 */
.seq-group-idaas {
  grid-column: 3 / 6;
  border: 1.5px dashed var(--accent-sky-light);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.5rem 0.5rem;
  background: rgba(2, 132, 199, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.seq-group-label {
  text-align: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--accent-sky-light);
  letter-spacing: 0.05em;
}

.seq-group-actors {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

/* シーケンス本体エリア（縦ライフラインの背景） */
.seq-body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 0;
}

/* ライフライン背景（各アクターの中心を通る縦線） */
.seq-lifelines-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 56px;
  right: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  pointer-events: none;
  z-index: 0;
}

.seq-lifeline {
  height: 100%;
  margin: 0 auto;
  width: 2px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(148, 163, 184, 0.3) 0,
    rgba(148, 163, 184, 0.3) 6px,
    transparent 6px,
    transparent 12px
  );
}

/* メッセージ行（共通） */
.seq-msg-row {
  position: relative;
  z-index: 1;
  min-height: 40px;
  display: flex;
  align-items: center;
}

/* 固定行の操作列（番号表示） */
.seq-fixed-num-col {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* 固定矢印行 */
.seq-fixed-line {
  position: absolute;
  height: 2px;
  background: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  top: 50%;
  transform: translateY(-50%);
  transition: all 0.2s;
}

.seq-fixed-line.line-both {
  height: 4px;
  border-top: 1px solid var(--text-muted);
  border-bottom: 1px solid var(--text-muted);
  background: transparent;
}

.seq-fixed-line .seq-arrow-head {
  position: absolute;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1;
}

.seq-fixed-line .seq-arrow-head.arrow-right {
  right: -2px;
}

.seq-fixed-line .seq-arrow-head.arrow-left {
  left: -2px;
}

.seq-fixed-label {
  background: #090d16;
  border: 1px solid rgba(51, 65, 85, 0.6);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-sub);
  white-space: nowrap;
  z-index: 2;
}

/* 並べ替え境界ガイド */
.seq-reorder-divider {
  margin: 0.5rem 0;
  padding: 0.35rem 0.75rem;
  background: rgba(2, 132, 199, 0.1);
  border: 1px dashed var(--accent-sky);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-sky-light);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* 並べ替えリストコンテナ */
.seq-sortable-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* 並べ替え対象行ブロック */
.seq-sortable-item {
  position: relative;
  z-index: 2;
  min-height: 42px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px dashed rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.seq-sortable-item:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(56, 189, 248, 0.35);
}

/* ドラッグ中スタイル (SortableJS) */
.seq-item-chosen {
  background: rgba(30, 41, 59, 0.95) !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
  border-color: var(--accent-sky) !important;
  z-index: 10 !important;
}

.seq-item-ghost {
  opacity: 0.35;
  background: rgba(56, 189, 248, 0.1) !important;
  border: 2px dashed var(--accent-sky) !important;
}

/* 行の操作部（つまみ ＋ ▲▼ボタン） */
.seq-item-controls {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  z-index: 3;
}

.seq-drag-handle {
  color: var(--text-muted);
  cursor: grab;
  padding: 6px 3px;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.seq-drag-handle:hover, .seq-drag-handle:active {
  color: var(--accent-sky-light);
}

.seq-move-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.seq-btn {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--border-color);
  color: var(--text-sub);
  width: 20px;
  height: 15px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.seq-btn:hover {
  background: var(--accent-sky);
  color: #fff;
  border-color: var(--accent-sky);
}

/* 行内のアクターメッセージトラック（左56px分を避けた領域） */
.seq-row-track {
  position: relative;
  margin-left: 56px;
  width: calc(100% - 56px);
  height: 36px;
  display: flex;
  align-items: center;
}

/* 正誤状態ハイライト */
.seq-sortable-item.correct {
  border-color: rgba(16, 185, 129, 0.6) !important;
  background: rgba(16, 185, 129, 0.1) !important;
}

.seq-sortable-item.correct .seq-line,
.seq-sortable-item.correct .seq-loop {
  background-color: var(--accent-emerald) !important;
  border-color: var(--accent-emerald) !important;
}

.seq-sortable-item.correct .seq-arrow-head,
.seq-sortable-item.correct .loop-arrow {
  color: var(--accent-emerald) !important;
}

.seq-sortable-item.correct .seq-item-badge {
  border-color: var(--accent-emerald) !important;
  color: var(--accent-emerald-light) !important;
}

.seq-sortable-item.incorrect {
  border-color: rgba(244, 63, 94, 0.6) !important;
  background: rgba(244, 63, 94, 0.1) !important;
}

.seq-sortable-item.incorrect .seq-line,
.seq-sortable-item.incorrect .seq-loop {
  background-color: var(--accent-rose) !important;
  border-color: var(--accent-rose) !important;
}

.seq-sortable-item.incorrect .seq-arrow-head,
.seq-sortable-item.incorrect .loop-arrow {
  color: var(--accent-rose) !important;
}

.seq-sortable-item.incorrect .seq-item-badge {
  border-color: var(--accent-rose) !important;
  color: var(--accent-rose-light) !important;
}

/* 矢印線と中央バッジ */
.seq-line {
  position: absolute;
  height: 2px;
  background: var(--accent-sky);
  display: flex;
  align-items: center;
  justify-content: center;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.seq-line .seq-arrow-head {
  position: absolute;
  color: var(--accent-sky);
  font-size: 0.75rem;
  line-height: 1;
}

.seq-line .seq-arrow-head.arrow-right { right: -2px; }
.seq-line .seq-arrow-head.arrow-left { left: -2px; }

.seq-item-badge {
  background: #090d16;
  border: 1.5px solid var(--accent-sky);
  padding: 0.15rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  z-index: 3;
}

/* 自己ループ（U字型） */
.seq-loop {
  position: absolute;
  width: 28px;
  height: 22px;
  border: 2px solid var(--accent-sky);
  border-left: none;
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.seq-loop .loop-arrow {
  position: absolute;
  bottom: -5px;
  left: -2px;
  color: var(--accent-sky);
  font-size: 0.75rem;
  line-height: 1;
}

.seq-loop-label-wrapper {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
}

/* シーケンス図キャプション */
.seq-caption {
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(51, 65, 85, 0.5);
  letter-spacing: 0.05em;
}
